target_flash: flash read write return bool
This commit is contained in:
parent
664d09786a
commit
e968fc956c
|
@ -440,7 +440,7 @@ static bool target_cmd_range_erase(target *const t, const int argc, const char *
|
||||||
const uint32_t addr = strtoul(argv[1], NULL, 0);
|
const uint32_t addr = strtoul(argv[1], NULL, 0);
|
||||||
const uint32_t length = strtoul(argv[2], NULL, 0);
|
const uint32_t length = strtoul(argv[2], NULL, 0);
|
||||||
|
|
||||||
return target_flash_erase(t, addr, length) == 0;
|
return target_flash_erase(t, addr, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Accessor functions */
|
/* Accessor functions */
|
||||||
|
|
|
@ -143,7 +143,7 @@ bool target_flash_erase(target *t, target_addr_t addr, size_t len)
|
||||||
if (!flash_prepare(f))
|
if (!flash_prepare(f))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ret &= f->erase(f, local_start_addr, f->blocksize) == 0;
|
ret &= f->erase(f, local_start_addr, f->blocksize);
|
||||||
|
|
||||||
len -= MIN(local_end_addr - addr, len);
|
len -= MIN(local_end_addr - addr, len);
|
||||||
addr = local_end_addr;
|
addr = local_end_addr;
|
||||||
|
@ -267,7 +267,7 @@ static bool flash_buffered_flush(target_flash_s *f)
|
||||||
uint32_t len = f->buf_addr_high - aligned_addr;
|
uint32_t len = f->buf_addr_high - aligned_addr;
|
||||||
|
|
||||||
for (size_t offset = 0; offset < len; offset += f->writesize)
|
for (size_t offset = 0; offset < len; offset += f->writesize)
|
||||||
ret &= f->write(f, aligned_addr + offset, src + offset, f->writesize) == 0;
|
ret &= f->write(f, aligned_addr + offset, src + offset, f->writesize);
|
||||||
|
|
||||||
f->buf_addr_base = UINT32_MAX;
|
f->buf_addr_base = UINT32_MAX;
|
||||||
f->buf_addr_low = UINT32_MAX;
|
f->buf_addr_low = UINT32_MAX;
|
||||||
|
|
|
@ -35,8 +35,8 @@ struct target_ram {
|
||||||
typedef struct target_flash target_flash_s;
|
typedef struct target_flash target_flash_s;
|
||||||
|
|
||||||
typedef bool (*flash_prepare_func)(target_flash_s *f);
|
typedef bool (*flash_prepare_func)(target_flash_s *f);
|
||||||
typedef int (*flash_erase_func)(target_flash_s *f, target_addr_t addr, size_t len);
|
typedef bool (*flash_erase_func)(target_flash_s *f, target_addr_t addr, size_t len);
|
||||||
typedef int (*flash_write_func)(target_flash_s *f, target_addr_t dest, const void *src, size_t len);
|
typedef bool (*flash_write_func)(target_flash_s *f, target_addr_t dest, const void *src, size_t len);
|
||||||
typedef bool (*flash_done_func)(target_flash_s *f);
|
typedef bool (*flash_done_func)(target_flash_s *f);
|
||||||
|
|
||||||
struct target_flash {
|
struct target_flash {
|
||||||
|
|
Loading…
Reference in New Issue