TekBots

This bulletin board will help connect the developers and supporters of TekBots with users from OSU and other schools.
It is currently Tue Sep 16, 2014 4:30 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Lattice Diamond and Linux
PostPosted: Wed Apr 30, 2014 6:32 pm 
Offline

Joined: Tue Oct 15, 2013 4:04 pm
Posts: 5
Unless your distribution's package manager can handle RPM's, getting Diamond running on linux takes some manual intervention. Though I don't know the specific steps to get it running perfectly with every flavor of linux, here's the general steps I took to get it running on my system:

Installation/Running Diamond

First, download the appropriate package. In my case, I needed "Diamond 3.1 64-bit for Linux"... obviously, this won't work if you have a 32-bit system. It's a 1.1GB .RPM, normally meant for distributions that use the 'yum' package manager, like CentOS, Fedora, or Red Hat. If you're using a distro with yum, check the yum docs for how to install the package and ignore most everything else in here.

Next, make a directory somewhere for Diamond to live in and extract it with an RPM extractor. Your distribution most likely has one you can install from the package manager. Google is your friend here- rpm2cpio is a popular tool. On archlinux, a package called rpmextract is available in the AUR which is basically just a wrapper script for rpm2cpio.

At this point, you can go ahead and copy or symlink everything to the appropriate paths if you want. I didn't because I just wanted to see if I could get it running, which probably accounts for some of the broken features I have. The script to get Diamond running is located at ($diamond_dir)/usr/local/diamond3.1_x64/bin/lin64/diamond, so you can 'cd' to that directory and mark it executable with 'chmod +x ./diamond'.

After that, you should be able to run it by typing in './diamond' (within that script's directory) and hitting enter.

Programming the Board
Diamond's programmer talks to the FTDI chip with libftdi's D2XX drivers, which is installed by default on a lot of distributions (and I'm pretty sure is included in the kernel at this point). If it's not installed already, do that through your package manager. If you don't have a package manager or libftdi isn't in there, checkout FTDI's site at http://www.ftdichip.com/Drivers/D2XX.htm for some guidance.

I found that for Diamond to be able to program and detect my FPGA, I had to remove the auto-loaded ftdi and usb_serial modules. After you plug in your board, these kernel modules will be automatically loaded to supposedly enable communication with the board, but for whatever reason (or maybe I'm not understanding the process correctly), they inhibit communication between the FTDI chip and Diamond.


So... back to the terminal. First check which ftdi-related modules have been loaded after you plugged in your FPGA:

Code:
$ lsmod | grep ftdi
ftdi_sio               39723  0
usbserial              30821  1 ftdi_sio
usbcore               182430  11 usblp,snd_usb_audio,usb_storage,usbserial,snd_usbmidi_lib,ehci_hcd,ehci_pci,usbhid,ftdi_sio,xhci_hcd


Then, remove these modules:
Code:
$ rmmod ftdi_sio
$ rmmod usbserial


After removing the modules, you should be able to detect and program your board through Diamond. The modules will be automatically loaded every time you plug in your FPGA, so they'll also need to be removed each time before you can program your board with Diamond. Again, I'm not sure why this is- my assumption is that Diamond has some form of FTDI drivers built-in and the default kernel modules interfere with those. If that's the case, it's probably not a great idea to install libftdi if you don't already have it... but oh well.

Issues
Here's some issues that I've had, most likely related to not having things in the paths where Diamond is expecting them to be:
  • Simulations don't work
  • Occasional errors that prevent synthesizing and generating JEDEC files. Usually happens after programming. Save and restart program.

Other issues you might have with programming the board will most likely relate to permissions. Setting up udev properly is important- again, find specifics with Google.


Top
 Profile  
 
 Post subject: Re: Lattice Diamond and Linux
PostPosted: Fri May 02, 2014 12:36 pm 
Offline

Joined: Mon Oct 28, 2013 9:17 am
Posts: 2
Did you get Lattice USB working without their udev rules? I personally can't get USB drivers to woek in Diamond unless I run as root.

I'll try to script the rmmod steps into udev rules so its more conveinet.


Top
 Profile  
 
 Post subject: Re: Lattice Diamond and Linux
PostPosted: Fri May 02, 2014 2:35 pm 
Offline

Joined: Tue Oct 15, 2013 4:04 pm
Posts: 5
Honestly, I didn't look at their udev rules. When I first tried to program the board and failed, I figured it was a udev problem and threw a MODE:="777" rule in there so I wouldn't have to deal with it. I don't think that 777 is best practice though. Setting OWNER or GROUP might be a better way to go about this.

Having a script for the module stuff would be nice... I haven't put much effort into this past that initial bit since at this point I'm only using the board about once a week for a few minutes.

Minimal udev rule that's working for me (again... for anyone that may copy and paste this, 777 is probably not the best way to do this security-wise for any device):

Code:
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE:="777"


With this, I can program as a normal user without a problem.


Top
 Profile  
 
 Post subject: Re: Lattice Diamond and Linux
PostPosted: Sat May 03, 2014 4:45 pm 
Offline

Joined: Mon Oct 28, 2013 9:17 am
Posts: 2
Also, there seems to be a bit of discrepancy between your guide and mine in getting Lattice Diamond to program the FPGA... So here's my very similar guide:

Install Lattice Diamond by first converting the rpm package to deb using alien, then installing the deb package and symlinking the diamond binary:

Code:
$ sudo apt-get install alien
$ alien [name of lattice package]
$ sudo dpkg -i [name of lattice deb]
$ sudo ln -s /usr/local/diamond/3.1_x64/bin/lin64/diamond /bin/diamond


I then installed the Lattice FPGI USB drivers (requires libusb as a dependency):

Code:
$ sudo echo plugdev:x:501:username /etc/group
$ sudo /usr/local/diamond/3.1_x64/data/vmdata/
$ sudo ./udevsetup
$ sudo ./usbsetup

Plug in the Lattice FPGA, then probe to see if modules are loaded for the FTDI, and unload them:

Code:
$ sudo lsmod
$ sudo rmmod ftdi_sio
$ sudo rmmod usbserial


This step needs to be done every time the FPGA is plugged in, as the Linux kernel will load its module every time the FPGA is plugged in. I'll try to script this into udev for the sake of convenience.

Now start Lattice Diamond as root (the USB drivers don't seem to work without root):

Code:
$ sudo diamond


And Lattice Diamond should program the FPGA correctly.


Top
 Profile  
 
 Post subject: Re: Lattice Diamond and Linux
PostPosted: Thu May 29, 2014 6:30 am 
Offline

Joined: Wed Nov 20, 2013 3:16 pm
Posts: 1
Did anyone figure out how to use the simulation feature on a linux-os or is there no way around that problem?


Top
 Profile  
 
 Post subject: Re: Lattice Diamond and Linux
PostPosted: Thu May 29, 2014 3:45 pm 
Offline

Joined: Tue Oct 15, 2013 4:04 pm
Posts: 5
I've had no luck with it. I can't even find the binaries for it (either the Aldec one or the ModelSim one).


Top
 Profile  
 
 Post subject: Re: Lattice Diamond and Linux
PostPosted: Wed Jun 04, 2014 5:24 pm 
Offline

Joined: Tue Oct 15, 2013 4:04 pm
Posts: 5
For reference, here are the udev rules I use that allow essentially plug-and-play operation for programming the chip:

Code:
$ cat /etc/udev/rules.d/79-diamond.rules
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE:="777"
ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", RUN+="/usr/bin/rmmod ftdi_sio"


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group