Lisp and Forth on OpenWRT
OpenWRT is a Linux distribution for embedded
devices such as wireless routers. Instead of trying to create a single, static firmware,
OpenWrt provides a fully writable filesystem with package management.
OpenWRT already comes with Lua, and it's possible to include languages like
Python and PHP. Some people may prefer to write their automation scripts in
different languages, so I've tried to bring Lisp and Forth to OpenWRT.
This page contains instructions, Makefiles, patches and anything else needed
to get small Lisps, Forth variants and other interesting languages working on OpenWRT. So far
there are ports of TinyScheme, PicoLisp and Retro. These were chosen using
- (i) Well-known, mature implementations are preferred over
- (ii) it must be easy to cross-compile. It's not unusual for interpreters to depend
on an image that is written on-the-fly during compilation, using the binary that has
just been generated, for example; sometimes one needs to apply patches depending on
the architecture, with no help from autodetection in the Makefile... This complicates the process
- (iii) there must be some useful API for system access, or for something else that would be nice to do
on a wireless router (having, for example, a Scheme interpreter that only has
console read, write and display as methods to interact with
the outside world isn't very interesting).
- (iv) it must be small -- although there are devices with several Mb available that run on
OpenWRT, the smaller (and cheaper) routers have a very small amount of flash
The description of the packaged languages follows.
TinyScheme maintained by
Dimitrios Souflis, Kevin Cozens and Jonathan S. Shapiro is a
lightweight Scheme interpreter that implements as large a subset of R5RS as
was possible without getting very large and complicated. The package distributed
here includes the TSX
extension by Manuel Heras-Gilsanz, which provides support for operations with filesystem,
sockets, date/time, and more.
PicoLisp has the usual Lisp features (macros, homoiconicity andeval, first class functions, etc),
and the TSX extension gives you:
- Filesystem access
- Time functions
- Access to environment variables
- Execution of commands using /bin/sh
PicoLisp is a dialect of Lisp
that is remarkably small and simple, and yet quite useful in practice.
Besides the usual Lisp
features (macros, homoiconicity andeval, first class functions, etc), PicoLisp also has these
- A database supporting transactions;
- PicoLisp works as an application server framework (including an HTTP server);
- An API for system access (date/time, filesystem, etc);
- A logic programming engine (Pilog, which has the semantics of Prolog but the syntax of Lisp);
- Object-orientation extensions;
- Retro is a concatenative, stack based language with roots in Forth.
It is designed to be small, easily learned, and easily modified to meet specific needs, it has been
developed and refined through continual use by a small community over the last decade. Some
of the features of Retro are:
- A lightweight web application framework (casket)
- Color output to console (console)
- A small framework for building games (fiction)
- Filesystem access (files)
- A compatibility layer with Forth (forth)
The OpenWRT packaging was done by Jeronimo Pellegrini.
Send problem reports to j_p *** aleph0.info (put the @ sign
instead of the ***).
The tarballs listed below contain a Makefile that will download the
sources from this site (I have changed them so they compile
properly for OpenWRT. The approximate size of each package, after installed
on a qemu OpenWRT image, is listed.
- A text explaining how to
compile TinyScheme and PicoLisp for OpenWRT Backfire
- Not necessary but you may be interested in a text explaining how to run OpenWRT
- TinyScheme [ 208k ] : The tarball (1.40-openwrt2, 2012-05-20) for compiling TinyScheme.
This Makefile will download a modified version of TinyScheme from this site (aleph0.info). The only changes
are: (i) the use of -fPIC inside openwrt's buildroot, and (ii) the inclusion of TSX in a subdirectory,
and a tiny change to the Makefile so TSX will be compiled with TinyScheme.
- PicoLisp [ 684k ] : The tarball (3.1.0-openwrt1, 2012-05-20) for compiling PicoLisp.
The only patches applied are to the Makefile: (i) include a top-level Makefile, otherwise OpenWRT's build
framework won't compile the package; (ii) use $(CC) instead of gcc, because the GCC from OpenWRT buildroot needs
to be used (and not the host's default GCC installation; (iii) build the HTTP gate.
- Retro [ 228k ] : The tarball (11.3-openwrt1, 2012-05-23 for compiling Retro.
The only patch applied makes retro read the default image from /usr/lib/retro/retroImage instead
of the current directory. Note: libraries are included, but you need to create a symlink for them to be visible,
like this: ln -s /usr/lib/retro/library ./library
I'd also like to package TSION (another extension for TinyScheme, by Alex Measday, which allows
easy implementation of event-driven loops and TCP networking -- but I had no time yet to work
Chibi Scheme is another nice Scheme implementation that could be packaged, but I also had no time
to get it cross-compiled in the OpenWRT buildroot.
Bringing Schemix back to life would also be great -- a Scheme interpreter
module for the Linux kernel inside the wireless router! (This one is supposed to be fun, not necessaruly useful)
OpenWRT also has, in the subversion repository at svn://svn.openwrt.org/openwrt/packages/lang
(these are not maintained by me):
The Makefile there is for version 0.8.3 of SigScheme, but works for 0.85 (just change the version number
and MD5 sum in the Makefile).
- 4th, a Forth compiler by Hans Bezemer.