program-ice40-flash

CLI reference

glasgow run program-ice40-flash

Program the 25-series SPI NOR Flash memories found on many boards with iCE40 FPGAs. This applet is based on the memory-25q applet; in addition, it asserts the FPGA reset while programming the memory, and checks the CDONE pin to determine whether the FPGA has successfully read the configuration after the applet finishes.

See the description of the memory-25q applet for details.

usage: glasgow run program-ice40-flash [-h] [-V SPEC] [--cs PIN] [--sck PIN]
                                       [--io PINS] [--reset PIN] [--done PIN]
                                       [-f FREQ] [--dual-spi] [--quad-spi]
                                       [-A WIDTH] [-P SIZE]
                                       [--opcode-erase-4k OPCODE]
                                       [--opcode-erase-32k OPCODE]
                                       [--opcode-erase-64k OPCODE]
                                       OPERATION ...
-h, --help

show this help message and exit

-V <spec>, --voltage <spec>

configure I/O port voltage to SPEC (e.g.: ‘3.3’, ‘A=5.0,B=3.3’, ‘A=SA’)

--cs <pin>

bind the applet I/O line ‘cs’ to PIN (default: ‘A0’, required)

--sck <pin>

bind the applet I/O line ‘sck’ to PIN (default: ‘A1’, required)

--io <pins>

bind the applet I/O lines ‘copi’, ‘cipo’, ‘wp’, ‘hold’ to PINS (default: ‘A2,A3,A4,A5’, required)

--reset <pin>

bind the applet I/O line ‘reset’ to PIN (default: ‘A6’, required)

--done <pin>

bind the applet I/O line ‘done’ to PIN (default: ‘A7’, optional)

-f <freq>, --frequency <freq>

set SCK frequency to FREQ kHz (default: 12000)

--dual-spi

use dual-SPI modes if present in SFDP

--quad-spi

use quad-SPI modes if present in SFDP

-A {3,4}, --address-bytes {3,4}

use WIDTH address bytes for data region (choices: 3, 4, default: 3)

-P <size>, --page-size <size>

do not cross multiple-of-SIZE boundaries when programming

--opcode-erase-4k <opcode>

opcode for erasing a 4 KiB region

--opcode-erase-32k <opcode>

opcode for erasing a 32 KiB region

--opcode-erase-64k <opcode>

opcode for erasing a 64 KiB region

glasgow run program-ice40-flash erase

Erase memory range. Start and end of specified range must be aligned on erase size boundaries.

usage: glasgow run program-ice40-flash erase [-h] ADDRESS LENGTH
address

start with byte at ADDRESS

length

continue for LENGTH bytes

-h, --help

show this help message and exit

glasgow run program-ice40-flash erase-all

Erase memory range covering the entire chip.

usage: glasgow run program-ice40-flash erase-all [-h]
-h, --help

show this help message and exit

glasgow run program-ice40-flash identify

Identify memory by its JEDEC ID and (if available) Serial Flash Discoverable Parameters.

usage: glasgow run program-ice40-flash identify [-h] [--annotate-raw-sfdp]
-h, --help

show this help message and exit

--annotate-raw-sfdp

annotate known raw SFDP DWORDs with fields

glasgow run program-ice40-flash protect

Read or write Block Protection (BP) bits. The exact size and location of the protected area for a specific bit combination can only be determined from the device datasheet.

Setting all BP bits to zero may be necessary to execute the erase-all command or to resolve erase/program failures.

usage: glasgow run program-ice40-flash protect [-h] [BITMASK]
bitmask

write BITMASK to BP bits (e.g. 0000 to allow all, 1111 to protect all)

-h, --help

show this help message and exit

glasgow run program-ice40-flash read

Read memory range using the fastest available read command.

usage: glasgow run program-ice40-flash read [-h] [-f FILENAME] ADDRESS LENGTH
address

start with byte at ADDRESS

length

continue for LENGTH bytes

-h, --help

show this help message and exit

-f <filename>, --file <filename>

write memory contents to FILENAME

glasgow run program-ice40-flash verify

Read memory range using the fastest available read command, and compare with given data.

usage: glasgow run program-ice40-flash verify [-h] (-d DATA | -f FILENAME)
                                              ADDRESS
address

start with byte at ADDRESS

-h, --help

show this help message and exit

-d <data>, --data <data>

use hex bytes DATA as memory contents

-f <filename>, --file <filename>

use data from FILENAME as memory contents

glasgow run program-ice40-flash write

Write memory range using a read-modify-write sequence. Start and end of specified range do not need to be aligned on erase size boundaries.

usage: glasgow run program-ice40-flash write [-h] (-d DATA | -f FILENAME)
                                             ADDRESS
address

start with byte at ADDRESS

-h, --help

show this help message and exit

-d <data>, --data <data>

use hex bytes DATA as memory contents

-f <filename>, --file <filename>

use data from FILENAME as memory contents