MiniScript on a bare-metal Raspberry Pi
Published: 2024-03-02 14:25:14

I recently discovered a C++ library ([circle](https://github.com/rsta2/circle)) that simplifies writing C++ programs to run on the Raspberry Pi, directly "on the metal" — without any operating system.  I've had a Raspberry Pi 400 on my side table for a couple years now, running the standard Linux distribution, but not getting much use.  What I really wanted was an experience like the classic home computers of the 80s: turn it on, and within seconds you are at a friendly blinking cursor, waiting for you to type some BASIC (or in our case, [MiniScript](https://miniscript.org)) code.

So I decided to make exactly that.

![Animated GIF of MiniScript-Pi in action, showing `print "Hello world!`, `print 6*7`, and a MiniScript version of the classic 10PRINT demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1f5xdqpwfvxgz0qiu2tb.gif)

(For a bigger video showing the boot time and the Raspberry Pi, check out the [YouTube video](https://www.youtube.com/watch?v=09yh_Zz0UiA).)

## What it does

- Boots very fast
- Presents a working MiniScript REPL
- Supports command history
- Provides all the MiniScript core intrinsics (`print`, `rnd`, etc.)

## What it doesn't do

- Key auto-repeat
- Left/Right/Delete by word rather than by character
- Have any editor or persistent in-memory program
- Retain variables after hitting control-C
- Provide any intrinsic methods/classes beyond what's in the MiniScript core

With these limitations — particularly the lack of an editable program — it's really just a tech demo, not useful for any real work.  But it's a _neat_ tech demo, if I do say so myself.

## Try it!

If you have a Raspberry Pi (especially a Pi 4 — the code is untested and may not work on other versions of the Pi), you can run this yourself!  Download the zip file from the [release page](https://github.com/JoeStrout/MiniScript-Pi/releases/tag/v0.01), unzip it, and copy all the files therein onto an empty SD or MicroSD card formatted as FAT32.  Insert this card into your Raspberry Pi, and turn it on.  That's it!

If you're a developer and feeling adventurous, you can also try building it yourself.  The source is all [on GitHub](https://github.com/JoeStrout/MiniScript-Pi/).  It uses the [circle-stdlib](https://github.com/smuehlst/circle-stdlib/) project (which is [circle](https://github.com/rsta2/circle) plus some additions to support much of the C and C++ standard libraries) as a submodule; hopefully I've set that up correctly, but you could always clone that separately and place it in the MiniScript-Pi folder.  Check out [circle's build instructions](https://github.com/rsta2/circle#building) for info on setting up your toolchain.  (Mac users: be careful with the configure script, which does not work properly on MacOS; find me on Discord and I'll help you fix the script or configure manually.)

## What's next?

Honestly, as much fun as this is, I need to put it on the shelf for a while, so I can focus on other projects like getting Mini Micro 1.2.1 out the door.

But if this project excites you and you want to see further development, do let me know!  Your wish is my data point taken into serious consideration. 😁