mirror of
https://github.com/andreili/katapult.git
synced 2025-08-23 19:34:06 +02:00
lpc176x: Permit flashing to addresses other than CONFIG_APPLICATION_START
Allow flash_write_block() to write to arbitrary addresses as long as the flash address starts at a 256 byte boundary. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
fb50570994
commit
b45941967d
@ -19,7 +19,7 @@
|
||||
typedef void (*IAP)(uint32_t *, uint32_t *);
|
||||
|
||||
static uint8_t iap_buf[IAP_BUF_MIN_SIZE] __aligned(4);
|
||||
static uint32_t next_address = CONFIG_APPLICATION_START;
|
||||
static uint32_t next_address;
|
||||
static uint32_t page_write_count;
|
||||
|
||||
// Return the flash sector index for the page at the given address
|
||||
@ -131,9 +131,12 @@ flash_write_block(uint32_t block_address, uint32_t *data)
|
||||
// Not a block aligned address
|
||||
return -1;
|
||||
if (CONFIG_BLOCK_SIZE < IAP_BUF_MIN_SIZE) {
|
||||
if (block_address != next_address)
|
||||
// out of order request
|
||||
return -2;
|
||||
if (block_address != next_address) {
|
||||
if ((block_address | next_address) & (IAP_BUF_MIN_SIZE - 1))
|
||||
// out of order request
|
||||
return -2;
|
||||
next_address = block_address;
|
||||
}
|
||||
uint32_t buf_idx = block_address & (IAP_BUF_MIN_SIZE - 1);
|
||||
memcpy(&iap_buf[buf_idx], data, CONFIG_BLOCK_SIZE);
|
||||
if (buf_idx == IAP_BUF_MIN_SIZE - CONFIG_BLOCK_SIZE) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user