From 776dafbe8c729303176c0ce4cd845e649330e8c0 Mon Sep 17 00:00:00 2001 From: Loki077 Date: Tue, 17 Dec 2024 09:05:05 +1100 Subject: [PATCH 01/13] Tools: Speed up/ reordered Carbonix Build Script --- Tools/Carbonix_scripts/carbonix_waf_build.sh | 133 +++++++++++++------ 1 file changed, 93 insertions(+), 40 deletions(-) diff --git a/Tools/Carbonix_scripts/carbonix_waf_build.sh b/Tools/Carbonix_scripts/carbonix_waf_build.sh index 82f7a0211e..9e1f1295a4 100755 --- a/Tools/Carbonix_scripts/carbonix_waf_build.sh +++ b/Tools/Carbonix_scripts/carbonix_waf_build.sh @@ -1,54 +1,107 @@ #!/bin/bash +echo "Running distclean..." +./waf distclean +rm -Rf output + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Set the board name +board=$1 +echo "********************************" +echo "Board name: $board" +echo "********************************" + +# is_periph_board=$(./waf configure --board "$board" -g | tee >(grep -c "env set AP_PERIPH=1")) +is_periph_board=$(./waf configure --board "$board" -g | grep -c "env set AP_PERIPH=1") + # Exit if any command fails set -e -echo "Running distclean..." -./waf distclean +echo "is_periph_board: $is_periph_board" -main_boards=("CubeOrange" "CubeOrangePlus" "CubeOrange-Volanti" "CubeOrangePlus-Volanti" "CubeOrange-Ottano" "CubeOrangePlus-Ottano") -for board in "${main_boards[@]}"; do +if [ $is_periph_board -eq 0 ]; then echo "Compiling ArduPlane for $board..." - ./waf configure --board "$board" -g ./waf plane -done + echo "Script finished successfully." + exit 0 +fi + +# For periph boards, we take the extra step of generating a modified binary +# for each CPN param file in the AP_HAL_ChibiOS/hwdef/CarbonixCommon/cpn_params +# folder. This modified binary will have the CPN parameters embedded in it, and +# the board name set to the board name followed by the CPN parameter file name. + +# We build a version of AP_Periph with a long random string as the board name. +# This random string is replaced with the actual board name in the final binary. +# The random string is chosen to be long enough to accommodate the longest board +# name that we expect to use. Currently, we use 40, which is a little larger +# than the longest board name we have used so far: +# "CarbonixF405-no-crystal-Volanti-LWing". (and error is thrown if the board +# name is too long, so we can adjust this if we ever need a longer name) +max_board_name_length=40 +board_magic_string="lm3eBX7cJeaUer67lXdkNr83q2WzPRbE2MxAgnGq9esBjPVecYynx9Pry5sRJMgCX8384NTYZRDpuR8K" +if [ ${#board_magic_string} -lt $max_board_name_length ]; then + echo "max_board_name_length is too long (max ${#board_magic_string} bytes)" + exit 1 +fi +board_magic_string=${board_magic_string:0:max_board_name_length} + +# Compile AP_Periph +echo "Compiling AP_Periph for $board..." +printf "undef CAN_APP_NODE_NAME\ndefine CAN_APP_NODE_NAME \"$board_magic_string\"" > temp.hwdef +./waf configure --board "$board" --extra-hwdef=temp.hwdef -g +./waf AP_Periph -periph_boards=("CarbonixF405" "CarbonixF405-no-crystal") - -# Build all periph board with custom parameters -for board in "${periph_boards[@]}"; do - for file in $(find libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/cpn_params/ -name "*.parm"); do - # Extract the filename without the extension - filename=$(basename -- "$file") - filename="${filename%.*}" - # Extract the Parent folder name - foldername=$(basename -- "$(dirname -- "$file")") - echo "Compiling AP_Periph for $board with $filename with foldername $foldername..." - # Create extra hwdef file - printf "undef CAN_APP_NODE_NAME\ndefine CAN_APP_NODE_NAME \"$board-$filename\"" > temp.hwdef - - # Compile AP_Periph for each board - echo "Compiling AP_Periph for $board with $filename..." - ./waf configure --board "$board" --extra-hwdef=temp.hwdef --default-parameters="$file" -g - ./waf AP_Periph - - # Rename build outputs - mkdir -p output/$foldername/${filename}_$board - # Move all the files (not folders) in build/$board/bin to build/$board/bin/$filename - find build/$board/bin -maxdepth 1 -type f -exec mv {} output/$foldername/${filename}_$board \; - # Move default $file in the output folder - cp $file output/$foldername/${filename}_$board - - # Cleanup - rm temp.hwdef +# Loop through all CPN parameter files and generate modified binaries +bin_folder=build/$board/bin +for file in $(find libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/cpn_params/ -name "*.parm"); do + echo "Processing parameter file $file for $board..." + # Extract the filename without the extension + filename=$(basename -- "$file") + filename="${filename%.*}" + # Extract the Parent folder name + foldername=$(basename -- "$(dirname -- "$file")") + + # Create output folder + output_folder=output/${filename}_$board + mkdir -p $output_folder + # Copy param file in the output folder + cp $file $output_folder + + # The find/replace operation works by converting the binary to a single long + # line of hex, then uses sed to replace the magic string with the board name + # that has been padded with zeros to the same length as the magic string, + # then converts the hex back to binary. + new_board_name="$board-$filename" + if [ ${#new_board_name} -gt $max_board_name_length ]; then + echo "Board name '$new_board_name' is too long (max $max_board_name_length bytes)" + exit 1 + fi + board_magic_string_hex=$(echo -n "$board_magic_string" | xxd -p | tr -d '\n') + board_name_hex=$(echo -n "$new_board_name" | xxd -p | tr -d '\n') + # Pad with zeros to the same length as the magic string + board_name_hex=$(printf "%-${#board_magic_string_hex}s" "$board_name_hex" | tr ' ' '0') + + for binary in $bin_folder/AP_Periph $bin_folder/AP_Periph.bin; do + # Embed the parameters + echo "Embedding parameter file $filename into $binary..." + Tools/scripts/apj_tool.py $binary --set-file $file &> /dev/null + + # Set the board name + echo "Setting board name to $new_board_name in $binary..." + cp $binary $binary.tmp + xxd -p $binary | tr -d '\n' | sed "s/$board_magic_string_hex/$board_name_hex/g" | xxd -r -p > $binary.tmp + mv $binary.tmp $output_folder/$(basename $binary) + echo "Output binary Saved at : $output_folder/$(basename $binary)" done + echo "" done -# Build all Default periph board -for board in "${periph_boards[@]}"; do - echo "Compiling AP_Periph for $board..." - ./waf configure --board "$board" -g - ./waf AP_Periph -done +# Cleanup +rm temp.hwdef echo "Script completed successfully." From 74b05e954112b391367ed28a86f47b29df7137f4 Mon Sep 17 00:00:00 2001 From: Loki077 Date: Tue, 17 Dec 2024 09:05:42 +1100 Subject: [PATCH 02/13] Tools: Add aircraft configuration script. This commit introduces a new script, `aircraft_config.py`, which automates the process of packaging Aircraft firmware according to the xml file provided. The script reads an XML file containing the aircraft configuration and peripheral firmware information, replaces the 'cx_pilot_commit_id' placeholder with the actual commit ID, and copies the XML file to the hwdef directory to embed it in @ROMFS. It then builds the ArduPlane firmware for the specified flight controller and organizes the output files into a directory structure suitable for AFQT tool. Key features: - Parses the XML configuration file to extract the flight controller's board name. - Replaces the 'cx_pilot_commit_id' placeholder in the XML file with the provided commit ID. - Copies the modified XML file to the ROMFS_custom directory. - Copies the Carbonix Common lua script into ROMFS_custom directory. - Organizes the output files into a structured directory easy for AFQT. Usage: python aircraft_config.py This script simplifies the firmware build process and ensures that all necessary files are correctly organized for AFQT. --- Tools/Carbonix_scripts/aircraft_config.py | 256 ++++++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 Tools/Carbonix_scripts/aircraft_config.py diff --git a/Tools/Carbonix_scripts/aircraft_config.py b/Tools/Carbonix_scripts/aircraft_config.py new file mode 100644 index 0000000000..0dae0d95fe --- /dev/null +++ b/Tools/Carbonix_scripts/aircraft_config.py @@ -0,0 +1,256 @@ +""" +Build ArduPlane firmware and collect periph firmware to bundle for AFQT. + +This script reads an XML file that contains the aircraft configuration and +peripheral firmware information. It replaces the 'cx_pilot_commit_id' +placeholder with the actual commit ID, copies the XML file to the ROMFS_custom +directory to embed it in @ROMFS, copies the lua scripts from CarbonixCommon into +ROMFS_custom/scripts, builds the ArduPlane firmware for the flight controller, +and organizes the output files in a directory structure that can be bundled for AFQT. + +Usage: + python aircraft_config.py [--skip_periph] + +AP_FLAKE8_CLEAN + +""" +import os +import glob +import shutil +import argparse +import xml.etree.ElementTree as ET + + +def get_flight_controller_board_name(xml_file : str) -> str: + """Get the flight controller's board name from the XML file. + + Returns, for example, 'CubeOrange-Ottano'. + + Args: + xml_file (str): Path to the XML file. + Returns: + str: Board name of the flight controller. + """ + tree = ET.parse(xml_file) + root = tree.getroot() + flight_controller = root.find('flight_controller') + if flight_controller is None: + raise AssertionError(f"'flight_controller' element not found in {xml_file}") + board_name = flight_controller.find('board_name') + if board_name is None: + raise AssertionError(f"'board_name' element not found in the 'flight_controller' element in {xml_file}") + return board_name.text + + +def copy_configuration_file(xml_file : str, commit_id : str) -> str: + """Copy the XML file to the ROMFS_custom directory. + + Copies the aircraft definition XML file to a special directory to embed in + @ROMFS. In the process, it also replaces the 'cx_pilot_commit_id' + placeholder with the actual commit ID. + + Args: + xml_file (str): Path to the XML file. + commit_id (str): The commit ID to replace the placeholder with. + Returns: + str: Path to the destination file. + """ + with open(xml_file, 'r') as file: + content = file.read() + content = content.replace('cx_pilot_commit_id', commit_id) + destination_path = 'ROMFS_custom/AircraftConfiguration.xml' + os.makedirs(os.path.dirname(destination_path), exist_ok=True) + with open(destination_path, 'w') as file: + file.write(content) + print(f"Copied {xml_file} to {destination_path}") + return destination_path + + +def copy_lua_scripts(xml_file : str) -> None: + """Copy the Lua scripts to the scripts directory. + + Extracts the Lua scripts from the XML file and copies them to the + 'ROMFS_custom/scripts' directory. + + Args: + xml_file (str): Path to the XML file. + """ + tree = ET.parse(xml_file) + root = tree.getroot() + lua_script_list = root.find('lua_script_list') + if lua_script_list is None: + raise AssertionError(f"'lua_script_list' element not found in {xml_file}") + + for lua_script in lua_script_list.findall('lua_script'): + source_path = lua_script.find('source_path') + if source_path is None: + raise AssertionError(f"'source_path' element not found in {xml_file}") + destination_path = lua_script.find('destination_path') + if destination_path is None: + raise AssertionError(f"'destination_path' element not found in {xml_file}") + # copy the file in 'ROMFS_custom/scripts/' directory + destination_path = f'ROMFS_custom/scripts/{destination_path.text}' + os.makedirs(os.path.dirname(destination_path), exist_ok=True) + shutil.copy(source_path.text, destination_path) + print(f"Copied {source_path.text} to {destination_path}") + + +def extract_aircraft_info(xml_file : str) -> tuple: + """Extract the aircraft model and model version from the XML file. + + Args: + xml_file (str): Path to the XML file. + Returns: + tuple: A tuple containing the aircraft model and model + """ + tree = ET.parse(xml_file) + root = tree.getroot() + + aircraft = root.find('aircraft') + if aircraft is not None: + model = aircraft.find('model') + if model is None: + raise AssertionError(f"'model' element not found in the 'aircraft' element of {xml_file}") + model_version = aircraft.find('model_version') + if model_version is None: + raise AssertionError(f"'model_version' element not found in the 'aircraft' element of {xml_file}") + return model.text, model_version.text + + +def get_periph_board_names(xml_file : str) -> set: + """Get a set of peripheral firmware board names from the XML file. + + Returns a set of board names for all managed peripheral firmwares. For + example, + { + 'Ottano-M1_CarbonixF405', + 'Ottano-M2_CarbonixF405', + ... + } + Only peripherals with a 'firmware_path' element are included in this set. + Other peripherals are not managed by us and do not need to be bundled by + this script. + + Args: + xml_file (str): Path to the XML file. + Returns: + set: Set of peripheral board names. + """ + tree = ET.parse(xml_file) + root = tree.getroot() + + cpn_list = root.find('cpn_list') + if cpn_list is None: + raise AssertionError(f"'cpn_list' element not found in {xml_file}") + + periph_firmware_paths = set() + for cpn in cpn_list.findall('cpn'): + board_name = cpn.find('board_name') + if board_name is None: + raise AssertionError(f"'board_name' missing for CPN {cpn.get('id')} in {xml_file}") + firmware_path = cpn.find('firmware_path') + # If there is no firmware path, we don't need to bundle it + if firmware_path is None: + continue + periph_firmware_paths.add(board_name.text) + + return periph_firmware_paths + + +# Organize the build output files +def organize_output(xml_file : str, fc_firmware_name : str, peripherals : set) -> None: + """Organize the build output files in a directory structure for AFQT. + + The output directory structure is as follows: + final-output/ + ├── _/ + │ ├── / + │ ├── / + │ ├── / + │ ├── ... + │ ├── ReleaseNotes.txt + │ └── AFQT/ + │ └── target.xml + + Args: + xml_file (str): Path to the XML file. + fc_firmware_name (str): Name of the flight controller firmware binary. + peripherals (set): Set of peripheral board names. + """ + shutil.rmtree('final-output', ignore_errors=True) + model, model_version = extract_aircraft_info(xml_file) + + output_dir = 'final-output' + final_output_dir = os.path.join(output_dir, f"{model}_{model_version}") + os.makedirs(final_output_dir, exist_ok=True) + print(f"Output directory created at {final_output_dir}") + + # Move the firmware binary to the output directory + firmware_bin = f'build/{fc_firmware_name}/bin' + if not os.path.exists(firmware_bin): + raise FileNotFoundError(f"Flight controler firmware binary not found for {fc_firmware_name}") + shutil.copytree(firmware_bin, os.path.join(final_output_dir, fc_firmware_name)) + print(f"Moved {firmware_bin} binaries to {final_output_dir}/{fc_firmware_name}") + + # Move the periph firmware binary to the output directory + if len(peripherals) > 0: + for board_name in peripherals: + source_dir = glob.glob(f'periph-build/*/{board_name}') + if len(source_dir) == 0: + raise FileNotFoundError(f'Could not find periph-build/*/{board_name}') + if len(source_dir) > 1: + raise FileNotFoundError(f'Multiple directories found for periph-build/*/{board_name}') + source_dir = source_dir[0] + shutil.copytree(source_dir, os.path.join(final_output_dir, board_name)) + print(f"Moved {board_name} binaries to {final_output_dir}/{board_name}") + + # move Release Notes ArduPlane/ReleaseNotes.txt to the output directory + release_notes = 'ArduPlane/ReleaseNotes.txt' + if os.path.exists(release_notes): + shutil.copy(release_notes, final_output_dir) + print(f"Moved ReleaseNotes.txt to {final_output_dir}") + + # create a directory AFQT and Rename the xml file to target.xml and move it to the output directory + os.makedirs(os.path.join(final_output_dir, 'AFQT'), exist_ok=True) + target_xml = os.path.join(final_output_dir, 'AFQT', 'target.xml') + shutil.copy(xml_file, target_xml) + print(f"Moved {xml_file} to {target_xml}") + + +def build_flight_controller_firmware(board_name : str) -> None: + """Build ArduPlane firmware for the flight controller. + + Args: + board_name (str): Name of the board in hwdef, e.g., CubeOrange-Ottano + """ + result = os.system(f"./waf configure --board={board_name}") + if result != 0: + raise RuntimeError(f"Error configuring firmware for {board_name}") + result = os.system("./waf plane") + if result != 0: + raise RuntimeError(f"Error building firmware for {board_name}") + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('xml_file', help='Path to the XML file') + parser.add_argument('commit_id', help='Commit ID to replace') + parser.add_argument('--skip_periph', action='store_true', help='Skip peripheral firmware bundling') + args = parser.parse_args() + + print('XML file:', args.xml_file) + print('Commit ID:', args.commit_id) + + xml_file = copy_configuration_file(args.xml_file, args.commit_id) + copy_lua_scripts(xml_file) + fc_board_name = get_flight_controller_board_name(xml_file) + + build_flight_controller_firmware(fc_board_name) + peripherals = set() + if args.skip_periph: + print('Skipping peripheral firmware bundling') + else: + print('Bundling peripheral firmware') + peripherals = get_periph_board_names(xml_file) + organize_output(xml_file, fc_board_name, peripherals) + print('Done') From 4e0c741cc441b20d6cade2ac9a35a41104017fe7 Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 14:17:26 +1100 Subject: [PATCH 03/13] CarbonixCommon: Add aircraft Ottano AC_1 model --- .../aircraft_configuration/Ottano_AC_1.xml | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_1.xml diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_1.xml b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_1.xml new file mode 100644 index 0000000000..de51ef2f0e --- /dev/null +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_1.xml @@ -0,0 +1,129 @@ + + + + + Ottano + AC_1 + + + CubeOrange, + + Split CAN Architecture, + + Crystal CPNs, + CAN Servo, + adsb, + CAN GPS, + CAN Airspeed, + CAN Battery Monitor + + 1 + + + CubeOrange-Ottano + cx_pilot_commit_id + arduplane.apj + + + + 1 + Ottano-M1_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Ottano-M5_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + servo_.MKS-HBL6625:010 + b120233 + + + 1 + servo_.MKS-HBL6625:006 + b120233 + + + 1 + servo_.MKS-HBL6625:011 + b120233 + + + 1 + gps_org.ardupilot.HolybroG4_GPS + 6e519848 + + + 1 + Ottano-M4_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + batt_mon_io.p-systems.power-monitor + 108b4bb7 + + + 1 + arspd_org.ardupilot.f405_MatekGPS + 158c7c49 + + + 1 + adsb_org.ardupilot.MatekL431-ADSB + 9c6f307f + + + 2 + Ottano-M3_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Ottano-M2_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + servo_.MKS-HBL6625:010 + b120233 + + + 2 + servo_.MKS-HBL6625:006 + b120233 + + + 2 + servo_.MKS-HBL6625:011 + b120233 + + + 2 + gps_org.ardupilot.HolybroG4_GPS + 6e519848 + + + 2 + arspd_org.ardupilot.f405_MatekGPS + 158c7c49 + + + + + + + + + + + + + From b6d29278ccc657c2e1350a01a8acec0441bee527 Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 14:17:42 +1100 Subject: [PATCH 04/13] CarbonixCommon: Add aircraft Ottano AC_2 model --- .../aircraft_configuration/Ottano_AC_2.xml | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_2.xml diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_2.xml b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_2.xml new file mode 100644 index 0000000000..ac180eaf46 --- /dev/null +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_2.xml @@ -0,0 +1,129 @@ + + + + + Ottano + AC_2 + + + CubeOrangePlus, + + Split CAN Architecture, + + Crystal CPNs, + CAN Servo, + adsb, + CAN GPS, + CAN Airspeed, + CAN Battery Monitor + + 1 + + + CubeOrangePlus-Ottano + cx_pilot_commit_id + arduplane.apj + + + + 1 + Ottano-M1_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Ottano-M5_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + servo_.MKS-HBL6625:010 + b120233 + + + 1 + servo_.MKS-HBL6625:006 + b120233 + + + 1 + servo_.MKS-HBL6625:011 + b120233 + + + 1 + gps_org.ardupilot.HolybroG4_GPS + 6e519848 + + + 1 + Ottano-M4_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + batt_mon_io.p-systems.power-monitor + 108b4bb7 + + + 1 + arspd_org.ardupilot.f405_MatekGPS + 158c7c49 + + + 1 + adsb_org.ardupilot.MatekL431-ADSB + 9c6f307f + + + 2 + Ottano-M3_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Ottano-M2_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + servo_.MKS-HBL6625:010 + b120233 + + + 2 + servo_.MKS-HBL6625:006 + b120233 + + + 2 + servo_.MKS-HBL6625:011 + b120233 + + + 2 + gps_org.ardupilot.HolybroG4_GPS + 6e519848 + + + 2 + arspd_org.ardupilot.f405_MatekGPS + 158c7c49 + + + + + + + + + + + + + From c0fa9ddb21ccb4ba51f2cdc0ca330e2a7a0f71fd Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 14:18:06 +1100 Subject: [PATCH 05/13] CarbonixCommon: Add aircraft Volanti AC_1 model --- .../aircraft_configuration/Volanti_AC_1.xml | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_1.xml diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_1.xml b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_1.xml new file mode 100644 index 0000000000..d511645f2e --- /dev/null +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_1.xml @@ -0,0 +1,99 @@ + + + + + Volanti + AC_1 + + + CubeOrange, + + Diagonal CAN Architecture, + + Non Crystal CPNs, + CAN Airspeed + + 1 + + + CubeOrange-Volanti + cx_pilot_commit_id + arduplane.apj + + + + 1 + Volanti-M1_CarbonixF405-no-crystal + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-M2_CarbonixF405-no-crystal + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-M5_CarbonixF405-no-crystal + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-RWing_CarbonixF405-no-crystal + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-LTail_CarbonixF405-no-crystal + cx_pilot_commit_id + AP_Periph.bin + + + 1 + arspd + cx_pilot_commit_id + + + 2 + Volanti-M3_CarbonixF405-no-crystal + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Volanti-M4_CarbonixF405-no-crystal + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Volanti-LWing_CarbonixF405-no-crystal + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Volanti-RTail_CarbonixF405-no-crystal + cx_pilot_commit_id + AP_Periph.bin + + + 2 + arspd + + + + + + + + + + + + + + From 60af63a683324f60ccbcfec0b94af941c9801957 Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 14:18:35 +1100 Subject: [PATCH 06/13] CarbonixCommon: Add aircraft Volanti AC_2 model --- .../aircraft_configuration/Volanti_AC_2.xml | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_2.xml diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_2.xml b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_2.xml new file mode 100644 index 0000000000..642714983d --- /dev/null +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_2.xml @@ -0,0 +1,110 @@ + + + + + Volanti + AC_2 + + + CubeOrange, + + Diagonal CAN Architecture, + + Crystal CPNs, + CAN GPS, + CAN Airspeed + + 1 + + + CubeOrange-Volanti + cx_pilot_commit_id + arduplane.apj + + + + 1 + Volanti-M1_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-M2_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-M5_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-RWing_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-LTail_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + gps_org.ardupilot.HolybroG4_GPS + 6e519848 + + + 1 + gps_org.ardupilot.HolybroG4_GPS + 6e519848 + + + 1 + arspd_org.ardupilot.f405_MatekGPS + 158c7c49 + + + 2 + Volanti-M3_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Volanti-M4_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Volanti-LWing_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Volanti-RTail_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + arspd_org.ardupilot.f405_MatekGPS + 158c7c49 + + + + + + + + + + + + + From cf6dd3c89596d3a03ed4e72348a99559f4620042 Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 14:18:43 +1100 Subject: [PATCH 07/13] CarbonixCommon: Add aircraft Volanti AC_3 model --- .../aircraft_configuration/Volanti_AC_3.xml | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_3.xml diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_3.xml b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_3.xml new file mode 100644 index 0000000000..263beca7b3 --- /dev/null +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_3.xml @@ -0,0 +1,110 @@ + + + + + Volanti + AC_3 + + + CubeOrangePlus, + + Diagonal CAN Architecture, + + Crystal CPNs, + CAN GPS, + CAN Airspeed + + 1 + + + CubeOrangePlus-Volanti + cx_pilot_commit_id + arduplane.apj + + + + 1 + Volanti-M1_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-M2_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-M5_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-RWing_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + Volanti-LTail_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 1 + gps_org.ardupilot.HolybroG4_GPS + 6e519848 + + + 1 + gps_org.ardupilot.HolybroG4_GPS + 6e519848 + + + 1 + arspd_org.ardupilot.f405_MatekGPS + 158c7c49 + + + 2 + Volanti-M3_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Volanti-M4_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Volanti-LWing_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + Volanti-RTail_CarbonixF405 + cx_pilot_commit_id + AP_Periph.bin + + + 2 + arspd_org.ardupilot.f405_MatekGPS + 158c7c49 + + + + + + + + + + + + + From 363eb4a821ea531d88f39aeed2bf47eb75705625 Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 14:19:07 +1100 Subject: [PATCH 08/13] hwdef: remove lua script files from Carbonix hwdef As the scripts are going to be used from CarbonixCommon and are going to be added to the hwdef files during build from CI. --- .../hwdef/CubeOrange-Ottano/scripts/cx_built_in_test.lua | 1 - .../hwdef/CubeOrange-Ottano/scripts/cx_led_driver.lua | 1 - .../hwdef/CubeOrange-Ottano/scripts/cx_vtol_info.lua | 1 - .../hwdef/CubeOrange-Volanti/scripts/cx_built_in_test.lua | 1 - .../hwdef/CubeOrange-Volanti/scripts/cx_led_driver.lua | 1 - .../hwdef/CubeOrange-Volanti/scripts/cx_vtol_info.lua | 1 - .../hwdef/CubeOrangePlus-Ottano/scripts/cx_built_in_test.lua | 1 - .../hwdef/CubeOrangePlus-Ottano/scripts/cx_led_driver.lua | 1 - .../hwdef/CubeOrangePlus-Ottano/scripts/cx_vtol_info.lua | 1 - .../hwdef/CubeOrangePlus-Volanti/scripts/cx_built_in_test.lua | 1 - .../hwdef/CubeOrangePlus-Volanti/scripts/cx_led_driver.lua | 1 - .../hwdef/CubeOrangePlus-Volanti/scripts/cx_vtol_info.lua | 1 - 12 files changed, 12 deletions(-) delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_built_in_test.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_led_driver.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_vtol_info.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_built_in_test.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_led_driver.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_vtol_info.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_built_in_test.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_led_driver.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_vtol_info.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_built_in_test.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_led_driver.lua delete mode 120000 libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_vtol_info.lua diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_built_in_test.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_built_in_test.lua deleted file mode 120000 index dbb50da048..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_built_in_test.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_built_in_test.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_led_driver.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_led_driver.lua deleted file mode 120000 index 71087fb1e4..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_led_driver.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_led_driver.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_vtol_info.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_vtol_info.lua deleted file mode 120000 index 5954f416ca..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Ottano/scripts/cx_vtol_info.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_vtol_info.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_built_in_test.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_built_in_test.lua deleted file mode 120000 index dbb50da048..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_built_in_test.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_built_in_test.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_led_driver.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_led_driver.lua deleted file mode 120000 index 71087fb1e4..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_led_driver.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_led_driver.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_vtol_info.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_vtol_info.lua deleted file mode 120000 index 5954f416ca..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrange-Volanti/scripts/cx_vtol_info.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_vtol_info.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_built_in_test.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_built_in_test.lua deleted file mode 120000 index dbb50da048..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_built_in_test.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_built_in_test.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_led_driver.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_led_driver.lua deleted file mode 120000 index 71087fb1e4..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_led_driver.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_led_driver.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_vtol_info.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_vtol_info.lua deleted file mode 120000 index 5954f416ca..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Ottano/scripts/cx_vtol_info.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_vtol_info.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_built_in_test.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_built_in_test.lua deleted file mode 120000 index dbb50da048..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_built_in_test.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_built_in_test.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_led_driver.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_led_driver.lua deleted file mode 120000 index 71087fb1e4..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_led_driver.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_led_driver.lua \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_vtol_info.lua b/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_vtol_info.lua deleted file mode 120000 index 5954f416ca..0000000000 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubeOrangePlus-Volanti/scripts/cx_vtol_info.lua +++ /dev/null @@ -1 +0,0 @@ -../../CarbonixCommon/scripts/cx_vtol_info.lua \ No newline at end of file From d977d8ebfe86d50f91970c9d5d5fe4298f35189d Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 14:21:06 +1100 Subject: [PATCH 09/13] gitignore: added ROMFS_custom and final-output --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 2769d31790..246842e76c 100644 --- a/.gitignore +++ b/.gitignore @@ -155,6 +155,8 @@ dumpstack_*out build.tmp.binaries/ tasklist.json modules/esp_idf +ROMFS_custom/ +final-output/ # Ignore Python virtual environments # from: https://github.com/github/gitignore/blob/4488915eec0b3a45b5c63ead28f286819c0917de/Python.gitignore#L125 From 0906cd0b6906f6af64bb278d1f41b99595fd029a Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 14:29:15 +1100 Subject: [PATCH 10/13] Ci:Carbonix_build Parallel Upload and AC package. This is a major change to the Carbonix CI build process. features: - Build periph, and Flight controller boards in parallel. - Generate Aircraft Configuration packages using xml file in CarbonixCommo/aircraft_configuration folder. This is donw using the new aircraft_config.py script. - Upload the generated AC packages to the S3 server in parallel. --- .github/workflows/carbonix_build.yml | 326 ++++++++++++++++----------- 1 file changed, 199 insertions(+), 127 deletions(-) diff --git a/.github/workflows/carbonix_build.yml b/.github/workflows/carbonix_build.yml index b4cd5acca3..a5c19afb46 100644 --- a/.github/workflows/carbonix_build.yml +++ b/.github/workflows/carbonix_build.yml @@ -135,8 +135,199 @@ concurrency: cancel-in-progress: true jobs: + setup-s3-path: + runs-on: ubuntu-22.04 + outputs: + s3_path: ${{ steps.set-s3-path.outputs.s3_path }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Extract firmware version, commit id, and branch name + id: extract_info + run: | + FIRMWARE_VERSION=$(grep -oP 'define AP_CUSTOM_FIRMWARE_STRING "\K(.*)(?=")' libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/version.inc) + COMMIT_ID=$(git rev-parse --short HEAD) + BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/}) + echo "firmware_version=$FIRMWARE_VERSION" >> $GITHUB_ENV + echo "commit_id=$COMMIT_ID" >> $GITHUB_ENV + echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV + shell: bash + + - name: Set S3 Path + id: set-s3-path + run: | + DATE_HR=$(date +%Y%m%d_%H%M) + if [ "${{ github.event_name }}" == "release" ]; then + PATH_TO_S3=s3://carbonix-firmware-release-files/Carbopilot_V2/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}/ + echo "Release to: $PATH_TO_S3" + elif [ "${{ github.event_name }}" == "push" ] && [[ "${{ env.branch_name }}" == CxPilot* ]]; then + PATH_TO_S3=s3://carbonix-firmware-dev-files/Carbopilot_V2/${{ env.branch_name }}/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}/ + echo "PUSH : $PATH_TO_S3" + elif [ "${{ github.event_name }}" == "pull_request" ]; then + PATH_TO_S3=s3://carbonix-firmware-dev-files/Carbopilot_V2/PR/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}_${{ github.event.pull_request.number }}/ + echo "PR : $PATH_TO_S3" + else + PATH_TO_S3="s3://carbonix-firmware-dev-files/Carbopilot_V2/Manual/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}/" + echo "Manual trigger or other: $PATH_TO_S3" + fi + echo "s3_path=${PATH_TO_S3}" >> $GITHUB_OUTPUT + shell: bash + + build-periph: + runs-on: ubuntu-22.04 + needs: setup-s3-path + container: ardupilot/ardupilot-dev-${{ matrix.toolchain }}:v0.1.3 + strategy: + fail-fast: false + matrix: + config: [ + CarbonixF405, + CarbonixF405-no-crystal + ] + + toolchain: [ chibios ] + gcc: [10] + exclude: + - gcc: 10 + toolchain: chibios-clang + + steps: + - uses: actions/checkout@v4 + + - name: Prepare ccache timestamp + id: ccache_cache_timestamp + run: | + NOW=$(date -u +"%F-%T") + echo "timestamp=${NOW}" >> $GITHUB_OUTPUT + + - name: ccache cache files + uses: actions/cache@v4 + with: + path: ~/.ccache + key: ${{github.workflow}}-ccache-${{matrix.config}}-${{ matrix.toolchain }}-${{ matrix.gcc }}-${{steps.ccache_cache_timestamp.outputs.timestamp}} + restore-keys: ${{github.workflow}}-ccache-${{matrix.config}}-${{ matrix.toolchain }}-${{ matrix.gcc }} + + - name: setup ccache + run: | + . .github/workflows/ccache.env + + - name: Install bash tools + run: | + sudo apt-get update + sudo apt-get -y install xxd + + - name: build ${{matrix.config}} + shell: bash + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + if [[ ${{ matrix.toolchain }} == "chibios-clang" ]]; then + export CC=clang + export CXX=clang++ + fi + PATH="/usr/lib/ccache:/opt/gcc-arm-none-eabi-${{matrix.gcc}}/bin:$PATH" + PATH="/github/home/.local/bin:$PATH" + Tools/Carbonix_scripts/carbonix_waf_build.sh ${{ matrix.config }} + ccache -s + ccache -z + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-periph-${{ matrix.config }} + path: output/ + + collect-aircraft-config-files: + runs-on: ubuntu-22.04 + needs: build-periph + outputs: + aircraft-config-files: ${{ steps.collect.outputs.aircraft-config-files }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq + + - name: Collect XML files + id: collect + run: | + xml_files=$(find libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration -name "*.xml" -print0 | xargs -0 echo | tr -d '\n' | jq -R -s -c 'split(" ")') + echo "aircraft-config-files=$xml_files" >> $GITHUB_OUTPUT + + process-ac: + runs-on: ubuntu-22.04 + needs: [collect-aircraft-config-files, setup-s3-path] + container: ardupilot/ardupilot-dev-${{ matrix.toolchain }}:v0.1.3 + strategy: + fail-fast: false + matrix: + xml_file: ${{ fromJson(needs.collect-aircraft-config-files.outputs.aircraft-config-files) }} + toolchain: [ chibios ] + gcc: [10] + exclude: + - gcc: 10 + toolchain: chibios-clang + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Install bash tools + run: | + sudo apt-get update + sudo apt-get -y install xxd + + - name: Download all build artifacts + uses: actions/download-artifact@v4 + with: + path: periph-build/ + + - name: List files + run: | + ls -la periph-build/*/ + + - name: Configure Git Safe Directory + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + + - name: Get Commit ID + id: get_commit_id + run: | + COMMIT_ID=$(git rev-parse --short HEAD) + echo "commit_id=$COMMIT_ID" >> $GITHUB_ENV + shell: sh -e {0} + + - name: Run aircraft_config.py + run: | + python Tools/Carbonix_scripts/aircraft_config.py ${{ matrix.xml_file }} ${{ env.commit_id }} + ls -la final-output/*/ || echo "No files found" + + - name: Install AWS CLI + run: | + apt-get update -y + DEBIAN_FRONTEND=noninteractive apt-get install -y curl unzip + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" + unzip -q awscliv2.zip + ./aws/install --update + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Upload to S3 + run: | + PATH_TO_S3=${{ needs.setup-s3-path.outputs.s3_path }} + echo "Uploading Artifacts to: $PATH_TO_S3" + aws s3 cp final-output/ $PATH_TO_S3 --recursive + build-sitl: runs-on: 'windows-latest' + needs: setup-s3-path steps: - uses: actions/checkout@v4 with: @@ -171,12 +362,14 @@ jobs: echo "export CCACHE_MAXSIZE=400M" >> ~/ccache.conf && source ~/ccache.conf && ccache -s + - name: ccache cache files uses: actions/cache@v4 with: path: D:/a/ardupilot/ardupilot/ccache key: ${{ steps.ccache_cache_timestamp.outputs.cache-key }}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}} restore-keys: ${{ steps.ccache_cache_timestamp.outputs.cache-key }}-ccache- # restore ccache from either previous build on this branch or on base branch + - name: Prepare Python environment env: PATH: /usr/bin:$(cygpath ${SYSTEMROOT})/system32 @@ -216,142 +409,21 @@ jobs: path: artifacts retention-days: 90 - build-apj: - runs-on: ubuntu-22.04 - container: ardupilot/ardupilot-dev-${{ matrix.toolchain }}:v0.1.3 - strategy: - fail-fast: false # don't cancel if a job from the matrix fails - matrix: - toolchain: [ - chibios, - #chibios-clang, - ] - gcc: [10] - exclude: - - gcc: 10 - toolchain: chibios-clang - - steps: - # git checkout the PR - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - # Put ccache into github cache for faster build - - name: Prepare ccache timestamp - id: ccache_cache_timestamp - run: | - NOW=$(date -u +"%F-%T") - echo "timestamp=${NOW}" >> $GITHUB_OUTPUT - - name: ccache cache files - uses: actions/cache@v4 - with: - path: ~/.ccache - key: ${{github.workflow}}-ccache-${{ matrix.toolchain }}-${{ matrix.gcc }}-${{steps.ccache_cache_timestamp.outputs.timestamp}} - restore-keys: ${{github.workflow}}-ccache-${{ matrix.toolchain }}-${{ matrix.gcc }} # restore ccache from either previous build on this branch or on master - - name: setup ccache - run: | - . .github/workflows/ccache.env - - - name: build - shell: bash - run: | - git config --global --add safe.directory ${GITHUB_WORKSPACE} - if [[ ${{ matrix.toolchain }} == "chibios-clang" ]]; then - export CC=clang - export CXX=clang++ - fi - PATH="/usr/lib/ccache:/opt/gcc-arm-none-eabi-${{matrix.gcc}}/bin:$PATH" - PATH="/github/home/.local/bin:$PATH" - Tools/Carbonix_scripts/carbonix_waf_build.sh - ccache -s - ccache -z - - - name: Check build files - id: check_files - uses: andstor/file-existence-action@v2 - with: - files: "build/CubeOrange/*, build/CubeOrangePlus/*, build/CubeOrange-Volanti/*, build/CubeOrangePlus-Volanti/*, build/CubeOrange-Ottano/*, build/CubeOrangePlus-Ottano/*, build/CarbonixF405/*, build/CarbonixF405-no-crystal/*" - fail: true - - name: Gather build output - run: | - mkdir -p temp/others - for dir in CubeOrange CubeOrangePlus CubeOrange-Volanti CubeOrangePlus-Volanti CubeOrange-Ottano CubeOrangePlus-Ottano CarbonixF405 CarbonixF405-no-crystal; do - mkdir -p temp/others/$dir/bin - cp -vr build/$dir/bin/* temp/others/$dir/bin/ - done - cp -vr output/* temp/ - mv temp/others/CubeOrange-Volanti temp/Volanti - mv temp/others/CubeOrangePlus-Volanti temp/Volanti - mv temp/others/CubeOrange-Ottano temp/Ottano - mv temp/others/CubeOrangePlus-Ottano temp/Ottano - if [ -d "ArduPlane/ReleaseNotes.txt" ]; then - cp -v ArduPlane/ReleaseNotes.txt temp/ - else - echo "ReleaseNotes.txt File does not exist" - fi - if [ -d "libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/payloads" ]; then - cp -vr libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/payloads temp/ - else - echo "payloads Folder does not exist" - fi - shell: sh -e {0} - - name: Archive production artifacts - uses: actions/upload-artifact@v4 - with: - name: apj - path: temp - retention-days: 90 - - upload: - runs-on: ubuntu-22.04 - needs: [build-apj, build-sitl] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Extract firmware version, commit id, and branch name - id: extract_info - run: | - FIRMWARE_VERSION=$(grep -oP 'define AP_CUSTOM_FIRMWARE_STRING "\K(.*)(?=")' libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/version.inc) - COMMIT_ID=$(git rev-parse --short HEAD) - BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/}) - echo "firmware_version=$FIRMWARE_VERSION" >> $GITHUB_ENV - echo "commit_id=$COMMIT_ID" >> $GITHUB_ENV - echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV - shell: sh -e {0} - - - name: Download APJ build + - name: Download Artifacts uses: actions/download-artifact@v4 with: - name: apj path: temp - - name: Download SITL build - uses: actions/download-artifact@v4 - with: - name: sitl - path: temp/sitl - - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} aws-region: us-east-1 - + - name: Upload artifacts to S3 + shell: pwsh run: | - DATE_HR=$(date +%Y%m%d_%H%M) - if ${{ github.event_name == 'release' }}; then - PATH_TO_S3=s3://carbonix-firmware-release-files/Carbopilot_V2/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}/ - echo "Uploading to: $PATH_TO_S3" - aws s3 cp temp/ $PATH_TO_S3 --recursive - elif ${{ github.event_name == 'push' && startsWith(env.branch_name, 'CxPilot') }}; then - PATH_TO_S3=s3://carbonix-firmware-dev-files/Carbopilot_V2/${{ env.branch_name }}/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}/ - echo "Uploading to: $PATH_TO_S3" - aws s3 cp temp/ $PATH_TO_S3 --recursive - elif ${{ github.event_name == 'pull_request' }}; then - PATH_TO_S3=s3://carbonix-firmware-dev-files/Carbopilot_V2/PR/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}_${{ github.event.pull_request.number }}/ - echo "Uploading to: $PATH_TO_S3" - aws s3 cp temp/ $PATH_TO_S3 --recursive - fi + $env:PATH_TO_S3 = '${{ needs.setup-s3-path.outputs.s3_path }}' + echo "Uploading to: $env:PATH_TO_S3" + aws s3 cp temp/ $env:PATH_TO_S3 --recursive From 68baa81a53ddfb4a19ab3459e5398967af21cc7b Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 14:33:56 +1100 Subject: [PATCH 11/13] Ci:carbonix_build Skip build on label 'SKIP_BUILD' --- .github/workflows/carbonix_build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/carbonix_build.yml b/.github/workflows/carbonix_build.yml index a5c19afb46..ba815b3251 100644 --- a/.github/workflows/carbonix_build.yml +++ b/.github/workflows/carbonix_build.yml @@ -137,6 +137,7 @@ concurrency: jobs: setup-s3-path: runs-on: ubuntu-22.04 + if: ${{ !contains(github.event.pull_request.labels.*.name, 'SKIP_BUILD') }} outputs: s3_path: ${{ steps.set-s3-path.outputs.s3_path }} steps: @@ -176,6 +177,7 @@ jobs: build-periph: runs-on: ubuntu-22.04 + if: ${{ !contains(github.event.pull_request.labels.*.name, 'SKIP_BUILD') }} needs: setup-s3-path container: ardupilot/ardupilot-dev-${{ matrix.toolchain }}:v0.1.3 strategy: @@ -238,6 +240,7 @@ jobs: path: output/ collect-aircraft-config-files: + if: ${{ !contains(github.event.pull_request.labels.*.name, 'SKIP_BUILD') }} runs-on: ubuntu-22.04 needs: build-periph outputs: @@ -256,6 +259,7 @@ jobs: echo "aircraft-config-files=$xml_files" >> $GITHUB_OUTPUT process-ac: + if: ${{ !contains(github.event.pull_request.labels.*.name, 'SKIP_BUILD') }} runs-on: ubuntu-22.04 needs: [collect-aircraft-config-files, setup-s3-path] container: ardupilot/ardupilot-dev-${{ matrix.toolchain }}:v0.1.3 @@ -327,6 +331,7 @@ jobs: build-sitl: runs-on: 'windows-latest' + if: ${{ !contains(github.event.pull_request.labels.*.name, 'SKIP_BUILD') }} needs: setup-s3-path steps: - uses: actions/checkout@v4 From 905fddfa426e091f9ffa901386b2c4b6f6734b0c Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 14:34:51 +1100 Subject: [PATCH 12/13] Ci: carbonix_build commit id fix for PR. This fixes the bug where the PR commit in the folder name does not matches the one in the build. --- .github/workflows/carbonix_build.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/carbonix_build.yml b/.github/workflows/carbonix_build.yml index ba815b3251..c48f7a245c 100644 --- a/.github/workflows/carbonix_build.yml +++ b/.github/workflows/carbonix_build.yml @@ -143,6 +143,9 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + # PR runs, by default, create a merge commit and then checkout the merge commit. We don't want that. + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} - name: Extract firmware version, commit id, and branch name id: extract_info @@ -196,6 +199,10 @@ jobs: steps: - uses: actions/checkout@v4 + with: + # PR runs, by default, create a merge commit and then checkout the merge commit. We don't want that. + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} + submodules: 'recursive' - name: Prepare ccache timestamp id: ccache_cache_timestamp @@ -248,6 +255,9 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + # PR runs, by default, create a merge commit and then checkout the merge commit. We don't want that. + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} - name: Install jq run: sudo apt-get update && sudo apt-get install -y jq @@ -276,6 +286,8 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: + # PR runs, by default, create a merge commit and then checkout the merge commit. We don't want that. + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} submodules: 'recursive' - name: Install bash tools @@ -336,6 +348,8 @@ jobs: steps: - uses: actions/checkout@v4 with: + # PR runs, by default, create a merge commit and then checkout the merge commit. We don't want that. + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} submodules: 'recursive' - name: Prepare ccache timestamp id: ccache_cache_timestamp From 3fd27a2813d90bdfec8df74d53f74909129ff825 Mon Sep 17 00:00:00 2001 From: Loki077 Date: Fri, 27 Dec 2024 16:10:25 +1100 Subject: [PATCH 13/13] CarbonixCommon: add lua script in aircraft models. Add lua script in aircraft models to allow for customisation of the aircraft configuration. T his willl allow us to individualise the lua script for each aircraft model and also rename the lua script if needed. --- .../aircraft_configuration/Ottano_AC_1.xml | 14 ++++++++++++++ .../aircraft_configuration/Ottano_AC_2.xml | 14 ++++++++++++++ .../aircraft_configuration/Volanti_AC_1.xml | 14 ++++++++++++++ .../aircraft_configuration/Volanti_AC_2.xml | 14 ++++++++++++++ .../aircraft_configuration/Volanti_AC_3.xml | 14 ++++++++++++++ 5 files changed, 70 insertions(+) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_1.xml b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_1.xml index de51ef2f0e..b1d75ed9ae 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_1.xml +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_1.xml @@ -126,4 +126,18 @@ + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_built_in_test.lua + cx_built_in_test.lua + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_led_driver.lua + cx_led_driver.lua + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_vtol_info.lua + cx_vtol_info.lua + + diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_2.xml b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_2.xml index ac180eaf46..55fdb65a92 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_2.xml +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Ottano_AC_2.xml @@ -126,4 +126,18 @@ + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_built_in_test.lua + cx_built_in_test.lua + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_led_driver.lua + cx_led_driver.lua + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_vtol_info.lua + cx_vtol_info.lua + + diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_1.xml b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_1.xml index d511645f2e..aa31ad8db9 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_1.xml +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_1.xml @@ -96,4 +96,18 @@ + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_built_in_test.lua + cx_built_in_test.lua + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_led_driver.lua + cx_led_driver.lua + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_vtol_info.lua + cx_vtol_info.lua + + diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_2.xml b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_2.xml index 642714983d..defebe67cd 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_2.xml +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_2.xml @@ -107,4 +107,18 @@ + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_built_in_test.lua + cx_built_in_test.lua + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_led_driver.lua + cx_led_driver.lua + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_vtol_info.lua + cx_vtol_info.lua + + diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_3.xml b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_3.xml index 263beca7b3..ca8e84e05b 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_3.xml +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/aircraft_configuration/Volanti_AC_3.xml @@ -107,4 +107,18 @@ + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_built_in_test.lua + cx_built_in_test.lua + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_led_driver.lua + cx_led_driver.lua + + + libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_vtol_info.lua + cx_vtol_info.lua + +