Arduino
How to Download Arduino Bootloader to ATmega32U4
Introduction to ATmega32U4

The ATmega32U4 is a low-power Microchip 8-bit AVR RISC microcontroller with 32KB of self-programming flash memory, 2.5KB SRAM, 1KB EEPROM, USB 2.0 full-speed/low-speed device, 12-channel 10-bit A/D converter, and JTAG interface for chip debugging. This device achieves up to 16 MIPS throughput at 16 MHz. It can operate under 2.7-5.5V conditions. The Arduino Leonardo development board uses the ATmega32U4 MCU.
————————————————
What is a Bootloader?
Similar to the BIOS of a computer motherboard, the bootloader automatically performs BIOS settings upon startup or reboot. Some microcontrollers have the bootloader pre-programmed by the chip manufacturer, such as the bootloader downloaded via serial port. When the microcontroller is reset or powered on, it first executes the bootloader code to check if there are other commands to execute, then jumps to the user program code.
The Arduino development boards come with a pre-written bootloader, which allows the USB-to-serial chip to send download commands to the Arduino board, resetting it to enter the bootloader. The bootloader recognizes the download command and guides the new user program to be downloaded to the internal flash of the microcontroller. If no download command is recognized, it jumps to the original user application program to continue execution.
For newly manufactured ATmega32U4 chips, there is no Arduino bootloader pre-installed; users need to download the bootloader before they can use the serial port to download their application. In some rare cases, an old bootloader may cause some bugs, and writing a new version of the bootloader may solve the problem. This article will explain how to burn the Arduino Leonardo bootloader onto the ATmega32U4.
————————————————
Bootloader Download Interface and Connection

It has brought out the ICSP (in-circuit serial programming) interface of the ATmega32U4, as shown in the several SPI pins circled in the above image. With the working circuit of the ATmega32U4 and the ICSP interface identified, we also need a programmer (USBASP programmer).

Programmer pin definitions:

Wiring between the development board and the programmer:


After installing the programmer driver, connect the programmer to the computer.

Configuring Fuse Bits and Burning Bootloader
After connecting the programmer and the ATmega32U4 development board, check the device manager to ensure the programmer is correctly recognized, then open the ProgISP download software.

Fuse bit configuration is as follows:

Configuring fuse bits is very important; if set incorrectly, it may lock the microcontroller, and USBASP will be unable to connect to the microcontroller. Configure the fuse bits according to the above diagram, ensuring they are set correctly. After configuring the fuse bits, close the serial port by clicking the cross in the fuse bit configuration window, then proceed to steps 4 and 5 to load FLASH and burn it. Click to load FLASH.

Then find the installation directory of the Arduino IDE (X:XX\arduino\hardware\arduino\avr\bootloaders\caterina), where “X” is based on your actual installation directory. Open the file highlighted in the image below.

After selecting the file, click automatic to begin burning.

After successful burning, the interface and prompt will appear.

To verify if the bootloader has been successfully burned: connect the development board to the USB port of the computer and open the device manager to check if the port shows Arduino Leonardo (XX).


The bootloader for ATmega32U4 has been successfully burned.
Note: It is particularly important to pay attention to the fuse bit settings; if the fuse bits are set incorrectly, it is highly likely that the microcontroller will be locked, preventing USBASP from connecting to the microcontroller.
