image: use explitic padding on dependency version

This struct currently relies on padding being done by the C compiler.
Although this is generally done the same across targets, this isn't
required, and it is better to make any padding explicit.  This also
makes it clear that there is extra space in this structure that can be
used for another purpose.

The python imgtool is also fixed to match.  It was using a 32-bit int,
which only worked in the little endian case.

Signed-off-by: David Brown <david.brown@linaro.org>
This commit is contained in:
David Brown 2019-07-29 11:11:32 -06:00 committed by David Brown
parent 3901d32ead
commit bd7925e39e
2 changed files with 3 additions and 1 deletions

View File

@ -91,6 +91,8 @@ struct image_version {
struct image_dependency {
uint8_t image_id; /* Image index (from 0) */
uint8_t _pad1;
uint16_t _pad2;
struct image_version image_min_version; /* Indicates at minimum which
* version of firmware must be
* available to satisfy compliance

View File

@ -202,7 +202,7 @@ class Image():
for i in range(dependencies_num):
e = STRUCT_ENDIAN_DICT[self.endian]
payload = struct.pack(
e + 'I'+'BBHI',
e + 'B3x'+'BBHI',
int(dependencies[DEP_IMAGES_KEY][i]),
dependencies[DEP_VERSIONS_KEY][i].major,
dependencies[DEP_VERSIONS_KEY][i].minor,