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 followin criteria:
- well-known, mature implementations are preferred over new ones.
- 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 a lot.
- 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).
- 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 memory.
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. TinyScheme has the usual Lisp features (macros, homoiconicity and
eval, first class functions, etc), and the TSX extension gives you:
- Filesystem access
- Time functions
- Access to environment variables
- Execution of commands using /bin/sh Tinyscheme has been in development since 1998.
- 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 and
eval, first class functions, etc), PicoLisp also has these interesting features:
- 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;
- Coroutines. PicoLisp has been in development since 2002.
- 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 (
- Color output to console (
- A small framework for building games (
- Filesystem access (
- A compatibility layer with Forth (
forth) Retro has been in development since 2008.
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 this other text explaining how to run OpenWRT on qemu
- TinyScheme [ 63k ] : The tarball (1.41-openwrt2, 2014-08-12) 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 [ 191k ] : The tarball (3.1.7-openwrt1, 2014-08-04) 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 We don't build the HTTP gate anymore, because it uses ECC, and OpenWRT has it disabled in libopenssl.
- Retro [ 55k ] : The tarball (11.6-openwrt1, 2014-08-04) 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 on that.
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):
- Sigscheme. 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.