diff --git a/scripts/versions.py b/scripts/versions.py index e49093cd..a110b80f 100644 --- a/scripts/versions.py +++ b/scripts/versions.py @@ -73,40 +73,80 @@ def get_board_name(folder): return basename.split("_")[1] raise Exception(f"Unknown board name: {basename}") +def find_app_partition(data): + partition_begin = 0x8000 + partition_end = partition_begin + 0x4000 + # find the first parition with type 0x00 + for i in range(partition_begin, partition_end, 0x20): + # magic is aa 50 + if data[i] == 0xaa and data[i + 1] == 0x50: + # type is app + if data[i + 2] == 0x00: + # read offset and size + offset = struct.unpack("> 4) - chip_id = get_chip_id_string(data[0xC]) + flash_size = get_flash_size(app_data[0x3] >> 4) + chip_id = get_chip_id_string(app_data[0xC]) # get segments - segment_count = data[0x1] + segment_count = app_data[0x1] segments = [] offset = 0x18 + image_size = 0x18 for i in range(segment_count): - segment_size = struct.unpack("