241
Atmel ATmega16/32/64/M1/C1 [DATASHEET]
7647K–AVR–12/13
24.
Boot Loader Support – Read-while-write Self-Programming
ATmega16/32/64/M1/C1
In ATmega16/32/64/M1/C1, 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
●
●
Code efficient algorithm
●
Efficient read-modify-write support
Note:
1.
ming. 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 onFigure 24-2 on page 243. 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 244. 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
24.3
Read-while-write and no Read-while-write Flash Sections
Whether the CPU supports read-while-write or if the CPU is halted during a Boot Loader software update is dependent on which
address that is being programmed. In addition to the two sections that are configurable by the BOOTSZ Fuses as described
above, the flash is also divided into two fixed sections, the read-while-write (RWW) section and the no read-while-write (NRWW)
The main difference between the two sections is:
●
When erasing or writing a page located inside the RWW section, the NRWW section can be read during the operation.
●
When erasing or writing a page located inside the NRWW section, the CPU is halted during the entire operation.
Note that the user software can never read any code that is located inside the RWW section during a boot loader software
operation. The syntax “Read-while-write section” refers to which section that is being programmed (erased or written), not which
section that actually is being read during a boot loader software update.