L4 Flash erase issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-16 6:03 AM
MCU is STM32L4R9 with 1MB. I'm having trouble getting the device to erase the upper half of the flash programmatically. Apparently the device ships with opt bytes set for dual bank.
I connected the device to the STM32 programmer through USB and turned off the DBANK option byte, which changed programming somewhat and appears to program 0x2000 sized pages now. However it still doesn't appear to erase correctly, in this case it for sure won't erase page 127 or 0x080FE000.
What puzzles me is that the programmer shows DBANK off, but the debugger still shows the OPTR DBANK bit set. Also, the note says on page 160 of datasheet rm0432-stm32l4..
Note: For 1-Mbyte and 512-Kbyte Flash memory devices, do not care about
DBANK.
However this isn't really true, as this bit does apparently do something.
- Labels:
-
Flash
-
STM32L4 series
-
USB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-16 6:16 AM
The device always has two physical banks.
The Erase takes a sector and a bank​ coordinate.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-16 6:51 AM
Hmm. I'm missing something. Even in dbank = 1 I can't erase upper half pages. In the snippet, I would assume that Page of 0 should erase first sector at 0x8080000, but it doesn't.
SET_BIT(FLASH->CR, FLASH_CR_BKER);
MODIFY_REG(FLASH->CR, FLASH_CR_PNB, ((Page & 0xFFU) << FLASH_CR_PNB_Pos));
SET_BIT(FLASH->CR, FLASH_CR_PER);
SET_BIT(FLASH->CR, FLASH_CR_STRT);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-16 8:01 AM
Actually, it appears that the first and last pages of bank 2 aren't writing or erasing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-16 10:07 AM
Actually its looking like Jlink isn't refreshing flash memory display.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-03 12:35 PM
Coming back around to this, these smaller devices have an oddity in that the OPTR bank is always set, the memory map contains the whole thing, yet to program you have to set FLASH_CR BKER for anything in the upper half. So 128 for 1M and 64 for 512K
if (Page < 64) {
CLEAR_BIT(FLASH->CR, FLASH_CR_BKER);
} else {
Page -= 64;
SET_BIT(FLASH->CR, FLASH_CR_BKER);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-03 12:36 PM
I'm EFrie.3, it took some months to get back my login lost for unknown causes due to some ST forum bug.
