x1000: fix bug in nand_read_bytes
This didn't account for partial page reads properly which resulted in corrupted data. Fortunately, current released bootloaders do not perform such reads so they don't trigger this bug. Change-Id: I426a95ef8d0f20f4567498530e216d80e1aceef2
This commit is contained in:
parent
3bd5f335f7
commit
3cb7167e22
1 changed files with 4 additions and 4 deletions
|
@ -290,14 +290,14 @@ int nand_read_bytes(nand_drv* drv, uint32_t byte_addr, uint32_t byte_len, void*
|
|||
if(rc < 0)
|
||||
return rc;
|
||||
|
||||
memcpy(buffer, &drv->page_buf[offset], MIN(pg_size, byte_len));
|
||||
memcpy(buffer, &drv->page_buf[offset], MIN(pg_size - offset, byte_len));
|
||||
|
||||
if(byte_len <= pg_size)
|
||||
if(byte_len <= pg_size - offset)
|
||||
break;
|
||||
|
||||
byte_len -= pg_size - offset;
|
||||
buffer += pg_size - offset;
|
||||
offset = 0;
|
||||
byte_len -= pg_size;
|
||||
buffer += pg_size;
|
||||
page++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue