A Scheme Interpreter for ARM Microcontrollers

SourceForge.net Logo

ARMPIT SCHEME is an interpreter for the Scheme language (lexically-scoped dialect of Lisp) that runs on RISC microcontrollers with ARM core. It is based mostly on the description of the Revised^5 Report on the Algorithmic Language Scheme (r5rs) and is transitioning towards R7RS-small. It contains some extensions (for I/O) and some omissions (to fit within MCU memory). It is designed to support multitasking and multiprocessing (partially for now). Armpit Scheme is expected to be well suited to educational settings, including student projects in courses on control and instrumentation, or capstone design courses where microcontrollers are needed. It is meant to enrich the spectrum of interpreted languages available for MCUs (eg. BASIC and FORTH) and can be an alternative to MCU-based bytecode interpreters (eg. for Scheme, Java, Lua or Python) and to compiled languages (eg. C).

The name "Armpit" was selected for this project because it includes "ARM" (as in ARM core MCU) and "pit" (as in kernel, noyau, nucleus, the core of an Operating System (OS)). Armpit Scheme, once loaded, governs the operation of the MCU, and is "Scheme to the metal" in the sense of running without any other OS. It may be thought of as turning the MCU into a rudimentary Scheme machine. The screenshot below shows the system running on a NanoPC-T3 Plus, communicating via USB. Minicom is used to communicate with the board which reads, evaluates and prints the result of the entered expressions.


Figure 1: Sample Interaction with Armpit Scheme

This version of Armpit Scheme supports USB keyboards for various MCU boards. The figure below shows a Logitech wireless USB keyboard used with the NanoPC-T3 Plus (in a metal case; right behind the keyboard).


Figure 2: USB Keyboard Example with NanoPC-T3 Plus

External display, on LCD or via DVI or HDMI, is also supported for some of the boards. Connecting both a keyboard and an external display provides an environment that is nearly standalone. Still missing are an editor, mouse support (possibly), and the ability of the "boot.scm" startup file to properly instantiate libraries. The code needed to use keyboard and display is given in the example pages (below). Figure 3 shows the result of loading the console.scm file in a running system.


Figure 3: Console Example using the NanoPC-T3+, Logitech keyboard, and a 1080p TV

The latest development snapshot of Armpit Scheme is 080. It is distributed under the MIT License and is a beta releases, with both known bugs and unknown bugs. The source code, and pre-assembled (ready-to-use) binary image files, can be downloaded from the armpit project page at SourceForge. You can also view the source code from your web browser.

In version 080, the base characters are from the 16-bit unicode set (rather than 7-bit ASCII). Strings are made up of sequences of these characters, and symbols (eg. function names) are encoded in UTF-8. A memory allocation nursery is used on Cortex-M to help speed-up garbage collection in these slower systems. The code is split-up into a small Live-SD (LSD) bootloader which is MCU- (and board-) specific, and the Scheme interpreter (ArmPit Scheme, aka: APS) which depends on the MCU's Machine Language (Thumb2, Aarch32 or Aarch64) and allows for two Thumb2 memory layouts. The MCUs capable of 64-bit operation (eg. Cortex-A53) are run in 64-bit mode (not 32-bit compatibility mode). To produce a unified code base that successfully assembles and runs across the selected targets, some minimum requirements were set for the boards on which Armpit Scheme 080 runs (relative to previous versions). For 080, the MCU needs to be a Cortex-M4F or above, with a FPU, an MMU or MPU, and the board needs to have an SD-card slot for the LSD bootloader to fetch the APS. Wherever possible, the bootloader is also placed on an SD-card, to be loaded and executed by the MCU's boot ROM, such that the overall operation is as a Live-SD (or Live Disk) whereby the MCU (or board) flash storage is not needed (and not used). In all cases, user files are stored on the SD card.

The system is documented in several web pages: 

The lastest release is designed to run on the following boards (see build_all script):

Table 1: Armpit Scheme Development MCU Board Specifications

CPUUSBLCD /USB (*)
BOARDMANUFACTURER MCU COREMHZ (*)RAMDEVICEDVI (*)KEYBOARD
EK-TM4C1294XLTI TM4C1294NCPDT Cortex-M4F120256 KBNative--
STM32F429 DiscoveryST STM32F429ZIT6U Cortex-M4F1688 MBNativeLCD-
LPC4330-XplorerNGX Electronics LPC4330 Cortex-M4F204128 KBNative--
LPC4357-XplorerNGX Electronics LPC4357 Cortex-M4F20432 MBNativeLCDyes
STM32F746G DiscoveryST STM32F746NGH6U Cortex-M72168 MBNativeLCDyes
SAMV71-Xplained-UltraMicrochip AT91SAMV71Q21A Cortex-M72522 MBNative--
SAME70-XplainedMicrochip ATSAME70Q21 Cortex-M73002 MBNative--
MIMXRT1050 EVKNXP MIMXRT1052 Cortex-M760032 MBNativeLCD-
SAMA5D4-Xplained-UltraMicrochip ATSAMA5D44 Cortex-A5528512 MBNativeDVIyes
BeagleBoard (B7)TI OMAP3530 Cortex-A8600128 MBNative--
Overo TideGumstix OMAP3530 Cortex-A8720512 MBNative--
BeagleBone BlackTI AM3359 Cortex-A8900512 MBNativeDVIyes
BeagleBoard-XM-(C2)TI DM3730 Cortex-A81000512 MBNativeDVIyes
Duovero CrystalGumstix OMAP4430 Cortex-A99001 GBNativeDVIyes
Parallela P1601 Desktop Adapteva Xilinx XC7Z010 Cortex-A96671 GBNative--
A64-OlinuxinoOlimex Allwinner A64 Cortex-A536721 GB---
NanoPC-T3FriendlyARM Samsung S5P6818 Cortex-A538001 GBNativeDVIyes
NanoPC-T3+FriendlyARM Samsung S5P6818 Cortex-A538002 GBNativeDVIyes
iMX8M-EVKNXP i.MX8M Cortex-A538003 GBuart conv.--
Odroid-C2HardKernel Amlogic S905 Cortex-A5315362 GBNative--

(*) CPU speeds (MHz) are configured speeds and may be lower than the allowable maximum for any of the MCUs in the table. LCDs, DVI displays and USB keyboards are programmed from within user or library space (not in the core -- see mcu-specific program examples).


External links of potential interest include:

 

Acknowledgment and Disclaimer


Armpit Scheme is presently developed at the Fischell Department of Bioengineering of the A.J. Clark School of Engineering at the University of Maryland at College Park. Part of its development (until 02/07) was based upon work supported by the National Science Foundation under Grant No. 0134424. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the Department, School, University or of the National Science Foundation.  

Last updated July 22, 2018

bioe-hubert-at-sourceforge.net