Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eraser select for non-uniform 4k devices #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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