stm32f4: flash: support discontinuous sectors on banked flash
The sector list is numerically contiguous, but the bits to write are not contiguous. Good job ST. Fixes: https://github.com/libopencm3/libopencm3/pull/934 Don't see any reason to make public definitions of these sorts of magic numbers, they're completely internal to sector addressing.
This commit is contained in:
parent
6e1edc3656
commit
30d88452e6
@ -359,6 +359,11 @@ void flash_erase_sector(uint8_t sector, uint32_t program_size)
|
||||
flash_wait_for_last_operation();
|
||||
flash_set_program_size(program_size);
|
||||
|
||||
/* Sector numbering is not contiguous internally! */
|
||||
if (sector >= 12) {
|
||||
sector += 4;
|
||||
}
|
||||
|
||||
FLASH_CR &= ~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT);
|
||||
FLASH_CR |= (sector & FLASH_CR_SNB_MASK) << FLASH_CR_SNB_SHIFT;
|
||||
FLASH_CR |= FLASH_CR_SER;
|
||||
|
Loading…
x
Reference in New Issue
Block a user