From a9455ec3d3d43b75d830bf3c49c58c4ec4746410 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 9 Sep 2024 13:09:36 +1000 Subject: [PATCH] waf: fixed app signature in elf files this fixes an issue when developing for ChibiOS AP_Periph targets where loading the elf file in gdb doesn't allow it to run as it doesn't have the correct AP_Periph signature (crc, board type etc) This patch modifies the elf file to fill in the signature, so when you load in gdb the bootloader will be able to run the signature checks and load the firmware --- Tools/ardupilotwaf/chibios.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Tools/ardupilotwaf/chibios.py b/Tools/ardupilotwaf/chibios.py index 60fd1ef4ee..785bce15bc 100644 --- a/Tools/ardupilotwaf/chibios.py +++ b/Tools/ardupilotwaf/chibios.py @@ -273,12 +273,14 @@ class set_app_descriptor(Task.Task): else: descriptor = b'\x40\xa2\xe4\xf1\x64\x68\x91\x06' - img = open(self.inputs[0].abspath(), 'rb').read() + elf_file = self.inputs[0].abspath() + bin_file = self.inputs[1].abspath() + img = open(bin_file, 'rb').read() offset = img.find(descriptor) if offset == -1: Logs.info("No APP_DESCRIPTOR found") return - offset += 8 + offset += len(descriptor) # next 8 bytes is 64 bit CRC. We set first 4 bytes to # CRC32 of image before descriptor and 2nd 4 bytes # to CRC32 of image after descriptor. This is very efficient @@ -310,7 +312,19 @@ class set_app_descriptor(Task.Task): desc = struct.pack('