2.3.1 In-System Programmable Flash Memory and Bootloader Support
Both AVR families allow updates of the program memory using software. The on-chip in-system reprogrammable Flash memory is used mainly for program storage. For software security, the Flash Program Memory space is divided into sections with different access rights: megaAVR devices have two sections (the Boot section and Application Program section), while AVR Dx devices provide three configurable sections (Boot Code section, Application Code section, and Application Data section).
For the megaAVR devices, the size of the Boot section can be configured using BOOTSZ[1:0] fuses to any from the following values: 512, 1024, 2048 or 4096 words. This section is located at the end of the Flash memory.
For the AVR Dx devices, the size of the Boot section can be configured to any value with a granularity of 512 bytes using the Boot Size (BOOTSIZE) fuse, and it is located at the beginning of the Flash area. The remaining Flash can be split into an Application Program section and Application Data section using the CODESIZE fuse. For security reasons, the code executing from the Boot section can write the Application section or Data section, the code executing from the Application section can write only the Data section, and the code executing from the Data section cannot write to any Flash section. This mechanism prevents unintentional alteration of sections. Additional to this hardware mechanism, the device implements software options that can prevent an unwanted read of the boot code from other sections.