AnsweredAssumed Answered

Two remaining questions on dual bank flash on STM32L152

Question asked by Lynn Linse on Feb 14, 2017
Latest reply on Feb 28, 2017 by Lynn Linse

I've read through AN4767, AN4808 and several others. I think I understand how nBFB2 can cause BANK 2 to be addressed as 0x0800000 & BANK1 aliases to 0x0804000 (L152 has 512K, so 2x256k banks). First a great shout-out to Clive One Thank You , who makes the forum worth searching & asking at :-]. Hope you get a pay raise this year & every year!

 

My remaining questions:

1) Does this swap also affect EEPROM? AN4808 (& others) say code running in BANK1 should use EEPROM BANK2, and vis-vera since the banks share HW controllers & this allows code to run/read while writing EEPROM. So are the EEPROM banks swapped as well, or should the 'aliased' image at 0x08000000 always use EEPROM BANK2 as-if code was BANK1?

 

2) The "Ping-Pong" effect - someone else asked this, but wasn't directly answered.

2a) I understand if I start running my FWv1 in HW-BANK1 & HW-BANK2 empty (BFB2 can be anything). So field upgrade to FWv2 means I copy to 0x08040000 (V-BANK2), then I do my own CRC & confirmation that upgrade worked. If my confirmation fails, I erase that bank & wait to try FW upgrade again. If it works, with BFB2=0, then a reboot means we'll run FWv2 in HW-BANK2 which looks like V-BANK1.

2b) I also assume now if we do FWv3, erasing/writing 0x0804000 is actually writing into HW-BANK1, while we're running FWv2 in HW-BANK2.

2c) so my ping-pong question - do I need to set BFB2=1, so a reboot returns to FWv3 in HW-BANK1 and ignores old FWv2 in HW-BANK2? I assume if BFB2=0, we'll always/only run FWv2 in HW-BANK2 since it has correct SRAM in first word ... unless I erase first page, which kills/disables any fall-back to older FWv2.

2d) rewording my question, do I manually need to twiddle BFB2 to select 'odd' or 'even' revisions of my FW, which toggle between 'forcing HW-BANK1' and 'auto-picking HW-BANK2 while fall-back to HW-BANK1'?

 

3) Last question, with BFB2 set to 0, what is the safest absolute way to know which HW-BANK is 0x08000000 & which is 0x0804000? For example, of first word of BANK2 was 0, then we're running HW-BANK1; if first word of BANK2 was SRAM, then we're running HW-BANK2. So what's best way to know which HW-BANK is "the other one" - for my Ping-Pong management?

Outcomes