Datasheet

229
ATmega48/88/168 Automotive [DATASHEET]
7530K–AVR–07/14
24. Boot Loader Support – Read-While-Write Self-Programming, ATmega88 and
ATmega168
In Atmel
®
ATmega88 and Atmel ATmega168, the boot loader support provides a real read-while-write self-programming
mechanism for downloading and uploading program code by the MCU itself. This feature allows flexible application software
updates controlled by the MCU using a flash-resident boot loader program. The boot loader program can use any available
data interface and associated protocol to read code and write (program) that code into the flash memory, or read the code
from the program memory. The program code within the boot loader section has the capability to write into the entire flash,
including the boot loader memory. The boot loader can thus even modify itself, and it can also erase itself from the code if
the feature is not needed anymore. The size of the boot loader memory is configurable with fuses and the boot loader has
two separate sets of boot lock bits which can be set independently. This gives the user a unique flexibility to select different
levels of protection.
24.1 Boot Loader Features
Read-while-write self-programming
Flexible boot memory size
High security (separate boot lock bits for a flexible protection)
Separate fuse to select reset vector
Optimized page
(1)
size
Code efficient algorithm
Efficient read-modify-write support
Note: 1. A page is a section in the flash consisting of several bytes (see Table 25-12 on page 247) used during
programming. The page organization does not affect normal operation.
24.2 Application and Boot Loader Flash Sections
The flash memory is organized in two main sections, the application section and the boot loader section
(see Figure 24-2 on page 231). The size of the different sections is configured by the BOOTSZ fuses as shown in
Table 24-6 on page 240 and Figure 24-2 on page 231. These two sections can have different level of protection since they
have different sets of lock bits.
24.2.1 Application Section
The application section is the section of the flash that is used for storing the application code. The protection level for the
application section can be selected by the application boot lock bits (boot lock bits 0), see Table 24-2 on page 232. The
application section can never store any boot loader code since the SPM instruction is disabled when executed from the
application section.
24.2.2 BLS – Boot Loader Section
While the application section is used for storing the application code, the The boot loader software must be located in the
BLS since the SPM instruction can initiate a programming when executing from the BLS only. The SPM instruction can
access the entire flash, including the BLS itself. The protection level for the boot loader section can be selected by the boot
loader lock bits (boot lock bits 1), see Table 24-3 on page 232.