diff --git a/cpu/lpc23xx/ldscripts/lpc23xx.ld b/cpu/lpc23xx/ldscripts/lpc23xx.ld index 53156e7c8f..48c5e91f9e 100644 --- a/cpu/lpc23xx/ldscripts/lpc23xx.ld +++ b/cpu/lpc23xx/ldscripts/lpc23xx.ld @@ -204,6 +204,10 @@ SECTIONS _sram = ORIGIN(ram); _eram = ORIGIN(ram) + LENGTH(ram); + /* Populate information about rom size */ + _srom = ORIGIN(rom); + _erom = ORIGIN(rom) + LENGTH(rom); + .heap1 ALIGN(4) (NOLOAD) : { _sheap1 = ORIGIN(ram_ethernet); @@ -243,4 +247,8 @@ SECTIONS _sheap3 = . ; _eheap3 = ORIGIN(ram_battery) + LENGTH(ram_battery); } > ram_battery + + .end_fw (NOLOAD) : ALIGN(4) { + _end_fw = . ; + } > rom } diff --git a/cpu/lpc23xx/periph/flashpage.c b/cpu/lpc23xx/periph/flashpage.c index d35ceedcaa..80bb7c676d 100644 --- a/cpu/lpc23xx/periph/flashpage.c +++ b/cpu/lpc23xx/periph/flashpage.c @@ -34,6 +34,13 @@ typedef void (*IAP)(unsigned int[], unsigned int[]); static const IAP IAP_Entry = (IAP)0x7ffffff1; +/** + * @brief Memory markers, defined in the linker script + * @{ + */ +extern uint32_t _end_fw; +extern uint32_t _erom; + static uint32_t iap(uint32_t code, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4) { /* contains parameters for IAP command */ @@ -251,3 +258,13 @@ void flashpage_write(void *target_addr, const void *data, size_t len) DEBUG("ERROR: COPY_RAM_TO_FLASH: %u\n", err); } } + +unsigned flashpage_first_free(void) +{ + return flashpage_page(&_end_fw) + 1; +} + +unsigned flashpage_last_free(void) +{ + return flashpage_page(&_erom) - 1; +}