A Scheme Interpreter for ARM Microcontrollers:
ChangeLog for Snapshot 00.0241
Changes from snapshot 00.0225:
This snapshot supports 4 new boards: the LPC-P1343 from Olimex, the Blueboard-1768H
from NGX Electronics, the STR91X-M header board (or insm0001) from Insem/Lodin and
the STM32 Core
Module (aka STM32-dot-board or STM32 header board or insm0003) from InSem/Lodin.
USB Device functionality has been added to the TCT-Hammer board and STM32-H103 board.
Mark-and-Sweep garbage collection, based on the DSW algorithm, is now available.
All files in the bin directory were assembled with M-&-S rather than stop-and-copy.
As the code for M-&-S is larger than that for stop-and-copy the i2c subsystem has
been excluded when producing those .bin/.hex files.
This snapshot contains 4 new bytevector functions from R6RS: bytevector-u16-native-ref,
bytevector-u16-native-set!, bytevector-s32-native-ref and bytevector-s32-native-set!.
Code for bytevector-copy! is also within the source but is currently commented out due
to space constraints.
The functions logior, logxor, logand, lognot and ash have been renamed according to the
convention introduced in R6RS.
They are now named bitwise-ior, bitwise-xor, bitwise-and, bitwise-not and bitwise-arithmetic-shift,
Additional bitwise functions from R6RS are now available: bitwise-if, bitwise-bit-set?,
bitwise-copy-bit, bitwise-bit-field and bitwise-copy-bit-field.
These functions are meant to help streamline code related to peripheral access and pin
configuration, among others.
The bitwise functions in this implementation allow the user to mix integers and
4-octet bytevectors (in which case the integers are automatically upgraded to
This last modification may invalidate some non-standard example code developed
for prior snapshots (the function rvst used in prior-snapshot examples may be such
a casuality and is to be replaced by packed-data-set! described below).
Four special-purpose functions are now available:
(i) unlock - to unlock the file system (re-instated from previous snapshots),
(ii) packed-data-set! - to set data at the end of a packed code bytevector prior
to linking and/or unpacking,
(iii) address-of - to get the address of a register-and-offset or of a pointer object,
as a bytevector,
(iv) fsc - to crunch the file system, bringing all files to low addresses, freeing
up the upper addresses for possible libraries (this function is mainly for testing as
file system crunching is now done automatically when new libraries that encroach on
existing file space are added).
A global state vector is now available to help open-up the system.
This vector is returned by the (_GLV) function.
Its content are as follows: index 0 - scheme callbacks, 1 - current heaptop, 2 - i2c0 data,
3 - i2c1 data, 4 - default input/output port, 5 - main system buffer, 6 - open file
list, 7 - user environment, 8 - user obarray, 9 - heaptop0 or dummy, 10 - heaptop1 or grey set,
11 - file flash end page, 12 - library start page or null, 13 - built-in environment,
14 - parsing state 1 or environment 1 (for library forms),
15 - parsing state 2 or environment 2 (for library forms).
The global vector is stored on the heap and its contents are subject to garbage collection.
The scheme callbacks at index 0 are where a scheme interrupt system routine (scheme isr)
is to be stored and replaces the approach of previous snapshots where the scheme isr
was written to offset #x10000 on timer0.
The main system buffer at index 5 is described in the next paragraph.
The library start page at index 12 replaces the flib of previous snapshots.
The built-in environment at index 13 replaces the _BIE of previous snapshots.
A main system buffer, represented by a bytevector, is now available to access
and modify various system parameters.
This main system buffer is accessible at index 5 of the global vector (_GLV).
Although it is formally a bytevector, the contents of the main system buffer
are on word boundaries and, if suitable, may be accessed via vector (rather than
The contents of the main system buffer are (using vector indexing -- multiply
indices by 4 to get corresponding bytevector indices):
0 - file lock, 1 - machine interrupt service routine (misr) vector address, 2 - read buffer address,
3 - i2c0 mcu address or nothing, 4 - i2c0 state buffer, 9 - i2c1 state buffer,
14 - write buffer address, 15 - USB state buffer, 28 - enabled interrupts 0-31 (Cortex-M3 only),
29 - enabled interrupts 32-63 (Cortex-M3 only).
The main system buffer is stored outside of the heap and its contents are not subject to
garbage collection (the addresses it contains must be for above-heap or flash-stored objects).
The file lock at index 0 is a raw value that indicates that the file system is reserved if it
The misr vector at index 1 replaces the _ISR of prior snapshots and is originally stored
in flash which means that adding routines to it requires that it first be copied to an
above-heap (RAM) location.
The read and write buffers at indices 2 and 14 are bytevectors whose first octet denotes
the number of characters currently in the buffer (as scheme ints -- divide by 4 to get
actual number of characters) and they replace the _RBF and _WBF of prior snapshots.
With this representation, one could identify the size of the read buffer (+ 4 for the number of
characters octet) using: (bytevector-length (vector-ref (vector-ref (_GLV) 5) 2)).
The file system, if jammed, can be unlocked using:
(bytevector-s32-native-set! (vector-ref (_GLV) 5) 0 0)
or using the (unlock) function.
The library system has been enhanced to more closely approach that described in
The forms: library, import and export are now available.
The R6RS forms: only, except, rename and prefix are not available and library versioning
(version pattern matching) is not implemented.
Upon execution of a library form, the library gets written to flash (for MCUs with
executable flash space -- 18 boards out of the 25 supported) or above the heap
(for MCUs without executable flash space: LPC-H2103, TINY-2131, LPC-H2888, CS-E9302,
TCT-Hammer, LPC-P1343, TI-Beagle).
The function erase, with a negative input argument, (eg. (erase -2)) erases that
many flashed libraries in a last-in-firt-out process.
The special input argument -536870912 erases all library flash space as a recovery
process in case flash library space becomes broken (eg. (erase -536870912)).
Position 12 on the global vector (_GLV) links all libraries such that one can list the
names of existing user libraries on a given system with:
(map (lambda (e) (list (vector-ref (vector-ref e 0) 0))) (vector-ref (_GLV) 12)).
The import form is cumulative such that (import (my first lib)) followed by
(import (another library)) results in a system where both libraries are loaded.
Import does not error-out if the library to import does not exist.
With no input arguments, import re-initializes the built-in environment to its
initial state (eg. (import)) where bindings for symbols exported from previously
imported libraries resolve to a potential system crash (this may be enhanced
to a core throw in a future release -- in the meantime, it is best to not reference
de-imported symbols after executing the no-argument form of (import)).
The implementation of file ports and related functions has been modified to make it
possible to attach and integrate non-native file-system devices to the system
(eg. a SD card formatted in FAT16 attached via an SPI or MCI interface).
The functions: load, files, open-input-file, open-output-file, call-with-input-file and
call-with-output-file now take an optional port-model argument that can re-direct
their operation to such external file systems.
The implementation of the related code (driver) may be performed as a library, or
as regular code.
Two new machine code routines are exported to user space for linking ARMSchembled
code: _isx and _ism.
_isx is the standard ISR exit that clears the interrupt in the
VIC and then exits the ISR.
_ism is the routine that checks on the current memory reservation status during an ISR
and either resumes garbage collection or re-initializes partly completed memory
allocations, prior to continuing with an ISR that neeeds to allocate heap memory.
These routines are expected to find use in peripheral drivers implemented in ARMSchembly
(and possibly written as libraries) to deal, for example, with a PS/2 keyboard or the
i2c read/write subsytem.
The parser has been updated to recognize both ascii 10 and ascii 13 as possible ends
of expressions that trigger evaluation (needed for properly reading files coming from
The missing exclamation mark at the end of the string-fill! and vector-fill! functions
has been added.
A bug in the input-port? and output-port? functions has been corrected
so that they should work more properly.
A bug whereby lists stored outside of RAM would not be recognized as such has been fixed.
A bug that caused packed objects whose unpacked size exactly equalled the flash page
size to not unpack correctly (to flash) has been corrected.
Assembly switches at the top of armpit_00.0241.s have been modified.
Notably, a r3rs switch can now be used (mandatory for small memory MCUs:
LPC-H2103, TINY-2131 and LPC-P1343).
It removes the macro expander, call-with-values and dynamic-wind from the system,
thereby reducing it essentially from r5rs to r3rs.
Miscellaneous other source code adjustments have been performed to
maintain or enhance the compact size, functionality and performance
of the system.
Where appropriate, program examples are under development to
illustrate the application of the new features described above.
The read buffer sizes configured in mcu-specifc header files (variable name: RBF_size)
of this snapshot are given below.
Subtract 4 bytes from these values to identify the number of characters that the buffer can
hold (eg. 2KB means space for: 2048 - 4 = 2044 characters).
|Board ||Buffer Size||Board ||Buffer Size|
|SAM7_H256 || 2 KB||CS_E9302 || 64 KB|
|EVB_LM3S1968 || 2 KB||EVB_LM3S6965 || 2 KB|
|IDM_LM3S1958 || 2 KB||LPC_P1343 || 1 KB|
|Blueboard_1768 || 4 KB||LCDDemo_2158 || 4 KB|
|LPC2478_STK || 28 KB||LPC_H2103 || 1 KB|
|LPC_H2148 || 4 KB||LPC_H2214 || 16128 Bytes|
|LPC_H2294 || 16128 Bytes||SFE_Logomatic1 || 2 KB|
|SFE_Logomatic2 || 4 KB||TINY_2106 || 2 KB|
|TINY_2131 || 1 KB||TINY_2138 || 2 KB|
|LPC_H2888 || 128 KB||TI_Beagle || 64 KB|
|TCT_Hammer || 64 KB||STM32_DT_Board || 2 KB|
|STM32_H103 || 1536 Bytes||STR_H711 || 2 KB|
|STR91X_M || 2 KB|
Last updated January 14, 2011