We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 82e4950 commit a2396e7Copy full SHA for a2396e7
1 file changed
hal/rp2350.c
@@ -224,7 +224,21 @@ void hal_prepare_boot(void)
224
225
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
226
{
227
- flash_range_program(address - XIP_BASE, data, len);
+ uint8_t cache[WOLFBOOT_SECTOR_SIZE];
228
+ uint32_t written = 0;
229
+ uint32_t sz;
230
+ if (((uintptr_t)data & 0x20000000UL) == 0) {
231
+ /* Not in RAM: copy to cache before writing */
232
+ while (written < len) {
233
+ sz = WOLFBOOT_SECTOR_SIZE;
234
+ if (sz > (len - written))
235
+ sz = len - written;
236
+ memcpy(cache, data + written, sz);
237
+ flash_range_program(address - XIP_BASE + written, cache, sz);
238
+ written += sz;
239
+ }
240
+ } else
241
+ flash_range_program(address - XIP_BASE, data, len);
242
return 0;
243
}
244
0 commit comments