relocating program code STM32F103VE
there has been a bit written on this;
Crossworks Implementation of In-Application Bootloader for STM32 High-Density Devices
Compiling for a particular way of updating application
...change the start address and size of my program in memory?
and the manual pages etc.
However having read them and tried a number of things I find it not working.as expected.
Modified the STM32F103VE_MemoryMap.xml last line now
<MemorySegment size="0x78000" access="ReadOnly" name="FLASH" start="0x08008000"/> >
compile and load. I find the program vectors and program where I expect, and the
/* Configure vector table offset register */
ldr r0, =0xE000ED08
is set to 0x08008000 which is where the vectors are.
But still it goes off into the weeds after ctl_task_run() which I guess enables ints.
Any ideas?
Thanks for your time.
Cheers.,
Pete L.
-
This question was posted twice. A solution was found. For completeness a copy of the solution is posted here. Pete L.
This was due to a second call to SystemInit();; As the
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
line relied upon
#define FLASH_BASE ((uint32_t)0x08000000) /*!< FLASH base address in the alias region */
Which is incorrect. As I want it to be 0x08008000 This does not normally matter because the start.s file sets it correctly ;
ldr r0, =0xE000ED08
#ifdef VECTORS_IN_RAM
ldr r1, =_vectors_ram
#else
ldr r1, =_vectors
#endif
str r1, [r0]Using _vectors, AFTER the call to SystemInit();
However a second call to SystemInit(); buried in my code was resetting it to the incorrect address again.
Once that second call was commented out, all worked well with just the edit to the MemoryMap file. No other changes needed.
Now I'm having "fun" making memory segments and assigning them to pages in the bottom of flash Working well.
Still a little confused about the vectors, because if I leave the first page blank. On the memory window in the debugger I see 0xFE (?) but if I write a bunch of data there my program won't start. Well that makes sense, but why can't I see the vectors? I can live in ignorance about that while I get other work done, but it would be nice to know.
Cheers. Pete L.
Please sign in to leave a comment.
Comments
1 comment