Apio support for TinyFPGA-B2



Some weeks ago Luke gave us (Jesus Arroyo and me) a couple of TinyFPGA-B2 for giving support in Apio [1] / Icestudio. The first step is testing it in Apio. Latter we will support it in Icestudio, that is a graphical tool for making it very easy to synthesize and upload circuits into the OpenFPGA boards, on any platform (Linux, Windows and Mac). Both apps are free-software (Free as in Freedom)

We need your help for testing it before the release, specially Windows and Mac (Because Jesus and me are Linux users).

The first thing to do is intall python 2.7

Then, install apio (development version) with this command:

  • pip2 install apio==0.3.0b3

Collecting apio==0.3.0b3
Downloading apio-0.3.0b3.tar.gz
Requirement already satisfied: click<7,>=5 in /usr/local/lib/python2.7/dist-packages (from apio==0.3.0b3)
Requirement already satisfied: semantic_version>=2.5.0 in /usr/local/lib/python2.7/dist-packages (from apio==0.3.0b3)
Requirement already satisfied: requests<3,>=2.4.0 in /usr/local/lib/python2.7/dist-packages (from apio==0.3.0b3)
Requirement already satisfied: pyjwt<2,>=1.5.3 in /usr/local/lib/python2.7/dist-packages (from apio==0.3.0b3)
Requirement already satisfied: colorama in /usr/local/lib/python2.7/dist-packages (from apio==0.3.0b3)
Requirement already satisfied: pyserial<4,>=3 in /usr/local/lib/python2.7/dist-packages (from apio==0.3.0b3)
Requirement already satisfied: scons==3.0.1 in /usr/local/lib/python2.7/dist-packages (from apio==0.3.0b3)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python2.7/dist-packages (from requests<3,>=2.4.0->apio==0.3.0b3)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/local/lib/python2.7/dist-packages (from requests<3,>=2.4.0->apio==0.3.0b3)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python2.7/dist-packages (from requests<3,>=2.4.0->apio==0.3.0b3)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python2.7/dist-packages (from requests<3,>=2.4.0->apio==0.3.0b3)
Installing collected packages: apio
Running setuppy install for apio … done
Successfully installed apio-0.3.0b3

Now, check that apio is correctly installed:

  • apio --version
    apio, version 0.3.0b3

Now, let’s install the toolchain and other auxiliary packages

  • apio install --all

Create a working directory and add the following testing files:


module blinky(clk_i, led_o);

input clk_i;
output led_o;

reg [22:0] cnt;
reg tgl;

assign led_o = tgl;

always @ (posedge clk_i)
if (cnt[22])
tgl = !tgl;
cnt = 0;
cnt = cnt + 1;


  • blinky.pcf:

set_io led_o E1
set_io clk_i B4

From the working directory, let’s create a TinyFPGA-B2 project:

  • apio init -b TinyFPGA-B2
    Creating apio.ini file …
    File ‘apio.ini’ has been successfully created!

We need also to install the tool for programming the TinyFPGA-B2

  • pip2 install tinyfpgab

and enable the drivers

  • apio drivers --serial-enable
    Configure Serial drivers for FPGA
    Serial drivers enabled
    Unplug and reconnect your board

Now everything should be ok, ready for uploading our first test:

Press the button and type:

  • apio upload
    Board: TinyFPGA-B2
    [Wed Jan 3 18:05:06 2018] Processing TinyFPGA-B2

PROG: tinyfpgab -c /dev/ttyACM0 --program
icepack hardware.asc hardware.bin
tinyfpgab -c /dev/ttyACM0 --program hardware.bin
TinyFPGA B-series Programmer CLI
Using device id 1209:2100
Programming /dev/ttyACM0 with hardware.bin
Bootloader not active
Programming at addr 030000
Waking up SPI flash
135100 bytes to program
Erasing designated flash pages
Writing bitstream
Verifying bitstream

and the LED connected to the pin 10 will start blinking…

You can see a vídeo of the uploading process here: https://photos.app.goo.gl/RrrBxMyUMzKBg3fo2

Once the software is installed and configured correctly, you only have to edit your .v and .pcf files and execute apio upload

We need as much feedback as possible for the release. Once apio is debugged, you are only one or two clicks away from synthesizing and uploading circuits in your FPGA board. So easy… and from any platform: Linux, Win, Mac

I am looking forward to your tests. Thanks!

Best regards, Juan

[1] https://github.com/FPGAwars/apio


