rp: invert success logic in rp_flash_write

Target write operations return boolean values: `true` indicates a write
was successful, while `false` indicates there was a failure.

Inside the rpi target, there is a delegate function `rp_rom_call` that
performs the heavy lifting. It also returns `true` on success and
`false` on failure.

The rp_flash_write() function was inverting this logic, which caused it
to return `false` on success and `true` on failure. This behaviour was
exhibited as only the first 0x89c bytes successfully write to the
device.

Invert this logic in order to get rpi working again.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2022-09-01 12:57:24 +08:00 committed by Rachel Mant
parent 993c74bef4
commit 3e8f296dd5
1 changed files with 4 additions and 4 deletions

View File

@ -461,7 +461,7 @@ static bool rp_flash_write(target_flash_s *f, target_addr_t dest, const void *sr
rp_priv_s *ps = (rp_priv_s *)t->target_storage; rp_priv_s *ps = (rp_priv_s *)t->target_storage;
/* Write payload to target ram */ /* Write payload to target ram */
rp_flash_prepare(t); rp_flash_prepare(t);
bool ret = 0; bool ret = true;
#define MAX_WRITE_CHUNK 0x1000 #define MAX_WRITE_CHUNK 0x1000
while (len) { while (len) {
uint32_t chunksize = (len <= MAX_WRITE_CHUNK) ? len : MAX_WRITE_CHUNK; uint32_t chunksize = (len <= MAX_WRITE_CHUNK) ? len : MAX_WRITE_CHUNK;
@ -474,8 +474,8 @@ static bool rp_flash_write(target_flash_s *f, target_addr_t dest, const void *sr
* however it takes much longer if the XOSC is not enabled * however it takes much longer if the XOSC is not enabled
* so lets give ourselves a little bit more time (x10) * so lets give ourselves a little bit more time (x10)
*/ */
ret |= rp_rom_call(t, ps->regs, ps->rom_flash_range_program, (3 * chunksize * 10) >> 8); ret = rp_rom_call(t, ps->regs, ps->rom_flash_range_program, (3 * chunksize * 10) >> 8);
if (ret) { if (!ret) {
DEBUG_WARN("Write failed!\n"); DEBUG_WARN("Write failed!\n");
break; break;
} }
@ -485,7 +485,7 @@ static bool rp_flash_write(target_flash_s *f, target_addr_t dest, const void *sr
} }
rp_flash_resume(t); rp_flash_resume(t);
DEBUG_INFO("Write done!\n"); DEBUG_INFO("Write done!\n");
return !ret; return ret;
} }
static bool rp_mass_erase(target *t) static bool rp_mass_erase(target *t)