Skip to main content

Flash the C0-microSD

You can use the C0_microSD_toolkit.py script from the Signaloid-Compute-Module-Utilities repository to flash new bitstreams, firmware, and data to the C0-microSD.

Before you begin

  • Install Python 3.10 or later. The C0_microSD_toolkit.py script uses nothing outside the Python standard library. See Python Environment.
  • Clone the Signaloid-Compute-Module-Utilities repository, which contains the script.
  • Run every command with sudo, because flashing writes to the raw block device.

Flash the module

  1. Insert the C0-microSD into your computer.
  2. Identify the C0-microSD device path. For this example, we assume the device path is /dev/disk4. You can find more details on how to identify your C0-microSD in Identify your module.
  3. Verify that the C0-microSD is in Bootloader mode (solid red LED). If not, switch to Bootloader mode and power-cycle the device. You can find more details on how to switch the operation mode of your C0-microSD in Switch Between Operation Modes.
  4. Flash new firmware/data to the device using the C0_microSD_toolkit.py python script. While the flashing operation takes place, you should see the green LED of the C0-microSD blink rapidly.
warning

Never remove the module, and never remove power from the host, while the green LED is blinking. Flashing erases and reprograms whole 4 KiB sectors of the SPI flash, and a sector caught part way through holds neither its old contents nor its new contents. See Write and Erase Semantics.

MicroSD to SD card adapters often have a small switch on the side, ensure that the switch is in the position that allows writing to the C0-microSD. If the switch is not in the correct position, you will encounter a permission error when attempting to flash the bitstream.

Using the C0_microSD_toolkit.py tool

You can use the C0_microSD_toolkit.py Python script to configure the C0-microSD and flash new firmware. The script requires Python 3.10 or later and does not use any additional libraries. Following are the program's command-line arguments and usage examples:

usage: C0_microSD_toolkit.py [-h] -t TARGET_DEVICE [-b INPUT_FILE] [-p PAD_SIZE] [-u | -U | -q | -w | -s | -i | -y] [-f]

Signaloid C0-microSD-toolkit. Version 2.0

options:
-h, --help Show this help message and exit.
-t TARGET_DEVICE Specify the target device path.
-b INPUT_FILE Specify the input file for flashing (required with -u, -q, or -w).
-p PAD_SIZE Pad input file with zeros to target size.
-u Flash user data.
-U Flash user data with auto switching to and from bootloader mode.
-q Flash new Bootloader bitstream.
-w Flash new Signaloid SoC bitstream.
-s Switch boot mode.
-i Print target C0-microSD information, and run data verification.
-y Flash warmboot sector.
-f Force flash sequence (do not check for bootloader).
note

All options except -s and -U require the C0-microSD to be in Bootloader mode. The -U option switches the device into Bootloader mode and back for you, prompting for a power cycle each way.

Examples:

The following examples assume that the C0-microSD is located in /dev/disk4.

Flash new custom user bitstream:

sudo python3 ./C0_microSD_toolkit.py -t /dev/disk4 -b user-bitstream.bin

Flash new user data:

sudo python3 ./C0_microSD_toolkit.py -t /dev/disk4 -b program.bin -u

Flash new user data, switching to and from Bootloader mode automatically and padding the binary to 128 KiB. This is the command the application template and the demo repositories run for make flash:

sudo python3 ./C0_microSD_toolkit.py -t /dev/disk4 -b program.bin -U -p 128K

Flash new Bootloader bitstream:

sudo python3 ./C0_microSD_toolkit.py -t /dev/disk4 -b bootloader-bitstream.bin -q

Flash new Signaloid SoC bitstream:

sudo python3 ./C0_microSD_toolkit.py -t /dev/disk4 -b signaloid-soc.bin -w

Print target C0-microSD information and verify loaded bitstreams:

sudo python3 ./C0_microSD_toolkit.py -t /dev/disk4 -i

Flash the warmboot sector with the appropriate configuration. No input file needed for this operation.

sudo python3 ./C0_microSD_toolkit.py -t /dev/disk4 -y

Next steps