Dual bank booting problem
Hello!
I try to use dual bank option on the stm32l476 (256kB) for implementing a custom bootloader. I want just read new program (bin) by custom protocol and write it to another bank. After that I want to switch the banks, reset mcu and start the new program (from another bank).
Sounds easy!
My actions:
I built the program for bank1, load it to the address 0x08000000.
Then I loaded the same program to the bank 2 by address 0x08020000. (either with the st-link utility or just by writing to the flash directly from my program, tried both of variants).
After that I set option byte bfb2 from 0 to 1 (also either with st-link or just from program). But my mcu does not work at all.
I`ve compared the program in both banks and original .bin file with the help of the st-link utility and found that there is no difference between it (no corruption during program).
I`ve even tried to build program for bank 2 (with offset), but it also did not help.
I`ve noted that when I change the bfb2 bit, the value in the 0x4 address (entry point) also changes to strange address 0x1FFF6145 instead of 0x08005DE9 (my real entry point). I understand that mcu reads this address as an entry point and traps. But why does this address change to something strange one?
From the bank1 (bfb2=0) program works well.
Please, can anybody say what I do wrong?
Configurations: Boot0 connected to the ground. DaulBank=1, nBOOT1=1, FB_MODE=0
Best regards, Klynkin Kirill.
