| Details | Message |
|---|
Read-Only Author Mark Norman Posted 1-Jul-2009 14:00 GMT Toolset ARM |  How can I get the reset vector to jump straight to main Mark Norman I have created a image relocation scheme where my boot loader can load an image into one of several positions in the flash and execute them individually. This involves remapping the IVT from that created by the compiler/linker so that the processor jumps into the correct relocated isr positions. Now, here is the problem I have come up against. I need the boot loader to jump into the new located code. I initially thought it would be okay to just take the reset vector (with the location offset added) out the IVT and jump to that. The only problem I found is that this jumps to a load of scatter file initialisation code that does not appear to use relative addressing and jumps back to the boot loader code. I have managed to get the boot loader to jump directly to main (using hard coding) and this works beautifully, all the routines appear to be using the correct relative branches and jumps. But the main address moves around depending on the image content and needs to be obtained and passed in to the boot loader for it to work, which could be done by getting it placed into an image header but is a little clumbsy, requiring use of FROMELF and some other post linker scripting as well as the header decoding at the other end. So my question is.. how can I get the Keil compiler to set the main address into the reset part of the vector table? Or how can I program the reset isr to jump direct to main with out it calling all this initilisation stuff? Or can I just take out the initialisation, if so how? Hope there is enough but not too much detail there for me to make sense. |
|
Read-Only Author Tamir Michael Posted 1-Jul-2009 14:14 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Tamir Michael I have managed to get the boot loader to jump directly to main (using hard coding) and this works beautifully, all the routines appear to be using the correct relative branches and jumps no no no, this is fundamentally wrong. you must pass though the reset vector while the processor is in supervisor mode. so make sure your bootloader executes a SWI, from which the jump to application is performed. |
|
Read-Only Author Tamir Michael Posted 1-Jul-2009 14:15 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Tamir Michael you must be in supervisor mode in order to configure the stacks correctly. |
|
Read-Only Author Tamir Michael Posted 1-Jul-2009 14:17 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Tamir Michael the remapping of the vector table should depend on which application is executed. use the RAM_INTVEC REMAP RAM_MODE macros in the ASM tab of the different applications. |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 14:28 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman why is it fundamentally wrong? what is supervisor mode? Not sure what you mean by getting the bootloader execute the SWI. Sorry you have lost me here totally. Perhaps you misunderstand what I am doing, my bootloader will remap during the image load process, it does not relocate anything in its IVT, that would be very difficult. On reset the bootloader would do all the ordinary reset stuff and end up in its main routine which would decide which image to jump to, it knows the image positions but not their main start address. It can obtain their reset vectors but not their main address. |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 14:32 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman ..each image, including the boot loader has their own IVTs. |
|
Read-Only Author Tamir Michael Posted 1-Jul-2009 14:35 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Tamir Michael I did understand you and as I said, you are violating one of the foundations on which an ARM processor (not an M3 - don't know that one yet) is based. you cannot setup the different modes stacks when in user mode - in user mode, only the condition flags of the CPSR (CPSR_f) can be changed. In other modes, the entire CPSR can be changed. I suggest you read a little bit about an ARM processor and then apply what I have written above. You don't have to, but it is advisable to do the remapping from within the target application itself. |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 14:43 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman I'm using an M3. Don't know about other ARMs but this allows the resetting of the stack and the IVT pointer before jumping into a new image. The IAP_AN example supplied by ARM does the stack stuff i.e. /* Initialize user application's Stack Pointer */ __MSR_MSP(*(vu32*) ApplicationAddress); does this mean I'm still violating one of the foundations? The jump actually works, so I can't be that wrong. |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 14:45 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman sorry should have said it is resetting the IVT pointer in the new images main. |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 14:48 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman Is there any one out there who knows about the M3 that can answer my questions? It is a STM32F103xx. |
|
Read-Only Author Helping Zeusti Posted 1-Jul-2009 15:02 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Helping Zeusti Hello Master MARK. i know the m3 and i understand the problem. the m3 is diferrent to the old arms. you wait and see if i can find the answer. plz wait. always yo're freind. Zeusti. |
|
Read-Only Author Tamir Michael Posted 1-Jul-2009 15:26 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Tamir Michael Hello Master MARK does that make you a slave? |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 15:28 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman Sorry, you have lost me there??? |
|
Read-Only Author Tamir Michael Posted 1-Jul-2009 15:30 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Tamir Michael Mark, I was teasing the renowned professor Zuesti or whatever his nickname is. Why all know him around here... |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 15:47 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman Ah, good I understand. Does he normally give good advice? |
|
Read-Only Author Tamir Michael Posted 1-Jul-2009 15:52 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Tamir Michael I believe his reply of a minute ago (more or less) as well as his posting style speak for themselves. I hope he does surprise us, though. |
|
Read-Only Author Helping Zeusti Posted 1-Jul-2009 15:49 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Helping Zeusti Tapeer. have you read the abi yet? understand now? Always yo're freind. Zeusti. |
|
Read-Only Author Marcus Harnisch Posted 1-Jul-2009 15:56 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Marcus Harnisch I have never tried this, but here is an idea: Create a scatter file shared by all images, which will ensure common entry point and vector table addresses. Build the images with --apcs=/ropi. Position independent data is not necessary, since I take it you will be running only one image at a time. Install image at known address initialize stack pointer from new vector table as well as the vector table itself and branch to image entry point. Regards Marcus http://www.doulos.com/arm/ |
|
Read-Only Author Helping Zeusti Posted 1-Jul-2009 16:06 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Helping Zeusti marcus beet me to the response. but he has a good sugestion. Always yo're freind. Zeusti. (success rateing now fallen to 100%-1) |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 16:07 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman Thanks I think the scatter file is just the default for the processor type and will be common. Where exactly do I put --apcs=/ropi, you are right about the images running OAAT. "..branch to image entry point" There's where it goes wrong because the only address I can currently get my hands on is the "reset vector" which in turn calls misbehaving scatter file routines (call absolute addresses). Are you perhaps saying that inclusion of the --apcs=/ropi will make these scatter routines behave? All I want to do is just jump straight to main, therefore missing out the scatterfile stuff. So I want to be able to assign the image IVT with the main address instead of the reset routines. |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 16:11 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman Hang on, its come to me, don't go away I'll try it before I embarrass myself with a supid solution. |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 16:22 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman I should be able to get away with changing Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT __main LDR R0, =__main BX R0 ENDP to Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT main LDR R0, =main BX R0 ENDP i have a little problem with testing this a currently my boot loader and images are the same program only with the IVTs modified as I have not got a physical transport working yet ( which is to be I2C ). So a little move time to prove concept. Thanks for all your help :) |
|
Read-Only Author Marcus Harnisch Posted 1-Jul-2009 16:26 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Marcus Harnisch > I think the scatter file is just the default for the processor type > and will be common. You may have to come up with your own. > Where exactly do I put --apcs=/ropi, you are right about the images > running OAAT. Add this to the compiler options. And, BTW, according to the docs there are supposedly some limitations with Microlib. Just a heads up. > Are you perhaps saying that inclusion of the --apcs=/ropi will make > these scatter routines behave? It should, indeed. > All I want to do is just jump straight to main, therefore missing > out the scatterfile stuff. I don't think you want that. > So I want to be able to assign the image IVT with the main address > instead of the reset routines. But nobody cares what the address of your reset slot in the new vector table is. It'll never be used anyway. If a reset occurs, it takes down the vector table offset register and the boot loader vector table will be used again. Regards Marcus |
|
Read-Only Author Mark Norman Posted 1-Jul-2009 16:33 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Mark Norman >But nobody cares what the address of your reset slot in >the new >vector table is. It'll never be used anyway. If a reset >occurs, it >takes down the vector table offset register and the boot >loader vector >table will be used again. No I care because the reset vector is what the boot loader reads from ( from the new image ) before jumping to that entry point. It does not have to be the reset vector it could be any of the vectors that is not used, i just use it as a entry point holder for the boot loader ( or infact the other images ) to use for their jump into it. Um, other vectors, now theres an idea!!! |
|
Read-Only Author Marcus Harnisch Posted 1-Jul-2009 18:04 GMT Toolset ARM |  RE: How can I get the reset vector to jump straight to main Marcus Harnisch > No I care because the reset vector is what the boot loader reads from > ( from the new image ) before jumping to that entry point. That's what I meant. It is not used as actual Reset address, so you can use it for anything you like. Regards Marcus http://www.doulos.com/arm/ |
|