From 7aaa9ac06bdeb510628caef646f8b4a074b485bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E5=B7=A8=E9=BE=99?= Date: Mon, 18 Aug 2025 15:58:04 +0800 Subject: [PATCH] Resolve the error 'Could not install firmware.' - Fixes #3195 For burning custom firmware, the validation of 'GenericSerial' should be skipped. Resolve the error 'Could not install firmware.' --- .../firmware/FirmwareInstall.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/core/services/ardupilot_manager/firmware/FirmwareInstall.py b/core/services/ardupilot_manager/firmware/FirmwareInstall.py index 294ba0abdb..7319266f1b 100644 --- a/core/services/ardupilot_manager/firmware/FirmwareInstall.py +++ b/core/services/ardupilot_manager/firmware/FirmwareInstall.py @@ -67,16 +67,21 @@ def _validate_apj(firmware_path: pathlib.Path, platform: Platform) -> None: with open(firmware_path, "r", encoding="utf-8") as firmware_file: firmware_data = firmware_file.read() firm_board_id = int(json.loads(firmware_data).get("board_id", -1)) - expected_board_id = get_board_id(platform) - if expected_board_id == -1: - raise UnsupportedPlatform("Firmware validation is not implemented for this board yet.") - if firm_board_id == -1: - raise InvalidFirmwareFile("Could not find board_id specification in the firmware file.") - if firm_board_id != expected_board_id: - raise InvalidFirmwareFile(f"Expected board_id {expected_board_id}, found {firm_board_id}.") + except (OSError, json.JSONDecodeError) as error: + raise InvalidFirmwareFile(f"Could not load firmware file for validation: {firmware_path}") from error + + if platform == Platform.GenericSerial: + logger.warning("Skipping board_id validation for GenericSerial platform.") return - except Exception as error: - raise InvalidFirmwareFile("Could not load firmware file for validation.") from error + + expected_board_id = get_board_id(platform) + if expected_board_id == -1: + raise UnsupportedPlatform("Firmware validation is not implemented for this board yet.") + if firm_board_id == -1: + raise InvalidFirmwareFile("Could not find board_id specification in the firmware file.") + if firm_board_id != expected_board_id: + raise InvalidFirmwareFile(f"Expected board_id {expected_board_id}, found {firm_board_id}.") + return @staticmethod def _validate_elf(firmware_path: pathlib.Path, platform: Platform) -> None: