Restarting after saving an image with autorun


#1

Suppose I save to the SD card an image with an autorun function, turn off the device, and turn it back on. What image does the device start from? The default firmware or the saved image?


#2

I agree that the options are a bit confusing.

If you leave:

// #define resetautorun

commented out, nothing happens on reset or power-up.

If you uncomment that, and save an image with the default name ulisp.img, with:

(save-image)

it will be loaded on reset or power-up. This is useful for providing your own predefined functions.

If in addition you give a parameter, such as:

(save-image 'fun)

then the image will be loaded on reset or power-up, and the function fun will be run. The image should contain the definition of fun. For example:

(defun fun () "Welcome to uLisp!")

This is useful for creating a stand-alone project written in Lisp, such as a digital clock.

Note that it’s not the default firmware that’s being loaded, but just the compacted Lisp workspace, containing the function and variable definitions. It can be very small; just 152 bytes for the above fun example.

I’ve improved the explanation in Language reference - save-image.