2019-06-27 05:25 AM
I want to run the application code other than the default location of flash 0x08000000 in STM32 MCU.
For doing this I have modified the VECT_TAB_OFFSET = 0x200 in system_stm32l4xx.c
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET;
Also, FLASH (rx) : ORIGIN = 0x8000200, LENGTH = 512K in .ld file.
By doing this changes it is not working. So, apart from this is there any changes still required? Please help me on this.
2019-06-27 05:51 AM
The processor always reads the vector table at zero, the BOOTx pins determine what is mapped/shadowed here at start up.
Usually mapped with FLASH from 0x08000000
You can't change it to 0x08000200, but you will need to transfer control there from code or a table referenced at 0x08000000
You have created your image correctly, but the processor won't get there magically.
2019-06-27 05:54 AM
@Community member Can you tell me how to transfer control to 0x08000200 location from table referenced at 0x08000000?
2019-06-27 06:09 AM
Replicate the first two table entries, or jump/branch to the entry point
Reset_Handler PROC
EXPORT Reset_Handler
; ...
LDR R0, =0x08000200 ; Secondary Vector Table
LDR SP, [R0, #0] ; Load SP
LDR R0, [R0, #4] ; Load PC
BX R0 ; Jump too
ENDP ; Reset_Handler
2019-06-27 07:28 PM
@Community member I have added above instruction in the startup file but it is giving me the errors:
..\startup\startup_stm32l462xx.s:76: Error: bad instruction `reset_handler PROC'
..\startup\startup_stm32l462xx.s:77: Error: bad instruction `export Reset_Handler'
..\startup\startup_stm32l462xx.s:82: Error: bad instruction `endp Reset_Handler'
I added this at start in the startup file. Is it right? Let me correct if I mistake something, here I attached the my startup file.
2019-06-27 08:14 PM
I'm using Keil syntax, you'll need to adapt to GNU/GAS if that is what you're using.
Just take the body of the code
LDR R0, =0x08000200 /* Secondary Vector Table */
LDR SP, [R0, #0] /* Load SP */
LDR R0, [R0, #4] /* Load PC */
BX R0 /* Jump too */
You need to become a chameleon and not just blind copy everything.
2019-06-27 08:28 PM
@Community member This all stuff are low level so, I have not much idea about this. By the way it is still not working.