Skip to content

Commit 527b11f

Browse files
committed
implement suggested changes
- update FLASH_FIRMWARE length - use linker script define value
1 parent 205837c commit 527b11f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

ports/raspberrypi/common-hal/nvm/ByteArray.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "py/runtime.h"
3232
#include "src/rp2_common/hardware_flash/include/hardware/flash.h"
3333

34+
extern uint32_t __flash_binary_start;
35+
3436
uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t* self) {
3537
return self->len;
3638
}
@@ -39,12 +41,12 @@ static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_
3941
// Write a whole page to flash, buffering it first and then erasing and rewriting
4042
// it since we can only clear a whole page at a time.
4143
if (offset == 0 && len == FLASH_PAGE_SIZE) {
42-
flash_range_program(page_addr - 0x10000000, bytes, FLASH_PAGE_SIZE);
44+
flash_range_program(page_addr - (uint32_t) &__flash_binary_start, bytes, FLASH_PAGE_SIZE);
4345
} else {
4446
uint8_t buffer[FLASH_PAGE_SIZE];
4547
memcpy(buffer, (uint8_t*) page_addr, FLASH_PAGE_SIZE);
4648
memcpy(buffer + offset, bytes, len);
47-
flash_range_program(page_addr - 0x10000000, buffer, FLASH_PAGE_SIZE);
49+
flash_range_program(page_addr - (uint32_t) &__flash_binary_start, buffer, FLASH_PAGE_SIZE);
4850
}
4951
}
5052

ports/raspberrypi/link.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
MEMORY
2525
{
26-
FLASH_FIRMWARE (rx) : ORIGIN = 0x10000000, LENGTH = 1024k
26+
FLASH_FIRMWARE (rx) : ORIGIN = 0x10000000, LENGTH = 1020k
2727
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256k
2828
SCRATCH_X (rwx) : ORIGIN = 0x20040000, LENGTH = 4k
2929
SCRATCH_Y (rwx) : ORIGIN = 0x20041000, LENGTH = 4k

0 commit comments

Comments
 (0)