11.3.1.1.2 Logical Sections

The Flash can be divided into three logical sections, each consisting of a variable number of pages. These sections are:
  • Boot Loader Code (BOOT) - Flash section with full write access. Boot loader software must be placed in this section if used.
  • Application Code (APPCODE) - Flash section with limited write access. Executable application code is typically placed in this section.
  • Application Data (APPDATA) - Flash section without write access. Parameters are usually placed in this section.

Section Sizes

The Boot Size (FUSE.BOOTSIZE) fuse and Code Size (FUSE.CODESIZE) fuse set the sizes of these sections. The fuses select section sizes in blocks of 256 bytes. The BOOT section stretches from FLASHSTART to BOOTEND, and the APPCODE section extends from BOOTEND to CODEEND. The remaining area is the APPDATA section.

If FUSE.BOOTSIZE is written to ‘0’, the entire Flash is regarded as the BOOT section. If FUSE.CODESIZE is written to ‘0’ and FUSE.BOOTSIZE > 0, the APPCODE section runs from BOOTEND to the end of Flash (no APPDATA section).

When FUSE.CODESIZE ≤ FUSE.BOOTSIZE, the APPCODE section is removed, and the APPDATA runs from BOOTEND until the end of the Flash.
Table 11-2. Setting Up Flash Sections
BOOTSIZE CODESIZE BOOT Section APPCODE Section APPDATA Section
0 - 0 to FLASHEND - -
> 0 0 0 to BOOTEND BOOTEND to FLASHEND -
> 0 ≤ BOOTSIZE 0 to BOOTEND - BOOTEND to FLASHEND
> 0 > BOOTSIZE 0 to BOOTEND BOOTEND to CODEEND CODEEND to FLASHEND

Using the BOOT section for the application code is recommended if there is no boot loader software.

Note:
  1. After Reset, the default vector table location is at the start of the APPCODE section. The peripheral interrupts can be used in the code running in the BOOT section by relocating the interrupt vector table at the beginning of this section. That is done by setting the IVSEL bit in the CPUINT.CTRLA register. Refer to the CPUINT section for details.
  2. If BOOTEND/CODEEND, as determined by the BOOTSIZE/CODESIZE fuse settings, exceeds the device FLASHEND, the corresponding fuse setting is ignored, and the default value is used. Refer to Fuse in the Memories section for default values.

Size of Flash Sections Example

If FUSE.BOOTSIZE is written to 0x04 and FUSE.CODESIZE 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.