Improve documentation for new custom TLV.

pull/418/head
David Garske 2024-03-07 07:30:22 -08:00 committed by Daniele Lacamera
parent e3669245d5
commit 2826f70ca7
2 changed files with 13 additions and 12 deletions

View File

@ -185,7 +185,7 @@ Provides a PCR mask and digest to be signed and included in the header. The sign
Provides a value to be set with a custom tag
* `--custom-tlv tag len val`: Adds a TLV entry to the manifest header, corresponding
to the type identified by `tag`, with lenght `len` bytes, and assigns the value `val`.
to the type identified by `tag`, with length `len` bytes, and assigns the value `val`.
Values can be decimal or hex numbers (prefixed by '0x'). The tag is a 16-bit number.
Valid tags are in the range between 0x0030 and 0xFEFE.

View File

@ -77,17 +77,18 @@ The output image `test-app/image_v4_signed.bin` will contain the custom field wi
From the bootloader code, we can then retrieve the value of the custom field using the `wolfBoot_find_header` function:
```c
uint32_t custom_code34_field;
const uint16_t custom_code34_field_size = 4;
const uint16_t custom_code34_tag = 0x34;
int size;
size = wolfBoot_find_header(0x34, &custom_code34_field, sizeof(custom_code34_value));
if (size != custom_code34_field_size) {
uint32_t value;
uint8_t* ptr = NULL;
uint16_t tlv = 0x34;
uint8_t* imageHdr = (uint8_t*)WOLFBOOT_PARTITION_BOOT_ADDRESS; /* WOLFBOOT_PARTITION_UPDATE_ADDRESS */
uint16_t size = wolfBoot_find_header(imageHdr, tlv, &ptr);
if (size != sizeof(uint32_t) || ptr == NULL) {
/* Error: the field is not present or has the wrong size */
}
/* From here, the value 0xAABBCCDD is stored in custom_code34_value */
/* From here, the value 0xAABBCCDD is at ptr */
memcpy(&value, ptr, size);
printf("TLV 0x%x=0x%x\n", tlv, value);
```
### Image signing tool