Friday, 21 October 2016

Working with Lattice FPGA on Ubuntu 16.04

Designing with Lattice Diamond on Ubuntu 16.04


Recently I needed to use a small FPGA or CPLD for one of my latest projects, so I embarked on a search to find a suitable component. It had to meet the key criteria of low price (under £5) but retain a reasonable level of functionality. The implementation will contain  at least 10 manchester encoder/decoders, more than 20 programmable GPIOs, SPI or I2C slave interface for control, and avoid using external configuration memory.

After doing much research I settled on a Lattice MachXO2 device as it fitted the requirements nicely:

  • it is inexpensive compare to similar offerings from Altera and Xilinx, 
  • it uses internal configuration NVM and starts up in under a millisecond
  • it contains hardened SPI/I2C EFB module on chip that minimises the use of resourses
  • and as an added bonus - I can re-program it via I2C or SPI from my CPU

Lattice provides a Linux version of their Lattice Diamond design software, however it is in RPM format targeting Fedora/Suse.
I've been using Kubuntu as my primary system for many years and I am a bit reluctant to change to a different distro or run it in a VM. So, without hesitation I set about looking if other people have had success running it on a debian base system, and was encouraged by their results (see Resources).
Despite some initial hiccups I have also managed to get the latest Diamond Production Build 3.8.0.115.3  up and running on my Kubuntu 16.04, and now buisily designing with it.

Here are the steps:

1. Installation

First, download the RPM file from the LatticeSemi website (diamond_3_8-base_x64-115-3-x86_64-linux.rpm was the latest one at the time of writing this).

I have followed the instructions, but the schroot method did not work for me. Next I tried converting the RPM to DEB file using alien. It is important to include --scripts option when you convert the package as there are some post-installation scripts that should run to extract various files during installation.

Install alien if necessary

sudo apt-get install alien

Convert the package:

sudo alien --scripts diamond_3_8-base_x64-115-3-x86_64-linux.rpm
sudo dpkg --install diamond-3-8-base-x64_3.8-116_amd64.deb
After the installation was completed some additional tweaks were required as the some library dependancies weren't met, so the software wouldn't start:

Go to /usr/local/diamond/3.8_x64/bin/lin64 directory and replace the following symbolic links libQtCore.so.4 , libQtGui.so.4, libQtNetwork.so.4, libQtSql.so.4 to point to the following files instead of local using ln -s command:

sudo ln -s libQtCore.so.4 /usr/lib/x86_64-linux-gnu/libQtCore.so.4
sudo ln -s libQtGui.so.4 /usr/lib/x86_64-linux-gnu/libQtGui.so.4
sudo ln -s libQtNetwork.so.4 /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4
sudo ln -s libQtSql.so.4 /usr/lib/x86_64-linux-gnu/libQtSql.so.4

2. License

Use the MAC address of your primary interface to generate a license file using the Lattice website.
Important! Your primary network interface must be named eth0 as it is the only one that Diamond checks.
Place the .dat file you receive here: /usr/local/diamond/3.8_x64/license

3. Running

Go to /usr/local/diamond/3.8_x64/bin/lin64 directory and start ./diamond
If all goes well the GUI will start and you can start working on your project.
Here is what it what it looks like on my machine:

4. Device Programming

The FTDI driver used by Lattice Diamond clashes with ftdi_sio and usbserial modules that are loaded automatically when you plug your programmer/board into USB. Conequently, the Programmer part of the software fails to function properly.
To fix this run the following commands to unload the offending modules:

sudo rmmod ftdi_sio
sudo rmmod usbserial

This will have to be done every time you plug the board into the USB port.

Hope this helps,
Good luck!

Resources

Installation instructions:


A simple step-by-step video tutorial Lattice MachXO2 FPGA: https://youtu.be/SmdEP_ZsBgM

FTDI drivers on linux:

No comments:

Post a Comment