jshardware.c flash functions for nRF51 & nRF52 #805
Replies: 6 comments
-
Posted at 2015-09-23 by @gfwilliams jshSaveToFlash takes what's in RAM, compresses it, and writes it into flash memory (which pages are used depend on the board). jshLoadFromFlash just does the opposite. jshFlashContainsCode actually just checks for a 'magic word' in memory that shows that the flash has been written. However you're best off implementing at a lower level and then flash memory access is available via the Info about what the functions should do is here - let me know if you're not sure though. Finally, Espruino needs to know where the free pages are. It's just an entry in
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-23 by Kolban @mjdietz @gordon |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-27 by Kolban I've studied and plan to study more ... but if anyone can help me out by explaining some architecture it would be appreciated. I am at the point where in the ESP8266 support I can load JavaScript into the ESP8266 for execution ... but now am puzzled on what techniques should come into play should I want to "harden" or "save" the application such that when the ESP8266 boots and loads Espruino ... my app will start and come to life without me having to load it again through UART. Neil |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-27 by @gfwilliams When saving, Espruino takes what's in RAM, compresses it, and writes it into flash memory somewhere. Loading is the opposite (and Espruino checks to see if it has code just by checking for a magic byte at the end of that memory area). First, you need to find some free pages somewhere on the EP8266's flash memory. I don't know enough about it to help there - is there actually some kind of filesystem? But as above, once you know that you stick the address and size of memory you can allow into the
Docs in And that's it - everything else should be handled. Wasn't this something @aplikatika had done previously? I think his github page mentioned something. The saving code did change - because I wanted to make it easier to port to new platforms - but you should be able to crib the relevant bits of his work quite easily. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-30 by mjdietz OK so I'm thinking i change my linker file so that the last couple of pages in flash are reserved for saving. So right now in my linker my flash has an ORIGIN address that is incremented so it is just after the softdevice and it has a length that then goes to the end off flash to be used by my application. How many pages (each page is 4096 bytes) should I reserve for Espruino at the end so I get full functionality? 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? so then jshflashcontainscode() would just check the first address of this flash to see that it has been written? any specific value or just check that it is not completly ereased? and are you saying I dont actually have to implemtn jshSaveToFlash and load? I'm not sure how to compress ram etc.. thanks! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-30 by @gfwilliams
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 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
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
I actually wrote these up last week! :) https://github.com/espruino/Espruino/blob/master/README_BuildProcess.md#chip But yeah, address would be 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 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-09-23 by mjdietz
I am trying to implement some functions in jshardware.c
I want the save() functionality so I can save functions and variables and keep them when the device turns on. and then can use the onInit() functionality as well.
so I'm assuming to get this working I just need to implement the Flash functions in jshardware.c?
what exactly is jshSaveToFlash and jshLoadFromFlash supposed to do? I'm not really sure where or what the contents of JsVars is.
also how would you reccomend implementing jshFlashContainsCode()?
-Thanks
Mike
Beta Was this translation helpful? Give feedback.
All reactions