/stage2: Last updated 2022-01-21 07:31:47 by Conrad Wood

Stage 2 Loader


The stage2 loader is invoked by the stage1 loader.

The Stage 2 loader decides which scapplication, if any, to start. It maintains two partition tables in flash. Each partition table is check summed and contain a counter. The counter is increased each time the table is updated. On startup, the loader finds the table with the highest counter. The table contains information (a pointer) to an application. The loader then verifies the checksum of the application and, if correct, boots it. If incorrect, it will repeat the process with the previous application.

Stage 2 also includes code to update applications and/or factory reset the hardware via USB. This code is conditionally invoked, if either of the following is true:

The usb connection is capable of writing new applications to flash, resetting partitions, writing a new stage1 loader to flash and executing short programs in-memory.

A tool to use the loader usb connection is available here

Caution: The stage2 loader is not intended for daily use. It is intended to restore the system if a flash process fails during development.

Caution: the stage2 loader does not protect against overwriting crucial (loader) sections of the flash. Overwriting the loader might require JTAG connections to restore the hardware.

See also: slots