Tag Archives: Linux

Atmel AVRISP mkII working in Virtualbox

In the past I have had problems getting the Atmel AVRISP mkII to work with Virtualbox.  This can be really irritating if, like me, you want to write code in Linux but are forced to run Windows for Skype and various closed-source development tools (ugh).

Today, it seems to be working.  I can talk to the AVRISP with avrdude and program devices.  Cool!

I’m not sure what I changed.  I’m using Virtualbox 3.2.10 r66523, running on a Windows 7 64-bit host.  The VM/client OS is Ubuntu 10.10.  I created a USB filter for the AVRISP in the Virtual Machine settings; it doesn’t seem to work without it.  That might be what I was missing before.

To avoid having to run avrdude with root priveledges, I created the file /etc/udev/rules.d/10-avrisp2.rules with the contents:

SUBSYSTEM=="usb", SYSFS{idVendor}=="03eb", SYSFS{idProduct}=="2104", GROUP="adm", MODE="0666"

Pretty simple.

Oh, I should add that there is no guarantee other combinations of host/client OS will work.   If you’re getting different results, leave a comment.

AVR Toolchain Installation Instructions for Windows, Mac OS X, Linux

Mitch Altman and I are in the process of writing a book about Making Cool Things with Microcontrollers (for people who know nothing.)

The book features several DIY projects that use AVR microcontrollers.  We’re aiming to teach absolute beginners how to solder, basic electronics, and the process of turning a cool idea into reality by using microcontrollers.

I wrote these instructions about setting up a working avr-gcc environment in Windows, Mac OS X, or Linux.  Mitch and I felt that they could use some beta testing in the real world before bring included in the book, so we decided to make them available here.  We also felt that they might help some people get started with AVRs before the book is available.

We want to make the process of writing and compiling code for the AVR simple and accessible, so we’re not using any fancy IDEs (eg. no AVR Studio).  We also wanted to use the same software on all three operating systems, so Windows-only tools were out.  Instead, we’re using avr-gcc, the compiler behind WinAVR, CrossPack, and Arduino.

I would appreciate any feedback on these instructions.

Here they are:


Mac OS X


Update: I totally rewrote this post after getting feedback that I didn’t properly identify my target audience and explain why I chose avr-gcc.  Sorry!

Measuring network performance with iperf

My new place in Austin came with a huge perk for a tech geek like me – it came pre-wired for ethernet in every room.  (Well, technically not every room is wired.  The laundry room, bathrooms, and garage are not, an understandable oversight.)

After installing a new D-Link Gigabit Ethernet Switch, I wanted to check the throughput to see if I was actually getting gigabit speeds – particularly because the house is wired with CAT-5e cable (and not the recommended CAT-6).

There are many ways to measure network throughput.  In the past I have usually copied a file across the network and used a stopwatch to get a relative sense of speed.  However, due to file sharing protocol overhead I always got disappointing results and never knew maximum capability of my network.

This time, based on the advice of a more network-savvy friend, I decided to use a command-line tool called iperf.

iperf is a command-line tool to measure network performance.  It is very powerful, but also easy to use for simple tests.  For a more complete overview of what iperf is and what it can be used for, check out this tutorial or the iperf page on Wikipedia.  iperf has a lot of options, and I won’t cover the majority of them here.  For more usage information, consult the iperf manual.

If you run Debian or Ubuntu (Linux), iperf can be installed by executing

sudo apt-get install iperf

I did these tests with OS X on the Mac since both of my Macs have gigabit ethernet ports and my older PCs don’t.  A package for iperf is conveniently available from Macports.  It can be installed via the graphical package manager Porticus or opening a Terminal window and typing

sudo port install iperf

In my case, all I wanted was a quick test of TCP/IP network performance.  This is easy to do, but it requires two computers, a client and a server, both connected to the network under test.  Ideally, there should be no other network traffic during the test, as this will affect the results.

On the first computer, launch the iperf server by executing

iperf -s

You should see something like this:

Server listening on TCP port 5001
TCP window size: 64.0 KByte (default)

On the 2nd computer (the client), open a Terminal window and run

iperf -c <IP address or hostname of server> -i 1

Within a few seconds, you should start to see reports coming in on both the client and server terminal windows:

Client connecting to mini.home, TCP port 5001
TCP window size:   129 KByte (default)
[  3] local port 65142 connected with port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec    110 MBytes    924 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  1.0- 2.0 sec    101 MBytes    850 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  2.0- 3.0 sec    109 MBytes    914 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  3.0- 4.0 sec    100 MBytes    841 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  4.0- 5.0 sec    111 MBytes    927 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  5.0- 6.0 sec    102 MBytes    853 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  6.0- 7.0 sec    110 MBytes    923 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  7.0- 8.0 sec    102 MBytes    858 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  8.0- 9.0 sec  79.4 MBytes    666 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  9.0-10.0 sec  93.6 MBytes    785 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1018 MBytes    854 Mbits/sec

The last report (for the interval 0.0-10.0 sec) is the average throughput for the entire test.  I’m more than happy with 854 Mbits (927 Mbits/sec peak!) given my fairly long runs of CAT-5e cable and other machines using the network.   Contrast this with my results over 802.11g wireless:

[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  24.9 MBytes  20.9 Mbits/sec

Run avrdude on Ubuntu without root

A quick tip for Ubuntu users:

As installed by the avrdude package on Ubuntu, avrdude needs root priveledges to work properly with the Adafruit USBTinyISP AVR programmer.  This gets annoying pretty fast because to program an AVR you need to run avrdude (or make) with sudo every time or log in as root (not recommended).  Without sudo, avrdude will return an error:

avrdude: error: usbtiny_transmit: error sending control message: Operation not permitted
avrdude: initialization failed, rc=-1
 Double check connections and try again, or use -F to override
 this check.
avrdude: error: usbtiny_transmit: error sending control message: Operation not permitted
avrdude done.  Thank you.

LadyAda points out in her avrdude tutorial that there is a way around this behavior by setting up some udev rules for the USBTinyISP.  However, I found that the rules given in her tutorial did not work with my stock Ubuntu 9.10 installation.  The problem arises because the user Ubuntu creates on install is not part of the “users” group.

The fix:

Create a file called 10-usbtinyisp.rules in directory /etc/udev/rules.d

 SUBSYSTEM=="usb", SYSFS{idVendor}=="1781", SYSFS{idProduct}=="0c9f", GROUP="adm", MODE="0666"

Then execute:

 sudo restart udev

That’s it.  Unplug and replug in the USB cable to your USBTinyISP programmer.  Now avrdude should be able to access the USBTinyISP without root privileges.

If your account is part of another group, just change the GROUP= flag to that group instead.  New users in Ubuntu are assigned to a group named after their username by default, so that is another option (ie. GROUP=”yourusername”).  Interestingly, new users are not assigned to the “users” group, for reasons that escape me (and no doubt some of our more Linux-savvy readers can enlighten us about).