That's great! Thanks for posting up the code - I'd forgotten about the issues you can hit if you're evaluating a function from Flash memory when you delete the flash! You could actually call E.reboot() to properly force a reboot without waiting for it to crash :)
Just to add if you're using almost too much memory there is a very small chance that E.toString(ST.read(".bootcde")) will work, but will then fail later on once a bit more memory is used during eval - but it's super unlikely :)
I could definitely add the ability to use JsVars for storage when compacting, which would make it a little less likely that you have to do this. Potentially Espruino could also scan over all the functions inside itself and adjust the addresses such that compact wouldn't cause them to break when using save to flash.
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.
That's great! Thanks for posting up the code - I'd forgotten about the issues you can hit if you're evaluating a function from Flash memory when you delete the flash! You could actually call
E.reboot()
to properly force a reboot without waiting for it to crash :)Just to add if you're using almost too much memory there is a very small chance that
E.toString(ST.read(".bootcde"))
will work, but will then fail later on once a bit more memory is used duringeval
- but it's super unlikely :)I could definitely add the ability to use JsVars for storage when compacting, which would make it a little less likely that you have to do this. Potentially Espruino could also scan over all the functions inside itself and adjust the addresses such that
compact
wouldn't cause them to break when usingsave to flash
.