Skip to content

Uploading programs

Nico edited this page Mar 25, 2018 · 12 revisions

Upload sketches to the IO MCU

Short the 16u2's reset pin twice to enter bootloader mode. You can upload your Arduino sketch like you are used to. You need to check the new Serial port in the IDE. To start the 16u2 sketch again short reset once. To get Serial Debug output from the 328/2560 you also have to enter bootloader mode again.

Tip: When in 16u2 program mode(with working USB-Core + CDC Serial) you can select HoodLoader2 Uno / HoodLoader2 Mega 2560 and hit upload. The 16u2 will reset, go into bootloader mode and the program will upload to the 328 instead. If this trick does not work you need to reset into bootloader mode manually via double reset.

Select HoodLoader2 Uno/Mega in the boards menu: board_menu_328

Upload sketches to the USB MCU via IDE

You can now use the 16u2 as normal Arduino USB board like a Leonardo/Micro/Teensy. You may want to have a look at the HID Project for more HID devices. Have a look at avr/examples/ for HoodLoader2 related examples. Keep in mind that the Leds have inverted logic. Writing LOW means turn them on.

Select HoodLoader2 16u2 in the boards menu: board_menu_16u2

Once you've uploaded your first HoodLoader2 sketch it should switch to a different Serial comport and show up as HoodLoader2 16u2:

hoodloader2device

Flash/erase firmwares(.hex files) with avrdude

If you want to upload a self compiled firmware(.hex file) from for example a LUFA project like the HoodLoader1 you wont be able to use DFU via Flip any more. But you can use avrdude instead.

This can also be used to erase the program from your 16u2 if you always want to use it as normal USB-Serial bridge again (always stay in bootloader mode).

You can download the newest avrdude here. For Windows you need to put this libusb0.dll from the Arduino IDE into the avrdude folder.

Open a cmd or terminal and try the following code.

# select com port, device and .hex file yourself
# flash new firmware to the USB MCU
avrdude.exe -C avrdude.conf -p atmega16u2 -c avr109 -b 1200 -P COM1 -U flash:w:Firmware.hex
avrdude -p Atmega16u2 -c avr109 -b 1200 -P /dev/ttyACM0 -U flash:w:Firmware.hex

# erase firmware from USB MCU
avrdude.exe -C avrdude.conf -p atmega16u2 -c avr109 -b 1200 -P COM1 -e
avrdude -p atmega32u2 -c avr109 -b 1200 -P /dev/ttyACM0 -e

And yes, it's correct that you can have HoodLoader2 and HoodLoader1 running 'at the same time' since v2 is a real bootloader and v1 'only' a firmware. HoodLoader1 is depreciated though.