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).
Note: Pay special attention in setting oscillator options correctly. Even a small misadjustment could result in communication failure.

Recommended fuse bit settings are provided in the table below. See the device data sheet for detailed explanation of device dependent fuse bits.

Table 8-2. Recommended Fuse Bits
M8, M8515, M8535, M16, M162, M169, M32, M64M128328PB
BOOTSZ1:00:00:10:1
BOOTRST000
Note: “0” means programmed, “1” means not programmed.

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.
Note: It is important to understand that if the device is not properly locked then the memory can be accessed via an ISP interface and the whole point of encrypting the firmware is gone.

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.

Table 8-3. Recommended Lock Bits

M8, M8515, M8535, M16,

M162, M169, M32, M64, M128

328PB
BLB12 : BLB110 00 0
BLB02 : BLB011 11 1
LB2 : LB10 00 0