From 7a334af794c8d952149ed38b382d051bf7d0e4a9 Mon Sep 17 00:00:00 2001 From: davidk88 Date: Wed, 31 Aug 2022 08:00:55 +0200 Subject: [PATCH 1/2] Select next eraser if uniform 4k erase not supported --- sfud/src/sfud.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sfud/src/sfud.c b/sfud/src/sfud.c index 8bd3015..7fb1533 100644 --- a/sfud/src/sfud.c +++ b/sfud/src/sfud.c @@ -284,10 +284,16 @@ static sfud_err hardware_init(sfud_flash *flash) { } else { flash->chip.write_mode = SFUD_WM_PAGE_256B; } - /* find the the smallest erase sector size for eraser. then will use this size for erase granularity */ - flash->chip.erase_gran = flash->sfdp.eraser[0].size; - flash->chip.erase_gran_cmd = flash->sfdp.eraser[0].cmd; - for (i = 1; i < SFUD_SFDP_ERASE_TYPE_MAX_NUM; i++) { + /* find the the smallest erase sector size for eraser. then will use this size for erase granularity */ + i = 0; + /* if uniform 4k not supported choose next */ + if(flash->sfdp.eraser[0].size == 4096 && flash->sfdp.erase_4k == 0) { + i = 1; + } + flash->chip.erase_gran = flash->sfdp.eraser[i].size; + flash->chip.erase_gran_cmd = flash->sfdp.eraser[i].cmd; + i++; + for (; i < SFUD_SFDP_ERASE_TYPE_MAX_NUM; i++) { if (flash->sfdp.eraser[i].size != 0 && flash->chip.erase_gran > flash->sfdp.eraser[i].size) { flash->chip.erase_gran = flash->sfdp.eraser[i].size; flash->chip.erase_gran_cmd = flash->sfdp.eraser[i].cmd; From e703532b6421d143ebf07f1d6cea444c128b2e47 Mon Sep 17 00:00:00 2001 From: davidk88 Date: Wed, 31 Aug 2022 08:04:42 +0200 Subject: [PATCH 2/2] Update sfud.c --- sfud/src/sfud.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfud/src/sfud.c b/sfud/src/sfud.c index 7fb1533..b4c5d71 100644 --- a/sfud/src/sfud.c +++ b/sfud/src/sfud.c @@ -284,7 +284,7 @@ static sfud_err hardware_init(sfud_flash *flash) { } else { flash->chip.write_mode = SFUD_WM_PAGE_256B; } - /* find the the smallest erase sector size for eraser. then will use this size for erase granularity */ + /* find the the smallest erase sector size for eraser. then will use this size for erase granularity */ i = 0; /* if uniform 4k not supported choose next */ if(flash->sfdp.eraser[0].size == 4096 && flash->sfdp.erase_4k == 0) {