You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d78163d
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/flash_partitions.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,12 +124,36 @@ If the `FLAGS_HOME` build option is used then all flags are placed at the end of
124
124
flag
125
125
```
126
126
127
+
The trailer sector is erased independently from the image, so it can never hold any part of it,
128
+
and the final step of the swap needs one more sector to stage the image tail. For this reason each
129
+
partition must be at least two sectors long (three with `NVM_FLASH_WRITEONCE`, which keeps two
130
+
copies of the trailer), and the image can use the partition up to the trailer sector(s). The build
131
+
fails if `WOLFBOOT_PARTITION_SIZE` is smaller, unless `CUSTOM_PARTITION_TRAILER` is used.
132
+
133
+
### Custom partition trailer
134
+
127
135
You can use the `CUSTOM_PARTITION_TRAILER` option to implement your own functions for: `get_trailer_at`, `set_trailer_at` and `set_partition_magic`.
136
+
The trailers are then stored outside of the BOOT and UPDATE partitions, so:
137
+
138
+
- the image can use the whole partition, which may be a single sector long;
139
+
- triggering an update does not erase anything in the UPDATE partition;
140
+
- at the end of the swap, the bootloader resets the sector flags and the UPDATE state itself.
141
+
142
+
`set_trailer_at` may be asked to set bits back to 1 (e.g. resetting the flags to `SECT_FLAG_NEW`),
143
+
so on flash it has to erase and rewrite the storage where needed. The flash is unlocked when it is called.
128
144
129
145
To enable:
130
-
1) Add the `CUSTOM_PARTITION_TRAILER` build option to your `.config`: `CFLAGS_EXTRA+=--DCUSTOM_PARTITION_TRAILER`
146
+
1) Add `CUSTOM_PARTITION_TRAILER=1` to your `.config` (or `CFLAGS_EXTRA+=-DCUSTOM_PARTITION_TRAILER`,
147
+
in which case also export `CUSTOM_PARTITION_TRAILER=1` when running the `sign` tool, so it allows images as
148
+
large as the partition)
131
149
2) Add your own .c file using `OBJS_EXTRA`. For example for your own `src/custom_trailer.c` add this to your `.config`: `OBJS_EXTRA=src/custom_trailer.o`.
132
150
151
+
STM32F4 provides its own implementation in `hal/stm32f4.c`: the boot and update trailers are stored in
152
+
the 16KB flash sectors 1 and 2 (0x08004000 and 0x08008000, overridable with
153
+
`STM32F4_TRAILER_BOOT_ADDRESS` / `STM32F4_TRAILER_UPDATE_ADDRESS`), and wolfBoot is linked around them
154
+
(`hal/stm32f4-trailer.ld`: vector table in sector 0, code from sector 3). This allows the BOOT and UPDATE
155
+
partitions to use the 128KB sectors without wasting one of them for each trailer, see
156
+
`config/examples/stm32f407-discovery.config` and `config/examples/stm32f411-blackpill.config`.
133
157
134
158
## Overview of the content of the FLASH partitions
0 commit comments