Getting started with FPGA with only Free and Open source software and hardware tools tutorial

FPGA

iCE40 is the first FPGA family with completely Free and Open source software tools thanks to Clifford Wolf who put incredible amount of time to create tool which compiles Verilog code to iCE40 bitstream by reverse engineering the output of the closed source Lattice tools.

As soon as we saw his presentation at FOSDEM we decided that we should make iCE40 FPGA board to use with his IceStorm tools.

The result is iCE40HX1K-EVB completely open source hardware board with all CAD files on GitHub. Which could be programmed with IceStorm!

Clifford built his tool to work with the Lattice stick, there they use FTDI chip¬†to program the board, something we do not like at all ūüôā

In the next tutorials we will teach you how you can program iCE40HX1K-EVB with any other board or processor which have SPI, but we will start with Arduino-Leonardo or our equivalent OLIMEXINO-32U4.

OLIMEXINO-32U4 is also OSHW board and all CADs are available, Arduino IDE is also FOSS.

What you will need to follow this tutorial:

  • iCE40HX1K-EVB this is the core board with the FPGA, some buttons, LEDs, SRAM memory which will be very useful for the more advanced demos like VGA video generator, Oscilloscope with fast ADC etc which will follow
  • OLIMEXINO-32U4 which will act as programmer instead of FTDI, instead this board you can use any Arduino or other board just have to wire the SPI signals to the¬†iCE40HX1K-EVB programming connector, in this caseOLIMEXINO-32U4 UEXT connector is used and we connect it with 10 pin ribbon cable to¬†iCE40HX1K-EVB
  • CABLE-IDC10-15cm¬† to connect between boards 1. and 2.
  • USB-MINI-CABLE¬†to connect OLIMEXINO-32U4 to your host computer where you will install Clifford’s IceStorm and will build your verilog code.
  • SY0605E¬† power supply 5V adapter for¬†iCE40HX1K-EVB
  • optional but highly recommended USB-ISO – after burning several USB ports on laptops and desktops while playing with development boards now I’m very careful and do not connect anything directly, its very easy to drop tweezers or wire or drop of solder on top of the development board while it’s connected to your computer and the result is USB damage and expensive repair.USB-ISO¬†saves all these troubles and isolate your precious computer from problems with shorts, over voltages etc.

Installing IceStorm

We will install IceStorm from sources so first we have to make sure we have all tools to build it:

    sudo apt-get install build-essential clang bison flex libreadline-dev \
     gawk tcl-dev libffi-dev git mercurial graphviz \
     xdot pkg-config python python3 libftdi-dev

 

Installing the IceStorm Tools (icepack, icebox, iceprog, icetime, chip databases):

    git clone https://github.com/cliffordwolf/icestorm.git icestorm
    cd icestorm
    make -j$(nproc)
    sudo make install

 

Installing Arachne-PNR (the place&route tool):

    git clone https://github.com/cseed/arachne-pnr.git arachne-pnr
    cd arachne-pnr
    make -j$(nproc)
    sudo make install

 

Installing Yosys (Verilog synthesis):

    git clone https://github.com/cliffordwolf/yosys.git yosys
    cd yosys
    make -j$(nproc)
    sudo make install

If everything completes with no errors – congratulations you successfully installed the IceStorm!

Preparing OLIMEXINO-32U4 as programmer

Now we have to prepare OLIMEXINO-32U4  as our FPGA programmer.

Download latest Arduino IDE . We recommend you to use the one from arduino.cc current revision is 1.6.9.

Copy iceprog.ino sketch from GitHub to examples folder.

Plug the USB cable to OLIMEXINO-32U4 and start the Arduino IDE

    cd arduino-1.6.9
    sudo ./arduino

From Tools¬†menu select ‘Arduino Leonardo’ as board.

From the same menu select the PORT where the board is attached it will be something like: ‘/dev/ttyACM0 (Arduino Leonardo)’ or ‘/dev/ttyUSB0 (Arduino Leonardo)’

