Add extra GPIO pins using a Minimus AVR board

Following a suggestion on the mailing list, I (Lurch) bought a Minimus AVR board ages ago with the intention of seeing how I could use it in collaboration with the Bifferboard. The Minimus board has 21 digital IO lines, a fully-programmable AVR core (AT90USB162), needs no external programmer, and only costs a measly £4.95 plus p&p from here or here.

For a product so cheap I was surprised there wasn't more online resources about it, the best resource I found was

I've finally got round to spending a few days getting that "collaboration" working...

I downloaded the example led-flash project from and tidied it up a bit: see leds_test.tar.gz and leds_test.hex attached at the bottom of this page. To build the source on Ubuntu you'll need to apt-get install avr-binutils avr-gcc avr-libc and to flash the resulting leds_test.hex file to the Minimus you'll need to install dfu-programmer from source (at the time of writing, the version in the repositories isn't new enough).

So, after installing the prerequisites and extracting the leds_test tarball, typing make should produce you with a leds_test.hex

To flash this to the minimus you need to force it into "programming mode" by pressing and holding the RESET button, pressing and holding the HWB button, then releasing the RESET button, then releasing the HWB button - with a bit of practice you can do this by "rolling" your thumb over both buttons :) And with the Minimus in programming mode you can now upload the hex file by typing sudo make dfu (I couldn't be bothered with fiddling with udev rules to allow this as a non-root user).

When you now press&release the RESET button on the minimus, you should see the red and blue LEDs flashing alternately, and pressing the HWB button will make them flash faster. Cool!

So for my first "integration" with the bifferboard, I decided to wire up the RESET and HWB buttons to two of the Bifferboard's GPIO pins, so that I could "press the buttons" programatically. The RESET button is (obviously) connected to the /RST connector-hole, and a quick look at the AT90USB162 datasheet shows that HWB is connected to PD7. (A quick note for people unfamiliar with microcontrollers - they usually have their IO pins divided into 8-bit "ports", and in the case of the minimus we have access to pins 0-7 in port B, pins 2,4,5,6,7 in port C, and pins 0-7 in port D. The red LED 'A' is connected to PD6, and the blue LED 'B' is connected to PD5. As I mentioned in leds_test.c these are all active-low, i.e. when the blue LED is on, PD5 will read as 0V on a multimeter, and when the LED is off, PD5 will read as 5V (or 3.3V after doing the power mod below).)

"Out of the box" the minimus supports 5V I/O, so to connect the bifferboard's 3.3V IO to the minimus's IO I first had to follow these instructions (you'll want the "Power Options: +3.3v" option) to switch the minimus to using 3.3V I/O - if you don't do this first you could damage the bifferboard's IO pins.

And then I soldered couple of wires and a connector to the /RST and PD7 holes - see images below (click to enlarge).

...and then (assuming you've done the JTAG->GPIO mod) you can follow the GPIO SYSFS instructions - in my case I have RESET connected to GPIO11 and HWB connected to GPIO13, so with both pins set as 'out' and GPIO11 set to 0, and using the same hex file as before, the LEDs will flash slowly when GPIO13 is set to 1, and flash quickly when GPIO13 is set to 0.

And to make this easier, I cooked up a little bash script - minimus_gpio attached at the bottom of this page (only tested on Slackware ATM). After downloading it and copying it to your bifferboard, edit the RST_GPIO and HWB_GPIO as appropriate (GPIO mapping is here) and make the script executable, and then you can use:

minimus_gpio setup to export the relevant GPIO pins

minimus_gpio press_rst to 'press' (and hold) the RESET button

minimus_gpio release_rst to 'release' the RESET button

minimus_gpio press_hwb to 'press' (and hold) the HWB button

minimus_gpio release_hwb to 'release' the HWB button

minimus_gpio reset to reset the Minimus board (presses and releases the RESET button)

minimus_gpio enter_dfu to switch the Minimus into programming mode

minimus_gpio unsetup to unexport the GPIO pins again (if needed)

So, now that the bifferboard can automatically switch the minimus into programming mode, wouldn't it be useful if the bifferboard could also program hex files into the minimus? ;) Yup, I compiled the dfu-programmer SlackBuild on the bifferboard (again attached at the bottom of the page as dfu-programmer-0.5.4-i486-1_SBo.tgz). The 13.37 SlackBuild of dfu-programmer works fine on Bifferboard's 13.0 version of Slackware - after copying it to your bifferboard, install it with installpkg dfu-programmer-0.5.4-i486-1_SBo.tgz and then you can flash and run a hex file on your bifferboard directly by using:

minimus_gpio enter_dfu

dfu-programmer at90usb162 erase

dfu-programmer at90usb162 flash leds_test.hex

dfu-programmer at90usb162 start

minimus_gpio reset

or you can simply copy the leds_test tarball from earlier to your bifferboard, and replace the Makefile with Makefile.slackware attached below. As slackware-on-bifferboard runs from an external USB flash/disk, you'll obviously need to attach your slackware USB rootfs and minimus to bifferboard via a USB hub - this works fine.

Which of course leads to the next exciting question, can you edit and build hex files on the bifferboard directly?! Yes, thanks again to ...