relocating program code STM32F103VE
there is quite a bit written about this, but having read them and doing the simple change to the STM32F103VE_MemoryMap.xml file
<MemorySegment size="0x78000" access="ReadOnly" name="FLASH" start="0x08080000"/> >
I have checked that the vector table offset register points to the vector table at 0x08080000
The code runs off the rails at the first call to ctl_task_run() Have not been able to track why as yet.
Is there something I should do/check to bring the problem to light?
The program runs fine before I try and move the start address.
This move is in preparation to define a section for non-volatile variable storage, and eventually a bootloader.
Thank you for any assistance.
Cheers.
Pete L.
-
Have you modified the flash_placement.xml file so that the links re-locates your vectors to where you intend?
I have several application that run similar to what you describe.
I have modified the
STM32FXXXXXX_MemoryMap.xml ---> Define you memory areas (i.e. Bootloader / Program / Storage). In my case I relocated FLASH to 0x8020 0000)
flash_placement.xml ---> adjust the .vectors entry (in my case 0x8020 0000)
relocated the vector table using NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x20000) or equivalent.
-
Hi Royce,
Thanks for your reply. My post took a little while to appear here, in the mean time I emailed support and with some assistance from Michael found that the vector offset register was getting set incorrectly.
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.
Again thanks for your response.
Cheers.
Pete L.
-
Pete,
No problem.
Based on what you've stated, my take is that you may not have any initialized values at the original vector table location. The processor will always use the original vector table locations (exception being the BOOT0/1 pins options) on start up before the SCB->VTOR is executed. I have a bootloader application that utilizes the original vector table. After it decides what to boot, it adjust the vector table location to meet the application requirements. So, if you do not have any valid vectors defined in the original table, the application with run from the debugger, but not from a reset.Also, I'm not sure of changing the FLASH_BASE address. That may have some undesirable side affects. That is not a modification that was required for my applications.RA
Please sign in to leave a comment.
Comments
5 comments