How to build one
This is a write down on how to build the IceZero FPGA board by Black Mesa Labs for the Raspberry Pi Zero. Note that I did not design this board; I merely collected together some of the information out there.
What is the IceZero FPGA board?
An open-source FPGA HAT that fits onto a Raspberry Pi or Raspberry Pi Zero, and that can be flashed via the Raspberry Pi using a completely open-source tool-chain. No external programmer is required, and all parts are still solder-able without re-flow soldering.
The board features:
- A Lattice ICE40HX4 FPGA in a TQFP-144 package, which has ~4k logic cells (enough to synth a tiny RISC-V processor)
- A single red LED. It's great, trust me.
- Pin headers and Raspberry Pi GPIOs connected to the FPGA fabric
- Build cost: ~$22 parts per board + $5 for the PCB + your time
It doesn't have much, but that is what makes it great. Consider it a cheap linking brick between your Raspberry Pi, and the low level project you're trying to do.
What I learned building this board
- Soldering a TQFP-144 still is no fun. Use a lot of flex. Way more than you think is necessary. Carefully align everything before adding the first solder
- For resistors/capacitors: It helps to have a flux pen, and to pre-tin one of the two pads. Heat up the tinned solder pad with your soldering iron, and move the resistor/capacitor into the hot solder at the same time
- Order spares :) I had to recycle an SROM chip of an ESP8266 board because I destroyed one.
About Lattice FPGAs:
- They're pretty resilient to heat, and withstand some torture
- The FPGA won't power up if any of it's power lines are not connected
- You can test if your FPGA powers up by attaching a logic analyzer to the SPI pins -- the FPGA will try reading from the SRAM if the SS pin is left floating (if it's low, it'll go into slave mode, and wait for commands)
- All you need to get this FPGA running is: Power (1.2V, 3.3V), SPI pins (SS, SO, SI), and maybe an Oscillator, and a bunch of capacitors. It's simpler than you think. See this checklist.
About the board:
- The SPI flash is in theory not necessary -- I think the Raspberry Pi itself could bitbang the program (not verified) if you do not care for it to be available before linux startup.
- I feel like the SPI lines could have been connected to the Raspberry Pi SPI lines, instead of bit-banging the flash. There's always cable select.
- The "Reset" and "Done" pins around the SROM are not actually connected to the SROM, but to the FPGA. The pins on the SROM itself are unconnected -- only SI, SO, CLK is used.
- FPGA has to be held in RESET state while flashing the SPI ROM as the FPGA would otherwise control the CLK line
How to build an IceZero board?
The Black Mesa Labs blog post contains links to the Gerber files, and other info, but it lacks a schematic. I've collected all information I could find in a printable doc (see below) that should help with actually performing the build.
(Step 1) Order your boards from OSH Park, or other favorite PCB manufacturer
- You can skip the 4M SRAM if you never intend to use it in your programs.
- The serial flash can be replaced by any standard serial flash (as long as the pins match) -- they're fairly standardized. You only need ~4M for most applications (more if you want to put user code in there).
(Step 2) Order the parts required for the build. A Digikey parts list for two boards (with no spares, except capacitors) can be seen on the right
(Step 3) Build the board using the printable doc on the left. A few hints:
- Start with the Lattice TQFP, and use plenty of flux & a solder wick to remove any bridges. They're fairly hard to destroy (I had to unsolder mine via hot air, and re-solder them, and they're still fine)
- Then continue with the SRAM, SROM, Voltage regulators and Oscillator. Pin "1" for each chip can be seen in the doc below, and all these chips are well labelled. The boards from OSH Park will be missing any labeling that goes over exposed copper, so look at the images instead of the real board.
- Each of the three power regulator needs 4.7uF or 10uF capacitors. All other capacitors are 0.1uF
DigiKey Parts List (January 2019) for *two* boards
Quantity Part Number Manufacturer Part Number Description
2 220-1572-ND ICE40HX4K-TQ144 IC FPGA 107 I/O 144TQFP
2 706-1306-1-ND IS61LV25616AL-10TL-TR IC SRAM 4M PARALLEL 44TSOP II
2 1473-1484-1-ND SIT8008BI-12-XXE-100.000000G MEMS OSC XO 100.0000MHZ
4 BU33TD3WGCT-ND BU33TD3WG-TR IC REG LINEAR 3.3V 200MA 5SSOP
2 BU12TD3WGCT-ND BU12TD3WG-TR IC REG LINEAR 1.2V 200MA 5SSOP
10 1276-2087-1-ND CL10B475KQ8NQNC CAP CER 4.7UF 6.3V X7R 0603
5 641-1332-1-ND CDBU0520 DIODE SCHOTTKY 20V 500MA 0603
3 160-1176-1-ND LTST-C170CKT LED RED CLEAR SMD
2 W25Q128JVSIMCT-ND W25Q128JVSIM TR IC FLASH 128M SPI 133MHZ 8SOIC
40 720-1379-1-ND VJ0603Y104KXXCW1BC CAP CER 0.1UF 25V X7R 0603
20 1276-3485-1-ND RC1608F103CS RES SMD 10K OHM 1% 1/10W 0603
10 1276-3484-1-ND RC1608F102CS RES SMD 1K OHM 1% 1/10W 0603
2 S1011EC-40-ND PRPC040SAAN-RC CONN HEADER VERT 40POS 2.54MM
4 609-5148-ND 87606-810LF CONN RCPT 20POS 0.1 GOLD PCB
How to check if my IceZero board is working?
First, I'd suggest using a logic analyzer. It makes your life a lot simpler. Attach it to SPI pins to see if your FPGA is alive, and whether the SROM writes look okay.
On a new Raspberry Pi, you'll first need to install the necessary software:
sudo apt-get install fpga-icestorm arachne-pnr yosys
git clone https://github.com/thekroko/icotools.git
sudo make install_icezprog
Then, try flashing a blinky sketch and see what happens:
If everything worked correctly, you should see an output similar to the one below, and the LED on the IceZero board should be flashing at 2 Hz.
Flash ID: C8 40 13 C8 40 13 C8 40 13 C8 40 13 C8 40 13 C8 40 13 C8 40
Writing 0x000000 .. 0x00ffff: [erasing] [writing................] [readback................]
Writing 0x010000 .. 0x01ffff: [erasing] [writing................] [readback................]
Writing 0x020000 .. 0x020fbb: [erasing] [writing.] [readback.]