cancel
Showing results for 
Search instead for 
Did you mean: 

run program at address other than 0x8000000

jiangpen
Associate II
Posted on May 13, 2016 at 09:10

I have STM32L4, and I want build a program run at address like 0x08080000.

My env is uVision5, and I set the 1ROM1 address to 0x08080000 in uVision. I use fromelf command to generate the bin file from axf file and load it to the address of 0x08080000.

But when I perform the jump instruction, I always get the hard_fault.

May I know if anything missing? reset vector?

#stm32l4-bootloader-reset-vector
7 REPLIES 7
torsten2
Associate II
Posted on May 13, 2016 at 09:42

Hi Jiang,

there is a register containing the address of the interrupt vector table. The ST startup code sets this register to a fixed value (0x8000000). If you set the register to the address of the vector table, you can adjust your linker script and move your image without the need to change the startup code every time.

If for example your vector table is named g_pfnVectors, your startup code could look like this:

  SCB->VTOR = (uint32_t)&g_pfnVectors;

jiangpen
Associate II
Posted on May 13, 2016 at 10:33

Hi robitzki,

 May I know where is the best place to put this code?

SCB->VTOR = (uint32_t)&g_pfnVectors;

I am using the default start code, which looks like below

Vectors is the Vector, but I don't know how to set that in register.

thanks a lot

JP

  __Vectors_Size                           0x00000188   Number         0  startup_stm32l476xx.o ABSOLUTE

    __Vectors                                0x08080000   Data           4  startup_stm32l476xx.o(RESET)

    __Vectors_End                            0x08080188   Data           0  startup_stm32l476xx.o(RESET)

torsten2
Associate II
Posted on May 13, 2016 at 10:58

I don’t know what you are quoting (looks like a map file), but the best place would be the startup code. My startup code is in a file called system_stm32l4xx.c. There is a function called SystemInit() and at the end, there is an assignment to VTOR register. If you replace this with:

  extern const uint32_t g_pfnVectors;

  /* Configure the Vector Table location add offset address ------------------*/

  SCB->VTOR = (uint32_t)&g_pfnVectors;

you should be fine, no matter where your place your application.

Radosław
Senior
Posted on May 13, 2016 at 11:52

>>My startup code is in a file called system_stm32l4xx.c.

This isn't startup code.

It is imposible to start code from  any address. Booting is posibble only for adresses begin of flash, begin of SRAM, or bootloader adress depending on BOOT settings.

If you wanna start code from different adress, still your startup code must be at 0x08000000.

torsten2
Associate II
Posted on May 13, 2016 at 16:24

Well yes, we could now argue if code that isn’t written in assembler and isn’t in a file with „startup“ in its name is still startup code or if this is already firmware or something in-between (setup code, init code, post startup code, pre main code…). But I can see, why we should do this. The OP talked about „performing the jump“, so it seems that he is well aware that the first instructions executed by the CPU are still from reset vector from the vector table at 0x8000000.

Radosław
Senior
Posted on May 13, 2016 at 19:23

startup code means, that is code di implement everything what C(C++) standard needes to do before main.

Back to main problem, 0x0808000 is EEPROM, probably execution from eeprom is imposible.

Posted on May 13, 2016 at 19:38

You jump to it and it faults. Perhaps you should show the code you're actually doing the transfer of control with, and a trace of the instruction execution to the point at which it faults. At that point it should be much easier to determine why if faults rather than all of us guessing?

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