Skip to content

Commit 4b75152

Browse files
bigbrettdanielinux
authored andcommitted
add example to monolithic doc section
1 parent e16dfe6 commit 4b75152

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

docs/firmware_update.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,35 @@ application image was there previously.
212212
No wolfBoot code changes are required — only the update payload needs to
213213
be assembled differently. The payload is constructed by concatenating the
214214
new bootloader binary with the new signed application image and signing
215-
the result as a wolfBoot self-update:
215+
the result as a wolfBoot self-update. Note that the user must ensure that padding
216+
is supplied such that the header of the new signed app image will be located
217+
at an offset of `WOLFBOOT_PARTITION_BOOT_ADDRESS` from the base of the binary.
216218

217-
```
218-
cat wolfboot.bin image_v1_signed.bin > monolithic_payload.bin
219-
sign --wolfboot-update monolithic_payload.bin key.der 2
219+
220+
The following pseudo-shell-script demonstrates how to use standard CLI tools to
221+
build this padded image, where `$PRIVATE_KEY`, `$ARCH_FLASH_OFFSET` and
222+
`$WOLFBOOT_PARTITION_BOOT_ADDRESS` are the wolfBoot config variables that
223+
correspond to your platform
224+
225+
```sh
226+
# Sign your app image as v2 for inclusion in the monolithic payload. This generates test-app/image_v2_signed.bin
227+
tools/keytools/sign test-app/image.bin $(PRIVATE_KEY) 2
228+
229+
# Create padded wolfboot v2 binary file (0xFF fill to exact bootloader region size)
230+
# Bootloader region = $WOLFBOOT_PARTITION_BOOT_ADDRESS - $ARCH_FLASH_OFFSET
231+
dd if=/dev/zero bs=$$(($WOLFBOOT_PARTITION_BOOT_ADDRESS - $ARCH_FLASH_OFFSET)) count=1 2>/dev/null | tr '\000' '\377' > wolfboot_v2_padded.bin
232+
dd if=wolfboot.bin of=wolfboot_v2_padded.bin conv=notrunc 2>/dev/null
233+
234+
# Concatenate padded bootloader v2 + signed app v2 to form the monolithic payload
235+
cat wolfboot_v2_padded.bin test-app/image_v2_signed.bin > monolithic_payload.bin
236+
# Sign the monolithic payload as a wolfBoot self-update v2
237+
tools/keytools/sign --wolfboot-update monolithic_payload.bin $PRIVATE_KEY 2
220238
```
221239

222240
After the self-update completes, flash looks like:
223241

224242
```
225-
ARCH_FLASH_OFFSET BOOT_ADDRESS
243+
ARCH_FLASH_OFFSET WOLFBOOT_PARTITION_BOOT_ADDRESS
226244
| |
227245
v v
228246
[ new bootloader bytes | padding | new signed app image ]
@@ -243,11 +261,7 @@ partition.
243261

244262
- **Not power-fail safe.** Like all self-updates, a monolithic update
245263
erases the bootloader region and writes in-place. An interruption
246-
during the write leaves the device unbootable. Additionally, the BOOT
247-
partition is written without a prior erase — this relies on the
248-
partition being in an erased (0xFF) state, which is only guaranteed
249-
when the device has no prior application installed or the partition has
250-
been explicitly erased beforehand.
264+
during the write leaves the device unbootable.
251265

252266
- **Not revertable.** There is no swap or rollback mechanism. The old
253267
bootloader and application are destroyed during the update.

0 commit comments

Comments
 (0)