Skip to content

Commit 77f9da7

Browse files
tom-vanborneoa
authored andcommitted
flash/nor/kinetis: fix assertion during flash write
If the device has at lest one FlexNVM bank and it is set as EE backup only, the bank has no protection blocks. kinetis_fill_fcf() collects protection data from all banks before flash write of the sector containing FCF block. In case it encountered a FlexNVM bank with no protection blocks assert failed. Failed flash write of previously erased FCF block could cause engaging debugging lock (if the device was run or reset). Skip banks with zero protection blocks. Replace assert() by LOG_ERROR() as we have to finish FCF write. Change-Id: Ibe7e7ec6d0db4453b8a53c8256987621b809c99d Signed-off-by: Tomas Vanek <[email protected]> Suggested-by: Jasper v. Blanckenburg <[email protected]> Fixes: https://sourceforge.net/p/openocd/tickets/448/ Reviewed-on: https://review.openocd.org/c/openocd/+/8719 Tested-by: jenkins Reviewed-by: Jasper v. Blanckenburg <[email protected]> Reviewed-by: Antonio Borneo <[email protected]>
1 parent 3099547 commit 77f9da7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/flash/nor/kinetis.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,22 @@ static int kinetis_fill_fcf(struct flash_bank *bank, uint8_t *fcf)
14891489

14901490
kinetis_auto_probe(bank_iter);
14911491

1492-
assert(bank_iter->prot_blocks);
1492+
if (bank_iter->num_prot_blocks == 0) {
1493+
if (k_bank->flash_class == FC_PFLASH) {
1494+
LOG_ERROR("BUG: PFLASH bank %u has no protection blocks",
1495+
bank_idx);
1496+
} else {
1497+
LOG_DEBUG("skipping FLEX_NVM bank %u with no prot blocks (EE bkp only)",
1498+
bank_idx);
1499+
}
1500+
continue;
1501+
}
1502+
1503+
if (!bank_iter->prot_blocks) {
1504+
LOG_ERROR("BUG: bank %u has NULL protection blocks array",
1505+
bank_idx);
1506+
continue;
1507+
}
14931508

14941509
if (k_bank->flash_class == FC_PFLASH) {
14951510
for (unsigned int i = 0; i < bank_iter->num_prot_blocks; i++) {

0 commit comments

Comments
 (0)