From fbc82ee347076ca0abeacd8e463499a8d9682885 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 10 Apr 2026 12:09:38 +1000 Subject: [PATCH] Tools: convert to hwdef system --- .github/workflows/qurt_build.yml | 21 +++++++------- Tools/ardupilotwaf/boards.py | 16 ++++++++-- Tools/ardupilotwaf/qurt.py | 50 ++++++++++++++++++++++++++++++++ Tools/scripts/board_list.py | 6 +++- Tools/scripts/test_new_boards.py | 5 ++++ 5 files changed, 84 insertions(+), 14 deletions(-) diff --git a/.github/workflows/qurt_build.yml b/.github/workflows/qurt_build.yml index d153dd7233b..25707a18d24 100644 --- a/.github/workflows/qurt_build.yml +++ b/.github/workflows/qurt_build.yml @@ -151,14 +151,15 @@ jobs: - name: Build QURT run: | - ./waf configure --board QURT + set -ex + ./waf configure --board ModalAI-VOXL2 ./waf copter ./waf plane ./waf rover - cp -a build/QURT/bin/arducopter build/QURT/ArduPilot.so - cp -a build/QURT/bin/arducopter build/QURT/ArduPilot_Copter.so - cp -a build/QURT/bin/arduplane build/QURT/ArduPilot_Plane.so - cp -a build/QURT/bin/ardurover build/QURT/ArduPilot_Rover.so + cp -a build/ModalAI-VOXL2/bin/arducopter build/ModalAI-VOXL2/ArduPilot.so + cp -a build/ModalAI-VOXL2/bin/arducopter build/ModalAI-VOXL2/ArduPilot_Copter.so + cp -a build/ModalAI-VOXL2/bin/arduplane build/ModalAI-VOXL2/ArduPilot_Plane.so + cp -a build/ModalAI-VOXL2/bin/ardurover build/ModalAI-VOXL2/ArduPilot_Rover.so libraries/AP_HAL_QURT/packaging/make_package.sh ArduCopter arducopter libraries/AP_HAL_QURT/packaging/make_package.sh ArduPlane arduplane libraries/AP_HAL_QURT/packaging/make_package.sh Rover ardurover @@ -168,10 +169,10 @@ jobs: with: name: qurt-binaries path: | - build/QURT/ardupilot - build/QURT/ArduPilot_Copter.so - build/QURT/ArduPilot_Plane.so - build/QURT/ArduPilot_Rover.so - build/QURT/ArduPilot.so + build/ModalAI-VOXL2/ardupilot + build/ModalAI-VOXL2/ArduPilot_Copter.so + build/ModalAI-VOXL2/ArduPilot_Plane.so + build/ModalAI-VOXL2/ArduPilot_Rover.so + build/ModalAI-VOXL2/ArduPilot.so libraries/AP_HAL_QURT/packaging/*.deb retention-days: 7 diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index bbb2031be6f..c4e2761fb15 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -667,6 +667,10 @@ def add_dynamic_boards_linux(): '''add boards based on existence of hwdef.dat in subdirectories for ''' add_dynamic_boards_from_hwdef_dir(LinuxBoard, 'libraries/AP_HAL_Linux/hwdef') +def add_dynamic_boards_qurt(): + '''add boards based on existence of hwdef.dat in subdirectories for ''' + add_dynamic_boards_from_hwdef_dir(QURTBoard, 'libraries/AP_HAL_QURT/hwdef') + def add_dynamic_boards_sitl(): '''add boards based on existence of hwdef.dat in subdirectories for ''' add_dynamic_boards_from_hwdef_dir(SITLBoard, 'libraries/AP_HAL_SITL/hwdef') @@ -700,6 +704,7 @@ def get_boards_names(): add_dynamic_boards_chibios() add_dynamic_boards_esp32() add_dynamic_boards_linux() + add_dynamic_boards_qurt() add_dynamic_boards_sitl() return sorted(list(_board_classes.keys()), key=str.lower) @@ -1482,7 +1487,7 @@ class LinuxBoard(Board): # get name of class return self.__class__.__name__ -class QURT(Board): +class QURTBoard(Board): '''support for QURT based boards''' toolchain = 'custom' @@ -1491,6 +1496,11 @@ class QURT(Board): self.with_can = False + def configure(self, cfg): + # load hwdef, extract toolchain from cfg.env: + cfg.load('qurt') + super().configure(cfg) + def configure_toolchain(self, cfg): cfg.env.CXX_NAME = 'gcc' cfg.env.HEXAGON_SDK_DIR = "/opt/hexagon-sdk/4.1.0.4-lite" @@ -1525,7 +1535,7 @@ class QURT(Board): ] def configure_env(self, cfg, env): - super(QURT, self).configure_env(cfg, env) + super().configure_env(cfg, env) env.BOARD_CLASS = "QURT" env.HEXAGON_APP = "libardupilot.so" @@ -1571,7 +1581,7 @@ class QURT(Board): ] def build(self, bld): - super(QURT, self).build(bld) + super().build(bld) bld.load('qurt') def get_name(self): diff --git a/Tools/ardupilotwaf/qurt.py b/Tools/ardupilotwaf/qurt.py index ae8b9dd786d..d4587e05e6e 100644 --- a/Tools/ardupilotwaf/qurt.py +++ b/Tools/ardupilotwaf/qurt.py @@ -6,6 +6,56 @@ Waf tool for QURT build """ +import os +import sys +import traceback + +import hal_common + +sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../libraries/AP_HAL_QURT/hwdef/scripts')) +import qurt_hwdef # noqa: E402 + +def generate_hwdef_h(env): + '''run qurt_hwdef.py''' + print(f"{env.SRCROOT=} {type(env.SRCROOT)=}") + hwdef_dir = os.path.join(env.SRCROOT, 'libraries/AP_HAL_QURT/hwdef') + + if len(env.HWDEF) == 0: + env.HWDEF = os.path.join(hwdef_dir, env.BOARD, 'hwdef.dat') + hwdef_out = env.BUILDROOT + if not os.path.exists(hwdef_out): + os.mkdir(hwdef_out) + hwdef = [env.HWDEF] + if env.HWDEF_EXTRA: + hwdef.append(env.HWDEF_EXTRA) + + hwdef_obj = qurt_hwdef.QURTHWDef( + outdir=hwdef_out, + hwdef=hwdef, + quiet=False, + ) + hwdef_obj.run() + + return hwdef_obj + +def configure(cfg): + def srcpath(path): + return cfg.srcnode.make_node(path).abspath() + def bldpath(path): + return bldnode.make_node(path).abspath() + + env = cfg.env + bldnode = cfg.bldnode.make_node(cfg.variant) + env.SRCROOT = srcpath('') + env.BUILDROOT = bldpath('') + + try: + hwdef_obj = generate_hwdef_h(env) + except Exception: # noqa: BLE001 + traceback.print_exc() + cfg.fatal("Failed to process hwdef.dat") + hal_common.process_hwdef_results(cfg, hwdef_obj) + def build(bld): AARCH64_SDK_DIR = "/opt/aarch64-sdk/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu" AARCH64_CC = AARCH64_SDK_DIR + "/bin/aarch64-linux-gnu-gcc" diff --git a/Tools/scripts/board_list.py b/Tools/scripts/board_list.py index 924d6a79fc7..0ac09c1160f 100755 --- a/Tools/scripts/board_list.py +++ b/Tools/scripts/board_list.py @@ -67,7 +67,7 @@ class BoardList(object): ) self.hwdef_dir = [] - for haldir in 'AP_HAL_ChibiOS', 'AP_HAL_Linux', 'AP_HAL_ESP32', 'AP_HAL_SITL': + for haldir in 'AP_HAL_ChibiOS', 'AP_HAL_Linux', 'AP_HAL_ESP32', 'AP_HAL_QURT', 'AP_HAL_SITL': self.hwdef_dir.append(os.path.join(realpath, haldir, "hwdef")) def __init__(self): @@ -131,6 +131,8 @@ class BoardList(object): board.toolchain = 'arm-none-eabi' elif "ESP32" in hwdef_dir: board.toolchain = 'xtensa-esp32-elf' + elif "QURT" in hwdef_dir: + board.toolchain = "aarch64-linux-gnu" elif "SITL" in hwdef_dir: board.toolchain = None else: @@ -144,6 +146,8 @@ class BoardList(object): board.hal = "ESP32" elif "SITL" in hwdef_dir: board.hal = "SITL" + elif "QURT" in hwdef_dir: + board.hal = "QURT" else: raise ValueError(f"Unable to determine HAL for {hwdef_dir}") diff --git a/Tools/scripts/test_new_boards.py b/Tools/scripts/test_new_boards.py index 6a397a40732..77949d532c9 100755 --- a/Tools/scripts/test_new_boards.py +++ b/Tools/scripts/test_new_boards.py @@ -159,6 +159,11 @@ class TestNewBoards(BuildScriptBase): self.progress(f"Skipping ESP32 board {board.name}") continue + # Skip QURT boards - CI machine can't build them + if board.hal == "QURT": + self.progress(f"Skipping QURT board {board.name}") + continue + # Skip arms board - CI machine can't build it if board.toolchain == "arm-linux-gnueabihf": self.progress(f"Skipping arm-linux board {board.name}")