Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions sfud/src/sfud.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,15 @@ static sfud_err hardware_init(sfud_flash *flash) {
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++) {
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;
Expand Down