p'lisp

Bring p'lisp to a new board

For: People with a microcontroller or Linux board that p'lisp does not support yet, who are happy to build firmware.

p'lisp runs on more than the calculator. If you have a board we have never built for, you can port it yourself, test it, and send it in. This page is the whole path. You do not need to ask first.

One p'lisp on every board. A port does not fork the language. Your board gets the same p'lisp, the same nREPL and the same core library as every other board. What is yours is a thin layer: the chip's start-up code, the pins, and a board library for the parts on your board.

Work in progress. Ports are young. The ESP32-S3 port, the template for most new boards, is being merged now, and the selftest command in step 4 is being built. Until it ships, run the same checks by hand from the list in step 4, and paste what you see.

1. Check your board

Find your chip in this table. The chip family decides how much work the port is.

Chip familyWhere p'lisp is todayWhat a new board needs
RP2350 (Pico 2 and others)the p'lisp calculator's firmware; no nREPL prompt yeta pin map, a board library, and the nREPL console when it lands
ESP32-S3a Feather-style board, with an nREPL prompt over USB (being merged)a pin map and a board library
ESP32in progressa pin map and a board library, once the ESP32 port lands
Linux on ARM (Raspberry Pi 2 and newer, other arm64 boards)the plisp command's Linux builds (arm64, and armhf for Pi 2 and newer)usually nothing: install plisp
Anything else, including ARMv6 Linux (Pi Zero, Pi 1)none yeta new chip layer, then the above

A board on a family we already run is a small port: an afternoon for most people. A new chip family is a bigger job, and we will want to buy that chip to test it ourselves (step 6).

Size. p'lisp needs room. Use a chip with at least 256 KB of RAM and 2 MB of flash. Chips like the ATmega328 are too small.

2. Start from the nearest port

Copy the port whose chip is closest to yours, and give the copy your board's name:

Then change only what your board needs:

  1. Memory map and heap size. Set them from your chip's datasheet.
  2. The console. p'lisp talks to your computer through nREPL over the USB serial port. If your board has no USB serial, use a UART and a USB-to-serial adapter.
  3. The pin map. List every pin your board's parts use, with its name on the board.

Leave the evaluator, the nREPL core and the core library alone. If one of them must change for your board, open an issue first and say why: a change there changes every board.

3. Get a prompt

Today this works on the ESP32-S3 port only. Flash the board with the chip's usual tool (picotool or a debug probe for RP2350, espflash for ESP32). Connect your editor's nREPL client, or use plisp-serial-bridge, and evaluate:

(+ 1 2)

You should get 3. Then check the heap:

(board/heap)

If you get a map with :used and :free, the core runs. Every port provides board/heap and board/ms (milliseconds since start); the self-test needs both. Now add your board's parts (LEDs, buttons, screen, radio) as a board library: a set of p'lisp functions, such as led/set!, that call into your board layer. A board library is an opt-in package: apps that do not use it do not carry it.

4. Run the self-test

With the board on USB, run:

plisp device -s <port> selftest --board <your-board-name>

It does two things:

  1. Core checks. It sends a fixed set of p'lisp checks over nREPL: numbers, strings, collections, deep recursion, errors, garbage collection, timing and the nREPL itself. These are the same checks that every board runs. They need no help from you.
  2. Part checks. For each part in your board library, it does something you can see or hear, then asks you what happened: "Did the first LED turn red? (y/n)". Parts that can check themselves (a radio that joins your Wi-Fi, an I2C bus that finds its sensor) need no answer.

At the end it writes selftest-<your-board-name>.json and prints a summary. Exit code 0 means every check passed.

Until the command ships, do these by hand over nREPL and paste the results: (+ 1 2), (reduce + (range 100000)), (count (str (reduce * (range 1 200)))), (board/heap) before and after (dotimes [_ 1000] (vec (range 1000))), and each of your board library's functions.

5. Show it working

Record a short video or take a photo of the board doing something only it can do: the LEDs in a pattern you typed, a picture from its camera, a reading from its sensor. Put it anywhere we can see it, such as the pull request itself.

6. Send it in

Open a pull request on github.com/playplisp/plisp with:

What happens next. We read the code and the report against a fixed checklist. Then your board gets one of these labels on the site:

LabelMeans
BuildsThe firmware builds in our checks. Where an emulator exists for the chip, the core checks also pass on it on every change.
Community testedBuilds, and a person ran the self-test on a real board, sent the report and showed it working.
Lab testedWe ran the self-test on the same chip family ourselves.

Your board starts as Community tested when the review passes. It moves to Lab tested when we have that chip family on our bench.

Why we do not trust an emulator alone. For some chips, an emulator can run p'lisp's core checks on every change, with no board. But no emulator we use runs the parts that make a board worth having: Wi-Fi, USB, LEDs, cameras, most buses. Only a real board can show those work, so we ask for your report and your video, and we test each chip family on our own bench.

Thank you for porting p'lisp. Questions: hello@playplisp.com.