How do I flash MIDI firmware to Arduino Uno rev3?

Hello everyone

First of all - I'm a complete noob here, so please have patience with me :slight_smile:

I have an Arduino Uno rev3, which I want to turn into a MIDI device. I've found, that the HIDUINO firmware should do the job - see the project page here: GitHub - ddiakopoulos/hiduino: Native USB-MIDI on the Arduino

I don't have an external ISP, so I have tried to use another Arduino as an AVR ISP, as described in this guide: http://www.arduino.cc/playground/Code/MegaISP

I'm trying to flash the firmware with this command:

avrdude -p m328p -F -P /dev/cu.usbmodem621 -c avrisp -U flash:w:HIDUINO_MIDI.hex

The output of the terminal on my mac is attached.

To me, it all seems okay, but when the firmware is flashed, the arduino should show up as a MIDI device in the System Information, but it just shows up as a "Communication Device".

Can anyone help me why that is? Is the firmware not flashed correctly?
I have done something, because I am not longer able to upload sketches via the Arduino IDE, which I shouldn't be able to whith a different firmware.

Am I missing something important?
I hope someone can help me, because I am completely stuck with my project :slight_smile:

Terminal_output.txt (1.26 KB)

Hansibassi:
I'm trying to flash the firmware with this command:

avrdude -p m328p -F -P /dev/cu.usbmodem621 -c avrisp -U flash:w:HIDUINO_MIDI.hex

So, you have flashed your main processor (ATmega328) with a hex code that was intended for the serial-to-USB processor (ATmega16U2).

from the page you linked to, the correct command for an 8U2 is

avrdude -p at90usb82 -F -P usb -c avrispmkii -U flash:w:HIDUINO_MIDI.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

Check your avrdude documentation for the correct -p flag for a 16U2. And, connect to the ICSP header for the 16U2, not the one for the 328.

Hansibassi:
I have an Arduino Uno rev3, which I want to turn into a MIDI device. ...
I don't have an external ISP, so I have tried to use another Arduino as an AVR ISP

Try to follow this tutorial:
http://pdp11.byethost12.com/AVR/ArduinoAsProgrammer.htm

Okay #Nantonos, that makes good sense :slight_smile:

I found in the AVR documentation, that the -p flag for the 16u2 is 'm16u2', and I've connected to the ISP header for the 16u2.

I have changed the terminal command to:

avrdude -p m16u2 -F -P /dev/cu.usbmodem621 -c avrisp -U flash:w:HIDUINO_MIDI.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m -b 19200

This all seems right to me, but I get an error when I try to flash the chip:

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.

With a little searching, and in the tutorial #simplex linked to I've found, that I maybe need a crystal in my circuit, because the invalid device signature error could be caused by different clock frequencies. Or that's how I understood it.
Does that make sense?

And if I need a crystal, how do I connect it, when I'm using the ISP-header? I can't connect the crystal as in the tutorial you linked to #simplex, since I'm connecting to the ISP header

I found the schematic of Arduino Uno R3
see: http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf

The USB AVR you want to flash has already a crystal connected to it.

If the lines (SS, MOSI, MISO, SCK) of the Aruino Uno configured as ISP Programmer are connected to the ICSP header pins (Reset, MOSI, MISO, SCK) corresponding to the USB AVR on the second Arduino Uno, you should be able to program the USB AVR with avrdude.

Likely you have wrong ISP connections between the Arduino Uno as Programmer and the ICSP header of the USB AVR on the second Arduino Uno board.

The SS signal of Arduino Uno Programmer is available just on pin 10 not on the ICSP. You have to take this into account when you make the wiring.

Also, do not try to write anything in the 16u2 as long as this command:

c:\>avrdude -P COM3 -b 19200 -c avrisp -p m16u2 -n

returns error messages.

I resolved the issue :slight_smile:

#simplex, you were right about the fact, that the error was caused by wrong ISP connections.
Thank you for the help!

The final solution was as follows:

  • Load the MegaISP sketch to the first Arduino Uno used as the ISP programmer. The sketch is also included as an example in the Arduino IDE, under the name "ArduinoISP".

  • Connect this Arduino to the Arduino you want to program. The connections are as follows:
    Connect programmer pin 10 to the targets ICSP Reset header
    Connect pin 11 to MOSI
    Connect pin 12 to MISO
    Connect pin 13 to SCK

The ICSP header connectors is shown below:

The VTG and GND pins on the ICSP header is not used.

When using the Arduino Uno an 10uF capacitor has to be connected between RESET and GND, as described in the ArduinoISP tutorial

The final schematic should be as shown below:

  • Connect the programmer-Arduino to the computer, open Terminal/the commando promt and type the following command: avrdude -p m16u2 -F -P /dev/cu.usbmodem621 -c avrisp -U flash:w:HIDUINO_MIDI.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m -b 19200
    '/dev/cu.usbmodem621' should be replaced by the port, your Arduino is connected to. [/li]
  • You're done :slight_smile:

Nicely documented. Thanks for reporting back on how you solved the problem.

I want to do the same thing, but I have Windows, instead of the command, what should I do? Sorry if it's a noob question, I'm have no idea about command lines.