Skip to the content
4 layers34.8 × 18 mmSpi fiend, the printed circuit board in 3D

STM32F042-based USB to SPI device for programming iCE40 FPGAs

Size
34.8 × 18 mm
Copper layers
4
Thickness
4.69 mm
Parts
28
Nets
37
Pads
128
Tracks, vias
279, 46
Pours
2
Routed
Yes
KiCad
KiCad 6 (file 20211014)
Created
6 May 2019
Updated
30 Nov 2022

Overview

Spi fiend is an open-source printed circuit board by emeb, from the emeb/spi_fiend repository on GitHub, published under the MIT licence. It is a 4-layer board of 34.8 × 18 mm with 28 parts on 37 nets, routed with 279 tracks and 46 vias.

It is built around the STM32F042G6U6 and DRTR5V0U4S. Its parts include 9 resistors, 5 capacitors, 5 connectors, 3 ICs and 3 diodes. It belongs with the fPGA and programmable logic and interfaces and adapters boards and the STM32 boards of this library.

Main components

2

README

README.md

spi_fiend

STM32F042-based USB to SPI device for programming iCE40 FPGAs

board

Most open-source projects that use Lattice iCE40 FPGAs rely on the FTDI FT2232 High-speed UART/FIFO chip to provide a SPI interface for programming the FPGA and SPI Flash chip which contains the bitstream for self-configuration at power-up. I've got nothing against FTDI, but the chips are big, require a crystal and are fairly expensive in DIY quantities. On top of that I've been using STM32 for years and have been looking for an excuse to dig into some more USB applications so a USB to SPI bridge seemed like a good place to start.

This device uses the small and inexpensive STM32F042F6P6 in a 20-pin TSSOP package. It supports crystal-less USB operation by syncing its internal RC oscillator to the USB SOF signal and has enough SRAM and Flash to support a moderately complex feature set:

  • USB powered
  • Crystal-less operation
  • Presents an ordinary ACM / CDC class device that looks like a serial port.
  • Supports direct loading into the iCE40 SRAM for quick development cycles.
  • Supports read/write/erase of standard SPI Flash devices used for FPGA configuration.
  • Includes automatic swapping of MOSI/MISO when switching between FPGA and SPI Flash.
  • MCU Serial port is pinned out for debugging and future expansion.

prerequisites

To build this you will need the following tools:

Building Hardware

The board design is available in the 'hardware' directory. The Kicad PCB can be submitted directly to OSHpark.com, or traditional Gerbers can be exported using the application. Part values and packages are noted in the schematic.

Note: in the Revision 1 PCB layout the USB connector doesn't overhang the PCB edge and there is a slight interference with the lower lip. Filing a slight chamfer on the PCB edge under the connector will allow it to sit flush to the board.

Building Firmware

The Firmware README has instructions on building the preferred firmware for the SPI Fiend.

Building Host Application

The host appliction runs on a Linux PC and communicates with the hardware device via standard USB Serial protocols. Build the host application by changing to the 'host' directory and executing 'make'. The built-in help should provide a guide to available options, but here's a quick list of common actions:

  • load a binary into the FPGA: ./cdc_prog BINARY_FILE
  • load a binary into SPI Flash: ./cdc_prog -a ADDRESS -w BINARY_FILE
  • read SPI flash contents to a file: ./cdc_prog -a ADDRESS -l LENGTH -r > OUTPUT_FILE
  • erase SPI FLASH block: ./cdc_prog -a ADDRESS -e
  • read SPI Flash ID: ./cdc_prog -i

In ordinary operation, the LED nearest the USB connector lights to indicate powerup, the center LED lights when an error is detected during operation and the outer LED lights when programming SPI flash.

Status

2019-05-06

Initial commit with hardware, firmware and host application

2022-11-11

Updated with dual firmware that supports FPGA, flash and UART

Parts

28
QtyValueFootprintReferences
51kResistor_SMD:R_0402_1005MetricR1, R2, R3, R4, R5
30.1uFCapacitor_SMD:C_0402_1005MetricC1, C2, C3
3LED_ALTLED_SMD:LED_0603_1608MetricD1, D2, D3
25k1Resistor_SMD:R_0402_1005MetricR8, R9
2SW_Pushemeb_library:SW_SPST_PTS815SW1, SW2
110kResistor_SMD:R_0402_1005MetricR6
110ufCapacitor_SMD:C_0805_2012MetricC5
11MResistor_SMD:R_0402_1005MetricR7
11ufCapacitor_SMD:C_0402_1005MetricC4
1CONN_01X04Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ2
1CONN_01X05Connector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_VerticalJ5
1CONN_01X07Connector_PinHeader_2.54mm:PinHeader_1x07_P2.54mm_VerticalJ3
1DRTR5V0U4SPackage_TO_SOT_SMD:SOT-363_SC-70-6U2
1PROG HEADERConnector_PinHeader_1.27mm:PinHeader_2x05_P1.27mm_Vertical_SMDJ4
1STM32F042G6U6emeb_library:IC_STM32F042G6U6U1
1USB_C_Receptacle_USB2.0Connector_USB:USB_C_Receptacle_HRO_TYPE-C-31-M-12J1
1Val**emeb_library:avatar_smallRef**
1XC6222B331MR-GPackage_TO_SOT_SMD:SOT-23-5U3

More from emeb/spi_fiend

1
  • 2 layers19.1 × 31.8 mmSpi fiend, the printed circuit board in 3D

    Spi fiend

    emeb/spi_fiend

    STM32F042-based USB to SPI device for programming iCE40 FPGAs

    23 parts17MIT

Similar boards

  • 4 layers81.7 × 31.8 mmEsp32c3 fpga, the printed circuit board in 3D

    Esp32c3 fpga

    ICE-V-Wireless/ICE-V-Wireless

    Combined ESP32C3 and iCE40 FPGA board

    94 parts82MIT
  • 4 layers40 × 16 mmIce dongle, the printed circuit board in 3D

    Ice dongle

    emeb/ice-dongle

    USB-C Dongle with ice40 UP5k FPGA

    48 parts7MIT
  • 4 layers40 × 16 mmRp2040-dongle, the printed circuit board in 3D

    Rp2040-dongle

    emeb/RP2040_Projects

    A collection of random projects based on the Raspberry Pi RP2040 MCU

    44 parts3MIT
  • 4 layers76.2 × 31.8 mmEsp32c3 fpga, the printed circuit board in 3D

    Esp32c3 fpga

    kitspace-test-repos/kicad6-file-collection

    93 partsMIT
  • 2 layers50 × 25 mmRx5808-receiver, the printed circuit board in 3D

    Rx5808-receiver

    msaribekyan/rx5808-receiver

    RX5808 based 5.8 GHz analog video receiver module

    39 parts3GPL-3.0
  • 2 layers29.2 × 39.4 mmMagspoof, the printed circuit board in 3D

    Magspoof

    wrickert/RickMagSpoof

    Rickert variant of the MagSpoof

    24 parts3
  • 2 layers50 × 25 mmLasgun, the printed circuit board in 3D

    Lasgun

    Outine/Lasgun

    IR LED blaster and IR receiver for dogfighting mini quads.

    23 parts
  • 4 layers24.9 × 19.3 mmSoundoff, the printed circuit board in 3D

    Soundoff

    xobs/soundoff

    Disable a USB port when the host is asleep

    29 parts

Questions

How big is the Spi fiend PCB?

It measures 34.8 × 18 mm and has 4 copper layers, 4.69 mm thick.

What parts does the Spi fiend use?

28 parts, built around the STM32F042G6U6 and DRTR5V0U4S. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Spi fiend KiCad files?

From the emeb/spi_fiend repository on GitHub, at the commit this page was made from: the board is hardware/v0.2/spi_fiend.kicad_pcb and its schematic hardware/v0.2/spi_fiend.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Spi fiend design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).