cancel
Showing results for 
Search instead for 
Did you mean: 

Run application other than 0x08000000 in STM32L4

AP_040
Senior

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.

6 REPLIES 6

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AP_040
Senior

@Community member​ Can you tell me how to transfer control to 0x08000200 location from table referenced at 0x08000000?

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AP_040
Senior

@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.

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AP_040
Senior

@Community member​ This all stuff are low level so, I have not much idea about this. By the way it is still not working.