Friday, 13 August 2010

Digilent Adept2 on Ubuntu

[UPDATE] Just discovered this a load of misguided rubbish. The digilent install.sh script uses "bash". Ubuntu uses "dash" as "sh" and isn't compatible. To run the install.sh do "sudo bash install.sh" not "sudo sh install.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 (install.sh):
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/ld.so.conf.d/digilent-adept.conf
/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 )

Sunday, 18 July 2010

Managing Portage's Disk Usage

Even if you mount /var/tmp/portage as a tmpfs type portage still uses your hard drive a lot. To ensure that portage doesn't interfere with other programs that have a higher level of io-demand you need to say a special option in /etc/make.conf

PORTAGE_IONICE_COMMAND="ionice -c 3 -p \${PID}"
"-c 3" indicates that portage should only use idle hdd time for it's operations.

Friday, 9 July 2010

Bridge Wireless and Wired Network Adapters in Linux

In this blog post I shall describe how to bridge your wired connection to your wireless adapter. To be more specific the wireless (called wlan0 from now) is where the master device is receiving it's network (i.e. internet) connection; the wired connection (called eth0 from now on) is what you are going to share the connection via.

First things first you need to know how to compile a custom kernel. If you don't, stop here and find out how to. If you do no how you need to add the following entries to your.config file:

CONFIG_NF_CONNTRACK=y
CONFIG_NF_CT_ACCT=y
CONFIG_NF_CONNTRACK_MARK=y
CONFIG_NF_CONNTRACK_ZONES=y
CONFIG_NF_CONNTRACK_EVENTS=y
CONFIG_NF_CT_PROTO_DCCP=y
CONFIG_NF_CT_PROTO_GRE=y
CONFIG_NF_CT_PROTO_SCTP=y
CONFIG_NF_CT_PROTO_UDPLITE=y
CONFIG_NF_CONNTRACK_AMANDA=y
CONFIG_NF_CONNTRACK_FTP=y
CONFIG_NF_CONNTRACK_H323=y
CONFIG_NF_CONNTRACK_IRC=y
CONFIG_NF_CONNTRACK_NETBIOS_NS=y
CONFIG_NF_CONNTRACK_PPTP=y
CONFIG_NF_CONNTRACK_SANE=y
CONFIG_NF_CONNTRACK_SIP=y
CONFIG_NF_CONNTRACK_TFTP=y
CONFIG_NF_CT_NETLINK=y
CONFIG_NF_DEFRAG_IPV4=y
CONFIG_NF_CONNTRACK_IPV4=y
CONFIG_NF_CONNTRACK_PROC_COMPAT=y
CONFIG_NF_NAT=y
CONFIG_NF_NAT_NEEDED=y
CONFIG_NF_NAT_SNMP_BASIC=y
CONFIG_NF_NAT_PROTO_DCCP=y
CONFIG_NF_NAT_PROTO_GRE=y
CONFIG_NF_NAT_PROTO_UDPLITE=y
CONFIG_NF_NAT_PROTO_SCTP=y
CONFIG_NF_NAT_FTP=y
CONFIG_NF_NAT_IRC=y
CONFIG_NF_NAT_TFTP=y
CONFIG_NF_NAT_AMANDA=y
CONFIG_NF_NAT_PPTP=y
CONFIG_NF_NAT_H323=y
CONFIG_NF_NAT_SIP=y
CONFIG_NF_CONNTRACK_IPV6=y

You'll need to build a new kernel and boot of it.

Next you'll need dnsmasq. Set that up to serve ip addresses to eth0 ranging from 192.168.1.69.2 to 100. For me I edited /etc/dnsmasq.conf and added (I have no idea what 12h means. Maybe 12 hosts in the range 2-100):
dhcp-range=192.168.69.2,192.168.69.100,12h
interface=eth0

eth0's address needs to made 192.168.69.1
ifconfig eth0 192.168.69.1

If iptables is not there install it and then run:
iptables -t nat -A POSTROUTING -s 192.168.69.0/24 -d 0/0 -j MASQUERADE
Make the kernel to allow forwarding:
 echo "1" > /proc/sys/net/ipv4/ip_forward
Run dnsmasq:
/etc/init.d/dnsmasq start

All done.


NB. This was done on Funtoo

Sunday, 14 March 2010

Fluke 17B

A couple of weeks back I was looking to buy a multimeter. I wanted to stay away from cheap £20 Chinese junk but couldn't afford an expensive Fluke that I used at University and liked.

Then I came across the Fluke 15/17B. These 2 multimeters are all over eBay for ~£50-70 and have very little information about them other than a few forum debates about their authenticity, who could possibly be making them and a calibration manual at the Fluke website. Well, I bought the 17B and on the box it states:
Not for sale outside of China
Warranty void if sold outside of China

As I had no warranty I thought i'd crack open and have a look at the insides. Here are a few images of the device:

_DSC0313.jpeg
_DSC0294.jpeg
_DSC0301.jpeg

Full Set


All in all it's not a bad device. The mode selector is firm, has a good weight, nothing rattles, feels rugged enough for my use, uses AA batteries and the soldering is OK (not amazing).

I am happy with it.