Friday, 13 August 2010

Digilent Adept2 on Ubuntu

[UPDATE] Just discovered this a load of misguided rubbish. The digilent script uses "bash". Ubuntu uses "dash" as "sh" and isn't compatible. To run the do "sudo bash" not "sudo sh"

Back in February I bought a Nexys2 from Digilent for a very reasonable sum, at least in FPGA terms. However, I can not stand developing any code in Windows; I just find it awkward. At the time my options for programming the Nexys2 was limited:

  1. Use the windows-only Digilent tool (Adept)
  2. Use a perl script and custom firmware called nexy2prog.
The problem with nexy2prog is that the changes to the FPGA are not permanent when using this very handy programmer.

Fast-forward to now and I find that Digilent has created a Linux client for the Adept programmer. It does the job for what I need: upload my bitfiles to the FPGA PROM. An added bonus is that it's command-line (there is no gui). Once installed I have had no problems; the documentation is lacking and the argument passing to the CLI program is not that intuitive nor described in "-h" but it does at least help you when you pass the wrong arguments.

The main issue is the installer. Frankly I get the feeling the person tasked to write the installer was a bit green. Admittedly, i'm no good at Bash but I can at least see that the bash used in Adept's installer is using very strange code. The main example is extraneous parenthesis. Example 1, right at the start of one of the installers (
mname=($(uname -m))
That will not work and causes the script to exit it's execution. It should look like this:
mname=$(uname -m)

Example 2:
if [[ "${manpath}" == */usr/local/man* ]]
Those extra [] and "" are just unnecessary.

The thing is these issues (along with a couple that are just nit-picking) are throughout the over-engineered installer-scripts that are up to 700 lines in length (that are very well documented. A huge plus).

I did go through and clean up one of the installer-scripts and it installed fine but honestly, it's pointless and here I've outlined how you can go from a +1000 line installer scripts (both of the scripts) to just 16lines (at least on 32bit Ubuntu):

Make sure you have downloaded the 32bit Adept runtime and utilities and saved them in the same common directory. Then:

tar xaf digilent.adept*.tar.gz
cd digilent.adept*-i686/
sudo -s
cp -av lib/* /usr/local/lib/
mkdir /usr/local/lib/firmware
cp -av firmware/* /usr/local/lib/firmware/
mkdir -p /usr/local/share/digilent/data
cp -a jtscdvclist.txt /usr/local/share/digilent/data/
cp -av 52-digilent-usb.rules /etc/udev/rules.d/
echo "/usr/local/lib/" >> /etc/
/sbin/udevadm control --reload-rules
cd ../

tar xaf adept.utilities*1-i686.tar.gz
cd adept.utilities*1-i686/
cp -av bin/* /usr/local/bin/

There you have it. Done. (At least on my machine and this procedure cannot be guaranteed to work on yours. :D )