The Source for Java Technology Collaboration


Building Squawk for other MCUs

The purpose of this document is to provide a guide to porting Squawk to other microcontrollers (MCU). While most of the document describes the process of porting Squawk to the STM32 family of MCUs, most of the information is relevant.

The STM32 is a family of MCUs from ST Microelectronics based on the Cortex-M3 core from ARM. The Squawk port described in this document uses the STM32F103ZE? MCU which has 64KB of RAM and 512KB of non-volatile memory.

Squawk components

Bootloader

The bootloader initialises the device before handing control to Squawk. The bootloader for the eSPOT resides in the SPOT core libraries and is responsible for initialising peripherals, setting up stacks and configuring interrupt handlers. Once these tasks have been completed, the bootloader passes control to Squawk. The eSPOT boot loader code also contains a number of system calls used by the eSPOT Java libraries.

Squawk

Squawk is written almost entirely in Java, with a small part written in C or assembler to allow Squawk to control the underlying hardware. All platform specific code is contained in vmcore/rts. Each subfolder in rts represents a specific MCU e.g. gcc-9200 contains the platform specific files for the ARM920T? MCU that is used in the eSPOT.

For any Squawk port the following C functions must be provided:

static void ioExecute(void)

Execute an IO operation for a Squawk isolate.

void CIO_initialize(JNIEnv *jniEnv, char *classPath, char** args, int argc)

Initialises the IO subsystem. This is not implemented for the eSPOT or the bSPOT port of Squawk.

volatile jlong sysTimeMillis(void)

Return the current time in milliseconds.

jlong sysTimeMicros()

Return the current time in microseconds.

long sysconf(int code)

Analogous to sysconf() in UNIX. The function allows Squawk to query the current value of a configurable system variable. A system variable may be device specific so it needs to be re-implemented for each MCU Squawk targets.

The only parameter that must be implemented is _SC_PAGESIZE which informs the caller of the size of a memory page of the underlying hardware. It is used by Squawk to determine how much memory should be allocated when creating a byte buffer which allocates buffers as a multiple of the memory page size. Both the eSPOT and bSPOT ports of Squawk return a size of 4K. It cannot be determined why 4K was chosen for the bSPOT port since the MCU used by the bSPOT (AT91R40008?) does not have an MMU.

__INLINE void osbackbranch()

Called by Squawk when a back branch occurs.

void osfinish()

Called while Squawk exits. For the eSPOT and bSPOT this function disables interrupts and restarts Squawk.

__INLINE void osloop()

Cannot determine what the purpose of this function is. This function is not implemented for the eSPOT or the bSPOT.

The platform specific code also needs to call main(int argc, char *argv[]) which starts the higher layers of Squawk. The above calls must be declared in a file named os.c or linked against a file named os.c. This file is pulled in automatically during the Squawk build process.

Squawk builder plug-in

When building Squawk for a device, the Squawk build system needs to know where the low level glue code resides and how it should be compiled. This low level glue code includes the C/assembly code files and linker scripts and what toolchain should be used to compile the code. To do this, the Squawk build system has a plug-in mechanism that allows MCU specific build commands to be easily integrated into the build process.

The builder plugin for the eSPOT resides in squawk-spots and the contains two build commands: one to build the bootstrap and one to build and link the native code for the eSPOT.

Building Squawk

Testing Squawk

-- Main.fraybentos - 28 May 2009

Topic BuildingSquawkForOtherMCUs . { Edit | Ref-By | Printable | Diffs r12 < r11 < r10 < r9 < r8 | More }
 XML java.net RSS

Revision r12 - 12 Oct 2009 - 10:04:30 - Main.sander_1986
Parents: WebHome > Squawk > BuildingSquawk