After being away for a year it's nice to see all the progress on Espruino!
I did struggle for quite some time to update my stuff and to get my code working again under V2.01, so I thought I'd write up a quick how-to so I remember the next time I try to do something :-) Maybe it also helps someone else 'cause very little of this is spelled out anywhere that I could find (the best info is at http://www.espruino.com/Saving but that page is not linked to from any other page on http://www.espruino.com!)
- I have a bunch of apps that are fairly large and must run from flash.
- I use local modules.
- The apps must run auto-run at boot time.
- I prefer CLI over the IDE.
I couldn't do an OTA update from pre-V2 of Espruino to V2.x due to a changed flash layout (512 vs 1024KB partitions). I have esp-12e modules with 4MB flash, so I installed the official espressif tool https://github.com/espressif/esptool/ and flashed using:
esptool -p /dev/ttyUSB0 write_flash --flash_size 4MB-c1 --flash_mode qio 0 espruino_2v01_esp8266_4mb_combined_4096.bin
In the IDE I had to set the options SAVE_TO_FLASH to 1 and MODULE_AS_FUNCTION to true. But I don't want to use the IDE...
So I installed the espruino cli:
- Install node.js version 8 (old!), I'm using Linux and untarred the binary archive from the node.js site in
/home/sw/node-v8 (non-std location, use any dir you like)
- Install espruino using
/home/sw/node-v8/bin/npm install espruino
In order to ensure that I can run the cli using node-v8, I created a little shell script I call
espruino --no-ble --config SAVE_ON_SEND=1 --config MODULE_AS_FUNCTION=true "$@"
To flash an application I have the main file in a
projects subdirectory and the modules in a
modules subdirectory. I simply
require(...) the module in the main file. The flashing command is:
./expruino-v8 -p tcp://esp8266.local:23 -w -m projects/foo.js
The -w option means that espruino stays connected and shows me the console output.
The application uses an
onInit() to start and that gets invoked automatically at the end of the upload.