cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Dual bank boot & RWW - Fail to flash Bank1 while running from Bank2

egoltzman
Senior
Posted on June 15, 2016 at 08:58

I'm working with STM32F429NI with 2Mbytes of internal flash

I use the dual bank boot mode & RWW to support FW upgrade to a product. I basically followed the examples I saw at STM32Cube_FW_F4_V1.7.0\Projects\STM324x9I_EVAL\Examples\FLASH\

The user insert a SD with the new FW, the SW identify it, load the FW bin file to memory and flash it to the non-active bank, that is, I start with the SW loaded at 0x8000000 and the BFB2 option byte is 0 (boot from bank 1), then if there is a new FW I flash it to 0x8100000 (after unlock and erase) and after verify it I change the BFB2 to 1 and reset the system. The system is boot from Bank 2 

successfully

.

Now, when I try to load a new FW version while I'm running from bank 2 I'm doing the same procedure but on Bank 1, that is unlock, erase and flash bank 1 with the new code, verify it and set BFB2 to zero but at that stgae the system 

hangs

!!

When I read the flash with a J-Link at that point I see that bank 1 is all FF, that is, the erase worked but the flashing didn't. I change the bank to all zero and repeat the process to make sure that the erase is working and it is.

I'm checking for error on the calls to HAL_FLASH_Program but I did not see any.

Any idea what I am doing wrong?

#stm32f4-rww-dual_bank_boot
6 REPLIES 6
Posted on June 15, 2016 at 09:11

Seems hard to believe your verify is doing the job properly.

The memory map swaps but the flash controller and sector numbering do not.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
rchris
Associate II
Posted on June 15, 2016 at 13:21

I have also used the example and for me it works. Your flash start address when programming should always be 0x08100000. Also, there was an error in the Reference Manual telling us to relocate the vector table, which is wrong. This was corrected in the last edition.

egoltzman
Senior
Posted on June 16, 2016 at 16:43

Thank you Clive! The second sentence in your reply was all what I needed.

I did not realize that there is an internal swap and I tried to swap from my code, this is why when I moved from bank 1 to bank 2 things worked since I actually erased the right sectors and copied the code to the ''other bank'' address - 0x8100000.

When the code was running from bank 2 I erased the right sectors but wrote to address 0x8000000, that is on the running code... and then switch the banks and stuck on the erased flash!

I did not found in the description of the dual bank mode this information about the memory swap, can you point me to it?

egoltzman
Senior
Posted on June 16, 2016 at 16:46

Thank you christopher! Together with Clive answer and yours I realized my fault and fix it to work  

Great help!

Posted on June 16, 2016 at 21:42

I did not found in the description of the dual bank mode this information about the memory swap, can you point me to it?

I'm able to infer a lot from the manuals, mostly by eliminating a vast number of impractical ways something won't get done in an IC design.

You should look at the FB_MODE, and other bits, within SYSCFG_MEMRMP register, and the hardware/mechanism the System Loader is going to be able to utilize to do what it is specified to do.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Lavanya1
Associate II

I'm facing the same issue. I  couldn't find the solution. Could you please share the solution?