8.4 Installing the Bootloader
Compile the bootloader and then download it to the target using Atmel Studio 7 or later. Before running the bootloader, the following fuse bits must be configured:
- Size of Boot Loader Section. Set fuse bits so that the section size matches the BOOT_SIZE setting, as described earlier. Note that the BLS is usually given in words, but the BOOT_SIZE parameter is given in bytes.
- Boot reset vector. The boot reset vector must be enabled.
- Oscillator options. The oscillator fuse bits are device dependent. They may require configuration (affects USART).
Recommended fuse bit settings are provided in the table below. See the device data sheet for detailed explanation of device dependent fuse bits.
M8, M8515, M8535, M16, M162, M169, M32, M64 | M128 | 328PB | |
---|---|---|---|
BOOTSZ1:0 | 0:0 | 0:1 | 0:1 |
BOOTRST | 0 | 0 | 0 |
It is recommended to program lock bits to protect both the application memory and the bootloader, but only after fuse bits have been set. Lock bits can be programmed using Microchip IDE (Atmel Studio 7 or later). BLS lock bits will also be set during firmware update, provided that they have been defined as command line arguments when the firmware is encrypted. The recommended lock bit settings are:
- Memory lock bits: These should be set to prevent unauthorized access to memory. Note that after the memory has been locked it cannot be accessed via in-system programming without erasing the device.
- Protection mode for Boot Loader Section: SPM and LPM should not be allowed to write to or read from the BLS. This will prevent the firmware in the application section to corrupt the bootloader and will keep the decryption keys safe.
- Protection mode for application section: No restrictions should be set for SPM or LPM accessing the application section; otherwise the bootloader cannot program it.
Recommended lock bit setting for present AVR MCUs are given in the table below. See the device data sheet for a detailed explanation of lock bits.
M8, M8515, M8535, M16, M162, M169, M32, M64, M128 | 328PB | |
---|---|---|
BLB12 : BLB11 | 0 0 | 0 0 |
BLB02 : BLB01 | 1 1 | 1 1 |
LB2 : LB1 | 0 0 | 0 0 |