From fd3322c61226722685ad112113649933436489a3 Mon Sep 17 00:00:00 2001 From: Jonny Dyer Date: Mon, 2 Nov 2020 20:47:11 -0800 Subject: [PATCH 1/2] Fixed c structure definition in add_version_info.py and fixed example c files in README.md --- README.md | 14 +++++++++----- add_version_info.py | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index def0f84..4eec94d 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ struct version_info { extern volatile const struct version_info version_info; -void print_version_info(int verbose); +void print_version_info(const struct version_info *v); ``` #### `version.c` @@ -74,15 +74,19 @@ volatile const struct version_info version_info = { void print_version_info(const struct version_info *v) { printf( - "%s v%d.%d.%d %s %s %s\n" - " Compiled %s %s by %s on %s\n" + "%s v%d.%d.%d %s\n\r" + "Compiled %s %s by %s on %s\n\r" + "Image Start: 0x%x Size: %d\n\r" + "Image CRC: 0x%x\n", v->product_name, v->major, v->minor, v->patch, v->vcs_id, v->build_date, v->build_time, - v->build_date, v->build_time, - v->build_user, v->build_host + v->build_user, v->build_host, + v->image_start, v->image_size, + v->image_crc ); + } void main(void) diff --git a/add_version_info.py b/add_version_info.py index 526f8b9..58e4cf8 100755 --- a/add_version_info.py +++ b/add_version_info.py @@ -34,6 +34,7 @@ import ctypes import datetime import os +import struct import elf_reader from crc32_forge import CRC32 @@ -60,6 +61,10 @@ class version_info(ctypes.LittleEndianStructure): ("build_host" , ctypes.c_char * 16), ("build_date" , ctypes.c_char * 16), ("build_time" , ctypes.c_char * 16), + ("product_name" , ctypes.c_char * 32), + ("major" , ctypes.c_int32), + ("minor" , ctypes.c_int32), + ("patch" , ctypes.c_int32), ("vcs_info_end" , ctypes.c_char * 16) ] From 64ac7380d44112046e84f334af073ae4ca45007a Mon Sep 17 00:00:00 2001 From: Jonny Dyer Date: Sat, 7 Aug 2021 13:35:35 -0700 Subject: [PATCH 2/2] limited length of host name to 16 bytes to fit within packed struct --- add_version_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add_version_info.py b/add_version_info.py index 58e4cf8..84c4598 100755 --- a/add_version_info.py +++ b/add_version_info.py @@ -84,7 +84,7 @@ def fill_version_info(info): dprint(info.vcs_id.decode(ENCODING)) info.build_user = bytes(getpass.getuser(), ENCODING) - info.build_host = bytes(platform.node(), ENCODING) + info.build_host = bytes(platform.node()[0:16], ENCODING) mtime = datetime.datetime.fromtimestamp( os.path.getmtime(args.source) ) info.build_date = bytes(mtime.strftime("%Y-%m-%d"), ENCODING)