Close

Hiduino Firmware

A project log for Organ Pedalboard MIDI Conversion

Arduino Uno shield & sketch to convert the input from 32 switches to MIDI notes via Hiduino firmware

johan-cronjeJohan Cronje 03/13/2015 at 21:030 Comments

Before I can test the breadboarded circuit, I wanted to figure out how to flash the Arduino's firmware. The Uno actually has 2 Atmel MCUs, the main ATmega328 & then a ATmega16U2 which I believe handles the serial-USB connection.

Using Hiduino firmware to replace the stock Arduino firmware, turns the Uno into a class-compliant USB-MIDI device which any MIDI software will recognize.

This step actually gave me the most headaches as there are more than 1 way to do this.

At first I tried DFU programming which most links I found suggested. This involves switching the Uno into DFU mode then running the dfu-programmer utility. I could not get this to work at all, as my Uno refused to go into DFU mode. Much later I realized my Uno had a really old firmware installed on the ATmega16U2! I confirmed this by flashing the official Uno firmware (included in the /hardware subdirectory in the Arduino IDE software directory).

An alternate way to flash the ATmega16U2 is using avrdude, which I found to be much simpler. I hooked up a 6 pin connector to the ICSP (the one close to the USB connector) & using my USBASP flashed the Uno in a few seconds.

avrdude -p m16u2 -F -P usb -c usbasp -U flash:w:usbserial_uno_16u2.hex \
-U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m
IMPORTANT NOTE: Once you have flashed Hiduino to your Uno, you will no longer be able to write sketches to it via the USB cable. This is a PITA to deal with, as you have to flash the stock firmware, write the sketch, then flash Hiduino again. I couldn't find a way to make this process easier - maybe someone can enlighten me?

To flash the Hiduino MIDI firmware use the following command (with a USBASP):

avrdude -p at90usb82 -F -P usb -c usbasp -U flash:w:arduino_midi.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m
Note that I used at90usb82 to flash the Hiduino firmware.

The USBASP programming cable attaches to the Uno as shown here:

Discussions