Booting PicoLisp on the MCU
Given below is the sequence of events that occur after the MCU is powered up. The platform-initialisation code is executed. This program does very low-level platform setup, copies ROM contents to internal RAM, zeroes out BSS section, sets up the stack pointer and long jumps to the main function.
1. The main function calls the platform-specific initialisation function and returns a result that can be either a value indicating success or failure. If it fails, main instantly gets blocked. A debugger can then inspect the internals of the state machine.
2. The main function then initialises the rest of the system: ROM file system, XMODEM and terminal support.
3. If files /rom/autorun.l or /mmc/autorun.l exist, these are executed. If one file is found before the other, it terminates further execution of the other file and the context jumps to the next step. If it returns after execution, or if files are not found, boot process continues with the next step.
4. If boot parameter is set to standard and the shell was compiled in the image, it is started. In the absence of the shell, standard PicoLisp server is started.
PicoLisp for MCUs
PicoLisp can be compiled to either support a user console over UART (the default and by far the most popular) or a console over TCP/IP. It can run on a wide variety of MCUs. Some practical aspects of using PicoLisp are listed below:
1. Code base is hardware independent. It proves to be extremely portable across different architectures.
2. Programs in PicoLisp are highly adaptable, field programmable and re-configurable for a variety of practical applications.
3. Lisp Programming the MCU follows a very natural iterative process because PicoLisp permits the user to develop programs in an interactive and incremental way. The code supplies various tools to aid in native Lisp programming (like an onboard vi-clone text editor and XMODEM implementation to share files).
4. PicoLisp is a very extensible piece of software. Adding support for newer peripherals or modules is a naturally-smooth process.
5. Code bears a royalty-free, permissive, non-copyleft free software licence. This permits code reuse within a proprietary digital base.
Examples with Mizar32 board (Lisp Programming)
Mizar32 development board (Fig. 3) is a low-cost, stackable multi-board computer designed and produced under Free Hardware Licence by SimpleMachines. It is composed of a base module with Atmel AVR32 AT32UC3A0256 system-on-chip processor running at 66MHz with 32MB of SDRAM, 64kB SRAM, 256kB of flash memory, SD card slot, USB port and JTAG connector. A range of add-on boards can be stacked on its bus connectors to provide a serial port, a character based LCD display, VGA/mouse/keyboard/audio board, Ethernet and so on.
It runs PicoLisp (Lisp programming) as its standard software, allowing fast production of custom solutions.
Mizar32 is shipped with PicoLisp interpreter programmed into flash, including support for the optional TCP/IP networking module.
Mizar32 can also be programmed by the end user with different, customised versions of PicoLisp, FreeRTOS or with other stand-alone programs.
Once we have PicoLisp running on the board, you can access all MCU peripherals from Lisp. There are three Mizar32 variants, namely, A, B and C. These use AT32UC3A0512, AT32UC3A0256 and AT32UC3A0128 chips, respectively. SDRAM interface is the same for all three, which is 32MB. The difference is in flash size. Otherwise, the board layout, memory layout is the same.