From 0ab10fee0b6afb94e7bdba2a13f7116145b9030a Mon Sep 17 00:00:00 2001 From: James Turton Date: Fri, 14 May 2021 18:12:36 +0200 Subject: [PATCH] rp: Increase timeout for flash_range_program If the RP2040 is using the ring oscilator (ROSC) rather than the crystal oscilator (XOSC) then flashing program will take much longer. As the XOSC is not enabled at boot we should not assume it will be enabled before the debugger is connected (or indeed at all), thus should use the longer timeout during load commands. --- src/target/rp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/target/rp.c b/src/target/rp.c index 207e47f..b215803 100644 --- a/src/target/rp.c +++ b/src/target/rp.c @@ -283,8 +283,12 @@ int rp_flash_write(struct target_flash *f, ps->regs[0] = dest; ps->regs[1] = SRAM_START; ps->regs[2] = chunksize; + /* Loading takes 3 ms per 256 byte page + * however it takes much longer if the XOSC is not enabled + * so lets give ourselves a little bit more time (x10) + */ ret |= rp_rom_call(t, ps->regs, ps->flash_range_program, - (3 * chunksize) >> 8); /* 3 ms per 256 byte page */ + (3 * chunksize * 10) >> 8); if (ret) { DEBUG_WARN("Write failed!\n"); break;