We are working on a remote FW update feature, where we receive the FW binary from USB. The process starts with erasing a region in flash bank 2 (0x08040000）. Then it receives the FW image and flashes them. Finally, it CRC checks the entire new FW in the bank2.
Then We will switch bank1 to bank2 step by setting BFB2 to 1. And I am sure that main flash is boot area and DBANK bit is 1. Moreover I read AN2606 and AN4767, even I test ST example code( NUCLEO-G474RE\Examples\FLASH\FLASH_DualBoot ) on NUCLEO-G474RE board.
Unfortunately, all of the test is failed.
For my test, FLASH_OPTR BFB2 is set to 1 that I can watch it on STM32CubeProgrammer. But the BF_MODE bit of SYSCFG->MEMRMP is always 0, I don't know whether the flash bank is switched successfully or not.
Would you please investigate what happened?
Any help will be great and appreciated! Thank you.
Hi @Yang Yang
The forum moderator had marked your post as needing a little more investigation and direct support. An online support case has been created on your behalf, please stand by for just a moment and you will hear from us.
The problem can be due to following behavior:
If BFB2=1 then address 0x0000 0000 is mapped to system bootloader (written as note in RM0440 under SYSCFG_MEMRMP register description). If BFB2=1 system bootloder is activated. Bootloader then jumped to your code in Bank2. But 0x0000 0000 mapping remained to system bootloader (system memory). Your code from BANK2 should be executed correctly until first interrupt arrives. Default interrupt vector table (VTOR) is set after reset to address 0x0000 0000. In normal (standard) execution it is correct - because if executing program from Bank1 (if BFB2=0) the Bank1 (0x0800 0000) is mapped to 0x0000 0000 (interrupt tables are aliased). But if BFB2=1 the address 0x0000 0000 is aliased to bootloader. If interrupt occurs your code jumps (from Bank2) to bootloader interrupt table (where can be while (1) loop or some another routine).
Try to correct this in your code: At the beginning of your code add this redirection of VTOR to BANK2 interrupt table (instead of default 0x0000 0000):
SCB->VTOR = 0x0840 0000
Try to do this and give me please answer if this helped.