From 8a9a70a8db1f6864787db8b53364a130acdfc3f8 Mon Sep 17 00:00:00 2001 From: Igor Opaniuk Date: Wed, 17 Jun 2020 01:00:45 +0300 Subject: tdx-cfg-block: fix serial number creation Add proper calculation of offset for data structures, which size is not multiple of 4 bytes. Testing: Verdin iMX8MM # cfgblock create 0038100206603368 A valid Toradex config block is present, still recreate? [y/N] y Toradex config block successfully written Verdin iMX8MM # reset resetting ... U-Boot 2018.03-00013-g98fb859-dirty (Jun 17 2020 - 00:58:58 +0300) ... Model: ..., Serial#06603368 Relates-to: ELB-2772 Signed-off-by: Igor Opaniuk --- board/toradex/common/tdx-cfg-block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c index 9d202e39c8..9e5fe95982 100644 --- a/board/toradex/common/tdx-cfg-block.c +++ b/board/toradex/common/tdx-cfg-block.c @@ -610,7 +610,7 @@ static int write_tag(u8 *config_block, int *offset, int tag_id, tag->id = tag_id; tag->flags = TAG_FLAG_VALID; /* len is provided as number of 32bit values after the tag */ - tag->len = tag_data_size / sizeof(u32); + tag->len = (tag_data_size + sizeof(u32) - 1) / sizeof(u32); *offset += sizeof(struct toradex_tag); if (tag_data && tag_data_size) { memcpy(config_block + *offset, tag_data, -- cgit v1.2.3