SPI flash use on BX?


So the BX has 8Mb flash. How much of that is taken by the FPGA bitstream, and how much is free for use? And at what address?

Easiest way to add RAM (32MB) to BX

If you run tinyprog -m it will list the metadata for any connected BX boards. The metadata contains an address map of the SPI flash. There’s a location for the user bitstream and another location for user data. If you run tinyprog -u userdata.bin it will program the user data area with your binary data. You have about 6mbit available.


Here’s an example of what it looks like and how to interpret the data:

> tinyprog -m
    "port": "COM5",
    "boardmeta": {
      "hver": "1.0.0",
      "name": "TinyFPGA BX",
      "fpga": "ice40lp8k-cm81",
      "uuid": "83eb5888-ee36-40ef-b954-f23da11f23d9"
    "bootmeta": {
      "bver": "1.0.1",
      "bootloader": "TinyFPGA USB Bootloader",
      "update": "https://tinyfpga.com/update/tinyfpga-bx",
      "addrmap": {
        "userimage": "0x28000-0x50000",
        "bootloader": "0x000a0-0x28000",
        "userdata": "0x50000-0x100000"

The metadata is formatted in JSON. It is actually stored directly in the SPI flash in this way (except for the serial port name). The bootmeta\addrmap element contains the full address map. The userdata element contains the address range of the user data area in the flash. It starts at 0x50000 and goes up to but not including 0x100000.


Ooh nice, thanks. Now, is there a Verilog module somewhere for accessing the flash chip that I can just pop into my code? (I assume there has to be, if the bootloader configures the FPGA to read/write the flash…)


Clifford Wolf’s picosoc is what I’ve been using. It has a picorv32 CPU and maps the SPI flash into the CPU’s address space. The SPI controller within the bootloader is specialized for the bootloader itself and might not be so easy to reuse. The picosoc SPI peripheral on the other hand is very reusable.


Yeah, I found https://github.com/tinyfpga/TinyFPGA-Bootloader/blob/master/common/usb_spi_bridge_ep.v but it is tied to the USB protocol. I’ll check out the picosoc SPI periph.



Does PicoSoC work “out of the box” with BX? (Other than minor changes for pins and SPI flash memory layout.


I have a project I can share on GitHub using picosoc. It has a makefile for building the Verilog and C code. Picorv32 can run C++ as well, but I haven’t gotten the linker script working properly for static initialization of objects.



Did you end up sharing this project? I am trying to figure out how to use the SPI memory and having an example would be extremely helpful.

Thank you


It is one of the examples - https://github.com/tinyfpga/TinyFPGA-BX/tree/master/examples/picosoc

The spimemio.v file implements execute-in-place from the SPI flash memory.