Instructions for porting uLisp to a new platform


#1

Here are some draft instructions for porting uLisp to a new platform that it doesn’t currently support.

I’ve made this topic a Wiki - if you’re trying out these instructions feel free to edit it to improve what I’ve written or add information you think is missing (just click the Edit icon at the bottom of the topic).

Requirements

To port uLisp to a new platform it needs to satisfy the following requirements:

  • At least 2 Kbytes of RAM.
  • At least 32 Kbytes of program memory; probably more for 32-bit platforms.
  • A core for the Arduino IDE.
  • Support for serial via the Arduino IDE Serial Monitor.

Check that you can upload and run the Blink sketch from File->Examples->01.Basics in the Arduino IDE.

Select the most appropriate starting point

Choose an existing version of uLisp that’s close to the platform that you’re planning to support. Currently the choice is:

  • AVR uLisp: for 16-bit AVR processors. No floating-point support. Images are saved in the on-chip EEPROM.

  • ARM uLisp: for 32-bit ARM chips. Floating-point support. Images are saved to an SD card if available, or to DataFlash if available.

  • ESP uLisp: for 32-bit ESP8266 and ESP32 platforms. Images are saved to flash using EEPROM emulation. Includes Wi-Fi extensions.

Specify the workspace

If you don’t do this step you’ll typically get the error:

'WORKSPACESIZE' was not declared in this scope

Locate the section in the uLisp source beginning:

// Workspace

and add a section to the list of supported platforms; for example:

#elif defined(MY_PLATFORM)
  #define WORKSPACESIZE 3072       /* Cells (8*bytes) */

MY_PLATFORM should be the #define used by the Arduino IDE to identify the platform. I haven’t found a reliable way of discovering this. If in doubt invent a name, and put a:

#define MY_PLATFORM

at the start of the source file.

Edit the line:

#define WORKSPACESIZE 3072

to specify the number of Lisp objects to allocate. On 16-bit platforms each object is 4 bytes, and on 32-bit platforms each object is 8 bytes. Basically the best approach is to give a small value at first, such as 1024, and then increase it until you either get low-memory warnings by the Arduino IDE, or you get erratic behaviour due to not enough stack space.

You should now be able to compile uLisp.

Open the Serial Monitor and check that you get a uLisp prompt. Try typing an input and check that an appropriate response is echoed.

This is the first step; there’s more you’ll need to do to provide support for all uLisp’s features on your platform, but I’ll deal with those on request in further posts.

To check that uLisp is working correctly try some of the benchmarks at:

Benchmarks


Suggested boards for running uLisp?
How can I get uLisp to run on a Nordic nRF52840?
#2

There is an updated version of this information here:

Porting uLisp to a new platform