0
votes

I want to write a bootloader for my stm32l4 mcu which (after pressing a button) jumps to another part of flash and run the app on that part. for application part I write a simple blinky and generate its BIN file and copy this bin file to address 0x0800 8000 of flash memory.

Now I do not know how can I jump to this address and run this blinky app.

would anyone help me?

best!

2
I'd mark this as a duplicate of stackoverflow.com/questions/14393715/… except that is for Stellaris - the answer however applies to any Cortex-M3 or M4. - Clifford
Why exactly can't you use a function? Are you flashing the code in multiple steps or something? Running code from data flash? - Lundin

2 Answers

0
votes

At least two alternatives spring to mind:

  1. Use a function pointer:

        /* ... */
        void (*app)(void) = (void (*)(void))0x08008000;
        app();
    
  2. Declare an external function and resolve it with your linker script:

        /* ... */
        void app(void);
        app();
    

    How to define the address in the linker script depends on your linker.

0
votes

I guess you could also rewrite the Interrupt Vector Table. I dont know exactly how the stm32l4 works, but have a look at the start up code. At some point it loads the program counter with a predefined value. You could rewrite this value and reset the MCU.