tree: 91e3946c4fd831d99126f7df0a48a2a4b227d27f [path history] [tgz]
  1. .gitignore
  2. ftdi_spi_interface.cc
  3. ftdi_spi_interface.h
  4. Makefile
  5. README.md
  6. spi_interface.h
  7. spiflash.cc
  8. updater.cc
  9. updater.h
  10. verilator_spi_interface.cc
  11. verilator_spi_interface.h
sw/host/spiflash/README.md

SPI Flash

spiflash is a tool used to update the firmware stored in OpenTitan's flash. The tool resets OpenTitan and signals the boot ROM to enter bootstrap mode before sending the update payload.

Currently, the tool only supports Verilator targets.

Build instructions

spiflash is written in C++17.

Required packages:

$ sudo apt-get install libssl-dev libftdi1-dev

Build command:

$ cd ${REPO_TOP}/util/spiflash
$ make clean && make

Run the tool in Verilator

Build boot_rom:

$ cd ${REPO_TOP}/sw/boot_rom
$ make clean && make SIM=1

Build and run Verilator with boot_rom enabled:

$ cd ${REPO_TOP}
$ fusesoc --cores-root . sim --build-only lowrisc:systems:top_earlgrey_verilator
$ build/lowrisc_systems_top_earlgrey_verilator_0.1/sim-verilator/Vtop_earlgrey_verilator \
  --rominit=sw/boot_rom/boot_rom.vmem

Build hello_world program:

$ cd ${REPO_TOP}/sw/hello_world
$ make clean && make SIM=1

Run spiflash. In this example we use SPI device /dev/pts/3 as an example. After the transmission is complete, you should be able to see the hello_world output in the UART console.

$ cd ${REPO_TOP}/util/spiflash
$ make clean && make
$ ./spiflash --input=../../sw/hello_world/hello_world.bin --verilator=/dev/pts/3

TODOs

  • Implement ACK handshake between boot_rom and spiflash.
  • Add support for FPGA targets via FTDI interface.