I'm thinking i change my linker file so that the last couple of pages in flash are reserved for saving
In the STM32F1 builds I put the saved code at the end of flash like you're doing, but I keep the linker as-is. I just have the check_flash (iirc?) script that does a sanity check of the binary's size afterwards (based on board.py) to make sure the image isn't so big that it overlaps the end of flash memory.
The bonus here is that if the binary is too big then you're told - but it still links, so you can look at the symbols in the binary and see what's taking up too much space.
In the interest of keeping things simple (with those changes for LINKER_x in build_platform_config, I think we could keep the Nordic linker files?) I'd think about doing that.
How many pages (each page is 4096 bytes) should I reserve for Espruino at the end so I get full functionality?
It depends on the amount of RAM dedicated to variables... As the RAM is compressed (ish) before writing I'd say you need about half the amount of RAM. So if you had 4000 variables that's 4000 * 16 = 64000 bytes, so I'd save about 32000 bytes?
Also in BOARDS.py would address by the address of the first page to be used to save? then flash_availialbe would be the total bytes of these save pages? also what is place_text_section?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
In the STM32F1 builds I put the saved code at the end of flash like you're doing, but I keep the linker as-is. I just have the
check_flash
(iirc?) script that does a sanity check of the binary's size afterwards (based onboard.py
) to make sure the image isn't so big that it overlaps the end of flash memory.The bonus here is that if the binary is too big then you're told - but it still links, so you can look at the symbols in the binary and see what's taking up too much space.
In the interest of keeping things simple (with those changes for
LINKER_x
in build_platform_config, I think we could keep the Nordic linker files?) I'd think about doing that.It depends on the amount of RAM dedicated to variables... As the RAM is compressed (ish) before writing I'd say you need about half the amount of RAM. So if you had 4000 variables that's
4000 * 16 = 64000 bytes
, so I'd save about 32000 bytes?I actually wrote these up last week! :) https://github.com/espruino/Espruino/blob/master/README_BuildProcess.md#chip
But yeah, address would be
end_of_flash - size_of_saved_code_area
. you can ignore place_text_section as you're using your own linker file.Best to look at [the olimexino board file])(https://github.com/espruino/Espruino/blob/master/boards/OLIMEXINO_STM32.py) as that does basically what you want.
Actually the last 4 bytes IIRC - but you shouldn't need to implement that. All you need are these guys and the rest is done for you.
Yep - literally just these 4 functions and you're sorted