Getting uLisp to run on the Arduino Nano


#1

The Arduino Nano is essentially just a smaller form-factor version of the popular Arduino Uno, based on the same ATmega328P processor, and it’s a popular board because Chinese clones are available for a few dollars/pounds. Previously I’d assumed that uLisp would run on it with the same performance as on the Arduino Uno.

However, I was recently contacted by a micro programming group whose students have Arduino Nanos, but have been struggling to get uLisp running on them.

Further investigation revealed that the Arduino Nano differs from the Arduino Uno in one crucial aspect. From the specifications on the Arduino site:

  • Arduino Uno (Rev 3): Flash memory 32 KB of which 0.5 KB used by bootloader.
  • Arduino Nano: Flash memory 32 KB, of which 2 KB used by bootloader.

If you install uLisp on the Arduino Uno you get:

Sketch uses 32194 bytes (99%) of program storage space. Maximum is 32256 bytes.

It fits, but only with 62 bytes spare.

However, if you try and install it on the Arduino Nano you get the error:

Sketch uses 32194 bytes (104%) of program storage space. Maximum is 30720 bytes.
Sketch too big

So uLisp is taking the same amount of space on each board, but the Arduino Nano bootloader is taking up an additional 1536 bytes!

The solutions

There are two possible solutions:

Run an earlier version of uLisp

The most recent version of uLisp that will fit on the Arduino Nano is Version 2.5:

http://www.ulisp.com/list?2E6U

For a list of newer features that you will be missing out on, see Older versions.

Install the Uno bootloader

A better solution is to install the improved Uno bootloader, and then pretend that the Nano is a Uno. You can always use the same procedure to put back the Arduino Nano bootloader if you want to (although I’m not sure why you would want to do that!).

The procedure is as follows:

  • Disconnect the USB cable from the Arduino Nano.
  • Connect an ISP programmer to the 6-pin ISP header on the Arduino Nano.

I used the USBasp programmer that comes with a cable that fits on the 6-way header; it’s available from many vendors and on eBay:

USBasp programmer on eBay.

Orient the header plug with MISO connected to the pin marked 1.

Alternatively you can use an Arduino Uno as an ISP programmer:

How to burn the bootloader in an Arduino Nano using an Arduino UNO

Connect it to the ISP header with six cables. If your board doesn’t have an ISP header, connect to the six corresponding pins on the edge connector: GND, VCC, MOSI, MISO, SCK, and RESET.

  • On the Arduino IDE Tools menu set Programmer to USBasp.
  • On the Tools menu choose the Arduino AVR Boards core and set Board to Arduino Uno.
  • Choose Burn Bootloader.

You should now be able to use the Arduino Nano by selecting Arduino Uno as the board type, and you’ll be able to upload uLisp.


Unclear errors when trying to compile on different Arduino boards
#2

I remember you used to have a “stripped down” version, and maybe that is something to consider: for such platforms, to have a version that is “frozen” and “primitive”, and only updated if the platform requires it (e.g. for installation). I am not sure didn’t uLisp on the UNO already “take it too far” to be practical… “Features” are meanigless, after all, if you have no space to employ them!


#3

The cut-down version you’re thinking of is uLisp Zero:

uLisp Zero

No, uLisp on the Arduino Uno is a fully-featured version of uLisp. Apart from a couple of limitations (16-bit integer arithmetic, no arrays), it contains the same functions as the 32-bit versions of uLisp. And, as of Version 4.0, symbol names are no longer limited to three characters.

The main restriction is the small amount of RAM on the ATmega328P (2 Kbytes), but it’s still perfectly usable for running small programs, such as all the Simple examples.


#4

Have you ever considered “uLisp Zero with integer maths”? I think for many people and uses that will be enough…


#5

Anyone is welcome to extend uLisp Zero to do that. However, I don’t see what the advantage would be of leaving out the other features. I don’t think it would make Lisp run any faster, and the amount of available workspace would be the same.


#6

It’s not about “faster”, David! :)

It is about the idea that your uLips Zero is actually AWESOME, NEARLY useable for all sorts of demonstrations, and the “only thing sort of missing” - is elementary maths. I am lacking, unfortunately, the expertise, but I have always wondered. You know, three-letter-symbols, no strings, no frills… but, with math… It would be SO SMALL!

(I cannot say “it would be impressive” or “it would be brilliant”, because, you guess it, ALL you have done is brilliant and impressive… so it would be, but in that regard - without difference to the rest!)