OK, so I had to install diamond on linux recently and had to spend a good evening to get it up and running. I've seen other posts of people struggling with it so I decided to write a small guide on this topic, since none of the instructions worked for me. In my case I'm using XO3 board, diamond 3.7 on debian.
- Step 1: getting diamond + license
You have to register on their website to obtain the license. That might require a dozen of fake email addresses, since their stupid authentication system is living it's own life. When you fill in your "company" don't write "Unaffiliated" as suggested on the website - that will most likely result in unactivated account and you will keep getting "page not found" errors. To obtain a license you need to fill in your MAC address - I usually generate a random address and spoof it when I need to. Also, you have to renew the license every 6 months. Honestly, that's just a pain in the ass which is why I've been looking towards other vendors for quite a while.
- Step 2: installing diamond
In case your distribution doesn't support rpm-packages you can still install it without any problems. However,
don't use alien on debian and it's derivatives - you'll waste lots of time and it won't work properly. Simply unpack the rpm package (put it in ~/local/diamond for example) and then unpack .tar archives in each subfolder (./bin/bin.tar, ./cae_library/cae_library.tar, etc). Now you should be able to run ./bin/lin64/diamond. If it complains about missing libraries then install those separately.
- Step 3: installing the license
MAC address in the license file has to match the address of
eth0 interface. To spoof MAC-address run:
# ip link set dev eth0 down
# ip link set dev eth0 address XX:XX:XX:XX:XX:XX
I do that on every machine where I use diamond.
Great idea, Lattice. Thanks for making my life so much easier.- Step 4: getting the programmer to work
At this point if you attach the programmer and run diamond, it will crash with a segfault and complain about usb write permissions. To get the programmer working we need to set the appropriate permissions and also unbind the ftdi_sio driver. However, in my case XO3 board has a FT2232H chip which provides a dual interface. If you look at dmesg output you should see something like
[71334.912360] usb 8-2: Product: Lattice XO3L Starter Kit
[71334.912363] usb 8-2: Manufacturer: Lattice
[71334.915149] ftdi_sio 8-2:1.0: FTDI USB Serial Device converter detected
...
[71334.918138] ftdi_sio 8-2:1.1: FTDI USB Serial Device converter detectedIf you try to unbind ftdi_sio from device 8-2 it will not work - you have to specify device 8-2:1.0. In this case we only need to unbind the first interface, since it's used for programming.
Here is a complete udev rule:
# Lattice FTDI programmer
SUBSYSTEM == "usb", DRIVER == "usb", \
ATTRS{idVendor} == "0403", ATTRS{idProduct} == "6010", \
MODE := "0666", RUN += "/bin/sh -c 'basename %p:1.0 > /sys/bus/usb/drivers/ftdi_sio/unbind'"
Place it under
/etc/udev/rules.d/49-lattice.rules and run
udevadm trigger afterwards.
If everything works properly, you should have similar dmesg output after attaching the board:
[71334.915526] usb 8-2: FTDI USB Serial Device converter now attached to ttyUSB0
[71334.918138] ftdi_sio 8-2:1.1: FTDI USB Serial Device converter detected
...
[71334.927683] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[71334.927699] ftdi_sio 8-2:1.0: device disconnected