mirror of https://github.com/wolfSSL/wolfBoot.git
[rp2350] Added cache in RAM for hal_flash_write
parent
82e4950b59
commit
d6ba220e55
16
hal/rp2350.c
16
hal/rp2350.c
|
|
@ -224,7 +224,21 @@ void hal_prepare_boot(void)
|
|||
|
||||
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
|
||||
{
|
||||
flash_range_program(address - XIP_BASE, data, len);
|
||||
uint8_t cache[WOLFBOOT_SECTOR_SIZE];
|
||||
uint32_t written = 0;
|
||||
uint32_t sz;
|
||||
if (((uintptr_t)data & 0x20000000UL) == 0) {
|
||||
/* Not in RAM: copy to cache before writing */
|
||||
while (written < len) {
|
||||
sz = WOLFBOOT_SECTOR_SIZE;
|
||||
if (sz > (len - written))
|
||||
sz = len - written;
|
||||
memcpy(cache, data + written, sz);
|
||||
flash_range_program(address - XIP_BASE + written, cache, sz);
|
||||
written += sz;
|
||||
}
|
||||
} else
|
||||
flash_range_program(address - XIP_BASE, data, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2005,7 +2005,7 @@ int wolfBoot_nsc_erase_update(uint32_t address, uint32_t len)
|
|||
return -1;
|
||||
if (address + len > WOLFBOOT_PARTITION_SIZE)
|
||||
return -1;
|
||||
hal_flash_erase(address + WOLFBOOT_PARTITION_UPDATE_ADDRESS, len);
|
||||
return hal_flash_erase(address + WOLFBOOT_PARTITION_UPDATE_ADDRESS, len);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -2016,7 +2016,7 @@ int wolfBoot_nsc_write_update(uint32_t address, const uint8_t *buf, uint32_t len
|
|||
return -1;
|
||||
if (address + len > WOLFBOOT_PARTITION_SIZE)
|
||||
return -1;
|
||||
hal_flash_write(address + WOLFBOOT_PARTITION_UPDATE_ADDRESS, buf, len);
|
||||
return hal_flash_write(address + WOLFBOOT_PARTITION_UPDATE_ADDRESS, buf, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue