

Spi fiend
STM32F042-based USB to SPI device for programming iCE40 FPGAs
- Size
- 19.1 × 31.8 mm
- Copper layers
- 2
- Thickness
- 1.6 mm
- Parts
- 23
- Nets
- 31
- Pads
- 98
- Tracks, vias
- 233, 19
- Pours
- 1
- Routed
- Yes
- KiCad
- KiCad 5 (file 20171130)
- 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 2-layer board of 19.1 × 31.8 mm with 23 parts on 31 nets, routed with 233 tracks and 19 vias.
It is built around the STM32F042F6P6 and 74LVC1G3157. Its parts include 6 capacitors, 4 resistors, 4 ICs, 4 connectors 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
2README
README.mdspi_fiend
STM32F042-based USB to SPI device for programming iCE40 FPGAs

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:
- Kicad - schematic & PCB editor.
- GCC ARM Embedded - cross-compiler for ARM Cortex M: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm
- dfu-util - USB DFU driver application available in most distributions.
- Basic Linux user C compiler (for host application)
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
23| Qty | Value | Footprint | References |
|---|---|---|---|
| 4 | 0.1uF | Capacitors_SMD:C_0603_HandSoldering | C1, C3, C4, C6 |
| 3 | 1k | Resistors_SMD:R_0603_HandSoldering | R1, R2, R3 |
| 3 | LED_ALT | LEDs:LED_0603_HandSoldering | D1, D2, D3 |
| 2 | 10uF | Capacitors_SMD:C_0805_HandSoldering | C2, C5 |
| 2 | 74LVC1G3157 | TO_SOT_Packages_SMD:SOT-363_SC-70-6_Handsoldering | U3, U4 |
| 2 | switch_no | footprints:PUSHBUTTON_SMD_KMR2 | SW1, SW2 |
| 1 | 10k | Resistors_SMD:R_0603_HandSoldering | R4 |
| 1 | CONN_01X04 | Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm | J1 |
| 1 | CONN_01X05 | Pin_Headers:Pin_Header_Straight_1x05_Pitch2.54mm | J2 |
| 1 | CONN_01X07 | Pin_Headers:Pin_Header_Straight_1x07_Pitch2.54mm | J4 |
| 1 | MCP1802 | TO_SOT_Packages_SMD:SOT-23-5_HandSoldering | U2 |
| 1 | STM32F042F6P6 | Housings_SSOP:TSSOP-20_4.4x6.5mm_Pitch0.65mm | U1 |
| 1 | USB_OTG | footprints:USB_Micro-B_10103594-0001LF_NoSlot | J3 |
More from emeb/spi_fiend
1- 4 layers34.8 × 18 mm

Similar boards
- 4 layers60.8 × 61.3 mm

- 2 layers120.4 × 100.4 mm

Relaymux
PetteriAimonen/relaymux
Hardware and firmware for a USB connected relay box
59 parts18BSD-2-Clause - 2 layers15.9 × 25 mm

IMU
abstractfoundry/lumicube-boards
PCB and firmware design files for some of the LumiCube components
26 parts - 2 layers100 × 73.3 mm

Pride Badge
aziraphale/pride-badge-v1
🌈⚡Pride badge PCB with LEDs, STM32, and 3D printed diffuser+case!
136 parts - 2 layers20 × 38.5 mm

Arm tiny pcb
Chicken-Fried/STM32-NanoCortex
Ultra-compact USB-C development board powered by STM32F042 (ARM Cortex-M0) with native DFU, ceramic-only LDO power stage & CaveRover branding.
29 partsCERN-OHL-S-2.0 - 2 layers21 × 14.4 mm

Hub imu
ckemere/usb-imu
USB IMU for camera rigs: BNO055 module (STM32F042) and an FE1.1S hub carrier with JST-GH camera ports. KiCad 9.
19 partsCERN-OHL-P-2.0 - 2 layers135 × 21 mm

Usbc pd airsoft module
Fluffik214/airsoft-battery-module
This is a USB-C PD charger and cell monitor for a 3S LiPo that lives in an airsoft stock tube. It has one USB-C port.
98 parts - 2 layers46.2 × 36.8 mm

Questions
How big is the Spi fiend PCB?
It measures 19.1 × 31.8 mm and has 2 copper layers, 1.6 mm thick.
What parts does the Spi fiend use?
23 parts, built around the STM32F042F6P6 and 74LVC1G3157. 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.1/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).