target/nxpke04: flash read write return bool
This commit is contained in:
parent
220293abc6
commit
ac6aaaeab0
|
@ -116,8 +116,8 @@ static const uint8_t cmdLen[] = {
|
||||||
|
|
||||||
/* Flash routines */
|
/* Flash routines */
|
||||||
static bool ke04_command(target *t, uint8_t cmd, uint32_t addr, const uint8_t data[8]);
|
static bool ke04_command(target *t, uint8_t cmd, uint32_t addr, const uint8_t data[8]);
|
||||||
static int ke04_flash_erase(target_flash_s *f, target_addr_t addr, size_t len);
|
static bool ke04_flash_erase(target_flash_s *f, target_addr_t addr, size_t len);
|
||||||
static int ke04_flash_write(target_flash_s *f, target_addr_t dest, const void *src, size_t len);
|
static bool ke04_flash_write(target_flash_s *f, target_addr_t dest, const void *src, size_t len);
|
||||||
static bool ke04_flash_done(target_flash_s *f);
|
static bool ke04_flash_done(target_flash_s *f);
|
||||||
static bool ke04_mass_erase(target *t);
|
static bool ke04_mass_erase(target *t);
|
||||||
|
|
||||||
|
@ -322,21 +322,20 @@ static bool ke04_command(target *t, uint8_t cmd, uint32_t addr, const uint8_t da
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ke04_flash_erase(target_flash_s *f, target_addr_t addr, size_t len)
|
static bool ke04_flash_erase(target_flash_s *f, target_addr_t addr, size_t len)
|
||||||
{
|
{
|
||||||
while (len) {
|
while (len) {
|
||||||
if (ke04_command(f->t, CMD_ERASE_FLASH_SECTOR, addr, NULL)) {
|
if (!ke04_command(f->t, CMD_ERASE_FLASH_SECTOR, addr, NULL))
|
||||||
/* Different targets have different flash erase sizes */
|
return false;
|
||||||
len -= f->blocksize;
|
|
||||||
addr += f->blocksize;
|
/* Different targets have different flash erase sizes */
|
||||||
} else {
|
len -= f->blocksize;
|
||||||
return 1;
|
addr += f->blocksize;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ke04_flash_write(target_flash_s *f, target_addr_t dest, const void *src, size_t len)
|
static bool ke04_flash_write(target_flash_s *f, target_addr_t dest, const void *src, size_t len)
|
||||||
{
|
{
|
||||||
/* Ensure we don't write something horrible over the security byte */
|
/* Ensure we don't write something horrible over the security byte */
|
||||||
target *t = f->t;
|
target *t = f->t;
|
||||||
|
@ -348,15 +347,14 @@ static int ke04_flash_write(target_flash_s *f, target_addr_t dest, const void *s
|
||||||
}
|
}
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
if (ke04_command(f->t, CMD_PROGRAM_FLASH, dest, src)) {
|
if (!ke04_command(f->t, CMD_PROGRAM_FLASH, dest, src))
|
||||||
len -= KE04_WRITE_LEN;
|
return false;
|
||||||
dest += KE04_WRITE_LEN;
|
|
||||||
src += KE04_WRITE_LEN;
|
len -= KE04_WRITE_LEN;
|
||||||
} else {
|
dest += KE04_WRITE_LEN;
|
||||||
return 1;
|
src += KE04_WRITE_LEN;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ke04_flash_done(target_flash_s *f)
|
static bool ke04_flash_done(target_flash_s *f)
|
||||||
|
|
Loading…
Reference in New Issue