Skip to content

Uploading programs

Nico edited this page Aug 8, 2015 · 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 you can select HL2 Uno HID-Bridge and hit upload. The 16u2 will reset, go into bootloader mode and the program will upload to the 328 instead.

Upload sketches to the USB MCU via IDE

You can now use the 16u2 as normal Arduino USB board like a Leonardo/Micro/Teensy. Therefore you need the HID-Project which you should have installed above. Read the how to use section for HoodLoader2 of the HID Project.

Have a look at the examples in the HID Project and check out the pinout below. Keep in mind that the Leds have inverted logic. Writing LOW means turn them on. Once you've uploaded your first HoodLoader2 sketch it should switch to a different Serial comport and show up as HoodLoader2 16u2:

hoodloader2device

Deactivating USB-Core

If you don't want to use the USB-Core you can also choose under Tools/USB Core "No USB functions" to get rid of the USB stuff and save the ram for other stuff if you don't need it. You also don't need the HID Project essentially if you don't want to use the USB functions.

The workaround is no longer needed with version 2.0.1 or newer.

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).

A copy of avrdude for windows is already included in tools/avrdude/. The libusb0.dll was taken from an Arduino IDE installation. You can download the newest avrdude here.

Open a cmd or terminal and try the following code. You can also use the provided tools/flash.bat file (windows only) for easier uploading.

# 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 57600 -P COM1 -U flash:w:HoodLoader1_8.hex

# erase firmware from USB MCU
avrdude.exe -C avrdude.conf -p atmega16u2 -c avr109 -b 57600 -P COM1 -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.