In a future release of uLisp I propose the following changes to save-image and load-image to:
- Allow saving images to non-volatile memory even when SD card is enabled
- Improve the autoloading and autorunning of images on reset
- Warn about potentially invalid images
- Make the feature less confusing.
Current behaviour
If you do not have SD card support
-
You can save to or load from non-volatile memory.
-
One image (“ulisp.img” on LittleFS) can be saved or loaded
-
Undocumented: in addition on LittleFS you can give a filename and save multiple different images to non-volatile memory.
If you have SD card support
-
You can only save to or load from SD card.
-
If you do not give a filename the default file “ulisp.img” is used.
-
You can give a filename and save/load multiple different images.
If resetautorun and SD card support are enabled
-
The default image “ulisp.img” is loaded from SD card on reset.
-
If it was saved with a function parameter, that function will be run.
If resetautorun is enabled but not SD card support
-
The image (“ulisp.img” on LittleFS) is loaded from non-volatile memory on reset.
-
If it was saved with a function parameter that function will be run.
To enable resetautorun
- You had to change the #define resetautorun setting and upload uLisp again.
Proposed new behaviour
-
If you don’t give a filename, save-image/load-image will use non-volatile memory.
-
If you do give a filename, save-image/load-image will use SD card, or if not installed, give an error “SD card not available”.
-
The #define resetautorun will no longer be used, and you will now be able to change the behaviour without re-compiling and uploading uLisp as follows:
-
If the second parameter to save-image is t the image will be loaded from non-volatile memory on reset.
-
If the second parameter to save-image is a function, the image will be loaded from non-volatile memory and that function run on reset.
-
-
To improve on the currently non-ideal behaviour, loading an image saved from an older version of uLisp will display a warning:
This image was saved from an older version of uLisp and may not be valid.
Alternatively, rather than check the uLisp version, one idea is to do a silent pprintall on save-image, calculate a checksum over the output, and save it in the image header. Then do the same on load-image, and display a warning if they don’t agree.
Potential problems with the proposed changes
-
Users who are using the undocumented ability to save named image files on LittleFS will no longer be able to do so.
-
Users will no longer be able to autoload or autorun an image from SD card on reset.
-
Platforms without the ability to save images to non-volatile memory will not be able to use resetautorun (these platforms are BBC Micro:bit, Maxim MAX32620FTHR, Sipeed Maixduino, and Sipeed MAiX BiT).
-
To turn off autoloading on reset or autoloading and running on reset you will have to resave the image with a different parameter.
I’d welcome any comments or suggestions for improvements.