Table of contents

lispBM: A Lisp for Microcontrollers

LispBM (LBM) is a lisp or scheme like programming language for microcontrollers. LispBM also borrows a couple of ideas from Erlang when it comes to concurrency, message passing, pattern matching and process monitoring. The LispBM runtime system can be compiled for either 32 or 64 bit platforms and runs on a wide range of hardware such as for example STM32, NRF52, ESP32 or X86. When running the LispBM runtime system on a microcontroller it can be built on top of ChibiOS, FreeRTOS or ZephyrOS or, if you are adventurous, on bare-metal. LispBM can also be built to run on top of a regular linux.

Who wouldn't want a REPL (read eval print loop) on their embedded platform? This is what LispBM is for!

Want to get involved and help out?

There are lots of interesting things to code on in and around the LispBM runtime system. I would love to interact with people who are interested in high-level programming languages on microcontrollers (or elsewhere) so please do not be shy to make contact. Together we can make great stuff happen ;)

  1. Are you interested in microcontrollers and programming languages?
  2. Do you like both imperative and functional programming?
  3. Clone the repository and join the fun!
  4. Join the discord server

There are areas where insights and help would matter greatly. Some I can think of are:

  1. Running LispBM on system simulators.
  2. LispBM efficiency.
  3. Code size optimisation. Do more with less, while maintaining performance.
  4. Documentation and testing.
  5. Useful extension libraries.
  6. Lisp scriptable home automation.
  7. Lisp scriptable MIDI sequencers.
  8. Lisp scriptable Audio synthesizers.
  9. Porting the Linux REPL to Windows.
  10. Interface with RUST as a language for writing LBM extensions.
  11. partial-evaluation, supercompilation and byte-code compilation.
  12. Real time garbage collection.
  13. Linter/code-preprocessor/checker tailored to LBM idiosyncrasies.
  14. Quickcheck-like property based testing of programs written in LBM.

Getting started with LispBM

The LispBM source code is available on github .

Getting started on embedded: easy

The easiest way to get started with LispBM programming is to use VESC-Tool together with the VESC EXPRESS Firmware on an esp32c3.

VESC-Tool gives you access to a very capable IDE for lisp programming on embedded systems and the VESC Express firmware provides built in functionality to interface with CAN, WIFI, BLE and UART as well as GPIO and display drivers.

If you are looking for a more bare-bones way to add scripting capabilities to your embedded system, LispBM is quite platform independent and can be compiled for many different MCUs and systems. LispBM can tie into the rest of your application via what we call “extensions” which are C functions that can be called from your LispBM scripts.

Getting started on embedded: hard

If you want to build your own lisp environment based on LispBM on top of ChibiOS, Zephyr, FreeRTOS or bare-metal then this is quite possible! I am sorry, though, that there is currently not very much documentation about how to get going with that. Looking at how the vesc_express integration works is one starting point as well as the x86 REPL mentioned below.

Getting started on Linux

Start by cloning the LispBM repository. Open a terminal and issue command

git clone https://github.com/svenssonjoel/lispBM.git

You should now have a directory called lispBM. Go into it and into the repl subdirectory.

cd lispBM
cd repl

Now, you have multiple choices on how to build the REPL. To build the 32bit version (which is most similar to what you will run on a microcontroller) issue the make command.

make

If the make command above fails, it is most likely because there are some missing dependencies.

Building the 32bit version of the repl requires 32bit libraries. If you are on an Ubuntu platform you get 32bit standard libraries by installing gcc-multilib.

In addition to gcc-multilib the REPL requires libreadline andlibpng. You need to get the 32bit versions of these libraries. On Ubuntu you can run the following commands.

sudo apt install gcc-multilib libreadline-dev:i386 libpng-dev:i386

If you were unable to install the 32bit dependencies with the command above, you may need to instruct the package manager that you are interested in 32bit packages as well.

sudo dpkg --add-architecture i386

Then retry the previous step to install the dependencies.

If installing the dependencies finished successfully, make should now work and the repl executable should be built.

Start the REPL and explore!

./repl

You should now be greeted by the LispBM REPL in a way similar to what is shown below.

Lisp REPL started! (LBM Version: 0.27.1)
Type :quit to exit.
     :info for statistics.
     :load [filename] to load lisp source.
#

Try to evaluate some expressions. Type (+ 1 2) and press enter.

Lisp REPL started! (LBM Version: 0.27.1)
Type :quit to exit.
     :info for statistics.
     :load [filename] to load lisp source.
# (+ 1 2)
> 3
# 

When you input code at the # prompt, LispBM answers on a new line starting with >.

Alternatively the REPL can be built as a 64bit binary. Building the 64bit binary requires 64bit versions of the readline and png libraries.

On Ubuntu you get the dependcies by doing sudo apt install libreadline-dev libpng-dev. Then to build the executable you issue the following command.

make all64

Lastly, the REPL can be build with SDL (Simple Directmedia Layer) for graphical output. This is done by issueing the following command.

make sdl64 

Or for 32bit.

make sdl

The REPL with SDL requires libsdl2-dev and libsdl2-image-dev libraries or the 32 bit versions (for 32bit repl binary) libsdl2-dev:i386 and libsdl2-image-dev:i386.

Documentation

Editor support

Testing of LispBM

The table below contains test reports for the recent numbered releases of LispBM. The test reports applies to the tagged states with the same numbering on Github.

Testlog Tagged version
0.28.0 tag 0.28.0
0.27.0 tag 0.27.0
0.26.0 tag 0.26.0
0.25.0 tag 0.25.0
0.24.0 tag 0.24.0
0.23.0 tag 0.23.0

NOTE: The scan-build directory is empty if the scan-build tool finds no issues with the code.


We expand on our testing from time to time but currently apply the following testing methods

Implement a lisp for microcontrollers

The pages below outline steps of development that LispBM went through during 2020 - 2022. The information is quite outdated in relation to what LispBM has become since then but perhaps still contain something fun for someone else who wants to build a lisp from the ground up.

LispBM Performance Evolution

The performance of the LispBM implementation continuously evolves as we introduce new features and engage in optimization efforts. We work to enhance its efficiency for microcontrollers, such as the STM32F4 running at 168MHz.

Below, you can find performance charts illustrating LispBM's performance on a set of benchmarks:

Performance on a small set of benchmarks. Performance (log scale) on a small set of benchmarks.

If you're interested in the technical details and benchmarks, you can explore our benchmark code here:

Benchmarks 2022_02_27

Other Lisp-Like Languages for Microcontrollers

Explore a range of Lisp-like programming languages that are tailored for microcontroller development. These languages are designed to thrive in resource-constrained environments, making them ideal choices for embedded systems. Whether you're looking for a lightweight solution or a minimalist Lisp dialect, these languages offer unique approaches to microcontroller programming.

Is your favourite microcontroller lisp missing from this list? Please send the details in an email bo(dot)joel(dot)svensson(whirly-a)gmail(dot)com.


LispBM stickers: Lispy the llama

The LispBM mascot, Lispy the llama, was created by PixiLadyArt. Thank you, Pixi!

Lispy the llama Glitter lispy the llama
Order glitter llama here
Order the classic classy Lispy the llama here