Skip to content

Burn the bootloader from another Arduino

Nico edited this page Mar 14, 2015 · 10 revisions

You can also use a 2nd Arduino to flash the bootloader. For example if you can't access the first Arduino for some reason. We are just uploading the installation sketch to another Arduino and connect the wires a bit different.

You can use any kind of Arduino Leonardo/Micro/Mega/Uno/Nano etc for this operation.

1. Prepare your Arduino

Unplug both Arduinos from USB. Never change wires when the devices are powered! Connect all wires from the 2nd Arduinos main MCU to the 16u2. You also need to connect 5V-5V and GND-GND to power the board. Unplug the USB cable of the Arduino you are flashing. In this case you do not need the capacitor which we use in the standalone version.

Connections

Pin connections:
328/2560 - 16u2
GND      - GND
5V       - 5V
MOSI     - MOSI
MISO     - MISO
SCK      - SCK
PIN 10   - 16u2 RESET

2. Upload the installation sketch

  1. Connect your Arduino to your PC
  2. Select the Arduino board that acts as uploader (do not select 16u2).
  3. Open the installation sketch HoodLoader2_Installation_Sketch.ino
  4. Edit the Settings if needed (for 8u2 or 32u2 board for example).
  5. Upload the installation sketch to your Arduino Uno/Mega (Ctrl + U).
  6. Wait until it says "Done uploading". This may take a while.

board-programmer

3. Burn the bootloader

Once the installation sketch is uploaded to your main MCU you are able to burn the bootloader to your 16u2. To control the burning you have two options:

Control via Serial:
  1. Open the Serial port monitor at baud 115200.
  2. No capacitor needed, ignore that.
  3. Follow the instructions (press 'U' or 'M' + Enter) and wait.
  4. The 2nd Arduino will flash the new bootloader.
  5. Wait until the Serial Monitor says programming finished.
  6. You may close the Serial monitor now.

For more help have a look here.

installation-sketch

4. Check bootloader installation

Now your Arduino should be flashed with the new bootloader. To check your HoodLoader2 installation read on here. If its not correctly installed read the instructions carefully and try again.

5. (Optional) Switch back to the old DFU bootloader

You can use avrdude to flash .hex files so DFU is not really needed anymore. If you want to switch back to the original DFU bootloader with Usb-Serial anyways just do the same procedure. Enter 'D' for DFU on the Serial monitor or short pin 8 to ground.

By default this will only install the DFU bootloader, not the USB-Serial Firmware. If you also want to install the USB-Serial Firmware with DFU at once you should change some default settings. Set FORCE_MEGA_BOOTLOADER to true if you want to flash the DFU bootloader for an Arduino Mega.

// make some of these false to reduce compile size (the ones you don't want)
#define USE_ATMEGA8U2 false
#define USE_ATMEGA16U2 true
#define USE_ATMEGA32U2 false
#define USE_AT90USB162 false // todo, not supported

// also use Mega 16u2 bootloader files?
#define USE_MEGA_BOOTLOADER false

// force Mega bootloader for blind pin selection/DFU hex file
#define FORCE_MEGA_BOOTLOADER false

// DFU options (16u2 only)
#ifdef USE_ATMEGA16U2
#define USE_ATMEGA16U2_DFU true
// use the full 16kb DFU Bootloader with USB-Serial
// you have to deactuivate the mega bootloader then
// but you can stull burn a mega DFU file in the followed setting
#define USE_ATMEGA16U2_DFU_FULL true
#endif