Open the iceprog.ino sketch.

From menu SketchInclude libraryManage libraries check if you have SPI and SPIFlash libraries installed if not install them.

Compile and Upload the sketch.

If everything complete without error now you have OLIMEXINO-32U4 set as iCE40HX1K-EVB programmer!

Add support for OLIMEXINO-32U4 in IceStorm

Copy iceprogduino folder from GitHub to icestorm folder and build it

    cd icestorm/iceprogduino
    make
    make install

Make your first program for FPGA – blink LED

Copy demo code from GitHub to icestorm/examples

    cd icestorm/examples/ice40hx1k-evb
    make
    make prog

If everything finish with no error you will see LED1 and LED2 blinking on iCE40HX1K-EVB.

Congratulations! You made blinking LED on FPGA!

Now check what is the content of example.v , ice40hx1k-evb.pcf and Makefile and learn why the LEDs blink and what happen when you press together BUT1 and BUT2?

Next tutorial will be how to use iCE40HX1K-EVB with A20-OLinuXino-MICRO as both host for the IceStorm tool and programmer via UEXT connector with just cable and what additional options it gives like loading the code directly to FPGA whthout using SPI flash and your can change FPGA code in milliseconds.

TuxCon the FOSS Conference for Mobile and Embedded devices is less than 2 weeks away

Image

TuxCon¬†¬†is a community-driven event about free and open-source software for mobile and embedded devices. The event is organized by Plovdiv’s hackerspace Hackafe and the entry is free.

Saturday, 28th of June is the day for lectures: the schedule is available at TuxCon web http://tuxcon.mobi/#schedule

During the event there are two lectures where OLinuXino Open Source Hardware Linux computers will be discussed:

Image

The first lecture is “Physical computing with Linux” in which it¬†will be explained at a non-embedded developers level how to access all hardware resources from the Linux user space for OLinuXino like GPIOs, I2C, SPI, UARTs, the Power management – how to make your code aware of whether it runs on Battery or on Mains power supply, what is the temperature of the processor, is the battery charging or not, etc. It will also be explained how to connect sensors, how to connect steppers and servos, how to control them from Linux, how to setup a web server on OLinuXino, how to make all of the hardware resources, offered by this board, available via web interface as well as how to attach camera and do OpenCV processing, and more.

Image

The Second lecture is “Linux driver” where it will be explained how a Linux Driver is created and there will be a step-by-step explanation of how a driver for new hardware like MOD-IO board connected to OLinuXino via UEXT is created. MOD-IO boards have relays and ADCs which will be made available for use in Linux user space via the written driver.

Of course there will be other interesting lectures about Android, FirefoxOS, Tizen etc.

Do not forget that on Sunday 29th of June at the Olimex training building we will run Hardware and Software Hackathons.

Image

There will be a soldering workshop for the well-known FOSDEM Arduino clone board, where you will be trained how to solder alone your first Arduino and then program it and use it.

There will also be two Software tasks for the Hackathon:

 

Image

To make fancy web interface for controlling an interactive RGB LED table:¬†the RGB table have 8×8 RGB Leds which are addressable individually and four proximity sensors at the four sides which detect if someone sits on this side.

 

Image

The second task is to do same for the Coctail-Mixing-Machine – it has 6 fluid pumps connected to the relays which could be opened/closed for a certain amount of time; controlling the volume of the drink in the recipe, flow sensors will give feed back if the fluid is flowing through the pipes; RGB addressable LEDs will be put under every bottle and pump which will make a LED animation while preparing the drink or will signal when the bottle is empty.

Both Hardware tasks will be performed¬†with OLinuXino and all hardware resources will be available through User space APIs, so if you want to participate start thinking in advance¬†and surprise us with your solution ūüôā

Everyone who participates in the Hardware Hackathon will keep the Arduino board they built for themselves as a prize.

For everyone participating in the Software Hackathon there will be FOSDEM board prizes and the best solutions will win two A20-OLinuXino-MICRO.

 

Next Newer Entries