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 on the description in the Revised^5 Report on the Algorithmic Language Scheme (r5rs), with some extensions (for I/O) and some omissions (to fit within MCU memory). It is further designed to support multitasking and multiprocessing. The implementation is sufficient to run the Runge-Kutta program example presented at the end of r5rs (except on the smallest MCUs) and preliminary tests suggest that it may run miniKANREN as well. Potential applications include robotics and smart wearable devices.
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 or Java) and to compiled languages (eg. C). Armpit Scheme is OpenSource, distributed under the MIT license.
The name "Armpit" was selected for this project because it includes "ARM" (as in ARM core MCU) and "pit" (as in kernel, noyau, 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 current stable version of Armpit Scheme is 00.0098. It is a beta release with both known bugs and unknown bugs. The current development snapshot of Armpit Scheme is 00.0137. It is an alpha release, also with known and unknown bugs. It works on AT91SAM7 (ARM7TDMI) microcontrollers from Atmel, EP9300 (ARM920T) microcontrollers from CIRRUS, LM3S1000 (Cortex-M3) microcontrollers from Luminary Micro, LPC2000 (ARM7TDMI) and LPC2800 (ARM7TDMI) microcontrollers from NXP (formerly from Philips), and STR7 (ARM7TDMI) and STM32 (Cortex-M3) microcontrollers from STMicroelectronics. Armpit Scheme has been tested on boards from Future Designs: LCDDemo-LPC2158, from Luminary Micro: Stellaris LM3S1968 Evaluation Board, from Newmicros: Tiny2106, Tiny2131, Tiny2138, from Olimex: CS-EP9302, LPC-H2103, LPC-H2148, LPC-H2214, LPC-H2888, SAM7-H256, STM32-H103, STR-H711, and from SparkFun Electronics: Logomatic V1.0. Ports to additional ARM devices and boards are in the planning stages.
The screenshot below shows Armpit Scheme running on a Tiny2106 board. Minicom is used to communicate with the board which reads, evaluates and prints the result of the entered expressions. The number in front of the "armpit>" prompt indicates the number of bytes of heap space that remain available.
Armpit Scheme is distributed under the MIT License. The source code, and pre-assembled (ready-to-upload) Intel Hex and binary image files, can be downloaded from the armpit project summary page or the download site at SourceForge. Alternatively, you can view and download the source code from your web browser.
The system is documented in several web pages:
For microcontrollers of the LPC2000 family, the Intel Hex image files from the Armpit Scheme download site can be uploaded to the MCU's FLASH memory via ISP (rs232 interface) using lpc21isp (1) or lpc21isp (2) (Linux or Windows -- as of June 7, 2007 those links appear inactive, try Yahoo lpc21isp, Augsburg lpc21isp, mikrocontroller lpc21isp or cmucam lpc21isp, alternatively lpcflash4linux or lpc2k_pgm), or the NXP (Philips) LPC2000 Flash ISP Utility (Windows).
For microcontrollers of the LPC2800 family, the Binary image file from the Armpit Scheme download site can be uploaded to the MCU's FLASH memory using NXP's MASS DFU program (Windows).
For microcontrollers of the AT91SAM7 family, the Binary image file from the Armpit Scheme download site can be uploaded to the MCU's FLASH memory via ISP using AT91-ISP and SAM-BA (USB interface, Windows), Sam_I_Am (USB interface, Linux), SAM7_PGM (rs232 interface, Linux) or sam7utils (USB interface, multiple OSs).
For microcontrollers of the EP9300, LM3S1000, STM32 and STR7 families, the Binary image file from the Armpit Scheme download site can be uploaded to the MCU's FLASH memory using OpenOCD (Linux/Unix, Windows), and a JTAG wiggler.
Once Armpit Scheme is loaded onto the MCU you can communicate with its REP (Read-Eval-Print loop) using a terminal emulation program such as Minicom (Solaris, Linux, Mac OSX: fink install minicom) or HyperTerminal (Windows). Communication parameters for on-board rs232 serial interfaces (including USB-to-rs232) are 9600,8N1. For boards with USB (LPC-H2148, SAM7-H256 and STR-H711) the USB communication parameters are 115200,8N1 and the interface (USB CDC ACM) uses either the built-in driver in Linux and MacOSX, the usbsacm driver in Solaris 10 (built-in since 07/07) or the built-in usbser.sys driver in Windows (Search for it and copy it out of the .cab archive). In *NIX, look at /dev to find the new port that Minicom should use to connect with Armpit Scheme (eg. /dev/term/0 on Solaris, /dev/tty.usbmodem4B11 on Mac OSX, /dev/ttyUSB0 on Linux). On MS Windows, the OS applies a user-supplied file to attach device and driver -- you can use usbser.inf from the lpcusb project or adapt gserial.inf (cut it out from middle of page) by changing the Vendor ID in [GSerialDeviceList] to "USB\VID_FFFF&PID_0005", then, use Device Manager to find which COM port HyperTerminal should use to connect to the Armpit Scheme device.
The source code of Armpit Scheme (eg. armpit_00.0098.s) can be modified and re-assembled (if desired). Armpit Scheme is written in ARM assembly language (ARM7TDMI) and assembled with the GNU assembler (version 2.17). Development is performed on SUN Sparc under Solaris 10 (SunOS blade 5.11 snv_27 sun4u sparc SUNW) with the assembler from the GNU ARM Toolchain made available by CodeSourcery. You may use any appropriate develoment environment (Linux, MacOSX, Windows) to modify, reassemble and upload the code. The first few lines of source code are used to specify the target board. In version 00.0017 you can just uncomment the line corresponding to your target (here: Tiny2106) and reassemble for that board:
TINY_2106 = 1
@TINY_2131 = 1
@TINY_2138 = 1
@H_2148 = 1
@H_2214 = 1
@ 1- Select MCU Family:
LPC_2000 = 1 @ uncommment if assembling for NXP LPC2000 family MCU
@AT91_SAM7 = 1 @ uncommment if assembling for ATMEL AT91SAM7 family MCU
@STR_7xx = 1 @ uncommment if assembling for ST STR7xx family MCU
@ 2 - Select Board:
@TINY_2106 = 1 @ uncomment if assembling for NewMicros Tiny-2106 board (lpc2000)
@TINY_2131 = 1 @ uncomment if assembling for NewMicros Tiny-2131 board (lpc2000)
@TINY_2138 = 1 @ uncomment if assembling for NewMicros Tiny-2138 board (lpc2000)
@SFE_Logomatic= 1 @ uncomment if assembling for SparkFun Logomatic board (lpc2000)
@LPC_H2103 = 1 @ uncomment if assembling for Olimex LPC-H2103 board (lpc2000)
LPC_H2148 = 1 @ uncomment if assembling for Olimex LPC-H2148 board (lpc2000)
@LPC_H2214 = 1 @ uncomment if assembling for Olimex LPC-H2214 board (lpc2000)
@SAM7_H256 = 1 @ uncomment if assembling for Olimex SAM7-H256 board (at91sam7s)
@STR_H711 = 1 @ uncomment if assembling for Olimex STR-H711 board (str7xx)
@ 3- Specify if board has USB:
has_usb = 1 @ uncomment if board has USB (comment out if board doesn't have USB)
arm-none-eabi-as -mcpu=arm7tdmi -o a.o armpit_00.0098.s
arm-none-eabi-ld -Map map.txt --script build_link_98 -o a.elf a.o
arm-none-eabi-objcopy -O ihex a.elf armpit_00.0098.hex
arm-none-eabi-objcopy -O binary a.elf armpit_00.0098.bin
where build_link_98 is the script file:
SECTIONS
{
.text 0x0000 :
{ *(.text) ; _endflash = . ; }
.data ram_address :
AT ( ADDR (.text) + SIZEOF (.text) )
{ _startram = . ; *(.data) ; _endram = . ; }
}
Note 1: The Tiny2131 and LPC-H2103 implementation of Armpit Scheme is a reduced version because of the small memory of the LPC2131 and LPC2103 MCUs.
Note 2: Using the USB plug (USB<->rs232) on the LPC-H2214 board requires that you first install the required driver for the on-board FTDI converter chip, onto the upload host.
Note 3: To compile lpc21isp (if needed) on Solaris 10, you may need to modify the C source code in lpc21isp.c, to replace the line:
cfmakeraw(&IspEnvironment->newtio);
IspEnvironment->newtio.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
IspEnvironment->newtio.c_oflag &= ~OPOST;
IspEnvironment->newtio.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
IspEnvironment->newtio.c_cflag &= ~(CSIZE|PARENB);
IspEnvironment->newtio.c_cflag |= CS8;
Note 4: Program upload onto the LPC-H2148 Flash has to be performed via the MCU's rs232 interface (or JTAG if available) as its USB device is not attached to the ISP bootloader.