Normally, ATMEL’s AVR microcontrollers are programmed using programmers. There are many ways to program the AVR microcontrollers, such as in-system programming, parallel programming and using bootloader. Advantage with the bootloader method is that you don’t need any external hardware to load the hex file on the microcontroller. A bootloader program is placed inside the boot section of the Flash memory, to handle communication with the host PC and facilitate programming of both Flash and EEPROM.
Programming using bootloader
The bootloader firmware loaded on the microcontroller allows in-system programming directly via TXD and RXD pins of the microcontroller. The code responsible for in-system programming via serial port resides in the configurable boot memory section of the microcontroller. When signalled using external switch while resetting the microcontroller, it gets active and waits for communication from the PC for loading the hex file on the microcontroller’s flash memory. The PC sends the hex file to the microcontroller. The code residing in the boot section loads the hex file on the microcontroller’s flash memory.
Once the programming process is complete, newly loaded code can be executed by pressing reset. Once the code is loaded on the microcontroller, UART is free and can be used for other applications.
Note that the bootloader gets invoked only if boot switch is kept pressed while the microcontroller is reset using reset switch.
The Flash memory is divided into two sections: application and bootloader. The application section contains the main code for the application, while the bootloader section contains the code for actual self-programming.
The store program memory instruction can be executed only from the bootloader section. The memory organisation is shown in Fig. 1. The size of the bootloader section can be selected using the BOOTSZ fuse bit setting (refer the table).