@@ -116,33 +116,44 @@ region of disk with the following properties:
1161162 . A write to one area does not restrict writes to other areas.
117117
118118The boot loader uses the following flash area IDs:
119-
120- ``` c
119+ ``` c
120+ /* Independent from multiple image boot */
121121#define FLASH_AREA_BOOTLOADER 0
122+ #define FLASH_AREA_IMAGE_SCRATCH 3
123+ ```
124+ ``` c
125+ /* If the boot loader is working with the first image */
122126#define FLASH_AREA_IMAGE_PRIMARY 1
123127#define FLASH_AREA_IMAGE_SECONDARY 2
124- #define FLASH_AREA_IMAGE_SCRATCH 3
128+ ```
129+ ``` c
130+ /* If the boot loader is working with the second image */
131+ #define FLASH_AREA_IMAGE_PRIMARY 5
132+ #define FLASH_AREA_IMAGE_SECONDARY 6
125133```
126134
127135The bootloader area contains the bootloader image itself. The other areas are
128- described in subsequent sections.
136+ described in subsequent sections. The flash could contain multiple executable
137+ images therefore the flash area IDs of primary and secondary areas are mapped
138+ based on the number of the active image (on which the bootloader is currently
139+ working).
129140
130141## Image Slots
131142
132- A portion of the flash memory is partitioned into two image slots: a primary
133- slot (0) and a secondary slot (1). The boot loader will only run an image from
134- the primary slot, so images must be built such that they can run from that
135- fixed location in flash. If the boot loader needs to run the image resident in
136- the secondary slot, it must copy its contents into the primary slot before doing
137- so, either by swapping the two images or by overwriting the contents of the
138- primary slot. The bootloader supports either swap- or overwrite-based image
139- upgrades, but must be configured at build time to choose one of these two
140- strategies.
141-
142- In addition to the two image slots , the boot loader requires a scratch area to
143- allow for reliable image swapping. The scratch area must have a size that is
144- enough to store at least the largest sector that is going to be swapped. Many
145- devices have small equally sized flash sectors, eg 4K, while others have
143+ A portion of the flash memory can be partitioned into multiple image areas, each
144+ contains two image slots: a primary slot and a secondary slot.
145+ The boot loader will only run an image from the primary slot, so images must be
146+ built such that they can run from that fixed location in flash. If the boot
147+ loader needs to run the image resident in the secondary slot, it must copy its
148+ contents into the primary slot before doing so, either by swapping the two
149+ images or by overwriting the contents of the primary slot. The bootloader
150+ supports either swap- or overwrite-based image upgrades, but must be configured
151+ at build time to choose one of these two strategies.
152+
153+ In addition to the slots of image areas , the boot loader requires a scratch
154+ area to allow for reliable image swapping. The scratch area must have a size
155+ that is enough to store at least the largest sector that is going to be swapped.
156+ Many devices have small equally sized flash sectors, eg 4K, while others have
146157variable sized sectors where the largest sectors might be 128K or 256K, so the
147158scratch must be big enough to store that. The scratch is only ever used when
148159swapping firmware, which means only when doing an upgrade. Given that, the main
0 commit comments