Skip to content

imgtool custom TLV disregards endian and always uses big endian #1846

@nordicjm

Description

@nordicjm

This was originally (a long time ago) reported to the wrong repository: apache/mynewt-mcumgr#152

The issue with imgtool is that the value of --custom-tlv is always encoded in big-endian format, one might assume that selecting the endian of the output would determine this but it does not, and according to https://github.com/mcu-tools/mcuboot/blob/main/boot/bootutil/include/bootutil/boot_status.h#L156 actually should not because all fields must be in little endian, therefore imgtool has a bug in this functionality.

Example:

imgtool sign -k /tmp/aa/bootloader/mcuboot/root-rsa-2048.pem --align 4 --version 1.2.3 -H 0x200 -S 0x78000 --custom-tlv 0xaa 0x22550011 hello_world/zephyr/zephyr.hex test.hex

The following is the raw bytes from the hex file (taken from JFlash): 00 AA 00 04 00 22 55 00 11, as can be seen 0x22550011 is wrongly added in big endian format.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions