2020-08-21 02:10 AM
Please help me understand the Bank1/Bank2 boot options of the STM32L1
Here's what I'm currently doing:
I have a blank MCU and flash program my code normally. A read operation done by STVP shows the program resides starting at address 0x8000000. BOOT0 pin is pulled low and BOOT1 is used as a GPIO. The nBFB2 bit is zero.
This program executes and all works well. Now I initiate a firmware upgrade which is an http request done via a GSM modem. The raw hex file is downloaded and written starting at address 0x8040000. After the whole write operation is completed, I execute NVIC_SystemReset(); and expect the reboot to be from Bank2. The problem is that it does not happen...in fact if I power my device after the firmware update, nothing happens in that there is no sign of life.
1) I can verify that the entire hex file was written and is in the correct location.
2) Given the status of the BOOT pins as well as the nBFB2 bit, I expect bootup from BANK2
3) Bear in mind that I haven't done any OPTION byte operations or changes. I am relying on the fact that the bootloader is checking BANK2 first and finding valid content meaning that it should and will boot from BANK2
Any advise will be much appreciated!
Thank you in advance!
2020-08-24 12:17 PM
I found the problem.
I had to actually edit my Linker config file before compiling the hex file:
define symbol __ICFEDIT_intvec_start__ = 0x08040000;
define symbol __ICFEDIT_region_ROM_start__ = 0x08040000;
I can now happily boot from either Bank by toggling the nBFB2 bit in the Option register