Problem on executing firmware from Bank2 on STM32 Dual-Bank flash

91 Views Asked by At

I'm currently working with the STM32L073RZ on a project that requires firmware update over a proprietary wireless protocol. The OTA method I'm working on is using the dual-bank feature of this MCU. I managed to successfully program BANK2 with the new firmware which is completely different from BANK1 firmware in terms peripherals used and overall functionality. My problem is that when i set the BFB2=1 to boot from BANK2 the MCU fails to execute the firmware.

I did some more tests by only programming BANK2 and trying to boot from it without having any firmware in BANK1 and still no luck. What am i doing wrong? Do i need a certain code to be programmed to BANK1 even if i don't want to use this bank at all? What part of the code from BANK1 is the MCU using when it's running the firmware in BANK2?

I should mention that I've read the ST's AN4767 and AN2606 documents on this matter. Also when i program two identical firmware on both banks (compiled with different linker scripts to match the bank address) and slightly change the code to identify which one is executing(ex. one bank led blink and one led on), everything works fine from both BANKS.

1

There are 1 best solutions below

0
mehdihfzp On

I actually found the problem. In my case i didn't pay attention to SYSCFG_CFGR1_UFB register. I was trying to switch the bank with the BFB2 register and also built the firmware for the address of bank2 which is wrong. Actually didn't know that when i switch the bank, the second bank's address will be always be bound to virtual address 0x08000000. Thanks to all the experts who have participated in this topic.