Ok, First report, on Windows 10 64bits, Intel I7 16Gb RAM

Directly on terminal (without admin permissions) I’ve got some issues with python 2 & 3, same error.

On terminal with admin permissions i’ve got some issues too, again with both versions

Using NATIVE Ubuntu inside Windows 10, I’ve some weird issues, I think there’s a problem with the language


2nd Report, on OSX


After few hours updating, upgrading and giving permissions, I’ve got the same issues as in Windows:

I’m going to research it


Ok, I resolve this mac issues creating the folder manually and giving some permissions. I’m going to test it!!


Ok, I’ve installed the toolchains with no problems. For non-mac users, darwin is the name of the custom OSX-BSD-Kernel


Hi ChuxMan,

Try to update these packages in Windows:

pip install -U setuptools
pip install -U wheel

Source: https://stackoverflow.com/questions/14296531/what-does-error-option-single-version-externally-managed-not-recognized-ind


Thanks Jesús, It works, but only with pip2, no pip either pip3.

I’m in the same point as in OS X. I need to take a meassure of the pin voltages at fabric default and I’ll continue with the test


Just followed these instructions on my Windows 10 machine and it worked perfectly. Very convenient way to get the whole FPGA toolchain up and running. I was using the regular Windows command-line for this, not the Ubuntu for Windows bash shell.


@obijuan, @JesusArroyo: One note, I used pip instead of pip2. My system didn’t have pip2 available. I believe that’s because I’m using Anaconda for my Windows Python install.


Hi, thanks!

The only reason to use Python 2 is to ensure that the tinyfpga programmer works. Apio works also with Python 3. In Linux there is available pip, pip2 and pip3. May be windows has no pip2 link but it doesn’t matter.

Btw: have you used this command apio drivers --serial-enable? This should launch the serial_installer. I think this is only required for W8 but my question is: ¿Is there anything wrong if you install it in other versions of Windows (W10)?



I’ve added the blink example to apio, so now it is much easier to test it

Once apio and the toolchains are installed, we execute this command for upgrading the examples:

$ apio install examples
Installing examples package:
Download apio-examples-0.0.9.zip
Downloading [####################################] 100%
Unpacking [####################################] 100%
Package ‘examples’ has been successfully installed!

All the available examples can be listed with this command:

$ apio examples -l
Blink the led on pin 13 of the TinyFPGA-B2 board

Let’s try the blink13 example

$ apio examples -d TinyFPGA-B2/blink13
Creating TinyFPGA-B2/blink13 directory …
Example ‘TinyFPGA-B2/blink13’ has been successfully created!

Now we enter into the new directory

$ cd TinyFPGA-B2/blink13/

Press the reset button and ejecute the upload command:

$ apio upload

The led connected to the pin13 will blink

Any feedback or test is very welcome


I executed this command and the serial installer found that I had already installed it previously. It shouldn’t cause problems to have it installed on Windows 10 like I do. It is actually just an INF file that tells Windows to use the virtual com port driver for all USB devices that advertise themselves as a virtual com port. Windows 10 serial USB support is way better and more forgiving than Windows 8.

B2 Programmer Suggestion: mention .bin files

What version of icestorm/yosys/arachne is used to build the Windows binaries ?
I would be very interested in APIO if it also supports the UP5K part,

When I searched for Windows builds of icestorm, I found only old versions for download.



Hi mnemonix,

We have this repository: https://github.com/FPGAwars/toolchain-icestorm with the scripts to build the toolchain for all the architectures. You can find here the final releases.

We can/want to create a new updated release, but I think the support for UP5K is still experimental and it would be nice to have Yosys 0.8, but it is not available yet.

But it’s a matter of time and the support will be easy. If you are interested we can create a branch to test it there.



Thank you JesusArroyo

I use the icestorm toolchain already on a Raspberry PI, and it works quite well (sometimes some Arachne errors). The icestorm team works on a board with the UP5K chip, so support will increase in the near future.

If I understand it correct, you need a Linux system to do the compiles with your scripts, also for Windows. I only have the RasPI with Linux, so I don’t think it will be practicable to do it myself.

But I can wait until you find the time. I just use IceCube2 on Windows until then.



I have updated apio to 0.3.0rc1. Use pip install -U apio==0.3.0rc1 to install it.

Now the tinyfpgab package is an extras_require for apio. So you don’t need to care about the compatible tinyfpgab version, apio does.

As always, let us know your feedback to verify this tool for all OS. Thanks!