Datasheet
237
ATmega48PA/88PA/168PA [DATASHEET]
9223F–AVR–04/14
27. Boot Loader Support – Read-While-Write Self-Programming
The boot loader support applies to Atmel
®
ATmega48PA/88PA/168PA
27.1 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 28-9 on page 255) used during program-
ming. The page organization does not affect normal operation.
27.2 Overview
In the Atmel ATmega48PA/88PA/168PA 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.
27.3 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 27-2).
The size of the different sections is configured by the BOOTSZ fuses as shown in Table 27-7 on page 247 and Figure 27-2.
These two sections can have different level of protection since they have different sets of lock bits.
27.3.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 27-2 on page 240. The
application section can never store any boot loader code since the SPM instruction is disabled when executed from the
application section.
27.3.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 27-3 on page 240.