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

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

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

23
QtyValueFootprintReferences
40.1uFCapacitors_SMD:C_0603_HandSolderingC1, C3, C4, C6
31kResistors_SMD:R_0603_HandSolderingR1, R2, R3
3LED_ALTLEDs:LED_0603_HandSolderingD1, D2, D3
210uFCapacitors_SMD:C_0805_HandSolderingC2, C5
274LVC1G3157TO_SOT_Packages_SMD:SOT-363_SC-70-6_HandsolderingU3, U4
2switch_nofootprints:PUSHBUTTON_SMD_KMR2SW1, SW2
110kResistors_SMD:R_0603_HandSolderingR4
1CONN_01X04Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mmJ1
1CONN_01X05Pin_Headers:Pin_Header_Straight_1x05_Pitch2.54mmJ2
1CONN_01X07Pin_Headers:Pin_Header_Straight_1x07_Pitch2.54mmJ4
1MCP1802TO_SOT_Packages_SMD:SOT-23-5_HandSolderingU2
1STM32F042F6P6Housings_SSOP:TSSOP-20_4.4x6.5mm_Pitch0.65mmU1
1USB_OTGfootprints:USB_Micro-B_10103594-0001LF_NoSlotJ3

More from emeb/spi_fiend

1
  • 4 layers34.8 × 18 mmSpi fiend, the printed circuit board in 3D

    Spi fiend

    emeb/spi_fiend

    STM32F042-based USB to SPI device for programming iCE40 FPGAs

    28 parts17MIT

Similar boards

  • 4 layers60.8 × 61.3 mmOS3M Mouse, the printed circuit board in 3D

    OS3M Mouse

    spoter368/os3m-hardware

    All the hardware needed to build your own OS3M Mouse!

    51 parts399
  • 2 layers120.4 × 100.4 mmRelaymux, the printed circuit board in 3D

    Relaymux

    PetteriAimonen/relaymux

    Hardware and firmware for a USB connected relay box

    59 parts18BSD-2-Clause
  • 2 layers15.9 × 25 mmIMU, the printed circuit board in 3D

    IMU

    abstractfoundry/lumicube-boards

    PCB and firmware design files for some of the LumiCube components

    26 parts
  • 2 layers100 × 73.3 mmPride Badge, the printed circuit board in 3D

    Pride Badge

    aziraphale/pride-badge-v1

    🌈⚡Pride badge PCB with LEDs, STM32, and 3D printed diffuser+case!

    136 parts
  • 2 layers20 × 38.5 mmArm tiny pcb, the printed circuit board in 3D

    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 mmHub imu, the printed circuit board in 3D

    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 mmUsbc pd airsoft module, the printed circuit board in 3D

    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

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).