Skip to content

Uploading programs

Nico edited this page Jan 18, 2015 · 12 revisions

a) Upload sketches to the 328/2560

Short the 16u2's reset pin twice to enter bootloader mode. You can upload your Arduino sketch like you are used to. You might need to check the correct Serial port in the IDE though. 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.

b) Upload sketches to the 16u2 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.

c) 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:

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
avrdude.exe -C avrdude.conf -p atmega16u2 -c avr109 -b 57600 -P COM1 -U flash:w:HoodLoader1_8.hex

avrdude.exe -C avrdude.conf -p atmega16u2 -c avr109 -b 57600 -P COM1 -e

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