Datasheet

214
ATtiny828 [DATASHEET]
8371A–AVR–08/12
21. Self-Programming with Boot Loader and Read-While-Write
21.1 Features
z Self-Programming Enables MCU to Erase, Write and Reprogram Application Memory
z Efficient Read-Modify-Write Support
z Support for Read-While-Write Self-Programming
z Boot Loader Section With Variable Size
z Lock Bits Allow Application Memory to Be Securely Closed for Further Access
z Separate Boot Lock Bits Allow High Security and Flexible Protection Schemes
z Separate Fuse for Setting Reset Vector
z Optimized Flash Page Size
z Code Efficient Algorithm
21.2 Overview
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 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.
If boot loader is not needed the entire Flash can be made available for application code.
21.3 Application and Boot Loader Flash Sections
The Flash memory is organized in two main section; the application section and the Boot Loader Section (BLS). See
Figure 91. The size of the different sections is configured by the BOOTSZ fuses, as shown in Table 82 on page 217.
These two sections can have different levels of protection since they have different sets of lock bits.
21.3.1 Application Section
The application section is the part of Flash that is used for storing the application code. The protection level for the
application section can be selected by the application boot lock bit (Boot Lock Bit 0). See Table 87 on page 226.
The application section can never store any boot loader code, since the SPM instruction is disabled when executed from
the application section.
21.3.2 BLS – Boot Loader Section
While the application section is used for storing the application code, the boot loader software must be located in the
Boot Loader Section (BLS), since the SPM instruction can initiate a programming when executed from the BLS, only.
The SPM instruction can access the entire Flash, including the BLS itself. The protection level for the BLS can be
selected by the boot loader lock bit (Boot Lock Bit 1). See Table 88 on page 226.
21.4 Read-While-Write and No Read-While-Write Flash Sections
During a software update by the boot loader the CPU either works in read-while-write -mode or is halted during the
operation. The type of operation dependens on which address is being programmed.