diff --git a/ROMFS/performance-test/CMakeLists.txt b/ROMFS/performance-test/CMakeLists.txt new file mode 100644 index 000000000000..56c6235ee2e0 --- /dev/null +++ b/ROMFS/performance-test/CMakeLists.txt @@ -0,0 +1,34 @@ +############################################################################ +# +# Copyright (c) 2025 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +add_subdirectory(init.d) diff --git a/ROMFS/performance-test/init.d/CMakeLists.txt b/ROMFS/performance-test/init.d/CMakeLists.txt new file mode 100644 index 000000000000..8a08b20ab2da --- /dev/null +++ b/ROMFS/performance-test/init.d/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2025 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +px4_add_romfs_files( + rcS +) diff --git a/ROMFS/performance-test/init.d/rcS b/ROMFS/performance-test/init.d/rcS new file mode 100644 index 000000000000..d79fe58c7674 --- /dev/null +++ b/ROMFS/performance-test/init.d/rcS @@ -0,0 +1,68 @@ +#!/bin/sh +# Un comment and use set +e to ignore and set -e to enable 'exit on error control' +set +e +# Un comment the line below to help debug scripts by printing a trace of the script commands +#set -x +# PX4FMU startup script. +# +# NOTE: environment variable references: +# If the dollar sign ('$') is followed by a left bracket ('{') then the +# variable name is terminated with the right bracket character ('}'). +# Otherwise, the variable name goes to the end of the argument. +# +# +# NOTE: COMMENT LINES ARE REMOVED BEFORE STORED IN ROMFS. +# +#------------------------------------------------------------------------------ +set R / + +# +# Print full system version. +# +ver all + +# +# Set the parameter file the board supports params on +# MTD device. +# +if mft query -q -k MTD -s MTD_PARAMETERS -v /fs/mtd_params +then + set PARAM_FILE /fs/mtd_params +fi + +# +# Load parameters. +# +# if the board has a storage for (factory) calibration data +if mft query -q -k MTD -s MTD_CALDATA -v /fs/mtd_caldata +then + param load /fs/mtd_caldata +fi + +# +# Load parameters. +# +param select $PARAM_FILE +if ! param load +then + param reset_all +fi + +# +# Try to mount the microSD card. +# +mount -t vfat /dev/mmcsd0 /fs/microsd +if [ $? = 0 ] +then + echo "SD card mounted at /fs/microsd" +else + echo "No SD card found" +fi + +unset R + +echo "" +echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" +echo "!!!!!! This is the PERFORMANCE TESTING firmware! WARNs and ERRORs are expected! !!!!!" +echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" +echo "" diff --git a/Tools/ci/generate_board_targets_json.py b/Tools/ci/generate_board_targets_json.py index 218862cecdb0..5749a988d1e5 100755 --- a/Tools/ci/generate_board_targets_json.py +++ b/Tools/ci/generate_board_targets_json.py @@ -69,7 +69,7 @@ def process_target(px4board_file, target_name): group = None if px4board_file.endswith("default.px4board") or \ - px4board_file.endswith("recovery.px4board") or \ + px4board_file.endswith("performance-test.px4board") or \ px4board_file.endswith("bootloader.px4board"): kconf.load_config(px4board_file, replace=True) else: # Merge config with default.px4board diff --git a/Tools/kconfig/allyesconfig.py b/Tools/kconfig/allyesconfig.py index 2c0f58d75a66..e432c52ec0fa 100644 --- a/Tools/kconfig/allyesconfig.py +++ b/Tools/kconfig/allyesconfig.py @@ -74,6 +74,7 @@ 'SYSTEMCMDS_I2CDETECT', # Not supported in SITL 'SYSTEMCMDS_DMESG', # Not supported in SITL 'SYSTEMCMDS_USB_CONNECTED', # Not supported in SITL + 'SYSTEMCMDS_MFT_CFG', # Not supported in SITL 'MODULES_SPACECRAFT', # Clashes with Control Allocation (mom's spaghetti code) ] diff --git a/boards/px4/fmu-v5x/performance-test.px4board b/boards/px4/fmu-v5x/performance-test.px4board new file mode 100644 index 000000000000..5e69dd7ae311 --- /dev/null +++ b/boards/px4/fmu-v5x/performance-test.px4board @@ -0,0 +1,31 @@ +CONFIG_BOARD_TOOLCHAIN="arm-none-eabi" +CONFIG_BOARD_ARCHITECTURE="cortex-m7" +CONFIG_BOARD_ETHERNET=y +CONFIG_BOARD_SERIAL_GPS1="/dev/ttyS0" +CONFIG_BOARD_SERIAL_GPS2="/dev/ttyS7" +CONFIG_BOARD_SERIAL_TEL1="/dev/ttyS6" +CONFIG_BOARD_SERIAL_TEL2="/dev/ttyS4" +CONFIG_BOARD_SERIAL_TEL3="/dev/ttyS1" +CONFIG_BOARD_SERIAL_EXT2="/dev/ttyS3" +CONFIG_BOARD_ROMFSROOT="performance-test" +CONFIG_DRIVERS_ADC_BOARD_ADC=y +CONFIG_SYSTEMCMDS_DMESG=y +CONFIG_SYSTEMCMDS_GPIO=y +CONFIG_SYSTEMCMDS_HARDFAULT_LOG=y +CONFIG_SYSTEMCMDS_I2CDETECT=y +CONFIG_SYSTEMCMDS_LED_CONTROL=y +CONFIG_SYSTEMCMDS_MFT=y +CONFIG_SYSTEMCMDS_MTD=y +CONFIG_SYSTEMCMDS_MFT_CFG=y +CONFIG_SYSTEMCMDS_PARAM=y +CONFIG_SYSTEMCMDS_PERF=y +CONFIG_SYSTEMCMDS_REBOOT=y +CONFIG_SYSTEMCMDS_SD_BENCH=y +CONFIG_SYSTEMCMDS_SD_STRESS=y +CONFIG_SYSTEMCMDS_SERIAL_TEST=y +CONFIG_SYSTEMCMDS_SYSTEM_TIME=y +CONFIG_SYSTEMCMDS_TOP=y +CONFIG_SYSTEMCMDS_TOPIC_LISTENER=y +CONFIG_SYSTEMCMDS_UORB=y +CONFIG_SYSTEMCMDS_VER=y +CONFIG_SYSTEMCMDS_WORK_QUEUE=y diff --git a/boards/px4/fmu-v6x/performance-test.px4board b/boards/px4/fmu-v6x/performance-test.px4board new file mode 100644 index 000000000000..5e69dd7ae311 --- /dev/null +++ b/boards/px4/fmu-v6x/performance-test.px4board @@ -0,0 +1,31 @@ +CONFIG_BOARD_TOOLCHAIN="arm-none-eabi" +CONFIG_BOARD_ARCHITECTURE="cortex-m7" +CONFIG_BOARD_ETHERNET=y +CONFIG_BOARD_SERIAL_GPS1="/dev/ttyS0" +CONFIG_BOARD_SERIAL_GPS2="/dev/ttyS7" +CONFIG_BOARD_SERIAL_TEL1="/dev/ttyS6" +CONFIG_BOARD_SERIAL_TEL2="/dev/ttyS4" +CONFIG_BOARD_SERIAL_TEL3="/dev/ttyS1" +CONFIG_BOARD_SERIAL_EXT2="/dev/ttyS3" +CONFIG_BOARD_ROMFSROOT="performance-test" +CONFIG_DRIVERS_ADC_BOARD_ADC=y +CONFIG_SYSTEMCMDS_DMESG=y +CONFIG_SYSTEMCMDS_GPIO=y +CONFIG_SYSTEMCMDS_HARDFAULT_LOG=y +CONFIG_SYSTEMCMDS_I2CDETECT=y +CONFIG_SYSTEMCMDS_LED_CONTROL=y +CONFIG_SYSTEMCMDS_MFT=y +CONFIG_SYSTEMCMDS_MTD=y +CONFIG_SYSTEMCMDS_MFT_CFG=y +CONFIG_SYSTEMCMDS_PARAM=y +CONFIG_SYSTEMCMDS_PERF=y +CONFIG_SYSTEMCMDS_REBOOT=y +CONFIG_SYSTEMCMDS_SD_BENCH=y +CONFIG_SYSTEMCMDS_SD_STRESS=y +CONFIG_SYSTEMCMDS_SERIAL_TEST=y +CONFIG_SYSTEMCMDS_SYSTEM_TIME=y +CONFIG_SYSTEMCMDS_TOP=y +CONFIG_SYSTEMCMDS_TOPIC_LISTENER=y +CONFIG_SYSTEMCMDS_UORB=y +CONFIG_SYSTEMCMDS_VER=y +CONFIG_SYSTEMCMDS_WORK_QUEUE=y diff --git a/cmake/kconfig.cmake b/cmake/kconfig.cmake index 7eaaa00d676c..a5c79ad131cc 100644 --- a/cmake/kconfig.cmake +++ b/cmake/kconfig.cmake @@ -35,7 +35,7 @@ if(EXISTS ${BOARD_DEFCONFIG}) # Depend on BOARD_DEFCONFIG so that we reconfigure on config change set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${BOARD_DEFCONFIG}) - if(${LABEL} MATCHES "default" OR ${LABEL} MATCHES "recovery" OR ${LABEL} MATCHES "bootloader" OR ${LABEL} MATCHES "canbootloader") + if(${LABEL} MATCHES "default" OR ${LABEL} MATCHES "performance-test" OR ${LABEL} MATCHES "bootloader" OR ${LABEL} MATCHES "canbootloader") # Generate boardconfig from saved defconfig execute_process( COMMAND ${CMAKE_COMMAND} -E env ${COMMON_KCONFIG_ENV_SETTINGS} diff --git a/src/systemcmds/mft_cfg/CMakeLists.txt b/src/systemcmds/mft_cfg/CMakeLists.txt new file mode 100644 index 000000000000..ca1a3b5544e2 --- /dev/null +++ b/src/systemcmds/mft_cfg/CMakeLists.txt @@ -0,0 +1,39 @@ +############################################################################ +# +# Copyright (c) 2025 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__mft_cfg + MAIN mft_cfg + COMPILE_FLAGS + SRCS + mft_cfg.cpp + ) diff --git a/src/systemcmds/mft_cfg/Kconfig b/src/systemcmds/mft_cfg/Kconfig new file mode 100644 index 000000000000..85091c6ff3b3 --- /dev/null +++ b/src/systemcmds/mft_cfg/Kconfig @@ -0,0 +1,5 @@ +menuconfig SYSTEMCMDS_MFT_CFG + bool "mft_cfg" + default n + ---help--- + Enable support for mft_cfg diff --git a/src/systemcmds/mft_cfg/mft_cfg.cpp b/src/systemcmds/mft_cfg/mft_cfg.cpp new file mode 100644 index 000000000000..c87c4e6bdc02 --- /dev/null +++ b/src/systemcmds/mft_cfg/mft_cfg.cpp @@ -0,0 +1,239 @@ +/**************************************************************************** +* +* Copyright (c) 2025 PX4 Development Team. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* 3. Neither the name PX4 nor the names of its contributors may be +* used to endorse or promote products derived from this software +* without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************/ + +/** +* @file mft_cfg.c +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static void usage(const char *reason) +{ + if (reason != nullptr) { + printf("%s\n\n", reason); + } + + PRINT_MODULE_DESCRIPTION("Tool to set and get manifest configuration"); + + PRINT_MODULE_USAGE_NAME("mft_cfg", "command"); + PRINT_MODULE_USAGE_COMMAND_DESCR("get", "get manifest configuration"); + PRINT_MODULE_USAGE_COMMAND_DESCR("set", "set manifest configuration"); + PRINT_MODULE_USAGE_COMMAND_DESCR("reset", "reset manifest configuration"); + PRINT_MODULE_USAGE_ARG("hwver|hwrev", "Select type: MTD_MTF_VER|MTD_MTF_REV", false); + PRINT_MODULE_USAGE_PARAM_INT('i', 0x10, 0x10, 0xFFFF, + "argument to set extended hardware id (id == version for , id == revision for )", false); + +} + + +static int print_extended_id(const char *type) +{ + mtd_mft_v0_t mtd_mft; + mtd_mft.version.id = MTD_MFT_v0; + mtd_mft.hw_extended_id = -1; + + const char *path = nullptr; + int ret_val = px4_mtd_query(type, NULL, &path); + + if (ret_val != PX4_OK) { + PX4_ERR("Can't get mtd query (%s, %i)", type, ret_val); + + } else { + + ret_val = board_get_eeprom_hw_info(path, (mtd_mft_t *)&mtd_mft); + + if (ret_val == PX4_OK) { + PX4_INFO("%s, hw_extended_id = %#x", type, mtd_mft.hw_extended_id); + + } else { + + if (ret_val == -EPROTO) { + PX4_ERR("Manifest data may not exist for %s", path); + + } else { + PX4_ERR("Can't read hw_extended_id from EEPROM (%s, %i)", type, ret_val); + } + } + } + + return ret_val; +} + +extern "C" __EXPORT int mft_cfg_main(int argc, char *argv[]) +{ + if ((argc == 2) && (!strcmp(argv[1], "get"))) { + + char type_ver[] = "MTD_MFT_VER"; + char type_rev[] = "MTD_MFT_REV"; + + print_extended_id(type_ver); + print_extended_id(type_rev); + + return 0; + + } else if (argc >= 3) { + + int ret_val = -1; + const char *path = nullptr; + bool arg_exist = false; + + for (int i = 2; i < argc; ++i) { + if (strcmp("hwver", argv[i]) == 0) { + ret_val = px4_mtd_query("MTD_MFT_VER", NULL, &path); + arg_exist = true; + break; + } + + if (strcmp("hwrev", argv[i]) == 0) { + ret_val = px4_mtd_query("MTD_MFT_REV", NULL, &path); + arg_exist = true; + break; + } + } + + if (!arg_exist) { + PX4_ERR("Missing or arguments'"); + return 1; + } + + if (ret_val != PX4_OK) { + PX4_ERR("Can't get mtd query (%i)", ret_val); + return 1; + } + + mtd_mft_v0_t mtd_mft; + mtd_mft.version.id = MTD_MFT_v0; + mtd_mft.hw_extended_id = -1; + + if (!strcmp(argv[1], "set")) { + if (argc == 5) { + + const char *myoptarg = NULL; + int ch = 0; + int myoptind = 1; + int hw_extended_id = -1; + + while ((ch = px4_getopt(argc, argv, "i:", &myoptind, &myoptarg)) != EOF) { + switch (ch) { + case 'i': + hw_extended_id = strtol(myoptarg, NULL, 0); + break; + + default: + PX4_ERR("To set id use '-i x'"); + break; + } + } + + if (hw_extended_id != -1) { + + mtd_mft.hw_extended_id = (uint16_t)hw_extended_id; + + ret_val = board_set_eeprom_hw_info(path, (mtd_mft_t *)&mtd_mft); + + if (ret_val != PX4_OK) { + PX4_ERR("Can't write to EEPROM (%i)", ret_val); + + } else { + board_get_eeprom_hw_info(path, (mtd_mft_t *)&mtd_mft); + PX4_INFO("New hw_extended_id = %#x", mtd_mft.hw_extended_id); + } + } + + } else { + PX4_ERR("Not enough arguments, try 'mft_cfg set hwver -i x'"); + return 1; + } + + return 0; + } + + if (!strcmp(argv[1], "get")) { + + ret_val = board_get_eeprom_hw_info(path, (mtd_mft_t *)&mtd_mft); + + if (ret_val == PX4_OK) { + PX4_INFO("hw_extended_id = %#x", mtd_mft.hw_extended_id); + + } else { + + if (ret_val == -EPROTO) { + PX4_ERR("Manifest data may not exist for %s", path); + + } else { + PX4_ERR("Can't read from EEPROM (%s, %i)", path, ret_val); + } + + return 1; + } + + return 0; + } + + if (!strcmp(argv[1], "reset")) { + + uint8_t buffer[64]; + memset(buffer, 0xFF, sizeof(buffer)); + + int fd = open(path, O_WRONLY); + + if (fd == -1) { + PX4_ERR("Failed to open partition %s", path); + return 1; + } + + while (write(fd, buffer, sizeof(buffer)) == sizeof(buffer)) {} + + PX4_INFO("Reset for %s completed. To remove manifest data from RAM, a reboot is required.", path); + close(fd); + + return 0; + } + + } else { + usage("Error, not enough parameters."); + return 1; + } + + return 0; +}