8 Flash Sections
Flash of the Relevant Devices can be split into three separate sections: BOOT, application code (APPCODE) and application data (APPDATA). This scheme allows for the protection and safe storage of several individual segments of code or data. The granularity of the division is 256 bytes.
If FUSE.BOOTEND is written to 0x04 and FUSE.APPEND is written to 0x08, the first 4*256 bytes will be BOOT, the next 4*256 bytes will be APPCODE, and the remaining Flash will be APPDATA.
- Code in the BOOT section can write to APPCODE and APPDATA
- Code in APPCODE can write to APPDATA
- Code in APPDATA cannot write to Flash or EEPROM
In addition to the directional write protection, two register bits can be used to increase restrictions.
By writing a 1
to the Application Code Section
Write Protection (APCWP) bit, the application code section is protected from
further writes. The bit can be found in the Control B (CTRLB) register of
the Nonvolatile Memory Controller (NVMCTRL) peripheral. This bit is cleared
on Reset.
As the BOOT section can never be written by the CPU, there is no
need to protect BOOT from writes in the same manner. But by writing a
1
to the Boot Section Lock (BOOTLOCK) bit in CTRLB
register of the NVMCTRL peripheral, reading and executing code from BOOT can
be prevented. This bit is cleared on Reset.
Refer to the Nonvolatile Memory Controller (NVMCTRL) chapter in the Relevant Devices data sheet for more details.