2013-10-24 10:44 AM
I run a program fine on bank 1. Then programmed BFB2 to 1. (BOOT0 = 0).
Compile Blinky to 0x08100000 and load it. Checked the flash by stlink-util and see0000: 20000468 081001c1.Those are correspondent to the .map file of STACK and reset_handler. Ok, good to go.Of course it won't work.I fired up the Keil debugger. found it began at 0x1fff 4abe, it's the bootloader. Fine, which is consistent to document. When BFB2 is 1, it will go to boot loader, then jump to bank 2.content on memory windows that shows normal too.then after a few steps (0x1fff4ac6). PC become 0x081001c0. all the flash contect become FF. I checked again the content by stlink. It's still valid, not FF. and of course. The PC is not the address of reset_handler. Somewhere in bootloader didn't go as I hope. (load SP from 0x08100000, and jump to 0x08100004 -> 0x081001c1 (reset_handle).). I wonder what's go wrong....The hardware is the STM32F4x9_EVAL.Sink2018-06-19 12:23 PM
It seems my suggestion to copy the code from bank1 to bank2 should have worked for stm32l0xxx and stm32l4xxx, where memory remap for bank swapping is supported. However, for my stm32l15x, the code in bank2 need the linker file to be configured to bank 2. This is easily achieved in IAR. In addition vtor is to be configured to point to bank2 in the SystemInit(). Last but not least, nBFB2 is to be reset once, possibly buy a code running from bank1.
This solution enables fail safe firmware upgrade of bank1 using st built in boot loader that resides in system memory. In case of failure the code from bank2 is run. However, since bank2 is only partially accessible by st boot loader (128 Kb out of the 256Kb are accessible), bank2 cant be updated by long ( > 128Kb) firmwares. So the back up code is always the original factory code and cant be updated.
2018-06-19 02:02 PM
The L1 is a much older design, usability of the STM32 designs has evolved and improved with each new generation/family
2018-06-19 04:20 PM
Check the errata for STM32L0xx, some versions don't have dual bank, and there are warnings about using it on the rest. For the STM32L1xx you have to put in your own bootloader to manage the bank remap.