From ddfcf85b1f375f3a66885eac5914a88229aa0068 Mon Sep 17 00:00:00 2001 From: James O'Shannessy <12959316+joshanne@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:23:10 +1100 Subject: [PATCH] scripts: Update uploader to read git hash from bootloader --- Tools/scripts/uploader.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Tools/scripts/uploader.py b/Tools/scripts/uploader.py index b926b26c232795..7f7affe2b588b3 100755 --- a/Tools/scripts/uploader.py +++ b/Tools/scripts/uploader.py @@ -237,13 +237,14 @@ class uploader(object): CHIP_FULL_ERASE = b'\x40' # full erase of flash - INFO_BL_REV = b'\x01' # bootloader protocol revision - BL_REV_MIN = 2 # minimum supported bootloader protocol - BL_REV_MAX = 5 # maximum supported bootloader protocol - INFO_BOARD_ID = b'\x02' # board type - INFO_BOARD_REV = b'\x03' # board revision - INFO_FLASH_SIZE = b'\x04' # max firmware size in bytes - INFO_EXTF_SIZE = b'\x06' # available external flash size + INFO_BL_REV = b'\x01' # bootloader protocol revision + BL_REV_MIN = 2 # minimum supported bootloader protocol + BL_REV_MAX = 6 # maximum supported bootloader protocol + INFO_BOARD_ID = b'\x02' # board type + INFO_BOARD_REV = b'\x03' # board revision + INFO_FLASH_SIZE = b'\x04' # max firmware size in bytes + INFO_EXTF_SIZE = b'\x06' # available external flash size + INFO_BL_GIT_HASH = b'\x07' # git hash of bootloader build PROG_MULTI_MAX = 252 # protocol max is 255, must be multiple of 4 READ_MULTI_MAX = 252 # protocol max is 255 @@ -737,6 +738,10 @@ def identify(self): self.board_rev = self.__getInfo(uploader.INFO_BOARD_REV) self.fw_maxsize = self.__getInfo(uploader.INFO_FLASH_SIZE) + # Git SHA introduced added in v6 + if self.bl_rev > 5: + self.git_hash_bl = self.__getInfo(uploader.INFO_BL_GIT_HASH) + def dump_board_info(self): # OTP added in v4: print("Bootloader Protocol: %u" % self.bl_rev) @@ -839,6 +844,9 @@ def dump_board_info(self): print(" board_type: %u" % self.board_type) print(" board_rev: %u" % self.board_rev) + git_hash_bl = "%x" % (self.git_hash_bl) if self.bl_rev > 5 else "UNKNOWN" + print(" git hash (Bootloader): %s" % git_hash_bl) + print("Identification complete") def board_name_for_board_id(self, board_id):