After getting the tinyFPGA working with the yosys / Arachne-PNR / icestorm toolchain as noted in my prior blog, I wanted to try out NextPNR  (the Arachne-PNR replacement). This turned out to be a bit of a bumpy ride. Yes, I know it's no fun if it is too easy, but I wonder if I'm approaching my maximum fun capacity? (spoiler: no, this is awesome!)

TL;DR. WSL Ubuntu 16.04 or later is needed. There's a known problem with NextPNR that prohibits the GUI version from compiling. The tinyFPGA has a iCE40LP8K-CM81; two parameters required: --lp8k and --package cm81. The iCEstick has a iCE40HX-1k on board.

First, it seemed that everything I had was the wrong version. apt-get update / upgrade does not really update as much as one might like. So I first updated CMake and Python:

cmake --version
sudo apt-get remove cmake
sudo apt-get install cmake3
sudo apt-get remove 'python3.*'
sudo apt-get install python3.5-dev

Next, I encountered a boost issue, similar to nextpnr issue 129 - cmake: "Could NOT find Boost -- Boost version: 1.58.0". Then I had this annoying problem where cmake Could NOT find PythonInterp: (even though Python 3.5.2 is installed). The problem here was simply that I ran CMake before having the proper version of dependencies installed and the error was cached in CMakeCache.txt !! Simply removing (or renaming) the file resolved that - however, I then encountered yet another boot problem (issue 215: CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'). This one turned out to be that I had Ubuntu 14.04 and needed something newer (thanks to @daveshah1 for pointing this out) - despite the icestorm tools explicitly naming Ubuntu 14 .04

Here's how I upgraded my WSL Ubuntu to the latest version (16.04):

sudo ls # pause if copy/paste for password prompt
sudo apt-get update --assume-yes
sudo apt-get upgrade --assume-yes
sudo apt-get install update-manager-core  --assume-yes
sudo do-release-upgrade
sudo apt-get update
sudo apt-get dist-upgrade
# doing this wiped out CMake, so I had to reinstall:
tar xf cmake-3.13.3.tar.gz
cd cmake-3.13.3
sudo make install
cmake --version
# pip was also wiped out (despite Python 3.6 being listed for tinyFBGA install, tinyprog is installed with pip, not pip3)
sudo apt-get install python3-pip
sudo apt-get install python-pip
Then install the nextpnr dependencies:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libboost-all-dev
sudo apt-get install python3-dev
sudo apt-get install qt5-default
sudo apt-get install clang-format
My final, working Makefile for getting the picosoc RISC-V example onto the tinyFPGA looks like this:

upload: hardware.bin firmware.bin
        tinyprog --com /dev/ttyS8 -p hardware.bin -u firmware.bin
hardware.blif: hardware.v spimemio.v simpleuart.v picosoc.v picorv32.v
        yosys -ql hardware.log -p 'synth_ice40 -top hardware -blif hardware.blif -json hardware.json ' $^
hardware.asc: hardware.pcf hardware.blif
        # arachne-pnr -r -d 8k -P cm81 -o hardware.asc -p hardware.pcf hardware.blif
        nextpnr-ice40 --lp8k --package cm81 --json hardware.json --pcf hardware.pcf --asc hardware.asc
hardware.bin: hardware.asc
        icetime -d hx8k -c 12 -mtr hardware.rpt hardware.asc
        icepack hardware.asc hardware.bin
firmware.elf: start.S firmware.c
        /opt/riscv32ic/bin/riscv32-unknown-elf-gcc -march=rv32imc -nostartfiles -Wl,-Bstatic,-T,,--strip-debu$
firmware.bin: firmware.elf
        /opt/riscv32ic/bin/riscv32-unknown-elf-objcopy -O binary firmware.elf /dev/stdout > firmware.bin
        rm -f firmware.elf firmware.hex firmware.bin firmware.o \
              hardware.blif hardware.log hardware.asc hardware.rpt hardware.bin

What versions are installed?

lsb_release -a
python --version
python3.5 --version
cmake --version
clang --version
echo qtf_default $(apt-cache show qt5-default | grep -m1 Version)
echo libboost-all-dev $(apt-cache show libboost-all-dev | grep -m1 Version)
for pk in build-essential clang bison flex libreadline-dev \
          gawk tcl-dev libffi-dev git mercurial graphviz   \
          xdot pkg-config python python3 libftdi-dev \
          qt5-default python3-dev libboost-dev; \
  do echo "$pk" $(apt-cache show "$pk" | grep -m1 Version); done
nextpnr-ice40 --version
yosys -V
/opt/riscv32ic/bin/riscv32-unknown-elf-gcc -v
pip --version
echo apio [pip]      $(pip  list | grep apio)
echo apio [pip3]     $(pip3 list | grep apio)
echo tinyprog [pip]  $(pip  list | grep tinyprog)
echo tinyprog [pip3] $(pip3 list | grep tinyprog)
Once nextpnr is all compiled, then next thing is to run it in GUI mode! So far, I have been unsuccessful here. At first, I tried to use the MingX, in the same way I did for my OpenWRT / Wireshark exercise . Despite working just fine on an older Ubuntu 14.4, this new 16.4 simply refused to play.

So instead, I tried CygWin/X - I fussed with it for quite some time before I eventually found a useful hint. First, run Cygwin installer . I selected all of the "X11" and "Xorg" items:

Next, in WSL:

export DISPLAY=:0 # you may wish you put in this your ~/.bashrc
The hint I found was that that I needed to start cygwin X-Server like this:

C:\cygwin64\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; exec /usr/bin/startxwin -- -listen tcp"
Specifically adding that -- -listen tcp command-line parameter. I also needed to copy the .Xauthority file from my cygwin home, to my WSL home. (yes, I know this is getting more kludgey with each step):

cp /mnt/c/cygwin64/home/gojimmypi/.Xauthority  .Xauthority
without doing this, I had an Authorization error like this:

$ xclock
Authorization required, but no authorization protocol specified
Error: Can't open display: :0
The xclock test works just fine: no errors. I'm able to get wireshark to run but I do see some warnings.
Sadly, nextpnr will not launch at all:

$ nextpnr-ice40 --gui
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.
Could not initialize GLX
Aborted (core dumped)
I tried using the export LIBGL_USE_WGL=1 as suggested here, but no change in outcome. I tried the glxinfo | grep OpenGL , but didn't have it installed. Next:

sudo apt-get install mesa-utils
glxinfo | grep OpenGL
This resulted in a new error: Error: couldn't find RGB GLX visual or fbconfig. I then tried to install more of the OpenGL stuff as suggested here . (no change in results)

sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev
Still no joy. I'm happy to have nextpnr working in command-line mode, and have successfully used it with the RISC-V on the TinyFPGA instead of Arachne-PNR, but I would have really like to have been able to see the GUI.
Copyright (c) gojimmypi all rights reserved. Blogger Image Move Cleaned: 5/3/2021 1:35:54 PM