Hi,
In my Cortex-M0 project, there are two program images residing at different memory locations: 0x0000_0000 and 0x0010_0000. Each program has its own vector table. M0 will boot from the program at 0x0010_0000 then switch to the other program (0x0000_0000) at the end.
What is the correct way to switch to the porgram at 0x0000_0000? I'm not sure whether the following instructions are correct or not.
LDR R6, =0x1 ; set R6 to 0x0000_0001 due to Thumb mode
LDR R0, [R6]
MOV SP, R0
LDR R1, [R6, #4]
BX R1
Can someone please point me the right implementation? Thanks a lot.
Thanks jensbauer, So it is similar to bootloader app I guessed. Some MCUs have inbuilt bootloader, isn't it? I think STM32F4 has one.
Also in this particular case, if VTOR is updated in the image #1, then it would later always execute image #2 when power cycled. It won't be able to get back to image #1 unless VTOR is again changed to vector table of image #1.
Changing VTOR isn't permanent; it's just like any other hardware register, and has a default on startup.
-So power-cycling will always execute image#1 in this particular case.
Most microcontrollers have a boot-ROM, yes. This makes it possible to program the devices in other ways than JTAG and SWD, for instance via UART or USB, but this of course depends on the boot-ROM code.
Thanks. I had this misunderstanding of VTOR..