diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 034f46e2b8..8065709d86 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,22 +1,9 @@ - ### Solved Problem -When ... I found that ... - Fixes #{Github issue ID} ### Solution -- Add ... for ... -- Refactor ... ### Changelog Entry For release notes: @@ -27,11 +14,10 @@ Documentation: Need to clarify page ... / done, read docs.px4.io/... ``` ### Alternatives -We could also ... ### Test coverage -- Unit/integration test: ... -- Simulation/hardware testing logs: https://review.px4.io/ ### Context Related links, screenshot before/after, video + +--> diff --git a/.github/workflows/flash_analysis.yml b/.github/workflows/flash_analysis.yml index 143d54790c..7f126352ab 100644 --- a/.github/workflows/flash_analysis.yml +++ b/.github/workflows/flash_analysis.yml @@ -54,6 +54,7 @@ jobs: run: | make clean make distclean + make submodulesclean - name: If it's a PR checkout the base branch if: ${{ github.event.pull_request }} diff --git a/.github/workflows/itcm_check.yml b/.github/workflows/itcm_check.yml index 5a1b0ecddc..767f69aa7c 100644 --- a/.github/workflows/itcm_check.yml +++ b/.github/workflows/itcm_check.yml @@ -41,6 +41,10 @@ jobs: scripts: > boards/nxp/tropic-community/nuttx-config/scripts/itcm_functions_includes.ld boards/nxp/tropic-community/nuttx-config/scripts/itcm_static_functions.ld + - target: nxp_mr-tropic + scripts: > + boards/nxp/mr-tropic/nuttx-config/scripts/itcm_functions_includes.ld + boards/nxp/mr-tropic/nuttx-config/scripts/itcm_static_functions.ld steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/sitl_tests.yml b/.github/workflows/sitl_tests.yml index 68e16bed71..813e78073b 100644 --- a/.github/workflows/sitl_tests.yml +++ b/.github/workflows/sitl_tests.yml @@ -118,7 +118,7 @@ jobs: PX4_HOME_LON: ${{matrix.config.longitude}} PX4_HOME_ALT: ${{matrix.config.altitude}} PX4_CMAKE_BUILD_TYPE: ${{matrix.config.build_type}} - run: test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 10 --abort-early --model ${{matrix.config.model}} --upload test/mavsdk_tests/configs/sitl.json --verbose --force-color + run: test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 10 --abort-early --model ${{matrix.config.model}} test/mavsdk_tests/configs/sitl.json --verbose --force-color timeout-minutes: 45 - name: Upload failed logs diff --git a/.vscode/cmake-variants.yaml b/.vscode/cmake-variants.yaml index b40113f5da..71aec979d4 100644 --- a/.vscode/cmake-variants.yaml +++ b/.vscode/cmake-variants.yaml @@ -241,6 +241,16 @@ CONFIG: buildType: MinSizeRel settings: CONFIG: ark_fpv_default + ark_mag_canbootloader: + short: ark_mag_canbootloader + buildType: MiniSizeRel + settings: + CONFIG: ark_mag_canbootloader + ark_mag_default: + short: ark_mag_default + buildType: MiniSizeRel + settings: + CONFIG: ark_mag_default ark_pi6x_bootloader: short: ark_pi6x_bootloader buildType: MinSizeRel @@ -411,6 +421,16 @@ CONFIG: buildType: MinSizeRel settings: CONFIG: micoair_h743-v2_default + micoair_h743-lite_bootloader: + short: micoair_h743-lite_bootloader + buildType: MinSizeRel + settings: + CONFIG: micoair_h743-lite_bootloader + micoair_h743-lite_default: + short: micoair_h743-lite + buildType: MinSizeRel + settings: + CONFIG: micoair_h743-lite_default modalai_fc-v1_default: short: modalai_fc-v1 buildType: MinSizeRel @@ -461,6 +481,16 @@ CONFIG: buildType: MinSizeRel settings: CONFIG: nxp_mr-canhubk3_fmu + nxp_mr-tropic_default: + short: nxp_mr-tropic_default + buildType: MinSizeRel + settings: + CONFIG: nxp_mr-tropic_default + nxp_mr-tropic_bootloader: + short: nxp_mr-tropic_bootloader + buildType: MinSizeRel + settings: + CONFIG: nxp_mr-tropic_bootloader nxp_tropic-community_default: short: nxp_tropic-community_default buildType: MinSizeRel diff --git a/Makefile b/Makefile index 80e0ee1f64..3639bbdee4 100644 --- a/Makefile +++ b/Makefile @@ -346,6 +346,7 @@ bootloaders_update: \ micoair_h743_bootloader \ micoair_h743-aio_bootloader \ micoair_h743-v2_bootloader \ + micoair_h743-lite_bootloader \ modalai_fc-v2_bootloader \ mro_ctrl-zero-classic_bootloader \ mro_ctrl-zero-h7_bootloader \ diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/10041_sihsim_airplane b/ROMFS/px4fmu_common/init.d-posix/airframes/10041_sihsim_airplane index 1853699171..100af65943 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/10041_sihsim_airplane +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/10041_sihsim_airplane @@ -27,7 +27,6 @@ param set-default SIH_KDV 0.2 param set-default SIH_VEHICLE_TYPE 1 # sih as fixed wing param set-default RWTO_TKOFF 1 # enable takeoff from runway (as opposed to launched) -param set-default CA_AIRFRAME 1 param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1030_gazebo-classic_plane b/ROMFS/px4fmu_common/init.d-posix/airframes/1030_gazebo-classic_plane index dc45a34029..81df6295d2 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1030_gazebo-classic_plane +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1030_gazebo-classic_plane @@ -44,8 +44,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1031_gazebo-classic_plane_cam b/ROMFS/px4fmu_common/init.d-posix/airframes/1031_gazebo-classic_plane_cam index 695f851ff0..64a0055323 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1031_gazebo-classic_plane_cam +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1031_gazebo-classic_plane_cam @@ -46,8 +46,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1032_gazebo-classic_plane_catapult b/ROMFS/px4fmu_common/init.d-posix/airframes/1032_gazebo-classic_plane_catapult index 12e828c08c..16e6648ad7 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1032_gazebo-classic_plane_catapult +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1032_gazebo-classic_plane_catapult @@ -46,8 +46,6 @@ param set-default MIS_TAKEOFF_ALT 30 param set-default NAV_ACC_RAD 15 param set-default NAV_DLL_ACT 2 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1033_jsbsim_rascal b/ROMFS/px4fmu_common/init.d-posix/airframes/1033_jsbsim_rascal index ef9df5af98..75e1009f23 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1033_jsbsim_rascal +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1033_jsbsim_rascal @@ -31,8 +31,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 param set-default RWTO_PSP 8 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1034_flightgear_rascal-electric b/ROMFS/px4fmu_common/init.d-posix/airframes/1034_flightgear_rascal-electric index ef9df5af98..75e1009f23 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1034_flightgear_rascal-electric +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1034_flightgear_rascal-electric @@ -31,8 +31,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 param set-default RWTO_PSP 8 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1035_gazebo-classic_techpod b/ROMFS/px4fmu_common/init.d-posix/airframes/1035_gazebo-classic_techpod index 68bb142094..db036041e5 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1035_gazebo-classic_techpod +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1035_gazebo-classic_techpod @@ -30,8 +30,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1036_jsbsim_malolo b/ROMFS/px4fmu_common/init.d-posix/airframes/1036_jsbsim_malolo index ef9df5af98..75e1009f23 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1036_jsbsim_malolo +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1036_jsbsim_malolo @@ -31,8 +31,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 param set-default RWTO_PSP 8 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1037_gazebo-classic_believer b/ROMFS/px4fmu_common/init.d-posix/airframes/1037_gazebo-classic_believer index 0a8343a4c8..cb39c54ffd 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1037_gazebo-classic_believer +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1037_gazebo-classic_believer @@ -38,8 +38,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1038_gazebo-classic_glider b/ROMFS/px4fmu_common/init.d-posix/airframes/1038_gazebo-classic_glider index ef2cd02606..9aedcf683e 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1038_gazebo-classic_glider +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1038_gazebo-classic_glider @@ -44,8 +44,6 @@ param set-default MIS_TAKEOFF_ALT 30 param set-default NAV_ACC_RAD 15 param set-default NAV_DLL_ACT 2 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1039_flightgear_rascal b/ROMFS/px4fmu_common/init.d-posix/airframes/1039_flightgear_rascal index 544fd746e1..ff99bf697b 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1039_flightgear_rascal +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1039_flightgear_rascal @@ -35,8 +35,6 @@ param set-default RWTO_MAX_PITCH 20 param set-default RWTO_PSP 8 param set-default RWTO_AIRSPD_SCL 1.8 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1039_gazebo-classic_advanced_plane b/ROMFS/px4fmu_common/init.d-posix/airframes/1039_gazebo-classic_advanced_plane index 1fafd1d488..396c17f3f5 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1039_gazebo-classic_advanced_plane +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1039_gazebo-classic_advanced_plane @@ -35,8 +35,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/1044_gazebo-classic_plane_lidar b/ROMFS/px4fmu_common/init.d-posix/airframes/1044_gazebo-classic_plane_lidar index 23b7757d4b..e2e67b078c 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/1044_gazebo-classic_plane_lidar +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/1044_gazebo-classic_plane_lidar @@ -46,8 +46,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/17001_flightgear_tf-g1 b/ROMFS/px4fmu_common/init.d-posix/airframes/17001_flightgear_tf-g1 index dd3b5759ba..875385e449 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/17001_flightgear_tf-g1 +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/17001_flightgear_tf-g1 @@ -43,8 +43,6 @@ param set-default FW_THR_TRIM 0.8 param set-default FW_THR_IDLE 0 param set-default COM_DISARM_PRFLT 0 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/17002_flightgear_tf-g2 b/ROMFS/px4fmu_common/init.d-posix/airframes/17002_flightgear_tf-g2 index 254b291eb0..061ed67745 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/17002_flightgear_tf-g2 +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/17002_flightgear_tf-g2 @@ -48,8 +48,6 @@ param set-default FW_THR_TRIM 0.8 param set-default FW_THR_IDLE 0 param set-default COM_DISARM_PRFLT 0 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/4003_gz_rc_cessna b/ROMFS/px4fmu_common/init.d-posix/airframes/4003_gz_rc_cessna index 96dd5fa151..58e09228eb 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/4003_gz_rc_cessna +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/4003_gz_rc_cessna @@ -53,8 +53,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 -param set-default CA_AIRFRAME 1 - param set-default COM_PREARM_MODE 2 param set-default CA_ROTOR_COUNT 1 diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/4008_gz_advanced_plane b/ROMFS/px4fmu_common/init.d-posix/airframes/4008_gz_advanced_plane index 8ac407bac4..184ed7ba0d 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/4008_gz_advanced_plane +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/4008_gz_advanced_plane @@ -11,8 +11,6 @@ PX4_SIM_MODEL=${PX4_SIM_MODEL:=advanced_plane} param set-default SIM_GZ_EN 1 -param set-default SENS_EN_ARSPDSIM 1 - param set-default FW_LND_ANG 8 param set-default FW_PR_FF 0.08 @@ -48,8 +46,6 @@ param set-default NAV_DLL_ACT 2 param set-default RWTO_TKOFF 1 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_SV_CS_COUNT 6 diff --git a/ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim b/ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim index ee24d195a7..5b4676e60e 100644 --- a/ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim +++ b/ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim @@ -159,24 +159,19 @@ if [ -n "${PX4_SIM_MODEL#*gz_}" ] && [ -z "${PX4_GZ_MODEL_NAME}" ]; then fi # Set up camera to follow the model if requested - if [ -n "${PX4_GZ_FOLLOW}" ]; then + if [ -z "${PX4_GZ_NO_FOLLOW}" ]; then echo "INFO [init] Setting camera to follow ${MODEL_NAME_INSTANCE}" - # Set camera to follow the model - ${gz_command} service -s "/gui/follow" --reqtype gz.msgs.StringMsg \ - --reptype gz.msgs.Boolean --timeout 5000 \ - --req "data: \"${MODEL_NAME_INSTANCE}\"" > /dev/null 2>&1 - # Set default camera offset if not specified follow_x=${PX4_GZ_FOLLOW_OFFSET_X:--2.0} follow_y=${PX4_GZ_FOLLOW_OFFSET_Y:--2.0} follow_z=${PX4_GZ_FOLLOW_OFFSET_Z:-2.0} # Set camera offset - ${gz_command} service -s "/gui/follow/offset" --reqtype gz.msgs.Vector3d \ - --reptype gz.msgs.Boolean --timeout 5000 \ - --req "x: ${follow_x}, y: ${follow_y}, z: ${follow_z}" > /dev/null 2>&1 + ${gz_command} topic -t /gui/track -m gz.msgs.CameraTrack \ + -p "track_mode: FOLLOW, follow_target: {name: '${MODEL_NAME_INSTANCE}'},\ + follow_offset: {x: ${follow_x}, y: ${follow_y}, z: ${follow_z}}, follow_pgain: 1.0, track_pgain: 1.0" echo "INFO [init] Camera follow offset set to ${follow_x}, ${follow_y}, ${follow_z}" fi diff --git a/ROMFS/px4fmu_common/init.d/airframes/1101_rc_plane_sih.hil b/ROMFS/px4fmu_common/init.d/airframes/1101_rc_plane_sih.hil index 2b54650a07..40e8110e04 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/1101_rc_plane_sih.hil +++ b/ROMFS/px4fmu_common/init.d/airframes/1101_rc_plane_sih.hil @@ -14,7 +14,6 @@ param set UAVCAN_ENABLE 0 -param set-default CA_AIRFRAME 1 param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d/airframes/17002_TF-AutoG2 b/ROMFS/px4fmu_common/init.d/airframes/17002_TF-AutoG2 index 7f85a770e1..f4e968098a 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/17002_TF-AutoG2 +++ b/ROMFS/px4fmu_common/init.d/airframes/17002_TF-AutoG2 @@ -40,8 +40,6 @@ param set-default FW_P_LIM_MAX 25 param set-default FW_P_LIM_MIN -5 param set-default FW_P_RMAX_NEG 20 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d/airframes/17003_TF-G2 b/ROMFS/px4fmu_common/init.d/airframes/17003_TF-G2 index 1907b33a32..c850b32402 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/17003_TF-G2 +++ b/ROMFS/px4fmu_common/init.d/airframes/17003_TF-G2 @@ -37,8 +37,6 @@ param set-default FW_P_LIM_MAX 25 param set-default FW_P_LIM_MIN -5 param set-default FW_P_RMAX_NEG 20 -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 diff --git a/ROMFS/px4fmu_common/init.d/airframes/2100_standard_plane b/ROMFS/px4fmu_common/init.d/airframes/2100_standard_plane index d872654722..e819c0ad4b 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/2100_standard_plane +++ b/ROMFS/px4fmu_common/init.d/airframes/2100_standard_plane @@ -10,7 +10,6 @@ . ${R}etc/init.d/rc.fw_defaults -param set-default CA_AIRFRAME 1 param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.3 param set-default CA_SV_CS_COUNT 4 diff --git a/ROMFS/px4fmu_common/init.d/airframes/2106_albatross b/ROMFS/px4fmu_common/init.d/airframes/2106_albatross index e27d146e03..6640dd5ea4 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/2106_albatross +++ b/ROMFS/px4fmu_common/init.d/airframes/2106_albatross @@ -32,7 +32,6 @@ param set-default FW_WR_IMAX 0.8 param set-default FW_WR_P 1 param set-default FW_W_RMAX 0 -param set-default CA_AIRFRAME 1 param set-default CA_ROTOR_COUNT 1 param set-default CA_SV_CS_COUNT 7 param set-default CA_SV_CS0_TRQ_R -0.5 diff --git a/ROMFS/px4fmu_common/init.d/airframes/3000_generic_wing b/ROMFS/px4fmu_common/init.d/airframes/3000_generic_wing index 6daab9cdac..8be0ee8d96 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/3000_generic_wing +++ b/ROMFS/px4fmu_common/init.d/airframes/3000_generic_wing @@ -10,8 +10,6 @@ . ${R}etc/init.d/rc.fw_defaults -param set-default CA_AIRFRAME 1 - param set-default CA_ROTOR_COUNT 1 param set-default CA_ROTOR0_PX 0.15 param set-default CA_SV_CS_COUNT 2 diff --git a/ROMFS/px4fmu_common/init.d/rc.fw_defaults b/ROMFS/px4fmu_common/init.d/rc.fw_defaults index a1e7ff450b..b1cc06f200 100644 --- a/ROMFS/px4fmu_common/init.d/rc.fw_defaults +++ b/ROMFS/px4fmu_common/init.d/rc.fw_defaults @@ -10,6 +10,8 @@ set VEHICLE_TYPE fw # MAV_TYPE_FIXED_WING 1 param set-default MAV_TYPE 1 +param set-default CA_AIRFRAME 1 + # # Default parameters for fixed wing UAVs. # diff --git a/ROMFS/px4fmu_common/init.d/rc.sensors b/ROMFS/px4fmu_common/init.d/rc.sensors index 759acb3b51..b67384483b 100644 --- a/ROMFS/px4fmu_common/init.d/rc.sensors +++ b/ROMFS/px4fmu_common/init.d/rc.sensors @@ -154,6 +154,12 @@ then fi fi +# Microchip MCP9808 temperature sensor external I2C +if param compare -s SENS_EN_MCP9808 1 +then + mcp9808 start -X +fi + # TE MS4515 differential pressure sensor external I2C if param compare -s SENS_EN_MS4515 1 then @@ -219,6 +225,18 @@ then pcf8583 start -X -a 0x51 fi +# ADC sensor ADS7953 external SPI +if param compare -s ADC_ADS7953_EN 1 +then + ads7953 start -S +fi + +# ADC sensor tla2528 external I2C +if param compare -s ADC_TLA2528_EN 1 +then + tla2528 start -X +fi + # probe for optional external I2C devices if param compare SENS_EXT_I2C_PRB 1 then diff --git a/Tools/module_config/generate_actuators_metadata.py b/Tools/module_config/generate_actuators_metadata.py index 196119259b..5d38ecf499 100755 --- a/Tools/module_config/generate_actuators_metadata.py +++ b/Tools/module_config/generate_actuators_metadata.py @@ -238,6 +238,7 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos ( 'disarmed', 'Disarmed', 'DIS', False ), ( 'min', 'Minimum', 'MIN', False ), ( 'max', 'Maximum', 'MAX', False ), + ( 'center', 'Center\n(for Servos)', 'CENT', False ), ( 'failsafe', 'Failsafe', 'FAIL', True ), ] for key, label, param_suffix, advanced in standard_params_array: diff --git a/Tools/module_config/generate_params.py b/Tools/module_config/generate_params.py index 92b2593656..ecc29a4519 100755 --- a/Tools/module_config/generate_params.py +++ b/Tools/module_config/generate_params.py @@ -284,6 +284,9 @@ Note that non-motor outputs might already be active in prearm state if COM_PREAR ''' minimum_description = \ '''Minimum output value (when not disarmed). +''' + center_description = \ +'''Servo Center output value (when not disarmed). ''' maximum_description = \ '''Maxmimum output value (when not disarmed). @@ -296,6 +299,7 @@ When set to -1 (default), the value depends on the function (see {:}). standard_params_array = [ ( 'disarmed', 'Disarmed', 'DIS', disarmed_description ), ( 'min', 'Minimum', 'MIN', minimum_description ), + ( 'center', 'Center', 'CENT', center_description ), ( 'max', 'Maximum', 'MAX', maximum_description ), ( 'failsafe', 'Failsafe', 'FAIL', failsafe_description ), ] @@ -312,6 +316,10 @@ When set to -1 (default), the value depends on the function (see {:}). standard_params[key]['default'] = -1 standard_params[key]['min'] = -1 + if key == 'center': + standard_params[key]['default'] = -1 + standard_params[key]['min'] = -1 + param = { 'description': { 'short': channel_label+' ${i} '+label+' Value', diff --git a/Tools/process_sensor_caldata.py b/Tools/process_sensor_caldata.py index e70ffc8878..c0c656e015 100755 --- a/Tools/process_sensor_caldata.py +++ b/Tools/process_sensor_caldata.py @@ -1656,9 +1656,9 @@ sensor_baro_0['pressure'] = median_filter(sensor_baro_0['pressure']) # fit data median_pressure = np.median(sensor_baro_0['pressure']) if noResample: - coef_baro_0_x = np.polyfit(temp_rel,100*(sensor_baro_0['pressure']-median_pressure),5) # convert from hPa to Pa + coef_baro_0_x = np.polyfit(temp_rel,(sensor_baro_0['pressure']-median_pressure),5) # pressure in Pascal else: - temperature, baro = resampleWithDeltaX(temp_rel,100*(sensor_baro_0['pressure']-median_pressure)) # convert from hPa to Pa + temperature, baro = resampleWithDeltaX(temp_rel,(sensor_baro_0['pressure']-median_pressure)) # pressure in Pascal coef_baro_0_x = np.polyfit(temperature,baro,5) baro_0_params['TC_B0_X5'] = coef_baro_0_x[0] @@ -1717,9 +1717,9 @@ if num_baros >= 2: # fit data median_pressure = np.median(sensor_baro_1['pressure']) if noResample: - coef_baro_1_x = np.polyfit(temp_rel,100*(sensor_baro_1['pressure']-median_pressure),5) # convert from hPa to Pa + coef_baro_1_x = np.polyfit(temp_rel,(sensor_baro_1['pressure']-median_pressure),5) # pressure in Pascal else: - temperature, baro = resampleWithDeltaX(temp_rel,100*(sensor_baro_1['pressure']-median_pressure)) # convert from hPa to Pa + temperature, baro = resampleWithDeltaX(temp_rel,(sensor_baro_1['pressure']-median_pressure)) # pressure in Pascal coef_baro_1_x = np.polyfit(temperature,baro,5) baro_1_params['TC_B1_X5'] = coef_baro_1_x[0] @@ -1778,9 +1778,9 @@ if num_baros >= 3: # fit data median_pressure = np.median(sensor_baro_2['pressure']) if noResample: - coef_baro_2_x = np.polyfit(temp_rel,100*(sensor_baro_2['pressure']-median_pressure),5) # convert from hPa to Pa + coef_baro_2_x = np.polyfit(temp_rel,(sensor_baro_2['pressure']-median_pressure),5) # pressure in Pascal else: - temperature, baro = resampleWithDeltaX(temp_rel,100*(sensor_baro_2['pressure']-median_pressure)) # convert from hPa to Pa + temperature, baro = resampleWithDeltaX(temp_rel,(sensor_baro_2['pressure']-median_pressure)) # pressure in Pascal coef_baro_2_x = np.polyfit(temperature,baro,5) baro_2_params['TC_B2_X5'] = coef_baro_2_x[0] @@ -1838,7 +1838,7 @@ if num_baros >= 4: # fit data median_pressure = np.median(sensor_baro_3['pressure']) - coef_baro_3_x = np.polyfit(temp_rel,100*(sensor_baro_3['pressure']-median_pressure),5) # convert from hPa to Pa + coef_baro_3_x = np.polyfit(temp_rel,(sensor_baro_3['pressure']-median_pressure),5) # pressure in Pascal baro_3_params['TC_B3_X5'] = coef_baro_3_x[0] baro_3_params['TC_B3_X4'] = coef_baro_3_x[1] baro_3_params['TC_B3_X3'] = coef_baro_3_x[2] diff --git a/Tools/px4moduledoc/srcparser.py b/Tools/px4moduledoc/srcparser.py index 8b56e7bb08..749acef762 100644 --- a/Tools/px4moduledoc/srcparser.py +++ b/Tools/px4moduledoc/srcparser.py @@ -15,7 +15,7 @@ class ModuleDocumentation(object): # TOC in https://github.com/PX4/PX4-Autopilot/blob/main/docs/en/SUMMARY.md valid_categories = ['driver', 'estimator', 'controller', 'system', 'communication', 'command', 'template', 'simulation', 'autotune'] - valid_subcategories = ['', 'camera', 'distance_sensor', 'imu', 'ins', 'airspeed_sensor', + valid_subcategories = ['', 'adc', 'camera', 'distance_sensor', 'imu', 'ins', 'airspeed_sensor', 'magnetometer', 'baro', 'optical_flow', 'radio_control','rpm_sensor', 'transponder'] max_line_length = 80 # wrap lines that are longer than this diff --git a/Tools/simulation/gazebo-classic/sitl_gazebo-classic b/Tools/simulation/gazebo-classic/sitl_gazebo-classic index 6697ab169c..ac718b6fb2 160000 --- a/Tools/simulation/gazebo-classic/sitl_gazebo-classic +++ b/Tools/simulation/gazebo-classic/sitl_gazebo-classic @@ -1 +1 @@ -Subproject commit 6697ab169ceab512dc706acea63df4c882662c60 +Subproject commit ac718b6fb2d6b337248e23702e75d6d1e2125054 diff --git a/Tools/simulation/gz b/Tools/simulation/gz index ee3835184c..947f75b25d 160000 --- a/Tools/simulation/gz +++ b/Tools/simulation/gz @@ -1 +1 @@ -Subproject commit ee3835184c816116887402d186962e13f4b1ff94 +Subproject commit 947f75b25d434f7a227b77307795cb9a71de91f1 diff --git a/boards/3dr/ctrl-zero-h7-oem-revg/nuttx-config/scripts/script.ld b/boards/3dr/ctrl-zero-h7-oem-revg/nuttx-config/scripts/script.ld index 45b12075e5..02e763a790 100755 --- a/boards/3dr/ctrl-zero-h7-oem-revg/nuttx-config/scripts/script.ld +++ b/boards/3dr/ctrl-zero-h7-oem-revg/nuttx-config/scripts/script.ld @@ -132,7 +132,6 @@ ENTRY(_stext) */ EXTERN(abort) EXTERN(_bootdelay_signature) -EXTERN(board_get_manifest) SECTIONS { diff --git a/boards/3dr/ctrl-zero-h7-oem-revg/src/CMakeLists.txt b/boards/3dr/ctrl-zero-h7-oem-revg/src/CMakeLists.txt index 1a47c940b7..6a7d2ce306 100755 --- a/boards/3dr/ctrl-zero-h7-oem-revg/src/CMakeLists.txt +++ b/boards/3dr/ctrl-zero-h7-oem-revg/src/CMakeLists.txt @@ -48,7 +48,6 @@ else() i2c.cpp init.c led.c - mtd.cpp spi.cpp timer_config.cpp usb.c diff --git a/boards/accton-godwit/ga1/default.px4board b/boards/accton-godwit/ga1/default.px4board index c154100bbe..94af680a4d 100644 --- a/boards/accton-godwit/ga1/default.px4board +++ b/boards/accton-godwit/ga1/default.px4board @@ -67,7 +67,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/accton-godwit/ga1/init/rc.board_defaults b/boards/accton-godwit/ga1/init/rc.board_defaults index f23e6c1743..92da057ef2 100644 --- a/boards/accton-godwit/ga1/init/rc.board_defaults +++ b/boards/accton-godwit/ga1/init/rc.board_defaults @@ -3,19 +3,13 @@ # board specific defaults #------------------------------------------------------------------------------ -# By disabling all 3 INA modules, we use the -# i2c_launcher instead. -param set - default SENS_EN_INA238 0 -param set - default SENS_EN_INA228 0 -param set - default SENS_EN_INA226 0 - # Mavlink ethernet (CFG 1000) -param set - default MAV_2_CONFIG 1000 -param set - default MAV_2_BROADCAST 1 -param set - default MAV_2_MODE 0 -param set - default MAV_2_RADIO_CTL 0 -param set - default MAV_2_RATE 100000 -param set - default MAV_2_REMOTE_PRT 14550 -param set - default MAV_2_UDP_PRT 14550 +param set-default MAV_2_CONFIG 1000 +param set-default MAV_2_BROADCAST 1 +param set-default MAV_2_MODE 0 +param set-default MAV_2_RADIO_CTL 0 +param set-default MAV_2_RATE 100000 +param set-default MAV_2_REMOTE_PRT 14550 +param set-default MAV_2_UDP_PRT 14550 safety_button start diff --git a/boards/ark/can-gps/src/board_config.h b/boards/ark/can-gps/src/board_config.h index 723310472f..81f0394944 100644 --- a/boards/ark/can-gps/src/board_config.h +++ b/boards/ark/can-gps/src/board_config.h @@ -47,7 +47,7 @@ #define GPIO_BTN_SAFETY /* PB15 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTB|GPIO_PIN15) /* Safety LED */ -#define GPIO_LED_SAFETY /* PA1 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN1) +#define GPIO_LED_SAFETY /* PA1 */ (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN1) /* Tone alarm output. */ #define TONE_ALARM_TIMER 2 /* timer 2 */ diff --git a/boards/ark/fmu-v6x/default.px4board b/boards/ark/fmu-v6x/default.px4board index a4b5c42f18..e2433a53cb 100644 --- a/boards/ark/fmu-v6x/default.px4board +++ b/boards/ark/fmu-v6x/default.px4board @@ -19,6 +19,7 @@ CONFIG_DRIVERS_DIFFERENTIAL_PRESSURE_AUAV=y CONFIG_COMMON_DISTANCE_SENSOR=y CONFIG_DRIVERS_DSHOT=y CONFIG_DRIVERS_GPS=y +CONFIG_DRIVERS_PPS_CAPTURE=y CONFIG_DRIVERS_HEATER=y CONFIG_DRIVERS_IMU_ANALOG_DEVICES_ADIS16507=y CONFIG_DRIVERS_IMU_INVENSENSE_ICM42688P=y @@ -71,7 +72,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/ark/fmu-v6x/init/rc.board_defaults b/boards/ark/fmu-v6x/init/rc.board_defaults index d20bbfa1c3..7b96f86974 100644 --- a/boards/ark/fmu-v6x/init/rc.board_defaults +++ b/boards/ark/fmu-v6x/init/rc.board_defaults @@ -14,10 +14,7 @@ param set-default MAV_2_RATE 100000 param set-default MAV_2_REMOTE_PRT 14550 param set-default MAV_2_UDP_PRT 14550 -param set-default SENS_EN_INA238 0 -param set-default SENS_EN_INA228 0 param set-default SENS_EN_INA226 1 - param set-default SENS_EN_THERMAL 1 param set-default SENS_IMU_MODE 1 param set-default SENS_IMU_TEMP 10.0 diff --git a/boards/ark/fmu-v6x/init/rc.board_sensors b/boards/ark/fmu-v6x/init/rc.board_sensors index aacbc22db0..c16ed31f69 100644 --- a/boards/ark/fmu-v6x/init/rc.board_sensors +++ b/boards/ark/fmu-v6x/init/rc.board_sensors @@ -1,6 +1,6 @@ #!/bin/sh # -# ARK FMUARKV6X specific board sensors init +# ARK FMU V6X specific board sensors init #------------------------------------------------------------------------------ set HAVE_PM2 yes set HAVE_PM3 yes @@ -69,28 +69,25 @@ fi if ver hwtypecmp ARKV6X000 then - # Internal SPI bus IIM42652 with SPIX measured frequency of 32.051kHz - iim42652 -R 3 -s -b 1 -C 32051 start + # Internal SPI bus IIM42652 + iim42652 -R 3 -s -b 1 start - # Internal SPI bus ICM42688p with SPIX measured frequency of 32.051kHz - icm42688p -R 9 -s -b 2 -C 32051 start + # Internal SPI bus ICM42688p + icm42688p -R 9 -s -b 2 start - # Internal SPI bus ICM42688p with SPIX measured frequency of 32.051kHz - icm42688p -R 6 -s -b 3 -C 32051 start + # Internal SPI bus ICM42688p + icm42688p -R 6 -s -b 3 start fi if ver hwtypecmp ARKV6X001 then - # Internal SPI bus IIM42653 with SPIX measured frequency of 32.051kHz - #iim42653 -R 3 -s -b 1 -C 32051 start + # Internal SPI bus IIM42653 iim42653 -R 3 -s -b 1 start - # Internal SPI bus IIM42653 with SPIX measured frequency of 32.051kHz - #iim42653 -R 9 -s -b 2 -C 32051 start + # Internal SPI bus IIM42653 iim42653 -R 9 -s -b 2 start - # Internal SPI bus IIM42653 with SPIX measured frequency of 32.051kHz - #iim42653 -R 6 -s -b 3 -C 32051 start + # Internal SPI bus IIM42653 iim42653 -R 6 -s -b 3 start fi diff --git a/boards/ark/fmu-v6x/src/CMakeLists.txt b/boards/ark/fmu-v6x/src/CMakeLists.txt index 78b8222f19..a120ebe336 100644 --- a/boards/ark/fmu-v6x/src/CMakeLists.txt +++ b/boards/ark/fmu-v6x/src/CMakeLists.txt @@ -57,8 +57,6 @@ else() mtd.cpp sdio.c spi.cpp - spix_sync.c - spix_sync.h timer_config.cpp usb.c ) diff --git a/boards/ark/fmu-v6x/src/board_config.h b/boards/ark/fmu-v6x/src/board_config.h index 302fbc22d9..16d0aa9300 100644 --- a/boards/ark/fmu-v6x/src/board_config.h +++ b/boards/ark/fmu-v6x/src/board_config.h @@ -241,7 +241,7 @@ /* PWM */ -#define DIRECT_PWM_OUTPUT_CHANNELS 8 +#define DIRECT_PWM_OUTPUT_CHANNELS 9 #define GPIO_FMU_CH1 /* PI0 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTI|GPIO_PIN0) #define GPIO_FMU_CH2 /* PH12 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTH|GPIO_PIN12) @@ -482,7 +482,7 @@ #define PX4_I2C_BUS_MTD 4,5 -#define BOARD_NUM_IO_TIMERS 3 +#define BOARD_NUM_IO_TIMERS 4 #define BOARD_SPIX_SYNC_FREQ 32000 __BEGIN_DECLS diff --git a/boards/ark/fmu-v6x/src/init.c b/boards/ark/fmu-v6x/src/init.c index 6c1c2257ed..c60f700af1 100644 --- a/boards/ark/fmu-v6x/src/init.c +++ b/boards/ark/fmu-v6x/src/init.c @@ -46,7 +46,6 @@ ****************************************************************************/ #include "board_config.h" -#include "spix_sync.h" #include #include @@ -290,9 +289,5 @@ __EXPORT int board_app_initialize(uintptr_t arg) #endif /* CONFIG_MMCSD */ - /* Configure the SPIX_SYNC output */ - spix_sync_servo_init(BOARD_SPIX_SYNC_FREQ); - spix_sync_servo_set(0, 150); - return OK; } diff --git a/boards/ark/fmu-v6x/src/spix_sync.c b/boards/ark/fmu-v6x/src/spix_sync.c deleted file mode 100644 index 056e38e75f..0000000000 --- a/boards/ark/fmu-v6x/src/spix_sync.c +++ /dev/null @@ -1,309 +0,0 @@ -/**************************************************************************** - * - * Copyright (C) 2023 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 Airmind 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 spix_sync.c -* -* -*/ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include -#include -#include - -#include - -#include "spix_sync.h" - -#define REG(_tmr, _reg) (*(volatile uint32_t *)(spix_sync_timers[_tmr].base + _reg)) - -#define rCR1(_tmr) REG(_tmr, STM32_GTIM_CR1_OFFSET) -#define rCR2(_tmr) REG(_tmr, STM32_GTIM_CR2_OFFSET) -#define rSMCR(_tmr) REG(_tmr, STM32_GTIM_SMCR_OFFSET) -#define rDIER(_tmr) REG(_tmr, STM32_GTIM_DIER_OFFSET) -#define rSR(_tmr) REG(_tmr, STM32_GTIM_SR_OFFSET) -#define rEGR(_tmr) REG(_tmr, STM32_GTIM_EGR_OFFSET) -#define rCCMR1(_tmr) REG(_tmr, STM32_GTIM_CCMR1_OFFSET) -#define rCCMR2(_tmr) REG(_tmr, STM32_GTIM_CCMR2_OFFSET) -#define rCCER(_tmr) REG(_tmr, STM32_GTIM_CCER_OFFSET) -#define rCNT(_tmr) REG(_tmr, STM32_GTIM_CNT_OFFSET) -#define rPSC(_tmr) REG(_tmr, STM32_GTIM_PSC_OFFSET) -#define rARR(_tmr) REG(_tmr, STM32_GTIM_ARR_OFFSET) -#define rCCR1(_tmr) REG(_tmr, STM32_GTIM_CCR1_OFFSET) -#define rCCR2(_tmr) REG(_tmr, STM32_GTIM_CCR2_OFFSET) -#define rCCR3(_tmr) REG(_tmr, STM32_GTIM_CCR3_OFFSET) -#define rCCR4(_tmr) REG(_tmr, STM32_GTIM_CCR4_OFFSET) -#define rDCR(_tmr) REG(_tmr, STM32_GTIM_DCR_OFFSET) -#define rDMAR(_tmr) REG(_tmr, STM32_GTIM_DMAR_OFFSET) -#define rBDTR(_tmr) REG(_tmr, STM32_ATIM_BDTR_OFFSET) - -#define BOARD_SPIX_SYNC_PWM_FREQ 1024000 - -unsigned -spix_sync_timer_get_period(unsigned timer) -{ - return (rARR(timer)); -} - -static void spix_sync_timer_init_timer(unsigned timer, unsigned rate) -{ - if (spix_sync_timers[timer].base) { - - irqstate_t flags = px4_enter_critical_section(); - - /* enable the timer clock before we try to talk to it */ - - modifyreg32(spix_sync_timers[timer].clock_register, 0, spix_sync_timers[timer].clock_bit); - - /* disable and configure the timer */ - rCR1(timer) = 0; - rCR2(timer) = 0; - rSMCR(timer) = 0; - rDIER(timer) = 0; - rCCER(timer) = 0; - rCCMR1(timer) = 0; - rCCMR2(timer) = 0; - rCCR1(timer) = 0; - rCCR2(timer) = 0; - rCCR3(timer) = 0; - rCCR4(timer) = 0; - rCCER(timer) = 0; - rDCR(timer) = 0; - - if ((spix_sync_timers[timer].base == STM32_TIM1_BASE) || (spix_sync_timers[timer].base == STM32_TIM8_BASE)) { - - /* master output enable = on */ - - rBDTR(timer) = ATIM_BDTR_MOE; - } - - /* If the timer clock source provided as clock_freq is the STM32_APBx_TIMx_CLKIN - * then configure the timer to free-run at 1MHz. - * Otherwise, other frequencies are attainable by adjusting .clock_freq accordingly. - */ - - rPSC(timer) = (spix_sync_timers[timer].clock_freq / BOARD_SPIX_SYNC_PWM_FREQ) - 1; - - /* configure the timer to update at the desired rate */ - - rARR(timer) = (BOARD_SPIX_SYNC_PWM_FREQ / rate) - 1; - - /* generate an update event; reloads the counter and all registers */ - rEGR(timer) = GTIM_EGR_UG; - - px4_leave_critical_section(flags); - } - -} - -void spix_sync_channel_init(unsigned channel) -{ - /* Only initialize used channels */ - - if (spix_sync_channels[channel].timer_channel) { - - unsigned timer = spix_sync_channels[channel].timer_index; - - /* configure the GPIO first */ - px4_arch_configgpio(spix_sync_channels[channel].gpio_out); - - uint16_t polarity = spix_sync_channels[channel].masks; - - /* configure the channel */ - switch (spix_sync_channels[channel].timer_channel) { - case 1: - rCCMR1(timer) |= (GTIM_CCMR_MODE_PWM1 << GTIM_CCMR1_OC1M_SHIFT) | GTIM_CCMR1_OC1PE; - rCCER(timer) |= polarity | GTIM_CCER_CC1E; - break; - - case 2: - rCCMR1(timer) |= (GTIM_CCMR_MODE_PWM1 << GTIM_CCMR1_OC2M_SHIFT) | GTIM_CCMR1_OC2PE; - rCCER(timer) |= polarity | GTIM_CCER_CC2E; - break; - - case 3: - rCCMR2(timer) |= (GTIM_CCMR_MODE_PWM1 << GTIM_CCMR2_OC3M_SHIFT) | GTIM_CCMR2_OC3PE; - rCCER(timer) |= polarity | GTIM_CCER_CC3E; - break; - - case 4: - rCCMR2(timer) |= (GTIM_CCMR_MODE_PWM1 << GTIM_CCMR2_OC4M_SHIFT) | GTIM_CCMR2_OC4PE; - rCCER(timer) |= polarity | GTIM_CCER_CC4E; - break; - } - } -} - -int -spix_sync_servo_set(unsigned channel, uint8_t cvalue) -{ - if (channel >= arraySize(spix_sync_channels)) { - return -1; - } - - unsigned timer = spix_sync_channels[channel].timer_index; - - /* test timer for validity */ - if ((spix_sync_timers[timer].base == 0) || - (spix_sync_channels[channel].gpio_out == 0)) { - return -1; - } - - unsigned period = spix_sync_timer_get_period(timer); - - unsigned value = (unsigned)cvalue * period / 255; - - /* configure the channel */ - if (value > 0) { - value--; - } - - - switch (spix_sync_channels[channel].timer_channel) { - case 1: - rCCR1(timer) = value; - break; - - case 2: - rCCR2(timer) = value; - break; - - case 3: - rCCR3(timer) = value; - break; - - case 4: - rCCR4(timer) = value; - break; - - default: - return -1; - } - - return 0; -} - -unsigned spix_sync_servo_get(unsigned channel) -{ - if (channel >= 3) { - return 0; - } - - unsigned timer = spix_sync_channels[channel].timer_index; - uint16_t value = 0; - - /* test timer for validity */ - if ((spix_sync_timers[timer].base == 0) || - (spix_sync_channels[channel].timer_channel == 0)) { - return 0; - } - - /* configure the channel */ - switch (spix_sync_channels[channel].timer_channel) { - case 1: - value = rCCR1(timer); - break; - - case 2: - value = rCCR2(timer); - break; - - case 3: - value = rCCR3(timer); - break; - - case 4: - value = rCCR4(timer); - break; - } - - unsigned period = spix_sync_timer_get_period(timer); - return ((value + 1) * 255 / period); -} - -int spix_sync_servo_init(unsigned rate) -{ - /* do basic timer initialisation first */ - for (unsigned i = 0; i < arraySize(spix_sync_timers); i++) { - spix_sync_timer_init_timer(i, rate); - } - - /* now init channels */ - for (unsigned i = 0; i < arraySize(spix_sync_channels); i++) { - spix_sync_channel_init(i); - } - - spix_sync_servo_arm(true); - return OK; -} - -void -spix_sync_servo_deinit(void) -{ - /* disable the timers */ - spix_sync_servo_arm(false); -} -void -spix_sync_servo_arm(bool armed) -{ - /* iterate timers and arm/disarm appropriately */ - for (unsigned i = 0; i < arraySize(spix_sync_timers); i++) { - if (spix_sync_timers[i].base != 0) { - if (armed) { - /* force an update to preload all registers */ - rEGR(i) = GTIM_EGR_UG; - - /* arm requires the timer be enabled */ - rCR1(i) |= GTIM_CR1_CEN | GTIM_CR1_ARPE; - - } else { - rCR1(i) = 0; - } - } - } -} diff --git a/boards/ark/fmu-v6x/src/timer_config.cpp b/boards/ark/fmu-v6x/src/timer_config.cpp index 3504c3569d..75d67bac99 100644 --- a/boards/ark/fmu-v6x/src/timer_config.cpp +++ b/boards/ark/fmu-v6x/src/timer_config.cpp @@ -60,8 +60,7 @@ constexpr io_timers_t io_timers[MAX_IO_TIMERS] = { initIOTimer(Timer::Timer5, DMA{DMA::Index1}), initIOTimer(Timer::Timer4, DMA{DMA::Index1}), initIOTimer(Timer::Timer12), - //initIOTimer(Timer::Timer1), - //initIOTimer(Timer::Timer2), + initIOTimer(Timer::Timer1), }; constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { @@ -73,18 +72,8 @@ constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel3}, {GPIO::PortD, GPIO::Pin14}), initIOTimerChannel(io_timers, {Timer::Timer12, Timer::Channel1}, {GPIO::PortH, GPIO::Pin6}), initIOTimerChannel(io_timers, {Timer::Timer12, Timer::Channel2}, {GPIO::PortH, GPIO::Pin9}), - //initIOTimerChannel(io_timers, {Timer::Timer1, Timer::Channel2}, {GPIO::PortE, GPIO::Pin11}), - //initIOTimerChannel(io_timers, {Timer::Timer1, Timer::Channel1}, {GPIO::PortE, GPIO::Pin9}), + initIOTimerChannelCapture(io_timers, {Timer::Timer1, Timer::Channel2}, {GPIO::PortE, GPIO::Pin11}), }; constexpr io_timers_channel_mapping_t io_timers_channel_mapping = initIOTimerChannelMapping(io_timers, timer_io_channels); - - -constexpr io_timers_t spix_sync_timers[MAX_SPIX_SYNC_TIMERS] = { - initIOTimer(Timer::Timer1), -}; - -constexpr timer_io_channels_t spix_sync_channels[MAX_SPIX_SYNC_TIMERS] = { - initIOTimerChannel(spix_sync_timers, {Timer::Timer1, Timer::Channel1}, {GPIO::PortE, GPIO::Pin9}), -}; diff --git a/boards/ark/fpv/default.px4board b/boards/ark/fpv/default.px4board index e7437b0cc7..abea5574b0 100644 --- a/boards/ark/fpv/default.px4board +++ b/boards/ark/fpv/default.px4board @@ -50,7 +50,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/ark/mag/canbootloader.px4board b/boards/ark/mag/canbootloader.px4board new file mode 100644 index 0000000000..46917280f6 --- /dev/null +++ b/boards/ark/mag/canbootloader.px4board @@ -0,0 +1,5 @@ +CONFIG_BOARD_TOOLCHAIN="arm-none-eabi" +CONFIG_BOARD_ARCHITECTURE="cortex-m4" +CONFIG_BOARD_ROMFSROOT="" +CONFIG_BOARD_CONSTRAINED_MEMORY=y +CONFIG_DRIVERS_BOOTLOADERS=y diff --git a/boards/ark/mag/default.px4board b/boards/ark/mag/default.px4board new file mode 100644 index 0000000000..53f391b7e8 --- /dev/null +++ b/boards/ark/mag/default.px4board @@ -0,0 +1,22 @@ +CONFIG_BOARD_TOOLCHAIN="arm-none-eabi" +CONFIG_BOARD_ARCHITECTURE="cortex-m4" +CONFIG_BOARD_ROMFSROOT="cannode" +CONFIG_BOARD_CONSTRAINED_MEMORY=y +CONFIG_DRIVERS_BOOTLOADERS=y +CONFIG_DRIVERS_MAGNETOMETER_RM3100=y +CONFIG_BOARD_UAVCAN_INTERFACES=1 +CONFIG_DRIVERS_UAVCANNODE=y +CONFIG_UAVCANNODE_MAGNETIC_FIELD_STRENGTH=y +CONFIG_MODULES_SENSORS=y +# CONFIG_SENSORS_VEHICLE_AIRSPEED is not set +# CONFIG_SENSORS_VEHICLE_AIR_DATA is not set +# CONFIG_SENSORS_VEHICLE_GPS_POSITION is not set +CONFIG_SYSTEMCMDS_PARAM=y +CONFIG_SYSTEMCMDS_PERF=y +CONFIG_SYSTEMCMDS_REBOOT=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/ark/mag/firmware.prototype b/boards/ark/mag/firmware.prototype new file mode 100644 index 0000000000..35ba6379fb --- /dev/null +++ b/boards/ark/mag/firmware.prototype @@ -0,0 +1,13 @@ +{ + "board_id": 93, + "magic": "PX4FWv1", + "description": "Firmware for the ARK MAG board", + "image": "", + "build_time": 0, + "summary": "ARKMAG", + "version": "0.1", + "image_size": 0, + "image_maxsize": 2080768, + "git_identity": "", + "board_revision": 0 +} diff --git a/boards/ark/mag/init/rc.board_sensors b/boards/ark/mag/init/rc.board_sensors new file mode 100644 index 0000000000..29163fabc9 --- /dev/null +++ b/boards/ark/mag/init/rc.board_sensors @@ -0,0 +1,6 @@ +#!/bin/sh +# +# board sensors init +#------------------------------------------------------------------------------ + +rm3100 -s -b 2 start diff --git a/boards/ark/mag/nuttx-config/canbootloader/defconfig b/boards/ark/mag/nuttx-config/canbootloader/defconfig new file mode 100644 index 0000000000..11b948472f --- /dev/null +++ b/boards/ark/mag/nuttx-config/canbootloader/defconfig @@ -0,0 +1,57 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD_CUSTOM=y +CONFIG_ARCH_BOARD_CUSTOM_DIR="../../../../boards/ark/mag/nuttx-config" +CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y +CONFIG_ARCH_BOARD_CUSTOM_NAME="px4" +CONFIG_ARCH_CHIP="stm32" +CONFIG_ARCH_CHIP_STM32=y +CONFIG_ARCH_CHIP_STM32F412CE=y +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARMV7M_MEMCPY=y +CONFIG_ARMV7M_USEBASEPRI=y +CONFIG_BINFMT_DISABLE=y +CONFIG_BOARDCTL=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEBUG_TCBINFO=y +CONFIG_DEFAULT_SMALL=y +CONFIG_DISABLE_MOUNTPOINT=y +CONFIG_EXPERIMENTAL=y +CONFIG_FDCLONE_DISABLE=y +CONFIG_FDCLONE_STDIO=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_INIT_STACKSIZE=4096 +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LIBC_LONG_LONG=y +CONFIG_LIBC_STRERROR=y +CONFIG_MM_REGIONS=2 +CONFIG_NAME_MAX=0 +CONFIG_NUNGET_CHARS=0 +CONFIG_PREALLOC_TIMERS=0 +CONFIG_PTHREAD_STACK_MIN=512 +CONFIG_RAM_SIZE=262144 +CONFIG_RAM_START=0x20010000 +CONFIG_RAW_BINARY=y +CONFIG_SIG_DEFAULT=y +CONFIG_SIG_SIGALRM_ACTION=y +CONFIG_SIG_SIGUSR1_ACTION=y +CONFIG_SIG_SIGUSR2_ACTION=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=30 +CONFIG_START_MONTH=11 +CONFIG_STDIO_DISABLE_BUFFERING=y +CONFIG_STM32_FLASH_CONFIG_G=y +CONFIG_STM32_NOEXT_VECTORS=y +CONFIG_STM32_TIM8=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/ark/mag/nuttx-config/include/board.h b/boards/ark/mag/nuttx-config/include/board.h new file mode 100644 index 0000000000..18079b86e1 --- /dev/null +++ b/boards/ark/mag/nuttx-config/include/board.h @@ -0,0 +1,132 @@ +/************************************************************************************ + * configs/px4fmu/include/board.h + * include/arch/board/board.h + * + * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 NuttX 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. + * + ************************************************************************************/ +#include "board_dma_map.h" + +#ifndef __ARCH_BOARD_BOARD_H +#define __ARCH_BOARD_BOARD_H + +#include +#ifndef __ASSEMBLY__ +# include +#endif + +#include + +/* HSI - 8 MHz RC factory-trimmed + * LSI - 32 KHz RC + * HSE - 8 MHz Crystal + * LSE - not installed + */ +#define STM32_BOARD_USEHSE 1 +#define STM32_BOARD_XTAL 8000000 +#define STM32_HSE_FREQUENCY STM32_BOARD_XTAL + +#define STM32_HSI_FREQUENCY 16000000ul +#define STM32_LSI_FREQUENCY 32000 + +/* Main PLL Configuration */ +#define STM32_PLLCFG_PLLM RCC_PLLCFG_PLLM(8) +#define STM32_PLLCFG_PLLN RCC_PLLCFG_PLLN(384) +#define STM32_PLLCFG_PLLP RCC_PLLCFG_PLLP_4 +#define STM32_PLLCFG_PLLQ RCC_PLLCFG_PLLQ(8) +#define STM32_PLLCFG_PLLR RCC_PLLCFG_PLLR(2) + +#define STM32_RCC_PLLI2SCFGR_PLLI2SM RCC_PLLI2SCFGR_PLLI2SM(16) +#define STM32_RCC_PLLI2SCFGR_PLLI2SN RCC_PLLI2SCFGR_PLLI2SN(192) +#define STM32_RCC_PLLI2SCFGR_PLLI2SQ RCC_PLLI2SCFGR_PLLI2SQ(2) +#define STM32_RCC_PLLI2SCFGR_PLLI2SR RCC_PLLI2SCFGR_PLLI2SR(2) +#define STM32_RCC_PLLI2SCFGR_PLLI2SSRC RCC_PLLI2SCFGR_PLLI2SSRC(0) /* HSE or HSI depending on PLLSRC of PLLCFGR*/ + +#define STM32_RCC_DCKCFGR2_CK48MSEL RCC_DCKCFGR2_CK48MSEL_PLL +#define STM32_RCC_DCKCFGR2_FMPI2C1SEL RCC_DCKCFGR2_FMPI2C1SEL_APB +#define STM32_RCC_DCKCFGR2_SDIOSEL RCC_DCKCFGR2_SDIOSEL_48MHZ + +#define STM32_SYSCLK_FREQUENCY 96000000ul + +/* AHB clock (HCLK) is SYSCLK (96MHz) */ +#define STM32_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK /* HCLK = SYSCLK / 1 */ +#define STM32_HCLK_FREQUENCY STM32_SYSCLK_FREQUENCY +#define STM32_BOARD_HCLK STM32_HCLK_FREQUENCY /* Same as above, to satisfy compiler */ + +/* APB1 clock (PCLK1) is HCLK/2 (48MHz) */ +#define STM32_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLKd2 /* PCLK1 = HCLK / 2 */ +#define STM32_PCLK1_FREQUENCY (STM32_HCLK_FREQUENCY/2) + +/* Timers driven from APB1 will be twice PCLK1 (see page 112 of reference manual) */ +#define STM32_APB1_TIM2_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM3_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM4_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM5_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM12_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM13_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM14_CLKIN (2*STM32_PCLK1_FREQUENCY) + +/* APB2 clock (PCLK2) is HCLK (96MHz) */ +#define STM32_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLK /* PCLK2 = HCLK */ +#define STM32_PCLK2_FREQUENCY (STM32_HCLK_FREQUENCY) + +/* Timers driven from APB2 will be PCLK2 since no prescale division */ +#define STM32_APB2_TIM1_CLKIN (STM32_PCLK2_FREQUENCY) +#define STM32_APB2_TIM8_CLKIN (STM32_PCLK2_FREQUENCY) +#define STM32_APB2_TIM9_CLKIN (STM32_PCLK2_FREQUENCY) +#define STM32_APB2_TIM10_CLKIN (STM32_PCLK2_FREQUENCY) +#define STM32_APB2_TIM11_CLKIN (STM32_PCLK2_FREQUENCY) + +/* Timer Frequencies, if APBx is set to 1, frequency is same to APBx otherwise frequency is 2xAPBx. */ +#define BOARD_TIM2_FREQUENCY (2 * STM32_PCLK1_FREQUENCY) +#define BOARD_TIM3_FREQUENCY (2 * STM32_PCLK1_FREQUENCY) +#define BOARD_TIM4_FREQUENCY (2 * STM32_PCLK1_FREQUENCY) +#define BOARD_TIM5_FREQUENCY (2 * STM32_PCLK1_FREQUENCY) +#define BOARD_TIM6_FREQUENCY (2 * STM32_PCLK1_FREQUENCY) +#define BOARD_TIM7_FREQUENCY (2 * STM32_PCLK1_FREQUENCY) +#define BOARD_TIM8_FREQUENCY (2 * STM32_PCLK2_FREQUENCY) + +/* Alternate function pin selections ************************************************/ + +/* UARTs */ +#define GPIO_USART2_RX GPIO_USART2_RX_1 +#define GPIO_USART2_TX GPIO_USART2_TX_1 + +/* CAN */ +#define GPIO_CAN1_RX GPIO_CAN1_RX_1 +#define GPIO_CAN1_TX GPIO_CAN1_TX_1 + +/* SPI */ +#define GPIO_SPI2_MISO GPIO_SPI2_MISO_1 /* PB14 */ +#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_1 /* PB15 */ +#define GPIO_SPI2_SCK GPIO_SPI2_SCK_1 /* PB10 */ + +#endif /* __ARCH_BOARD_BOARD_H */ diff --git a/boards/ark/mag/nuttx-config/include/board_dma_map.h b/boards/ark/mag/nuttx-config/include/board_dma_map.h new file mode 100644 index 0000000000..773b49fc34 --- /dev/null +++ b/boards/ark/mag/nuttx-config/include/board_dma_map.h @@ -0,0 +1,42 @@ +/**************************************************************************** + * + * Copyright (c) 2021 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. + * + ****************************************************************************/ + +#pragma once + +// DMA1 Channel/Stream Selections +//--------------------------------------------//---------------------------//---------------- +#define DMACHAN_SPI2_RX DMAMAP_SPI2_RX // DMA1, Stream 3, Channel 0 +#define DMACHAN_SPI2_TX DMAMAP_SPI2_TX // DMA1, Stream 4, Channel 0 + +// DMA2 Channel/Stream Selections +//--------------------------------------------//---------------------------//---------------- diff --git a/boards/ark/mag/nuttx-config/nsh/defconfig b/boards/ark/mag/nuttx-config/nsh/defconfig new file mode 100644 index 0000000000..665ad0c1c3 --- /dev/null +++ b/boards/ark/mag/nuttx-config/nsh/defconfig @@ -0,0 +1,149 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_DISABLE_ENVIRON is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_NSH_DISABLEBG is not set +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_DF is not set +# CONFIG_NSH_DISABLE_ECHO is not set +# CONFIG_NSH_DISABLE_ENV is not set +# CONFIG_NSH_DISABLE_EXEC is not set +# CONFIG_NSH_DISABLE_EXPORT is not set +# CONFIG_NSH_DISABLE_FREE is not set +# CONFIG_NSH_DISABLE_GET is not set +# CONFIG_NSH_DISABLE_HELP is not set +# CONFIG_NSH_DISABLE_ITEF is not set +# CONFIG_NSH_DISABLE_KILL is not set +# CONFIG_NSH_DISABLE_LOOPS is not set +# CONFIG_NSH_DISABLE_LS is not set +# CONFIG_NSH_DISABLE_MKDIR is not set +# CONFIG_NSH_DISABLE_MOUNT is not set +# CONFIG_NSH_DISABLE_MV is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PSSTACKUSAGE is not set +# CONFIG_NSH_DISABLE_PWD is not set +# CONFIG_NSH_DISABLE_RM is not set +# CONFIG_NSH_DISABLE_RMDIR is not set +# CONFIG_NSH_DISABLE_SEMICOLON is not set +# CONFIG_NSH_DISABLE_SET is not set +# CONFIG_NSH_DISABLE_SLEEP is not set +# CONFIG_NSH_DISABLE_SOURCE is not set +# CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_TIME is not set +# CONFIG_NSH_DISABLE_UMOUNT is not set +# CONFIG_NSH_DISABLE_UNSET is not set +# CONFIG_NSH_DISABLE_USLEEP is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD_CUSTOM=y +CONFIG_ARCH_BOARD_CUSTOM_DIR="../../../../boards/ark/mag/nuttx-config" +CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y +CONFIG_ARCH_BOARD_CUSTOM_NAME="px4" +CONFIG_ARCH_CHIP="stm32" +CONFIG_ARCH_CHIP_STM32=y +CONFIG_ARCH_CHIP_STM32F412CE=y +CONFIG_ARCH_INTERRUPTSTACK=768 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7M_MEMCPY=y +CONFIG_ARMV7M_USEBASEPRI=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_ASSERT_RESET_VALUE=0 +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BOARD_RESET_ON_ASSERT=2 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_HARDFAULT_ALERT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEBUG_TCBINFO=y +CONFIG_DEFAULT_SMALL=y +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=70 +CONFIG_FDCLONE_STDIO=y +CONFIG_FS_CROMFS=y +CONFIG_FS_ROMFS=y +CONFIG_GRAN=y +CONFIG_GRAN_INTR=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=750 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=2624 +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LIBC_LONG_LONG=y +CONFIG_LIBC_MAX_EXITFUNS=1 +CONFIG_MEMSET_64BIT=y +CONFIG_MEMSET_OPTSPEED=y +CONFIG_MM_REGIONS=2 +CONFIG_NAME_MAX=40 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_ARGCAT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_CMDPARMS=y +CONFIG_NSH_CROMFSETC=y +CONFIG_NSH_LINELEN=128 +CONFIG_NSH_MAXARGUMENTS=15 +CONFIG_NSH_NESTDEPTH=8 +CONFIG_NSH_QUOTE=y +CONFIG_NSH_ROMFSETC=y +CONFIG_NSH_ROMFSSECTSIZE=128 +CONFIG_NSH_VARS=y +CONFIG_PIPES=y +CONFIG_PREALLOC_TIMERS=50 +CONFIG_PTHREAD_MUTEX_ROBUST=y +CONFIG_PTHREAD_STACK_MIN=512 +CONFIG_RAM_SIZE=262144 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_READLINE_TABCOMPLETION=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=254 +CONFIG_SCHED_HPWORKSTACKSIZE=3000 +CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_EXTERNAL=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y +CONFIG_SCHED_WAITPID=y +CONFIG_SERIAL_TERMIOS=y +CONFIG_SIG_DEFAULT=y +CONFIG_SIG_SIGALRM_ACTION=y +CONFIG_SIG_SIGUSR1_ACTION=y +CONFIG_SIG_SIGUSR2_ACTION=y +CONFIG_SIG_SIGWORK=4 +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=30 +CONFIG_START_MONTH=11 +CONFIG_STDIO_BUFFER_SIZE=32 +CONFIG_STM32_ADC1=y +CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y +CONFIG_STM32_DMA1=y +CONFIG_STM32_DMA2=y +CONFIG_STM32_FLASH_CONFIG_G=y +CONFIG_STM32_FLASH_PREFETCH=y +CONFIG_STM32_FLOWCONTROL_BROKEN=y +CONFIG_STM32_JTAG_SW_ENABLE=y +CONFIG_STM32_PWR=y +CONFIG_STM32_SERIALBRK_BSDCOMPAT=y +CONFIG_STM32_SERIAL_DISABLE_REORDERING=y +CONFIG_STM32_SPI2=y +CONFIG_STM32_SPI2_DMA=y +CONFIG_STM32_SPI2_DMA_BUFFER=2048 +CONFIG_STM32_TIM8=y +CONFIG_STM32_USART2=y +CONFIG_STM32_USART_BREAKS=y +CONFIG_STM32_WWDG=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=24 +CONFIG_USART2_BAUD=57600 +CONFIG_USART2_RXBUFSIZE=600 +CONFIG_USART2_SERIAL_CONSOLE=y +CONFIG_USART2_TXBUFSIZE=1100 +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/ark/mag/nuttx-config/scripts/canbootloader_script.ld b/boards/ark/mag/nuttx-config/scripts/canbootloader_script.ld new file mode 100644 index 0000000000..48a59fe92d --- /dev/null +++ b/boards/ark/mag/nuttx-config/scripts/canbootloader_script.ld @@ -0,0 +1,134 @@ +/**************************************************************************** + * nuttx-config/scripts/canbootloader_script.ld + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 NuttX 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. + * + ****************************************************************************/ + +/* The STM32F412 has 1M of FLASH beginning at address 0x0800:0000 and + * 256Kb of SRAM. SRAM is split up into three blocks: + * + * 1) 112Kb of SRAM beginning at address 0x2000:0000 + * 2) 16Kb of SRAM beginning at address 0x2001:c000 + * 3) 64Kb of SRAM beginning at address 0x2002:0000 + * 4) 64Kb of TCM SRAM beginning at address 0x1000:0000 + * + * When booting from FLASH, FLASH memory is aliased to address 0x0000:0000 + * where the code expects to begin execution by jumping to the entry point in + * the 0x0800:0000 address range. + * + * The first 0x10000 of flash is reserved for the bootloader. + */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x08000000, LENGTH = 32K + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 192K +} + +OUTPUT_ARCH(arm) + +ENTRY(__start) /* treat __start as the anchor for dead code stripping */ +EXTERN(_vectors) /* force the vectors to be included in the output */ + +/* + * Ensure that abort() is present in the final object. The exception handling + * code pulled in by libgcc.a requires it (and that code cannot be easily avoided). + */ +EXTERN(abort) +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + /* + * Init functions (static constructors and the like) + */ + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(.init_array .init_array.*)) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/ark/mag/nuttx-config/scripts/script.ld b/boards/ark/mag/nuttx-config/scripts/script.ld new file mode 100644 index 0000000000..2f4769b8f5 --- /dev/null +++ b/boards/ark/mag/nuttx-config/scripts/script.ld @@ -0,0 +1,146 @@ +/**************************************************************************** + * scripts/ld.script + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 NuttX 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. + * + ****************************************************************************/ + +/* The STM32F412 has 1M of FLASH beginning at address 0x0800:0000 and + * 256Kb of SRAM. SRAM is split up into three blocks: + * + * 1) 112Kb of SRAM beginning at address 0x2000:0000 + * 2) 16Kb of SRAM beginning at address 0x2001:c000 + * 3) 64Kb of SRAM beginning at address 0x2002:0000 + * 4) 64Kb of TCM SRAM beginning at address 0x1000:0000 + * + * When booting from FLASH, FLASH memory is aliased to address 0x0000:0000 + * where the code expects to begin execution by jumping to the entry point in + * the 0x0800:0000 address range. + * + * The first 0x10000 of flash is reserved for the bootloader. + */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x08010000, LENGTH = 928K + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 192K +} + +OUTPUT_ARCH(arm) + +ENTRY(__start) /* treat __start as the anchor for dead code stripping */ +EXTERN(_vectors) /* force the vectors to be included in the output */ + +/* + * Ensure that abort() is present in the final object. The exception handling + * code pulled in by libgcc.a requires it (and that code cannot be easily avoided). + */ +EXTERN(abort) +EXTERN(_bootdelay_signature) + +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + . = ALIGN(8); + /* + * This section positions the app_descriptor_t used + * by the make_can_boot_descriptor.py tool to set + * the application image's descriptor so that the + * uavcan bootloader has the ability to validate the + * image crc, size etc + */ + KEEP(*(.app_descriptor)) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + /* + * Init functions (static constructors and the like) + */ + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(.init_array .init_array.*)) + _einit = ABSOLUTE(.); + } > flash + + + .ARM.extab : { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/ark/mag/src/CMakeLists.txt b/boards/ark/mag/src/CMakeLists.txt new file mode 100644 index 0000000000..4fae41fc0e --- /dev/null +++ b/boards/ark/mag/src/CMakeLists.txt @@ -0,0 +1,65 @@ +############################################################################ +# +# Copyright (c) 2020 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. +# +############################################################################ + +if("${PX4_BOARD_LABEL}" STREQUAL "canbootloader") + + add_library(drivers_board + boot_config.h + boot.c + led.c + ) + target_link_libraries(drivers_board + PRIVATE + nuttx_arch + nuttx_drivers + canbootloader + ) + target_include_directories(drivers_board PRIVATE ${PX4_SOURCE_DIR}/platforms/nuttx/src/canbootloader) + +else() + add_library(drivers_board + can.c + init.c + led.c + spi.cpp + ) + + target_link_libraries(drivers_board + PRIVATE + arch_spi + drivers__led # drv_led_start + nuttx_arch + nuttx_drivers + px4_layer + ) +endif() diff --git a/boards/ark/mag/src/board_config.h b/boards/ark/mag/src/board_config.h new file mode 100644 index 0000000000..ca6e5bb094 --- /dev/null +++ b/boards/ark/mag/src/board_config.h @@ -0,0 +1,88 @@ +/**************************************************************************** + * + * Copyright (c) 2021 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 board_config.h + * + * board internal definitions + */ + +#pragma once + +#include +#include +#include + +/* CAN Silent mode control */ +#define GPIO_CAN1_SILENT_S0 /* PB11 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN11) + +/* CAN termination software control */ +#define GPIO_CAN1_TERMINATION /* PB13 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN13) +#define GPIO_CAN_TERM GPIO_CAN1_TERMINATION + +/* Boot config */ +#define GPIO_BOOT_CONFIG /* PC15 */ (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTC|GPIO_PIN15|GPIO_EXTI) + +/* LEDs are driven with open drain to support Anode to 5V or 3.3V */ +#define GPIO_TIM1_CH1 /* PA8 */ (GPIO_TIM1_CH1_1|GPIO_OPENDRAIN|GPIO_SPEED_2MHz) +#define GPIO_TIM1_CH2 /* PA9 */ (GPIO_TIM1_CH2_1|GPIO_OPENDRAIN|GPIO_SPEED_2MHz) +#define GPIO_TIM1_CH3 /* PA10 */ (GPIO_TIM1_CH3_1|GPIO_OPENDRAIN|GPIO_SPEED_2MHz) + +#define FLASH_BASED_PARAMS + +/* High-resolution timer */ +#define HRT_TIMER 3 /* use timer 3 for the HRT */ +#define HRT_TIMER_CHANNEL 4 /* use capture/compare channel 4 */ + +#define PX4_GPIO_INIT_LIST { \ + GPIO_BOOT_CONFIG, \ + GPIO_CAN1_TX, \ + GPIO_CAN1_RX, \ + GPIO_CAN1_SILENT_S0, \ + GPIO_CAN1_TERMINATION, \ + } + +__BEGIN_DECLS + +#define BOARD_HAS_N_S_RGB_LED 1 +#define BOARD_MAX_LEDS BOARD_HAS_N_S_RGB_LED + +#ifndef __ASSEMBLY__ + +extern void stm32_spiinitialize(void); + +#include + +#endif /* __ASSEMBLY__ */ + +__END_DECLS diff --git a/boards/ark/mag/src/boot.c b/boards/ark/mag/src/boot.c new file mode 100644 index 0000000000..a26034e254 --- /dev/null +++ b/boards/ark/mag/src/boot.c @@ -0,0 +1,188 @@ +/**************************************************************************** + * + * Copyright (c) 2021 PX4 Development Team. All rights reserved. + * Author: Ben Dyer + * Pavel Kirienko + * David Sidrane + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include "boot_config.h" +#include "board.h" + +#include +#include +#include + +#include +#include "led.h" + +/************************************************************************************ + * Name: stm32_boardinitialize + * + * Description: + * All STM32 architectures must provide the following entry point. This entry point + * is called early in the initialization -- after all memory has been configured + * and mapped but before any devices have been initialized. + * + ************************************************************************************/ + +__EXPORT void stm32_boardinitialize(void) +{ + putreg32(getreg32(STM32_RCC_APB1ENR) | RCC_APB1ENR_CAN1EN, STM32_RCC_APB1ENR); + stm32_configgpio(GPIO_CAN1_RX); + stm32_configgpio(GPIO_CAN1_TX); + stm32_configgpio(GPIO_CAN1_SILENT_S0); + stm32_configgpio(GPIO_CAN1_TERMINATION); + putreg32(getreg32(STM32_RCC_APB1RSTR) | RCC_APB1RSTR_CAN1RST, STM32_RCC_APB1RSTR); + putreg32(getreg32(STM32_RCC_APB1RSTR) & ~RCC_APB1RSTR_CAN1RST, STM32_RCC_APB1RSTR); + +#if defined(OPT_WAIT_FOR_GETNODEINFO_JUMPER_GPIO) + stm32_configgpio(GPIO_GETNODEINFO_JUMPER); +#endif + +} + +/************************************************************************************ + * Name: board_deinitialize + * + * Description: + * This function is called by the bootloader code prior to booting + * the application. Is should place the HW into an benign initialized state. + * + ************************************************************************************/ + +void board_deinitialize(void) +{ + putreg32(getreg32(STM32_RCC_APB1RSTR) | RCC_APB1RSTR_CAN1RST, STM32_RCC_APB1RSTR); +} + +/**************************************************************************** + * Name: board_get_product_name + * + * Description: + * Called to retrieve the product name. The returned value is a assumed + * to be written to a pascal style string that will be length prefixed + * and not null terminated + * + * Input Parameters: + * product_name - A pointer to a buffer to write the name. + * maxlen - The maximum number of charter that can be written + * + * Returned Value: + * The length of characters written to the buffer. + * + ****************************************************************************/ + +uint8_t board_get_product_name(uint8_t *product_name, size_t maxlen) +{ + DEBUGASSERT(maxlen > UAVCAN_STRLEN(HW_UAVCAN_NAME)); + memcpy(product_name, HW_UAVCAN_NAME, UAVCAN_STRLEN(HW_UAVCAN_NAME)); + return UAVCAN_STRLEN(HW_UAVCAN_NAME); +} + +/**************************************************************************** + * Name: board_get_hardware_version + * + * Description: + * Called to retrieve the hardware version information. The function + * will first initialize the the callers struct to all zeros. + * + * Input Parameters: + * hw_version - A pointer to a uavcan_hardwareversion_t. + * + * Returned Value: + * Length of the unique_id + * + ****************************************************************************/ + +size_t board_get_hardware_version(uavcan_HardwareVersion_t *hw_version) +{ + memset(hw_version, 0, sizeof(uavcan_HardwareVersion_t)); + + hw_version->major = HW_VERSION_MAJOR; + hw_version->minor = HW_VERSION_MINOR; + + return board_get_mfguid(*(mfguid_t *) hw_version->unique_id); +} + +/**************************************************************************** + * Name: board_indicate + * + * Description: + * Provides User feedback to indicate the state of the bootloader + * on board specific hardware. + * + * Input Parameters: + * indication - A member of the uiindication_t + * + * Returned Value: + * None + * + ****************************************************************************/ +#define led(n, code, r , g , b, h) {.red = (r),.green = (g), .blue = (b),.hz = (h)} + +typedef begin_packed_struct struct led_t { + uint8_t red; + uint8_t green; + uint8_t blue; + uint8_t hz; +} end_packed_struct led_t; + +static const led_t i2l[] = { + + led(0, off, 0, 0, 0, 0), + led(1, reset, 128, 128, 128, 30), + led(2, autobaud_start, 0, 128, 0, 1), + led(3, autobaud_end, 0, 128, 0, 2), + led(4, allocation_start, 0, 0, 64, 2), + led(5, allocation_end, 0, 128, 64, 3), + led(6, fw_update_start, 32, 128, 64, 3), + led(7, fw_update_erase_fail, 32, 128, 32, 3), + led(8, fw_update_invalid_response, 64, 0, 0, 1), + led(9, fw_update_timeout, 64, 0, 0, 2), + led(a, fw_update_invalid_crc, 64, 0, 0, 4), + led(b, jump_to_app, 0, 128, 0, 10), + +}; + +void board_indicate(uiindication_t indication) +{ + rgb_led(i2l[indication].red, + i2l[indication].green, + i2l[indication].blue, + i2l[indication].hz); +} diff --git a/boards/ark/mag/src/boot_config.h b/boards/ark/mag/src/boot_config.h new file mode 100644 index 0000000000..76782f9a93 --- /dev/null +++ b/boards/ark/mag/src/boot_config.h @@ -0,0 +1,130 @@ +/**************************************************************************** + * + * Copyright (c) 2021 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 boot_config.h + * + * bootloader definitions that configures the behavior and options + * of the Boot loader + * This file is relies on the parent folder's boot_config.h file and defines + * different usages of the hardware for bootloading + */ + +#pragma once + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +/* Bring in the board_config.h definitions + * todo:make this be pulled in from a targed's build + * files in nuttx*/ + +#include "board_config.h" +#include "uavcan.h" +#include + +#include + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define OPT_PREFERRED_NODE_ID ANY_NODE_ID + +//todo:wrap OPT_x in in ifdefs for command line definitions +#define OPT_TBOOT_MS 3000 +#define OPT_NODE_STATUS_RATE_MS 800 +#define OPT_NODE_INFO_RATE_MS 50 +#define OPT_BL_NUMBER_TIMERS 7 + +/* + * This Option set is set to 1 ensure a provider of firmware has an + * opportunity update the node's firmware. + * This Option is the default policy and can be overridden by + * a jumper + * When this Policy is set, the node will ignore tboot and + * wait indefinitely for a GetNodeInfo request before booting. + * + * OPT_WAIT_FOR_GETNODEINFO_JUMPER_GPIO_INVERT is used to allow + * the polarity of the jumper to be True Active + * + * wait OPT_WAIT_FOR_GETNODEINFO OPT_WAIT_FOR_GETNODEINFO_JUMPER_GPIO + * Jumper + * yes 1 0 x + * yes 1 1 Active + * no 1 1 Not Active + * no 0 0 X + * yes 0 1 Active + * no 0 1 Not Active + * + */ +#define OPT_WAIT_FOR_GETNODEINFO 0 +#define OPT_WAIT_FOR_GETNODEINFO_JUMPER_GPIO 1 +#define OPT_WAIT_FOR_GETNODEINFO_JUMPER_GPIO_INVERT 1 + +#define OPT_ENABLE_WD 1 + +#define OPT_RESTART_TIMEOUT_MS 20000 + +/* Reserved for the Booloader */ +#define OPT_BOOTLOADER_SIZE_IN_K (1024*64) + +/* Reserved for the application out of the total + * system flash minus the BOOTLOADER_SIZE_IN_K + */ +#define OPT_APPLICATION_RESERVER_IN_K 0 + +#define OPT_APPLICATION_IMAGE_OFFSET OPT_BOOTLOADER_SIZE_IN_K +#define OPT_APPLICATION_IMAGE_LENGTH (FLASH_SIZE-(OPT_BOOTLOADER_SIZE_IN_K+OPT_APPLICATION_RESERVER_IN_K)) + + +#define FLASH_BASE STM32_FLASH_BASE +#define FLASH_SIZE STM32_FLASH_SIZE + +#define APPLICATION_LOAD_ADDRESS (FLASH_BASE + OPT_APPLICATION_IMAGE_OFFSET) +#define APPLICATION_SIZE (FLASH_SIZE-OPT_APPLICATION_IMAGE_OFFSET) +#define APPLICATION_LAST_8BIT_ADDRRESS ((uint8_t *)((APPLICATION_LOAD_ADDRESS+APPLICATION_SIZE)-sizeof(uint8_t))) +#define APPLICATION_LAST_32BIT_ADDRRESS ((uint32_t *)((APPLICATION_LOAD_ADDRESS+APPLICATION_SIZE)-sizeof(uint32_t))) +#define APPLICATION_LAST_64BIT_ADDRRESS ((uint64_t *)((APPLICATION_LOAD_ADDRESS+APPLICATION_SIZE)-sizeof(uint64_t))) + +/* If this board uses big flash that have large sectors */ + +#define OPT_USE_YIELD + +/* Bootloader Option***************************************************************** + * + */ +#define GPIO_GETNODEINFO_JUMPER (GPIO_BOOT_CONFIG & ~GPIO_EXTI) diff --git a/boards/ark/mag/src/can.c b/boards/ark/mag/src/can.c new file mode 100644 index 0000000000..7737965dc6 --- /dev/null +++ b/boards/ark/mag/src/can.c @@ -0,0 +1,130 @@ +/**************************************************************************** + * + * Copyright (C) 2021 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 can.c + * + * Board-specific CAN functions. + */ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "chip.h" +#include "arm_internal.h" + +#include "stm32.h" +#include "stm32_can.h" +#include "board_config.h" + +#ifdef CONFIG_CAN + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ +/* Configuration ********************************************************************/ + +#if defined(CONFIG_STM32_CAN1) && defined(CONFIG_STM32_CAN2) +# warning "Both CAN1 and CAN2 are enabled. Assuming only CAN1." +# undef CONFIG_STM32_CAN2 +#endif + +#ifdef CONFIG_STM32_CAN1 +# define CAN_PORT 1 +#else +# define CAN_PORT 2 +#endif + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ +int can_devinit(void); + +/************************************************************************************ + * Name: can_devinit + * + * Description: + * All STM32 architectures must provide the following interface to work with + * examples/can. + * + ************************************************************************************/ + +int can_devinit(void) +{ + static bool initialized = false; + struct can_dev_s *can; + int ret; + + /* Check if we have already initialized */ + + if (!initialized) { + /* Call stm32_caninitialize() to get an instance of the CAN interface */ + + can = stm32_caninitialize(CAN_PORT); + + if (can == NULL) { + canerr("ERROR: Failed to get CAN interface\n"); + return -ENODEV; + } + + /* Register the CAN driver at "/dev/can0" */ + + ret = can_register("/dev/can0", can); + + if (ret < 0) { + canerr("ERROR: can_register failed: %d\n", ret); + return ret; + } + + /* Now we are initialized */ + + initialized = true; + } + + return OK; +} + +#endif diff --git a/boards/ark/mag/src/init.c b/boards/ark/mag/src/init.c new file mode 100644 index 0000000000..a6290bdc7a --- /dev/null +++ b/boards/ark/mag/src/init.c @@ -0,0 +1,147 @@ +/**************************************************************************** + * + * Copyright (c) 2021 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 init.c + * + * board specific early startup code. This file implements the + * board_app_initialize() function that is called early by nsh during startup. + * + * Code here is run before the rcS script is invoked; it should start required + * subsystems and perform board-specific initialization. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include "board_config.h" +#include "led.h" +#include + +#include + +#include +#include +#include + +#include + +#include +#include + +# if defined(FLASH_BASED_PARAMS) +# include +#endif + +/************************************************************************************ + * Name: stm32_boardinitialize + * + * Description: + * All STM32 architectures must provide the following entry point. This entry point + * is called early in the initialization -- after all memory has been configured + * and mapped but before any devices have been initialized. + * + ************************************************************************************/ + +__EXPORT void stm32_boardinitialize(void) +{ + watchdog_init(); + + /* configure pins */ + const uint32_t gpio[] = PX4_GPIO_INIT_LIST; + px4_gpio_init(gpio, arraySize(gpio)); + + // Configure SPI all interfaces GPIO & enable power. + stm32_spiinitialize(); +} + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initalization logic and the the + * matching application logic. The value cold be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +__EXPORT int board_app_initialize(uintptr_t arg) +{ + px4_platform_init(); + +#if defined(FLASH_BASED_PARAMS) + static sector_descriptor_t params_sector_map[] = { + {2, 16 * 1024, 0x08008000}, + {3, 16 * 1024, 0x0800C000}, + {0, 0, 0}, + }; + + /* Initialize the flashfs layer to use heap allocated memory */ + int result = parameter_flashfs_init(params_sector_map, NULL, 0); + + if (result != OK) { + syslog(LOG_ERR, "[boot] FAILED to init params in FLASH %d\n", result); + } + +#endif // FLASH_BASED_PARAMS + + /* Configure the HW based on the manifest */ + //px4_platform_configure(); + + return OK; +} diff --git a/boards/ark/mag/src/led.c b/boards/ark/mag/src/led.c new file mode 100644 index 0000000000..24c3c42bf4 --- /dev/null +++ b/boards/ark/mag/src/led.c @@ -0,0 +1,124 @@ +/**************************************************************************** + * + * Copyright (c) 2021 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 led.c + * + * LED backend. + */ + +#include + +#include + +#include "chip.h" +#include "stm32_gpio.h" +#include "board_config.h" + +#include +#include + +#include "led.h" + +#define TMR_BASE STM32_TIM1_BASE +#define TMR_FREQUENCY STM32_APB2_TIM1_CLKIN +#define TMR_REG(o) (TMR_BASE+(o)) + +void rgb_led(int r, int g, int b, int freqs) +{ + + long fosc = TMR_FREQUENCY; + long prescale = 2048; + long p1s = fosc / prescale; + long p0p5s = p1s / 2; + uint16_t val; + static bool once = 0; + + if (!once) { + once = 1; + + /* Enable Clock to Block */ + modifyreg32(STM32_RCC_APB2ENR, 0, RCC_APB2ENR_TIM1EN); + + /* Reload */ + + val = getreg16(TMR_REG(STM32_BTIM_EGR_OFFSET)); + val |= ATIM_EGR_UG; + putreg16(val, TMR_REG(STM32_BTIM_EGR_OFFSET)); + + /* Set Prescaler STM32_TIM_SETCLOCK */ + + putreg16(prescale, TMR_REG(STM32_BTIM_PSC_OFFSET)); + + /* Enable STM32_TIM_SETMODE*/ + + putreg16(ATIM_CR1_CEN | ATIM_CR1_ARPE, TMR_REG(STM32_BTIM_CR1_OFFSET)); + + + putreg16((ATIM_CCMR_MODE_PWM1 << ATIM_CCMR1_OC1M_SHIFT) | ATIM_CCMR1_OC1PE | + (ATIM_CCMR_MODE_PWM1 << ATIM_CCMR1_OC2M_SHIFT) | ATIM_CCMR1_OC2PE, TMR_REG(STM32_GTIM_CCMR1_OFFSET)); + putreg16((ATIM_CCMR_MODE_PWM1 << ATIM_CCMR2_OC3M_SHIFT) | ATIM_CCMR2_OC3PE, TMR_REG(STM32_GTIM_CCMR2_OFFSET)); + putreg16(ATIM_CCER_CC3E | ATIM_CCER_CC3P | + ATIM_CCER_CC2E | ATIM_CCER_CC2P | + ATIM_CCER_CC1E | ATIM_CCER_CC1P, TMR_REG(STM32_GTIM_CCER_OFFSET)); + + + stm32_configgpio(GPIO_TIM1_CH1); + stm32_configgpio(GPIO_TIM1_CH2); + stm32_configgpio(GPIO_TIM1_CH3); + + /* master output enable = on */ + putreg16(ATIM_BDTR_MOE, (TMR_REG(STM32_ATIM_BDTR_OFFSET))); + } + + long p = freqs == 0 ? p1s : p1s / freqs; + putreg32(p, TMR_REG(STM32_BTIM_ARR_OFFSET)); + + p = freqs == 0 ? p1s + 1 : p0p5s / freqs; + + putreg32((r * p) / 255, TMR_REG(STM32_GTIM_CCR1_OFFSET)); + putreg32((g * p) / 255, TMR_REG(STM32_GTIM_CCR2_OFFSET)); + putreg32((b * p) / 255, TMR_REG(STM32_GTIM_CCR3_OFFSET)); + + val = getreg16(TMR_REG(STM32_BTIM_CR1_OFFSET)); + + if (freqs == 0) { + val &= ~ATIM_CR1_CEN; + + } else { + val |= ATIM_CR1_CEN; + } + + putreg16(val, TMR_REG(STM32_BTIM_CR1_OFFSET)); + +} diff --git a/boards/ark/fmu-v6x/src/spix_sync.h b/boards/ark/mag/src/led.h similarity index 81% rename from boards/ark/fmu-v6x/src/spix_sync.h rename to boards/ark/mag/src/led.h index 2e37c89086..b68e4aa70d 100644 --- a/boards/ark/fmu-v6x/src/spix_sync.h +++ b/boards/ark/mag/src/led.h @@ -1,6 +1,7 @@ /**************************************************************************** * - * Copyright (C) 2023 PX4 Development Team. All rights reserved. + * Copyright (C) 2015 PX4 Development Team. All rights reserved. + * Author: David Sidrane * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,11 +33,5 @@ ****************************************************************************/ __BEGIN_DECLS -void spix_sync_channel_init(unsigned channel); -int spix_sync_servo_set(unsigned channel, uint8_t value); -unsigned spix_sync_servo_get(unsigned channel); -int spix_sync_servo_init(unsigned rate); -void spix_sync_servo_deinit(void); -void spix_sync_servo_arm(bool armed); -unsigned spix_sync_timer_get_period(unsigned timer); +void rgb_led(int r, int g, int b, int freqs); __END_DECLS diff --git a/boards/ark/mag/src/spi.cpp b/boards/ark/mag/src/spi.cpp new file mode 100644 index 0000000000..b32d42b514 --- /dev/null +++ b/boards/ark/mag/src/spi.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** + * + * Copyright (C) 2021 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. + * + ****************************************************************************/ + +#include +#include +#include + +constexpr px4_spi_bus_t px4_spi_buses[SPI_BUS_MAX_BUS_ITEMS] = { + initSPIBus(SPI::Bus::SPI2, { + initSPIDevice(DRV_MAG_DEVTYPE_RM3100, SPI::CS{GPIO::PortB, GPIO::Pin12}, SPI::DRDY{GPIO::PortB, GPIO::Pin4}), + }), +}; + +static constexpr bool unused = validateSPIConfig(px4_spi_buses); diff --git a/boards/ark/mag/uavcan_board_identity b/boards/ark/mag/uavcan_board_identity new file mode 100644 index 0000000000..1e30c3d822 --- /dev/null +++ b/boards/ark/mag/uavcan_board_identity @@ -0,0 +1,17 @@ +# UAVCAN boot loadable Module ID +set(uavcanblid_sw_version_major ${PX4_VERSION_MAJOR}) +set(uavcanblid_sw_version_minor ${PX4_VERSION_MINOR}) +add_definitions( + -DAPP_VERSION_MAJOR=${uavcanblid_sw_version_major} + -DAPP_VERSION_MINOR=${uavcanblid_sw_version_minor} +) + +set(uavcanblid_hw_version_major 0) +set(uavcanblid_hw_version_minor 93) +set(uavcanblid_name "\"org.ark.mag\"") + +add_definitions( + -DHW_UAVCAN_NAME=${uavcanblid_name} + -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} + -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} +) diff --git a/boards/ark/pi6x/default.px4board b/boards/ark/pi6x/default.px4board index 84c6fd79f2..dda45cdf23 100644 --- a/boards/ark/pi6x/default.px4board +++ b/boards/ark/pi6x/default.px4board @@ -41,7 +41,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/auterion/fmu-v6s/default.px4board b/boards/auterion/fmu-v6s/default.px4board index 296f2db880..bc7883a1b8 100644 --- a/boards/auterion/fmu-v6s/default.px4board +++ b/boards/auterion/fmu-v6s/default.px4board @@ -14,6 +14,7 @@ CONFIG_COMMON_DISTANCE_SENSOR=y CONFIG_DRIVERS_DSHOT=y CONFIG_DRIVERS_GNSS_SEPTENTRIO=y CONFIG_DRIVERS_GPS=y +CONFIG_DRIVERS_PPS_CAPTURE=y CONFIG_DRIVERS_IMU_BOSCH_BMI088=y CONFIG_BMI088_ACCELEROMETER_INT2=y CONFIG_COMMON_LIGHT=y @@ -57,7 +58,6 @@ CONFIG_LOGGER_STACK_SIZE=4100 CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y @@ -77,9 +77,7 @@ CONFIG_MODULES_VTOL_ATT_CONTROL=y CONFIG_SYSTEMCMDS_ACTUATOR_TEST=y CONFIG_SYSTEMCMDS_BSONDUMP=y CONFIG_SYSTEMCMDS_DMESG=y -CONFIG_SYSTEMCMDS_GPIO=y CONFIG_SYSTEMCMDS_HARDFAULT_LOG=y -CONFIG_SYSTEMCMDS_I2C_LAUNCHER=y CONFIG_SYSTEMCMDS_I2CDETECT=y CONFIG_SYSTEMCMDS_LED_CONTROL=y CONFIG_SYSTEMCMDS_MFT=y @@ -91,7 +89,6 @@ 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 diff --git a/boards/auterion/fmu-v6s/init/rc.board_defaults b/boards/auterion/fmu-v6s/init/rc.board_defaults index 012605bee3..1efbfc3811 100644 --- a/boards/auterion/fmu-v6s/init/rc.board_defaults +++ b/boards/auterion/fmu-v6s/init/rc.board_defaults @@ -3,12 +3,6 @@ # board specific defaults #------------------------------------------------------------------------------ -# By disabling INA modules, we use the -# i2c_launcher instead. -param set-default SENS_EN_INA226 0 -param set-default SENS_EN_INA228 0 -param set-default SENS_EN_INA238 0 - # Set the backend of the dataman to SRAM param set-default SYS_DM_BACKEND 1 # Set TELEM1 as default mavlink connection @@ -19,6 +13,13 @@ param set-default SDLOG_BACKEND 2 # 200kOhm/10kOhm voltage divider on V_BAT param set-default BAT1_V_DIV 21 +# Uncomment to use PWM9 as Analog input +# param set-default PWM_MAIN_TIM2 -2 + +# Uncomment to use PWM10 as PPS input +# param set-default PWM_MAIN_TIM3 -2 +# param set-default PWM_MAIN_FUNC10 2064 + # Skynode: use the "custom participant", IP=10.41.10.1 config for uxrce_dds_client param set-default UXRCE_DDS_PTCFG 2 param set-default UXRCE_DDS_AG_IP 170461697 diff --git a/boards/auterion/fmu-v6s/nuttx-config/nsh/defconfig b/boards/auterion/fmu-v6s/nuttx-config/nsh/defconfig index 8dacaf564c..2fa27f6758 100644 --- a/boards/auterion/fmu-v6s/nuttx-config/nsh/defconfig +++ b/boards/auterion/fmu-v6s/nuttx-config/nsh/defconfig @@ -226,8 +226,8 @@ CONFIG_STM32H7_PHY_POLLING=y CONFIG_STM32H7_PROGMEM=y CONFIG_STM32H7_RTC=y CONFIG_STM32H7_RTC_HSECLOCK=y -CONFIG_STM32H7_RTC_MAGIC_REG=1 CONFIG_STM32H7_RTC_MAGIC=0xA5A5A5A5 +CONFIG_STM32H7_RTC_MAGIC_REG=1 CONFIG_STM32H7_RTC_MAGIC_TIME_SET=0xA6A6A6A6 CONFIG_STM32H7_SAVE_CRASHDUMP=y CONFIG_STM32H7_SERIALBRK_BSDCOMPAT=y @@ -238,9 +238,12 @@ CONFIG_STM32H7_SPI3_DMA_BUFFER=1024 CONFIG_STM32H7_SPI4=y CONFIG_STM32H7_SPI4_DMA=y CONFIG_STM32H7_SPI4_DMA_BUFFER=4096 -CONFIG_STM32H7_TIM12=y CONFIG_STM32H7_TIM1=y +CONFIG_STM32H7_TIM2=y CONFIG_STM32H7_TIM3=y +CONFIG_STM32H7_TIM4=y +CONFIG_STM32H7_TIM5=y +CONFIG_STM32H7_TIM8=y CONFIG_STM32H7_UART4=y CONFIG_STM32H7_UART5=y CONFIG_STM32H7_UART7=y diff --git a/boards/auterion/fmu-v6s/src/board_config.h b/boards/auterion/fmu-v6s/src/board_config.h index 0b2f3c9225..4e40de72eb 100644 --- a/boards/auterion/fmu-v6s/src/board_config.h +++ b/boards/auterion/fmu-v6s/src/board_config.h @@ -135,15 +135,14 @@ /* PWM Timers */ -#define BOARD_NUM_IO_TIMERS 2 -#define DIRECT_PWM_OUTPUT_CHANNELS 8 +/* 3 for PWM outputs, 1 for input capture */ +#define BOARD_NUM_IO_TIMERS 4 +/* 9 for PWM outputs, 1 for input capture */ +#define DIRECT_PWM_OUTPUT_CHANNELS 10 /* High-resolution timer */ -#define HRT_TIMER 8 /* use timer8 for the HRT */ -#define HRT_TIMER_CHANNEL 3 /* use capture/compare channel 3 */ - -#define HRT_PPM_CHANNEL /* T8C2 */ 2 /* use capture/compare channel 1 */ -#define GPIO_PPM_IN /* PC7 */ GPIO_TIM8_CH2IN_1 +#define HRT_TIMER 4 /* use timer4 for the HRT */ +#define HRT_TIMER_CHANNEL 1 /* use capture/compare channel 1 */ /* This board provides a DMA pool and APIs */ #define BOARD_DMA_ALLOC_POOL_SIZE 5120 diff --git a/boards/auterion/fmu-v6s/src/timer_config.cpp b/boards/auterion/fmu-v6s/src/timer_config.cpp index 66311d38e2..a409137ef8 100644 --- a/boards/auterion/fmu-v6s/src/timer_config.cpp +++ b/boards/auterion/fmu-v6s/src/timer_config.cpp @@ -44,11 +44,17 @@ * TIM3_CH2 T FMU_CH6 * TIM3_CH3 T FMU_CH7 * TIM3_CH4 T FMU_CH8 + * + * TIM5_CH1 T FMU_CH9 + * + * TIM8_CH2 T FMU_CAP1 < Input Capture */ constexpr io_timers_t io_timers[MAX_IO_TIMERS] = { initIOTimer(Timer::Timer1, DMA{DMA::Index1}), initIOTimer(Timer::Timer3, DMA{DMA::Index1}), + initIOTimer(Timer::Timer5), + initIOTimer(Timer::Timer8), }; constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { @@ -60,6 +66,8 @@ constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel2}, {GPIO::PortB, GPIO::Pin5}), initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel3}, {GPIO::PortB, GPIO::Pin0}), initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel4}, {GPIO::PortC, GPIO::Pin9}), + initIOTimerChannel(io_timers, {Timer::Timer5, Timer::Channel1}, {GPIO::PortA, GPIO::Pin0}), + initIOTimerChannelCapture(io_timers, {Timer::Timer8, Timer::Channel2}, {GPIO::PortC, GPIO::Pin7}), }; constexpr io_timers_channel_mapping_t io_timers_channel_mapping = diff --git a/boards/auterion/fmu-v6x/default.px4board b/boards/auterion/fmu-v6x/default.px4board index dece24a26f..84b4cbc57e 100644 --- a/boards/auterion/fmu-v6x/default.px4board +++ b/boards/auterion/fmu-v6x/default.px4board @@ -20,6 +20,7 @@ CONFIG_DRIVERS_DSHOT=y CONFIG_DRIVERS_GNSS_SEPTENTRIO=y CONFIG_DRIVERS_GPIO_MCP23009=y CONFIG_DRIVERS_GPS=y +CONFIG_DRIVERS_PPS_CAPTURE=y CONFIG_DRIVERS_IMU_BOSCH_BMI088=y CONFIG_DRIVERS_IMU_INVENSENSE_ICM20602=y CONFIG_DRIVERS_IMU_INVENSENSE_ICM42688P=y diff --git a/boards/auterion/fmu-v6x/init/rc.board_defaults b/boards/auterion/fmu-v6x/init/rc.board_defaults index 1a6fc9673c..e3fe7f0dc2 100644 --- a/boards/auterion/fmu-v6x/init/rc.board_defaults +++ b/boards/auterion/fmu-v6x/init/rc.board_defaults @@ -3,12 +3,6 @@ # board specific defaults #------------------------------------------------------------------------------ -# By disabling all 3 INA modules, we use the -# i2c_launcher instead. -param set-default SENS_EN_INA238 0 -param set-default SENS_EN_INA228 0 -param set-default SENS_EN_INA226 0 - # Skynode: use the "custom participant", IP=10.41.10.1 config for uxrce_dds_client param set-default UXRCE_DDS_PTCFG 2 param set-default UXRCE_DDS_AG_IP 170461697 diff --git a/boards/auterion/fmu-v6x/src/board_config.h b/boards/auterion/fmu-v6x/src/board_config.h index c304153abf..671a1c3e5f 100644 --- a/boards/auterion/fmu-v6x/src/board_config.h +++ b/boards/auterion/fmu-v6x/src/board_config.h @@ -471,7 +471,7 @@ #define PX4_I2C_BUS_MTD 4,5 -#define BOARD_NUM_IO_TIMERS 5 +#define BOARD_NUM_IO_TIMERS 4 /* No CDCACM driver for this board, so this is manually defined for version.c * so that the px4_board_version reports the correct board id to the companion */ diff --git a/boards/auterion/fmu-v6x/src/timer_config.cpp b/boards/auterion/fmu-v6x/src/timer_config.cpp index 928f4916f0..a1c458d9eb 100644 --- a/boards/auterion/fmu-v6x/src/timer_config.cpp +++ b/boards/auterion/fmu-v6x/src/timer_config.cpp @@ -50,8 +50,6 @@ * TIM1_CH3 T SPI2_DRDY2_ISM330_INT2 < Capture or GPIO INT * TIM1_CH1 T SPIX_SYNC > Pulse or GPIO strobe * - * TIM2_CH3 T HEATER > PWM OUT or GPIO - * * TIM14_CH1 T BUZZER_1 - Driven by other driver * TIM8_CH1_IN T FMU_PPM_INPUT - Sampled byt HRT by other driver */ @@ -61,7 +59,6 @@ constexpr io_timers_t io_timers[MAX_IO_TIMERS] = { initIOTimer(Timer::Timer4, DMA{DMA::Index1}), initIOTimer(Timer::Timer12), initIOTimer(Timer::Timer1), - initIOTimer(Timer::Timer2), }; constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { diff --git a/boards/beaglebone/blue/default.px4board b/boards/beaglebone/blue/default.px4board index 155e2fb7d1..42148e5013 100644 --- a/boards/beaglebone/blue/default.px4board +++ b/boards/beaglebone/blue/default.px4board @@ -14,6 +14,7 @@ CONFIG_DRIVERS_GPS=y CONFIG_DRIVERS_IMU_ANALOG_DEVICES_ADIS16448=y CONFIG_DRIVERS_IMU_INVENSENSE_ICM20948=y CONFIG_DRIVERS_IMU_INVENSENSE_MPU9250=y +CONFIG_DRIVERS_LINUX_PWM_OUT=y CONFIG_DRIVERS_MAGNETOMETER_HMC5883=y CONFIG_DRIVERS_RC_INPUT=y CONFIG_DRIVERS_SMART_BATTERY_BATMON=y @@ -30,8 +31,8 @@ CONFIG_MODULES_EVENTS=y CONFIG_MODULES_FLIGHT_MODE_MANAGER=y CONFIG_MODULES_FW_ATT_CONTROL=y CONFIG_MODULES_FW_AUTOTUNE_ATTITUDE_CONTROL=y -CONFIG_MODULES_FW_MODE_MANAGER=y CONFIG_MODULES_FW_LATERAL_LONGITUDINAL_CONTROL=y +CONFIG_MODULES_FW_MODE_MANAGER=y CONFIG_MODULES_FW_RATE_CONTROL=y CONFIG_MODULES_GIMBAL=y CONFIG_MODULES_GYRO_CALIBRATION=y diff --git a/boards/corvon/743v1/extras/corvon_743v1_bootloader.bin b/boards/corvon/743v1/extras/corvon_743v1_bootloader.bin index a920927833..0875784c2c 100644 Binary files a/boards/corvon/743v1/extras/corvon_743v1_bootloader.bin and b/boards/corvon/743v1/extras/corvon_743v1_bootloader.bin differ diff --git a/boards/corvon/743v1/firmware.prototype b/boards/corvon/743v1/firmware.prototype index d4b0d6af34..4adb42ad91 100644 --- a/boards/corvon/743v1/firmware.prototype +++ b/boards/corvon/743v1/firmware.prototype @@ -1,5 +1,5 @@ { - "board_id": 1188, + "board_id": 1189, "magic": "PX4FWv1", "description": "Firmware for the CORVON743v1 board", "image": "", diff --git a/boards/corvon/743v1/src/hw_config.h b/boards/corvon/743v1/src/hw_config.h index 6e63d9b9a7..b773631093 100644 --- a/boards/corvon/743v1/src/hw_config.h +++ b/boards/corvon/743v1/src/hw_config.h @@ -96,7 +96,7 @@ #define INTERFACE_USART 1 #define INTERFACE_USART_CONFIG "/dev/ttyS0,115200" #define BOOT_DELAY_ADDRESS 0x000001a0 -#define BOARD_TYPE 1188 +#define BOARD_TYPE 1189 #define BOARD_FLASH_SECTORS (14) #define BOARD_FLASH_SIZE (16 * 128 * 1024) #define APP_RESERVATION_SIZE (1 * 128 * 1024) diff --git a/boards/cuav/fmu-v6x/default.px4board b/boards/cuav/fmu-v6x/default.px4board index 3458e2735d..d54cb466a9 100644 --- a/boards/cuav/fmu-v6x/default.px4board +++ b/boards/cuav/fmu-v6x/default.px4board @@ -61,7 +61,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/cuav/fmu-v6x/init/rc.board_defaults b/boards/cuav/fmu-v6x/init/rc.board_defaults index 2274fe9c17..31fa79a42b 100644 --- a/boards/cuav/fmu-v6x/init/rc.board_defaults +++ b/boards/cuav/fmu-v6x/init/rc.board_defaults @@ -3,13 +3,6 @@ # board specific defaults #------------------------------------------------------------------------------ -# By disabling all 3 INA modules, we use the -# i2c_launcher instead. -param set-default SENS_EN_INA238 0 -param set-default SENS_EN_INA228 0 -param set-default SENS_EN_INA226 0 - - # Mavlink ethernet (CFG 1000) param set-default MAV_2_CONFIG 1000 param set-default MAV_2_BROADCAST 1 diff --git a/boards/cuav/x25-evo/init/rc.board_defaults b/boards/cuav/x25-evo/init/rc.board_defaults index 8ef1ad0b40..bae8be59e1 100644 --- a/boards/cuav/x25-evo/init/rc.board_defaults +++ b/boards/cuav/x25-evo/init/rc.board_defaults @@ -15,10 +15,6 @@ param set-default MAV_2_UDP_PRT 14550 param set-default BAT1_V_DIV 18 param set-default BAT1_A_PER_V 24 -param set-default SENS_EN_INA238 0 -param set-default SENS_EN_INA228 0 -param set-default SENS_EN_INA226 0 - param set-default USB_MAV_MODE 5 param set-default UAVCAN_SUB_GPS 1 diff --git a/boards/micoair/h743-aio/default.px4board b/boards/micoair/h743-aio/default.px4board index d6dd734283..11abe64a47 100644 --- a/boards/micoair/h743-aio/default.px4board +++ b/boards/micoair/h743-aio/default.px4board @@ -37,7 +37,6 @@ CONFIG_DRIVERS_POWER_MONITOR_VOXLPM=y CONFIG_DRIVERS_PPS_CAPTURE=y CONFIG_DRIVERS_PWM_OUT=y CONFIG_COMMON_RC=y -CONFIG_DRIVERS_RC_INPUT=y CONFIG_DRIVERS_ROBOCLAW=y CONFIG_COMMON_RPM=y CONFIG_DRIVERS_SMART_BATTERY_BATMON=y diff --git a/boards/micoair/h743-lite/bootloader.px4board b/boards/micoair/h743-lite/bootloader.px4board new file mode 100644 index 0000000000..19b6e662be --- /dev/null +++ b/boards/micoair/h743-lite/bootloader.px4board @@ -0,0 +1,3 @@ +CONFIG_BOARD_TOOLCHAIN="arm-none-eabi" +CONFIG_BOARD_ARCHITECTURE="cortex-m7" +CONFIG_BOARD_ROMFSROOT="" diff --git a/boards/micoair/h743-lite/default.px4board b/boards/micoair/h743-lite/default.px4board new file mode 100644 index 0000000000..f24ffc4fdb --- /dev/null +++ b/boards/micoair/h743-lite/default.px4board @@ -0,0 +1,107 @@ +CONFIG_BOARD_TOOLCHAIN="arm-none-eabi" +CONFIG_BOARD_ARCHITECTURE="cortex-m7" +CONFIG_BOARD_SERIAL_URT6="/dev/ttyS6" +CONFIG_BOARD_SERIAL_GPS1="/dev/ttyS2" +CONFIG_BOARD_SERIAL_GPS2="/dev/ttyS1" +CONFIG_BOARD_SERIAL_TEL1="/dev/ttyS0" +CONFIG_BOARD_SERIAL_TEL2="/dev/ttyS3" +CONFIG_BOARD_SERIAL_TEL3="/dev/ttyS4" +CONFIG_BOARD_SERIAL_TEL4="/dev/ttyS7" +CONFIG_BOARD_SERIAL_RC="/dev/ttyS5" +CONFIG_BOARD_PARAM_FILE="/fs/microsd/params" +CONFIG_DRIVERS_ADC_BOARD_ADC=y +CONFIG_DRIVERS_BAROMETER_GOERTEK_SPA06=y +CONFIG_DRIVERS_CAMERA_CAPTURE=y +CONFIG_DRIVERS_CAMERA_TRIGGER=y +CONFIG_DRIVERS_CDCACM_AUTOSTART=y +CONFIG_COMMON_DIFFERENTIAL_PRESSURE=y +CONFIG_DRIVERS_DIFFERENTIAL_PRESSURE_ASP5033=y +CONFIG_DRIVERS_DIFFERENTIAL_PRESSURE_ETS=y +CONFIG_DRIVERS_DIFFERENTIAL_PRESSURE_MS4515=y +CONFIG_COMMON_DISTANCE_SENSOR=y +CONFIG_DRIVERS_DSHOT=y +CONFIG_DRIVERS_GNSS_SEPTENTRIO=y +CONFIG_DRIVERS_GPS=y +CONFIG_DRIVERS_IMU_INVENSENSE_ICM45686=y +CONFIG_COMMON_MAGNETOMETER=y +CONFIG_COMMON_OPTICAL_FLOW=y +CONFIG_DRIVERS_POWER_MONITOR_INA220=y +CONFIG_DRIVERS_POWER_MONITOR_INA226=y +CONFIG_DRIVERS_POWER_MONITOR_INA228=y +CONFIG_DRIVERS_POWER_MONITOR_INA238=y +CONFIG_DRIVERS_POWER_MONITOR_PM_SELECTOR_AUTERION=y +CONFIG_DRIVERS_POWER_MONITOR_VOXLPM=y +CONFIG_DRIVERS_PPS_CAPTURE=y +CONFIG_DRIVERS_PWM_OUT=y +CONFIG_COMMON_RC=y +CONFIG_COMMON_RPM=y +CONFIG_DRIVERS_SMART_BATTERY_BATMON=y +CONFIG_DRIVERS_TAP_ESC=y +CONFIG_COMMON_TELEMETRY=y +CONFIG_DRIVERS_TONE_ALARM=y +CONFIG_COMMON_UWB=y +CONFIG_COMMON_WIND_SENSOR=y +CONFIG_MODULES_AIRSHIP_ATT_CONTROL=y +CONFIG_MODULES_AIRSPEED_SELECTOR=y +CONFIG_MODULES_BATTERY_STATUS=y +CONFIG_MODULES_CAMERA_FEEDBACK=y +CONFIG_MODULES_COMMANDER=y +CONFIG_MODULES_CONTROL_ALLOCATOR=y +CONFIG_MODULES_DATAMAN=y +CONFIG_MODULES_EKF2=y +CONFIG_MODULES_ESC_BATTERY=y +CONFIG_MODULES_EVENTS=y +CONFIG_MODULES_FLIGHT_MODE_MANAGER=y +CONFIG_MODULES_FW_ATT_CONTROL=y +CONFIG_MODULES_FW_AUTOTUNE_ATTITUDE_CONTROL=y +CONFIG_MODULES_FW_POS_CONTROL=y +CONFIG_MODULES_FW_RATE_CONTROL=y +CONFIG_MODULES_GIMBAL=y +CONFIG_MODULES_GYRO_CALIBRATION=y +CONFIG_MODULES_GYRO_FFT=y +CONFIG_MODULES_LAND_DETECTOR=y +CONFIG_MODULES_LANDING_TARGET_ESTIMATOR=y +CONFIG_MODULES_LOAD_MON=y +CONFIG_MODULES_LOCAL_POSITION_ESTIMATOR=y +CONFIG_MODULES_LOGGER=y +CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y +CONFIG_MODULES_MANUAL_CONTROL=y +CONFIG_MODULES_MAVLINK=y +CONFIG_MODULES_MC_ATT_CONTROL=y +CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y +CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y +CONFIG_MODULES_MC_POS_CONTROL=y +CONFIG_MODULES_MC_RATE_CONTROL=y +CONFIG_MODULES_NAVIGATOR=y +CONFIG_MODULES_PAYLOAD_DELIVERER=y +CONFIG_MODULES_RC_UPDATE=y +CONFIG_MODULES_SENSORS=y +CONFIG_MODULES_TEMPERATURE_COMPENSATION=y +CONFIG_MODULES_UXRCE_DDS_CLIENT=y +CONFIG_MODULES_VTOL_ATT_CONTROL=y +CONFIG_SYSTEMCMDS_ACTUATOR_TEST=y +CONFIG_SYSTEMCMDS_BL_UPDATE=y +CONFIG_SYSTEMCMDS_BSONDUMP=y +CONFIG_SYSTEMCMDS_DMESG=y +CONFIG_SYSTEMCMDS_DUMPFILE=y +CONFIG_SYSTEMCMDS_FAILURE=y +CONFIG_SYSTEMCMDS_GPIO=y +CONFIG_SYSTEMCMDS_HARDFAULT_LOG=y +CONFIG_SYSTEMCMDS_I2CDETECT=y +CONFIG_SYSTEMCMDS_NSHTERM=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_PASSTHRU=y +CONFIG_SYSTEMCMDS_SERIAL_TEST=y +CONFIG_SYSTEMCMDS_SYSTEM_TIME=y +CONFIG_SYSTEMCMDS_TESTS=y +CONFIG_SYSTEMCMDS_TOP=y +CONFIG_SYSTEMCMDS_TOPIC_LISTENER=y +CONFIG_SYSTEMCMDS_TUNE_CONTROL=y +CONFIG_SYSTEMCMDS_UORB=y +CONFIG_SYSTEMCMDS_USB_CONNECTED=y +CONFIG_SYSTEMCMDS_VER=y +CONFIG_SYSTEMCMDS_WORK_QUEUE=y diff --git a/boards/micoair/h743-lite/extras/micoair_h743-lite_bootloader.bin b/boards/micoair/h743-lite/extras/micoair_h743-lite_bootloader.bin new file mode 100755 index 0000000000..e9bf775cde Binary files /dev/null and b/boards/micoair/h743-lite/extras/micoair_h743-lite_bootloader.bin differ diff --git a/boards/micoair/h743-lite/firmware.prototype b/boards/micoair/h743-lite/firmware.prototype new file mode 100644 index 0000000000..6bf59c3712 --- /dev/null +++ b/boards/micoair/h743-lite/firmware.prototype @@ -0,0 +1,13 @@ +{ + "board_id": 1202, + "magic": "PX4FWv1", + "description": "Firmware for the MicoAir743-Lite board", + "image": "", + "build_time": 0, + "summary": "MicoAir743-Lite", + "version": "0.1", + "image_size": 0, + "image_maxsize": 1966080, + "git_identity": "", + "board_revision": 0 +} diff --git a/boards/micoair/h743-lite/init/rc.board_defaults b/boards/micoair/h743-lite/init/rc.board_defaults new file mode 100644 index 0000000000..6448d6d3ae --- /dev/null +++ b/boards/micoair/h743-lite/init/rc.board_defaults @@ -0,0 +1,28 @@ +#!/bin/sh +# +# board specific defaults +#------------------------------------------------------------------------------ +param set-default BAT1_A_PER_V 40 +param set-default BAT1_N_CELLS 4 +param set-default BAT1_V_CHARGED 4.2 +param set-default BAT1_V_DIV 21.12 +param set-default BAT1_V_EMPTY 3.2 + +param set-default SYS_HAS_MAG 0 +#param set-default SENS_EN_SPA06 1 +param set-default PWM_MAIN_TIM0 -4 +param set-default RC_INPUT_PROTO -1 + +param set-default MAV_2_CONFIG 104 +param set-default SER_TEL4_BAUD 115200 + +param set-default IMU_GYRO_CUTOFF 80 +param set-default SYS_AUTOSTART 4001 +param set-default MC_PITCHRATE_K 0.4 +param set-default MC_ROLLRATE_K 0.35 +param set-default MC_YAWRATE_K 1.2 +param set-default MC_YAWRATE_MAX 360 +param set-default MAV_TYPE 2 +param set-default CA_AIRFRAME 0 +param set-default CA_ROTOR_COUNT 4 +param set-default CBRK_SUPPLY_CHK 894281 diff --git a/boards/micoair/h743-lite/init/rc.board_extras b/boards/micoair/h743-lite/init/rc.board_extras new file mode 100644 index 0000000000..e7653077db --- /dev/null +++ b/boards/micoair/h743-lite/init/rc.board_extras @@ -0,0 +1,7 @@ +#!/bin/sh +# +# board specific extras init +#------------------------------------------------------------------------------ + +# enable onboard OSD chip +# atxxxx start -s diff --git a/boards/micoair/h743-lite/init/rc.board_sensors b/boards/micoair/h743-lite/init/rc.board_sensors new file mode 100644 index 0000000000..c9be0818b7 --- /dev/null +++ b/boards/micoair/h743-lite/init/rc.board_sensors @@ -0,0 +1,13 @@ +#!/bin/sh +# +# board specific sensors init +#------------------------------------------------------------------------------ + +board_adc start + +# # Internal SPI bus ICM45686 accel/gyro +icm45686 -s -b 3 -R 2 start + +# Internal baro +#spa06 -I -a 0x77 start +spa06 -X -a 0x77 -b 2 start diff --git a/boards/micoair/h743-lite/nuttx-config/bootloader/defconfig b/boards/micoair/h743-lite/nuttx-config/bootloader/defconfig new file mode 100644 index 0000000000..d6a33ff9f7 --- /dev/null +++ b/boards/micoair/h743-lite/nuttx-config/bootloader/defconfig @@ -0,0 +1,85 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_DEV_CONSOLE is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +# CONFIG_SPI_EXCHANGE is not set +# CONFIG_STM32H7_SYSCFG is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD_CUSTOM=y +CONFIG_ARCH_BOARD_CUSTOM_DIR="../../../../boards/micoair/h743-lite/nuttx-config" +CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y +CONFIG_ARCH_BOARD_CUSTOM_NAME="px4" +CONFIG_ARCH_CHIP="stm32h7" +CONFIG_ARCH_CHIP_STM32H743VI=y +CONFIG_ARCH_CHIP_STM32H7=y +CONFIG_ARCH_INTERRUPTSTACK=768 +CONFIG_ARMV7M_BASEPRI_WAR=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_ARMV7M_MEMCPY=y +CONFIG_ARMV7M_USEBASEPRI=y +CONFIG_BOARDCTL=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_ASSERT_RESET_VALUE=0 +CONFIG_BOARD_INITTHREAD_PRIORITY=254 +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=95150 +CONFIG_BOARD_RESET_ON_ASSERT=2 +CONFIG_CDCACM=y +CONFIG_CDCACM_IFLOWCONTROL=y +CONFIG_CDCACM_PRODUCTID=0x004b +CONFIG_CDCACM_PRODUCTSTR="MicoAir743-Lite" +CONFIG_CDCACM_RXBUFSIZE=6000 +CONFIG_CDCACM_TXBUFSIZE=12000 +CONFIG_CDCACM_VENDORID=0x3162 +CONFIG_CDCACM_VENDORSTR="MicoAir" +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEBUG_TCBINFO=y +CONFIG_DEFAULT_SMALL=y +CONFIG_EXPERIMENTAL=y +CONFIG_FDCLONE_DISABLE=y +CONFIG_FDCLONE_STDIO=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=750 +CONFIG_INIT_ENTRYPOINT="bootloader_main" +CONFIG_INIT_STACKSIZE=3194 +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LIBC_LONG_LONG=y +CONFIG_LIBC_STRERROR=y +CONFIG_MEMSET_64BIT=y +CONFIG_MEMSET_OPTSPEED=y +CONFIG_PREALLOC_TIMERS=50 +CONFIG_PTHREAD_STACK_MIN=512 +CONFIG_RAM_SIZE=245760 +CONFIG_RAM_START=0x20010000 +CONFIG_RAW_BINARY=y +CONFIG_SIG_DEFAULT=y +CONFIG_SIG_SIGALRM_ACTION=y +CONFIG_SIG_SIGUSR1_ACTION=y +CONFIG_SIG_SIGUSR2_ACTION=y +CONFIG_SPI=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=30 +CONFIG_START_MONTH=11 +CONFIG_STDIO_BUFFER_SIZE=32 +CONFIG_STM32H7_BKPSRAM=y +CONFIG_STM32H7_DMA1=y +CONFIG_STM32H7_OTGFS=y +CONFIG_STM32H7_PROGMEM=y +CONFIG_STM32H7_TIM1=y +CONFIG_SYSTEMTICK_HOOK=y +CONFIG_SYSTEM_CDCACM=y +CONFIG_TASK_NAME_SIZE=24 +CONFIG_TTY_SIGINT=y +CONFIG_TTY_SIGINT_CHAR=0x03 +CONFIG_TTY_SIGTSTP=y +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y +CONFIG_USBDEV_MAXPOWER=500 +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/micoair/h743-lite/nuttx-config/include/board.h b/boards/micoair/h743-lite/nuttx-config/include/board.h new file mode 100644 index 0000000000..12f99c9bb6 --- /dev/null +++ b/boards/micoair/h743-lite/nuttx-config/include/board.h @@ -0,0 +1,414 @@ +/************************************************************************************ + * nuttx-configs/px4_fmu-v6u/include/board.h + * + * Copyright (C) 2016-2019 Gregory Nutt. All rights reserved. + * Authors: David Sidrane + * + * 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 NuttX 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. + * + ************************************************************************************/ +#ifndef __NUTTX_CONFIG_MICOAIR743_LITE_INCLUDE_BOARD_H +#define __NUTTX_CONFIG_MICOAIR743_LITE_INCLUDE_BOARD_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include "board_dma_map.h" + +#include + +#ifndef __ASSEMBLY__ +# include +#endif + +#include "stm32_rcc.h" +#include "stm32_sdmmc.h" + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +/* Clocking *************************************************************************/ +/* The MicoAir743-Lite board provides the following clock sources: + * + * X1: 8 MHz crystal for HSE + * + * So we have these clock source available within the STM32 + * + * HSI: 64 MHz RC factory-trimmed + * HSE: 8 MHz crystal for HSE + */ + +#define STM32_BOARD_XTAL 8000000ul + +#define STM32_HSI_FREQUENCY 16000000ul +#define STM32_LSI_FREQUENCY 32000 +#define STM32_HSE_FREQUENCY STM32_BOARD_XTAL +#define STM32_LSE_FREQUENCY 32768 + +/* Main PLL Configuration. + * + * PLL source is HSE = 8,000,000 + * + * PLL_VCOx = (STM32_HSE_FREQUENCY / PLLM) * PLLN + * Subject to: + * + * 1 <= PLLM <= 63 + * 4 <= PLLN <= 512 + * 150 MHz <= PLL_VCOL <= 420MHz + * 192 MHz <= PLL_VCOH <= 836MHz + * + * SYSCLK = PLL_VCO / PLLP + * CPUCLK = SYSCLK / D1CPRE + * Subject to + * + * PLLP1 = {2, 4, 6, 8, ..., 128} + * PLLP2,3 = {2, 3, 4, ..., 128} + * CPUCLK <= 480 MHz + */ + +#define STM32_BOARD_USEHSE + +#define STM32_PLLCFG_PLLSRC RCC_PLLCKSELR_PLLSRC_HSE + +/* PLL1, wide 4 - 8 MHz input, enable DIVP, DIVQ, DIVR + * + * PLL1_VCO = (8,000,000 / 1) * 120 = 960 MHz + * + * PLL1P = PLL1_VCO/2 = 960 MHz / 2 = 480 MHz + * PLL1Q = PLL1_VCO/4 = 960 MHz / 4 = 240 MHz + * PLL1R = PLL1_VCO/8 = 960 MHz / 8 = 120 MHz + */ + +#define STM32_PLLCFG_PLL1CFG (RCC_PLLCFGR_PLL1VCOSEL_WIDE | \ + RCC_PLLCFGR_PLL1RGE_4_8_MHZ | \ + RCC_PLLCFGR_DIVP1EN | \ + RCC_PLLCFGR_DIVQ1EN | \ + RCC_PLLCFGR_DIVR1EN) +#define STM32_PLLCFG_PLL1M RCC_PLLCKSELR_DIVM1(1) +#define STM32_PLLCFG_PLL1N RCC_PLL1DIVR_N1(120) +#define STM32_PLLCFG_PLL1P RCC_PLL1DIVR_P1(2) +#define STM32_PLLCFG_PLL1Q RCC_PLL1DIVR_Q1(4) +#define STM32_PLLCFG_PLL1R RCC_PLL1DIVR_R1(8) + +#define STM32_VCO1_FREQUENCY ((STM32_HSE_FREQUENCY / 1) * 120) +#define STM32_PLL1P_FREQUENCY (STM32_VCO1_FREQUENCY / 2) +#define STM32_PLL1Q_FREQUENCY (STM32_VCO1_FREQUENCY / 4) +#define STM32_PLL1R_FREQUENCY (STM32_VCO1_FREQUENCY / 8) + +/* PLL2 */ + +#define STM32_PLLCFG_PLL2CFG (RCC_PLLCFGR_PLL2VCOSEL_WIDE | \ + RCC_PLLCFGR_PLL2RGE_4_8_MHZ | \ + RCC_PLLCFGR_DIVP2EN | \ + RCC_PLLCFGR_DIVQ2EN | \ + RCC_PLLCFGR_DIVR2EN) +#define STM32_PLLCFG_PLL2M RCC_PLLCKSELR_DIVM2(2) +#define STM32_PLLCFG_PLL2N RCC_PLL2DIVR_N2(48) +#define STM32_PLLCFG_PLL2P RCC_PLL2DIVR_P2(2) +#define STM32_PLLCFG_PLL2Q RCC_PLL2DIVR_Q2(2) +#define STM32_PLLCFG_PLL2R RCC_PLL2DIVR_R2(2) + +#define STM32_VCO2_FREQUENCY ((STM32_HSE_FREQUENCY / 2) * 48) +#define STM32_PLL2P_FREQUENCY (STM32_VCO2_FREQUENCY / 2) +#define STM32_PLL2Q_FREQUENCY (STM32_VCO2_FREQUENCY / 2) +#define STM32_PLL2R_FREQUENCY (STM32_VCO2_FREQUENCY / 2) + +/* PLL3 */ + +#define STM32_PLLCFG_PLL3CFG (RCC_PLLCFGR_PLL3VCOSEL_WIDE | \ + RCC_PLLCFGR_PLL3RGE_4_8_MHZ | \ + RCC_PLLCFGR_DIVQ3EN) +#define STM32_PLLCFG_PLL3M RCC_PLLCKSELR_DIVM3(2) +#define STM32_PLLCFG_PLL3N RCC_PLL3DIVR_N3(48) +#define STM32_PLLCFG_PLL3P RCC_PLL3DIVR_P3(2) +#define STM32_PLLCFG_PLL3Q RCC_PLL3DIVR_Q3(4) +#define STM32_PLLCFG_PLL3R RCC_PLL3DIVR_R3(2) + +#define STM32_VCO3_FREQUENCY ((STM32_HSE_FREQUENCY / 2) * 48) +#define STM32_PLL3P_FREQUENCY (STM32_VCO3_FREQUENCY / 2) +#define STM32_PLL3Q_FREQUENCY (STM32_VCO3_FREQUENCY / 4) +#define STM32_PLL3R_FREQUENCY (STM32_VCO3_FREQUENCY / 2) + +/* SYSCLK = PLL1P = 480MHz + * CPUCLK = SYSCLK / 1 = 480 MHz + */ + +#define STM32_RCC_D1CFGR_D1CPRE (RCC_D1CFGR_D1CPRE_SYSCLK) +#define STM32_SYSCLK_FREQUENCY (STM32_PLL1P_FREQUENCY) +#define STM32_CPUCLK_FREQUENCY (STM32_SYSCLK_FREQUENCY / 1) + +/* Configure Clock Assignments */ + +/* AHB clock (HCLK) is SYSCLK/2 (240 MHz max) + * HCLK1 = HCLK2 = HCLK3 = HCLK4 = 240 + */ + +#define STM32_RCC_D1CFGR_HPRE RCC_D1CFGR_HPRE_SYSCLKd2 /* HCLK = SYSCLK / 2 */ +#define STM32_ACLK_FREQUENCY (STM32_CPUCLK_FREQUENCY / 2) /* ACLK in D1, HCLK3 in D1 */ +#define STM32_HCLK_FREQUENCY (STM32_CPUCLK_FREQUENCY / 2) /* HCLK in D2, HCLK4 in D3 */ +#define STM32_BOARD_HCLK STM32_HCLK_FREQUENCY /* same as above, to satisfy compiler */ + +/* APB1 clock (PCLK1) is HCLK/2 (120 MHz) */ + +#define STM32_RCC_D2CFGR_D2PPRE1 RCC_D2CFGR_D2PPRE1_HCLKd2 /* PCLK1 = HCLK / 2 */ +#define STM32_PCLK1_FREQUENCY (STM32_HCLK_FREQUENCY/2) + +/* APB2 clock (PCLK2) is HCLK/2 (120 MHz) */ + +#define STM32_RCC_D2CFGR_D2PPRE2 RCC_D2CFGR_D2PPRE2_HCLKd2 /* PCLK2 = HCLK / 2 */ +#define STM32_PCLK2_FREQUENCY (STM32_HCLK_FREQUENCY/2) + +/* APB3 clock (PCLK3) is HCLK/2 (120 MHz) */ + +#define STM32_RCC_D1CFGR_D1PPRE RCC_D1CFGR_D1PPRE_HCLKd2 /* PCLK3 = HCLK / 2 */ +#define STM32_PCLK3_FREQUENCY (STM32_HCLK_FREQUENCY/2) + +/* APB4 clock (PCLK4) is HCLK/4 (120 MHz) */ + +#define STM32_RCC_D3CFGR_D3PPRE RCC_D3CFGR_D3PPRE_HCLKd2 /* PCLK4 = HCLK / 2 */ +#define STM32_PCLK4_FREQUENCY (STM32_HCLK_FREQUENCY/2) + +/* Timer clock frequencies */ + +/* Timers driven from APB1 will be twice PCLK1 */ + +#define STM32_APB1_TIM2_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM3_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM4_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM5_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM6_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM7_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM12_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM13_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM14_CLKIN (2*STM32_PCLK1_FREQUENCY) + +/* Timers driven from APB2 will be twice PCLK2 */ + +#define STM32_APB2_TIM1_CLKIN (2*STM32_PCLK2_FREQUENCY) +#define STM32_APB2_TIM8_CLKIN (2*STM32_PCLK2_FREQUENCY) +#define STM32_APB2_TIM15_CLKIN (2*STM32_PCLK2_FREQUENCY) +#define STM32_APB2_TIM16_CLKIN (2*STM32_PCLK2_FREQUENCY) +#define STM32_APB2_TIM17_CLKIN (2*STM32_PCLK2_FREQUENCY) + +/* Kernel Clock Configuration + * + * Note: look at Table 54 in ST Manual + */ + +/* I2C123 clock source */ + +#define STM32_RCC_D2CCIP2R_I2C123SRC RCC_D2CCIP2R_I2C123SEL_HSI + +/* I2C4 clock source */ + +#define STM32_RCC_D3CCIPR_I2C4SRC RCC_D3CCIPR_I2C4SEL_HSI + +/* SPI123 clock source */ + +#define STM32_RCC_D2CCIP1R_SPI123SRC RCC_D2CCIP1R_SPI123SEL_PLL2 + +/* SPI45 clock source */ + +#define STM32_RCC_D2CCIP1R_SPI45SRC RCC_D2CCIP1R_SPI45SEL_PLL2 + +/* SPI6 clock source */ + +#define STM32_RCC_D3CCIPR_SPI6SRC RCC_D3CCIPR_SPI6SEL_PLL2 + +/* USB 1 and 2 clock source */ + +#define STM32_RCC_D2CCIP2R_USBSRC RCC_D2CCIP2R_USBSEL_PLL3 + +/* ADC 1 2 3 clock source */ + +#define STM32_RCC_D3CCIPR_ADCSEL RCC_D3CCIPR_ADCSEL_PLL2 + +/* FDCAN 1 clock source */ + +#define STM32_RCC_D2CCIP1R_FDCANSEL RCC_D2CCIP1R_FDCANSEL_HSE /* FDCAN 1 2 clock source */ + +#define STM32_FDCANCLK STM32_HSE_FREQUENCY + +/* FLASH wait states + * + * ------------ ---------- ----------- + * Vcore MAX ACLK WAIT STATES + * ------------ ---------- ----------- + * 1.15-1.26 V 70 MHz 0 + * (VOS1 level) 140 MHz 1 + * 210 MHz 2 + * 1.05-1.15 V 55 MHz 0 + * (VOS2 level) 110 MHz 1 + * 165 MHz 2 + * 220 MHz 3 + * 0.95-1.05 V 45 MHz 0 + * (VOS3 level) 90 MHz 1 + * 135 MHz 2 + * 180 MHz 3 + * 225 MHz 4 + * ------------ ---------- ----------- + */ + +#define BOARD_FLASH_WAITSTATES 2 + +/* SDMMC definitions ********************************************************/ + +/* Init 480kHz, freq = PLL1Q/(2*div) div = PLL1Q/(2*freq) */ + +#define STM32_SDMMC_INIT_CLKDIV (300 << STM32_SDMMC_CLKCR_CLKDIV_SHIFT) + +/* 20 MHz Max for now - more reliable on some boards than 25 MHz + * 20 MHz = PLL1Q/(2*div), div = PLL1Q/(2*freq), div = 6 = 240 / 40 + */ + +#if defined(CONFIG_STM32H7_SDMMC_XDMA) || defined(CONFIG_STM32H7_SDMMC_IDMA) +# define STM32_SDMMC_MMCXFR_CLKDIV (6 << STM32_SDMMC_CLKCR_CLKDIV_SHIFT) +#else +# define STM32_SDMMC_MMCXFR_CLKDIV (100 << STM32_SDMMC_CLKCR_CLKDIV_SHIFT) +#endif +#if defined(CONFIG_STM32H7_SDMMC_XDMA) || defined(CONFIG_STM32H7_SDMMC_IDMA) +# define STM32_SDMMC_SDXFR_CLKDIV (6 << STM32_SDMMC_CLKCR_CLKDIV_SHIFT) +#else +# define STM32_SDMMC_SDXFR_CLKDIV (100 << STM32_SDMMC_CLKCR_CLKDIV_SHIFT) +#endif + +#define STM32_SDMMC_CLKCR_EDGE STM32_SDMMC_CLKCR_NEGEDGE + +/* LED definitions ******************************************************************/ +/* The board has two, LED_GREEN a Green LED and LED_BLUE a Blue LED, + * that can be controlled by software. + * + * If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any way. + * The following definitions are used to access individual LEDs. + */ + +/* LED index values for use with board_userled() */ + +#define BOARD_LED1 0 +#define BOARD_LED2 1 +#define BOARD_LED3 2 +#define BOARD_NLEDS 3 + +#define BOARD_LED_RED BOARD_LED1 +#define BOARD_LED_GREEN BOARD_LED2 +#define BOARD_LED_BLUE BOARD_LED3 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) +#define BOARD_LED2_BIT (1 << BOARD_LED2) +#define BOARD_LED3_BIT (1 << BOARD_LED3) + +/* If CONFIG_ARCH_LEDS is defined, the usage by the board port is defined in + * include/board.h and src/stm32_leds.c. The LEDs are used to encode OS-related + * events as follows: + * + * + * SYMBOL Meaning LED state + * Red Green Blue + * ---------------------- -------------------------- ------ ------ ----*/ + +#define LED_STARTED 0 /* NuttX has been started OFF OFF OFF */ +#define LED_HEAPALLOCATE 1 /* Heap has been allocated OFF OFF ON */ +#define LED_IRQSENABLED 2 /* Interrupts enabled OFF ON OFF */ +#define LED_STACKCREATED 3 /* Idle stack created OFF ON ON */ +#define LED_INIRQ 4 /* In an interrupt N/C N/C GLOW */ +#define LED_SIGNAL 5 /* In a signal handler N/C GLOW N/C */ +#define LED_ASSERTION 6 /* An assertion failed GLOW N/C GLOW */ +#define LED_PANIC 7 /* The system has crashed Blink OFF N/C */ +#define LED_IDLE 8 /* MCU is is sleep mode ON OFF OFF */ + +/* Thus if the Green LED is statically on, NuttX has successfully booted and + * is, apparently, running normally. If the Red LED is flashing at + * approximately 2Hz, then a fatal error has been detected and the system + * has halted. + */ + +/* Alternate function pin selections ************************************************/ + +#define GPIO_USART1_RX GPIO_USART1_RX_2 /* PA10 */ +#define GPIO_USART1_TX GPIO_USART1_TX_2 /* PA9 */ + +#define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */ +#define GPIO_USART2_TX GPIO_USART2_TX_1 /* PA2 */ + +#define GPIO_USART3_RX GPIO_USART3_RX_3 /* PD9 */ +#define GPIO_USART3_TX GPIO_USART3_TX_3 /* PD8 */ + +#define GPIO_UART4_RX GPIO_UART4_RX_2 /* PA1 */ +#define GPIO_UART4_TX GPIO_UART4_TX_2 /* PA0 */ + +#define GPIO_UART5_RX GPIO_UART5_RX_2 /* PB5 */ +#define GPIO_UART5_TX GPIO_UART5_TX_2 /* PB6 */ + +#define GPIO_USART6_RX GPIO_USART6_RX_1 /* PC7 */ +#define GPIO_USART6_TX GPIO_USART6_TX_1 /* PC6 */ + +#define GPIO_UART7_RX GPIO_UART7_RX_3 /* PE7 */ +#define GPIO_UART7_TX GPIO_UART7_TX_3 /* PE8 */ + +#define GPIO_UART8_RX GPIO_UART8_RX_1 /* PE0 */ +#define GPIO_UART8_TX GPIO_UART8_TX_1 /* PE1 */ + + +/* SPI + * + + */ + +#define ADJ_SLEW_RATE(p) (((p) & ~GPIO_SPEED_MASK) | (GPIO_SPEED_2MHz)) + +#define GPIO_SPI3_MISO GPIO_SPI3_MISO_1 /* PB4 */ +#define GPIO_SPI3_MOSI GPIO_SPI3_MOSI_1 /* PD6 */ +#define GPIO_SPI3_SCK ADJ_SLEW_RATE(GPIO_SPI3_SCK_1) /* PB3 */ + +/* I2C + * + + * + */ + +#define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 /* PB8 */ +#define GPIO_I2C1_SDA GPIO_I2C1_SDA_2 /* PB9 */ + +#define GPIO_I2C1_SCL_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN8) +#define GPIO_I2C1_SDA_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN9) + +#define GPIO_I2C2_SCL GPIO_I2C2_SCL_1 /* PB10 */ +#define GPIO_I2C2_SDA GPIO_I2C2_SDA_1 /* PB11 */ + +#define GPIO_I2C2_SCL_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN10) +#define GPIO_I2C2_SDA_GPIO (GPIO_OUTPUT | GPIO_OPENDRAIN | GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN11) + +# define PROBE_INIT(mask) +# define PROBE(n,s) +# define PROBE_MARK(n) + +#endif /*__NUTTX_CONFIG_MICOAIR743_LITE_INCLUDE_BOARD_H */ diff --git a/boards/micoair/h743-lite/nuttx-config/include/board_dma_map.h b/boards/micoair/h743-lite/nuttx-config/include/board_dma_map.h new file mode 100644 index 0000000000..fd6a97722a --- /dev/null +++ b/boards/micoair/h743-lite/nuttx-config/include/board_dma_map.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2021 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. + * + ****************************************************************************/ + +#pragma once +#define DMAMAP_SPI3_RX DMAMAP_DMA12_SPI3RX_0 +#define DMAMAP_SPI3_TX DMAMAP_DMA12_SPI3TX_0 diff --git a/boards/micoair/h743-lite/nuttx-config/nsh/defconfig b/boards/micoair/h743-lite/nuttx-config/nsh/defconfig new file mode 100644 index 0000000000..11a2d6967f --- /dev/null +++ b/boards/micoair/h743-lite/nuttx-config/nsh/defconfig @@ -0,0 +1,244 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_DEV_CONSOLE is not set +# CONFIG_DISABLE_ENVIRON is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_MMCSD_HAVE_CARDDETECT is not set +# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set +# CONFIG_MMCSD_MMCSUPPORT is not set +# CONFIG_MMCSD_SPI is not set +# CONFIG_NSH_DISABLEBG is not set +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_DF is not set +# CONFIG_NSH_DISABLE_ECHO is not set +# CONFIG_NSH_DISABLE_ENV is not set +# CONFIG_NSH_DISABLE_EXEC is not set +# CONFIG_NSH_DISABLE_EXIT is not set +# CONFIG_NSH_DISABLE_EXPORT is not set +# CONFIG_NSH_DISABLE_FREE is not set +# CONFIG_NSH_DISABLE_GET is not set +# CONFIG_NSH_DISABLE_HELP is not set +# CONFIG_NSH_DISABLE_ITEF is not set +# CONFIG_NSH_DISABLE_KILL is not set +# CONFIG_NSH_DISABLE_LOOPS is not set +# CONFIG_NSH_DISABLE_LS is not set +# CONFIG_NSH_DISABLE_MKDIR is not set +# CONFIG_NSH_DISABLE_MKFATFS is not set +# CONFIG_NSH_DISABLE_MOUNT is not set +# CONFIG_NSH_DISABLE_MV is not set +# CONFIG_NSH_DISABLE_PRINTF is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PSSTACKUSAGE is not set +# CONFIG_NSH_DISABLE_PWD is not set +# CONFIG_NSH_DISABLE_RM is not set +# CONFIG_NSH_DISABLE_RMDIR is not set +# CONFIG_NSH_DISABLE_SEMICOLON is not set +# CONFIG_NSH_DISABLE_SET is not set +# CONFIG_NSH_DISABLE_SLEEP is not set +# CONFIG_NSH_DISABLE_SOURCE is not set +# CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_TIME is not set +# CONFIG_NSH_DISABLE_UMOUNT is not set +# CONFIG_NSH_DISABLE_UNSET is not set +# CONFIG_NSH_DISABLE_USLEEP is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD_CUSTOM=y +CONFIG_ARCH_BOARD_CUSTOM_DIR="../../../../boards/micoair/h743-lite/nuttx-config" +CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y +CONFIG_ARCH_BOARD_CUSTOM_NAME="px4" +CONFIG_ARCH_CHIP="stm32h7" +CONFIG_ARCH_CHIP_STM32H743VI=y +CONFIG_ARCH_CHIP_STM32H7=y +CONFIG_ARCH_INTERRUPTSTACK=768 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7M_BASEPRI_WAR=y +CONFIG_ARMV7M_DCACHE=y +CONFIG_ARMV7M_DTCM=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_ARMV7M_MEMCPY=y +CONFIG_ARMV7M_USEBASEPRI=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_ASSERT_RESET_VALUE=0 +CONFIG_BOARD_CRASHDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=95150 +CONFIG_BOARD_RESET_ON_ASSERT=2 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_IFLOWCONTROL=y +CONFIG_CDCACM_PRODUCTID=0x0036 +CONFIG_CDCACM_PRODUCTSTR="MicoAir743-Lite" +CONFIG_CDCACM_RXBUFSIZE=6000 +CONFIG_CDCACM_TXBUFSIZE=12000 +CONFIG_CDCACM_VENDORID=0x1B8C +CONFIG_CDCACM_VENDORSTR="MicoAir" +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_HARDFAULT_ALERT=y +CONFIG_DEBUG_MEMFAULT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_SMALL=y +CONFIG_DEV_FIFO_SIZE=0 +CONFIG_DEV_PIPE_MAXSIZE=1024 +CONFIG_DEV_PIPE_SIZE=70 +CONFIG_EXPERIMENTAL=y +CONFIG_FAT_DMAMEMORY=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FAT_LFN_ALIAS_HASH=y +CONFIG_FDCLONE_STDIO=y +CONFIG_FS_BINFS=y +CONFIG_FS_CROMFS=y +CONFIG_FS_FAT=y +CONFIG_FS_FATTIME=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_INCLUDE_PROGMEM=y +CONFIG_FS_PROCFS_MAX_TASKS=64 +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_FS_ROMFS=y +CONFIG_GRAN=y +CONFIG_GRAN_INTR=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_I2C=y +CONFIG_I2C_RESET=y +CONFIG_IDLETHREAD_STACKSIZE=750 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3194 +CONFIG_IOB_NBUFFERS=24 +CONFIG_IOB_NCHAINS=24 +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LIBC_LONG_LONG=y +CONFIG_LIBC_MAX_EXITFUNS=1 +CONFIG_LIBC_STRERROR=y +CONFIG_MEMSET_64BIT=y +CONFIG_MEMSET_OPTSPEED=y +CONFIG_MMCSD=y +CONFIG_MMCSD_SDIO=y +CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE=y +CONFIG_MM_IOB=y +CONFIG_MM_REGIONS=4 +CONFIG_NAME_MAX=40 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_ARGCAT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_CMDPARMS=y +CONFIG_NSH_CROMFSETC=y +CONFIG_NSH_LINELEN=128 +CONFIG_NSH_MAXARGUMENTS=15 +CONFIG_NSH_NESTDEPTH=8 +CONFIG_NSH_QUOTE=y +CONFIG_NSH_ROMFSETC=y +CONFIG_NSH_ROMFSSECTSIZE=128 +CONFIG_NSH_STRERROR=y +CONFIG_NSH_VARS=y +CONFIG_OTG_ID_GPIO_DISABLE=y +CONFIG_PIPES=y +CONFIG_PREALLOC_TIMERS=50 +CONFIG_PRIORITY_INHERITANCE=y +CONFIG_PTHREAD_MUTEX_ROBUST=y +CONFIG_PTHREAD_STACK_MIN=512 +CONFIG_RAM_SIZE=245760 +CONFIG_RAM_START=0x20010000 +CONFIG_RAW_BINARY=y +CONFIG_RTC_DATETIME=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=249 +CONFIG_SCHED_HPWORKSTACKSIZE=1280 +CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_EXTERNAL=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_LPWORKPRIORITY=50 +CONFIG_SCHED_LPWORKSTACKSIZE=1632 +CONFIG_SCHED_WAITPID=y +CONFIG_SDMMC1_SDIO_PULLUP=y +CONFIG_SEM_PREALLOCHOLDERS=32 +CONFIG_SERIAL_TERMIOS=y +CONFIG_SIG_DEFAULT=y +CONFIG_SIG_SIGALRM_ACTION=y +CONFIG_SIG_SIGUSR1_ACTION=y +CONFIG_SIG_SIGUSR2_ACTION=y +CONFIG_SIG_SIGWORK=4 +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=30 +CONFIG_START_MONTH=11 +CONFIG_STDIO_BUFFER_SIZE=256 +CONFIG_STM32H7_ADC1=y +CONFIG_STM32H7_ADC3=y +CONFIG_STM32H7_BBSRAM=y +CONFIG_STM32H7_BBSRAM_FILES=5 +CONFIG_STM32H7_BDMA=y +CONFIG_STM32H7_BKPSRAM=y +CONFIG_STM32H7_DMA1=y +CONFIG_STM32H7_DMA2=y +CONFIG_STM32H7_DMACAPABLE=y +CONFIG_STM32H7_FLASH_OVERRIDE_I=y +CONFIG_STM32H7_I2C1=y +CONFIG_STM32H7_I2C2=y +CONFIG_STM32H7_I2C_DYNTIMEO=y +CONFIG_STM32H7_I2C_DYNTIMEO_STARTSTOP=10 +CONFIG_STM32H7_OTGFS=y +CONFIG_STM32H7_PROGMEM=y +CONFIG_STM32H7_RTC=y +CONFIG_STM32H7_RTC_HSECLOCK=y +CONFIG_STM32H7_RTC_MAGIC_REG=1 +CONFIG_STM32H7_SAVE_CRASHDUMP=y +CONFIG_STM32H7_SDMMC1=y +CONFIG_STM32H7_SERIALBRK_BSDCOMPAT=y +CONFIG_STM32H7_SERIAL_DISABLE_REORDERING=y +CONFIG_STM32H7_SPI3=y +CONFIG_STM32H7_SPI3_DMA=y +CONFIG_STM32H7_SPI3_DMA_BUFFER=2048 +CONFIG_STM32H7_SPI_DMATHRESHOLD=8 +CONFIG_STM32H7_TIM12=y +CONFIG_STM32H7_TIM15=y +CONFIG_STM32H7_TIM1=y +CONFIG_STM32H7_TIM3=y +CONFIG_STM32H7_TIM4=y +CONFIG_STM32H7_TIM8=y +CONFIG_STM32H7_UART4=y +CONFIG_STM32H7_UART5=y +CONFIG_STM32H7_UART7=y +CONFIG_STM32H7_UART8=y +CONFIG_STM32H7_USART1=y +CONFIG_STM32H7_USART2=y +CONFIG_STM32H7_USART3=y +CONFIG_STM32H7_USART6=y +CONFIG_STM32H7_USART_BREAKS=y +CONFIG_STM32H7_USART_INVERT=y +CONFIG_STM32H7_USART_SINGLEWIRE=y +CONFIG_STM32H7_USART_SWAP=y +CONFIG_SYSTEM_CDCACM=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=24 +CONFIG_UART4_RXBUFSIZE=600 +CONFIG_UART4_TXBUFSIZE=800 +CONFIG_UART5_RXBUFSIZE=600 +CONFIG_UART5_TXBUFSIZE=800 +CONFIG_UART7_RXBUFSIZE=600 +CONFIG_UART7_TXBUFSIZE=800 +CONFIG_UART8_RXBUFSIZE=600 +CONFIG_UART8_TXBUFSIZE=800 +CONFIG_USART1_RXBUFSIZE=1200 +CONFIG_USART1_TXBUFSIZE=1500 +CONFIG_USART2_RXBUFSIZE=600 +CONFIG_USART2_TXBUFSIZE=800 +CONFIG_USART3_RXBUFSIZE=600 +CONFIG_USART3_TXBUFSIZE=800 +CONFIG_USART6_BAUD=57600 +CONFIG_USART6_RXBUFSIZE=600 +CONFIG_USART6_TXBUFSIZE=800 +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y +CONFIG_USBDEV_MAXPOWER=500 +CONFIG_USEC_PER_TICK=1000 +CONFIG_WATCHDOG=y diff --git a/boards/micoair/h743-lite/nuttx-config/scripts/bootloader_script.ld b/boards/micoair/h743-lite/nuttx-config/scripts/bootloader_script.ld new file mode 100644 index 0000000000..fb877cc443 --- /dev/null +++ b/boards/micoair/h743-lite/nuttx-config/scripts/bootloader_script.ld @@ -0,0 +1,213 @@ +/**************************************************************************** + * scripts/script.ld + * + * Copyright (C) 2016, 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * + * 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 NuttX 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. + * + ****************************************************************************/ + +/* The Durandal-v1 uses an STM32H743II has 2048Kb of main FLASH memory. + * The flash memory is partitioned into a User Flash memory and a System + * Flash memory. Each of these memories has two banks: + * + * 1) User Flash memory: + * + * Bank 1: Start address 0x0800:0000 to 0x080F:FFFF with 8 sectors, 128Kb each + * Bank 2: Start address 0x0810:0000 to 0x081F:FFFF with 8 sectors, 128Kb each + * + * 2) System Flash memory: + * + * Bank 1: Start address 0x1FF0:0000 to 0x1FF1:FFFF with 1 x 128Kb sector + * Bank 1: Start address 0x1FF4:0000 to 0x1FF5:FFFF with 1 x 128Kb sector + * + * 3) User option bytes for user configuration, only in Bank 1. + * + * In the STM32H743II, two different boot spaces can be selected through + * the BOOT pin and the boot base address programmed in the BOOT_ADD0 and + * BOOT_ADD1 option bytes: + * + * 1) BOOT=0: Boot address defined by user option byte BOOT_ADD0[15:0]. + * ST programmed value: Flash memory at 0x0800:0000 + * 2) BOOT=1: Boot address defined by user option byte BOOT_ADD1[15:0]. + * ST programmed value: System bootloader at 0x1FF0:0000 + * + * The Durandal has a Switch on board, the BOOT0 pin is at ground so by default, + * the STM32 will boot to address 0x0800:0000 in FLASH unless the swiutch is + * drepresed, then the boot will be from 0x1FF0:0000 + * + * The STM32H743ZI also has 1024Kb of data SRAM. + * SRAM is split up into several blocks and into three power domains: + * + * 1) TCM SRAMs are dedicated to the Cortex-M7 and are accessible with + * 0 wait states by the Cortex-M7 and by MDMA through AHBS slave bus + * + * 1.1) 128Kb of DTCM-RAM beginning at address 0x2000:0000 + * + * The DTCM-RAM is organized as 2 x 64Kb DTCM-RAMs on 2 x 32 bit + * DTCM ports. The DTCM-RAM could be used for critical real-time + * data, such as interrupt service routines or stack / heap memory. + * Both DTCM-RAMs can be used in parallel (for load/store operations) + * thanks to the Cortex-M7 dual issue capability. + * + * 1.2) 64Kb of ITCM-RAM beginning at address 0x0000:0000 + * + * This RAM is connected to ITCM 64-bit interface designed for + * execution of critical real-times routines by the CPU. + * + * 2) AXI SRAM (D1 domain) accessible by all system masters except BDMA + * through D1 domain AXI bus matrix + * + * 2.1) 512Kb of SRAM beginning at address 0x2400:0000 + * + * 3) AHB SRAM (D2 domain) accessible by all system masters except BDMA + * through D2 domain AHB bus matrix + * + * 3.1) 128Kb of SRAM1 beginning at address 0x3000:0000 + * 3.2) 128Kb of SRAM2 beginning at address 0x3002:0000 + * 3.3) 32Kb of SRAM3 beginning at address 0x3004:0000 + * + * SRAM1 - SRAM3 are one contiguous block: 288Kb at address 0x3000:0000 + * + * 4) AHB SRAM (D3 domain) accessible by most of system masters + * through D3 domain AHB bus matrix + * + * 4.1) 64Kb of SRAM4 beginning at address 0x3800:0000 + * 4.1) 4Kb of backup RAM beginning at address 0x3880:0000 + * + * When booting from FLASH, FLASH memory is aliased to address 0x0000:0000 + * where the code expects to begin execution by jumping to the entry point in + * the 0x0800:0000 address range. + */ + +MEMORY +{ + itcm (rwx) : ORIGIN = 0x00000000, LENGTH = 64K + flash (rx) : ORIGIN = 0x08000000, LENGTH = 2048K + dtcm1 (rwx) : ORIGIN = 0x20000000, LENGTH = 64K + dtcm2 (rwx) : ORIGIN = 0x20010000, LENGTH = 64K + sram (rwx) : ORIGIN = 0x24000000, LENGTH = 512K + sram1 (rwx) : ORIGIN = 0x30000000, LENGTH = 128K + sram2 (rwx) : ORIGIN = 0x30020000, LENGTH = 128K + sram3 (rwx) : ORIGIN = 0x30040000, LENGTH = 32K + sram4 (rwx) : ORIGIN = 0x38000000, LENGTH = 64K + bbram (rwx) : ORIGIN = 0x38800000, LENGTH = 4K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +/* + * Ensure that abort() is present in the final object. The exception handling + * code pulled in by libgcc.a requires it (and that code cannot be easily avoided). + */ +EXTERN(abort) +EXTERN(_bootdelay_signature) + +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + . = ALIGN(32); + /* + This signature provides the bootloader with a way to delay booting + */ + _bootdelay_signature = ABSOLUTE(.); + FILL(0xffecc2925d7d05c5) + . += 8; + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + + } > flash + + /* + * Init functions (static constructors and the like) + */ + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(.init_array .init_array.*)) + _einit = ABSOLUTE(.); + } > flash + + + .ARM.extab : { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/micoair/h743-lite/nuttx-config/scripts/script.ld b/boards/micoair/h743-lite/nuttx-config/scripts/script.ld new file mode 100644 index 0000000000..85f4990724 --- /dev/null +++ b/boards/micoair/h743-lite/nuttx-config/scripts/script.ld @@ -0,0 +1,228 @@ +/**************************************************************************** + * scripts/script.ld + * + * Copyright (C) 2020 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * + * 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 NuttX 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. + * + ****************************************************************************/ + +/* The board uses an STM32H743II and has 2048Kb of main FLASH memory. + * The flash memory is partitioned into a User Flash memory and a System + * Flash memory. Each of these memories has two banks: + * + * 1) User Flash memory: + * + * Bank 1: Start address 0x0800:0000 to 0x080F:FFFF with 8 sectors, 128Kb each + * Bank 2: Start address 0x0810:0000 to 0x081F:FFFF with 8 sectors, 128Kb each + * + * 2) System Flash memory: + * + * Bank 1: Start address 0x1FF0:0000 to 0x1FF1:FFFF with 1 x 128Kb sector + * Bank 1: Start address 0x1FF4:0000 to 0x1FF5:FFFF with 1 x 128Kb sector + * + * 3) User option bytes for user configuration, only in Bank 1. + * + * In the STM32H743II, two different boot spaces can be selected through + * the BOOT pin and the boot base address programmed in the BOOT_ADD0 and + * BOOT_ADD1 option bytes: + * + * 1) BOOT=0: Boot address defined by user option byte BOOT_ADD0[15:0]. + * ST programmed value: Flash memory at 0x0800:0000 + * 2) BOOT=1: Boot address defined by user option byte BOOT_ADD1[15:0]. + * ST programmed value: System bootloader at 0x1FF0:0000 + * + * There's a switch on board, the BOOT0 pin is at ground so by default, + * the STM32 will boot to address 0x0800:0000 in FLASH unless the switch is + * drepresed, then the boot will be from 0x1FF0:0000 + * + * The STM32H743ZI also has 1024Kb of data SRAM. + * SRAM is split up into several blocks and into three power domains: + * + * 1) TCM SRAMs are dedicated to the Cortex-M7 and are accessible with + * 0 wait states by the Cortex-M7 and by MDMA through AHBS slave bus + * + * 1.1) 128Kb of DTCM-RAM beginning at address 0x2000:0000 + * + * The DTCM-RAM is organized as 2 x 64Kb DTCM-RAMs on 2 x 32 bit + * DTCM ports. The DTCM-RAM could be used for critical real-time + * data, such as interrupt service routines or stack / heap memory. + * Both DTCM-RAMs can be used in parallel (for load/store operations) + * thanks to the Cortex-M7 dual issue capability. + * + * 1.2) 64Kb of ITCM-RAM beginning at address 0x0000:0000 + * + * This RAM is connected to ITCM 64-bit interface designed for + * execution of critical real-times routines by the CPU. + * + * 2) AXI SRAM (D1 domain) accessible by all system masters except BDMA + * through D1 domain AXI bus matrix + * + * 2.1) 512Kb of SRAM beginning at address 0x2400:0000 + * + * 3) AHB SRAM (D2 domain) accessible by all system masters except BDMA + * through D2 domain AHB bus matrix + * + * 3.1) 128Kb of SRAM1 beginning at address 0x3000:0000 + * 3.2) 128Kb of SRAM2 beginning at address 0x3002:0000 + * 3.3) 32Kb of SRAM3 beginning at address 0x3004:0000 + * + * SRAM1 - SRAM3 are one contiguous block: 288Kb at address 0x3000:0000 + * + * 4) AHB SRAM (D3 domain) accessible by most of system masters + * through D3 domain AHB bus matrix + * + * 4.1) 64Kb of SRAM4 beginning at address 0x3800:0000 + * 4.1) 4Kb of backup RAM beginning at address 0x3880:0000 + * + * When booting from FLASH, FLASH memory is aliased to address 0x0000:0000 + * where the code expects to begin execution by jumping to the entry point in + * the 0x0800:0000 address range. + */ + +MEMORY +{ + ITCM_RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 64K + FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 1920K + + DTCM1_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64K + DTCM2_RAM (rwx) : ORIGIN = 0x20010000, LENGTH = 64K + AXI_SRAM (rwx) : ORIGIN = 0x24000000, LENGTH = 512K /* D1 domain AXI bus */ + SRAM1 (rwx) : ORIGIN = 0x30000000, LENGTH = 128K /* D2 domain AHB bus */ + SRAM2 (rwx) : ORIGIN = 0x30020000, LENGTH = 128K /* D2 domain AHB bus */ + SRAM3 (rwx) : ORIGIN = 0x30040000, LENGTH = 32K /* D2 domain AHB bus */ + SRAM4 (rwx) : ORIGIN = 0x38000000, LENGTH = 64K /* D3 domain */ + BKPRAM (rwx) : ORIGIN = 0x38800000, LENGTH = 4K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +/* + * Ensure that abort() is present in the final object. The exception handling + * code pulled in by libgcc.a requires it (and that code cannot be easily avoided). + */ +EXTERN(abort) +EXTERN(_bootdelay_signature) + +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + . = ALIGN(32); + /* + This signature provides the bootloader with a way to delay booting + */ + _bootdelay_signature = ABSOLUTE(.); + FILL(0xffecc2925d7d05c5) + . += 8; + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + + } > FLASH + + /* + * Init functions (static constructors and the like) + */ + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(.init_array .init_array.*)) + _einit = ABSOLUTE(.); + } > FLASH + + + .ARM.extab : { + *(.ARM.extab*) + } > FLASH + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > FLASH + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + + /* Pad out last section as the STM32H7 Flash write size is 256 bits. 32 bytes */ + . = ALIGN(16); + FILL(0xffff) + . += 16; + } > AXI_SRAM AT > FLASH = 0xffff + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > AXI_SRAM + + /* Emit the the D3 power domain section for locating BDMA data */ + + .sram4_reserve (NOLOAD) : + { + *(.sram4) + . = ALIGN(4); + _sram4_heap_start = ABSOLUTE(.); + } > SRAM4 + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/micoair/h743-lite/src/CMakeLists.txt b/boards/micoair/h743-lite/src/CMakeLists.txt new file mode 100644 index 0000000000..c47215375d --- /dev/null +++ b/boards/micoair/h743-lite/src/CMakeLists.txt @@ -0,0 +1,68 @@ +############################################################################ +# +# Copyright (c) 2021 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. +# +############################################################################ +if("${PX4_BOARD_LABEL}" STREQUAL "bootloader") + add_library(drivers_board + bootloader_main.c + usb.c + ) + target_link_libraries(drivers_board + PRIVATE + nuttx_arch + nuttx_drivers + bootloader + ) + target_include_directories(drivers_board PRIVATE ${PX4_SOURCE_DIR}/platforms/nuttx/src/bootloader/common) + +else() + add_library(drivers_board + i2c.cpp + init.c + led.c + sdio.c + spi.cpp + timer_config.cpp + usb.c + ) + add_dependencies(drivers_board arch_board_hw_info) + + target_link_libraries(drivers_board + PRIVATE + arch_io_pins + arch_spi + arch_board_hw_info + drivers__led + nuttx_arch + nuttx_drivers + px4_layer + ) +endif() diff --git a/boards/micoair/h743-lite/src/board_config.h b/boards/micoair/h743-lite/src/board_config.h new file mode 100644 index 0000000000..2eef26d59b --- /dev/null +++ b/boards/micoair/h743-lite/src/board_config.h @@ -0,0 +1,199 @@ +/**************************************************************************** + * + * Copyright (c) 2021 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 board_config.h + * + * Board internal definitions + */ + +#pragma once + +/**************************************************************************************************** + * Included Files + ****************************************************************************************************/ + +#include +#include +#include + +#include + +/**************************************************************************************************** + * Definitions + ****************************************************************************************************/ + + + +/* LEDs are driven with push open drain to support Anode to 5V or 3.3V */ + +# define GPIO_nLED_RED /* PE3 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN3) +# define GPIO_nLED_GREEN /* PE2 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN2) +# define GPIO_nLED_BLUE /* PE4 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN4) + +# define BOARD_HAS_CONTROL_STATUS_LEDS 1 +# define BOARD_OVERLOAD_LED LED_RED +# define BOARD_ARMED_STATE_LED LED_BLUE + + +/* + * ADC channels + * + * These are the channel numbers of the ADCs of the microcontroller that + * can be used by the Px4 Firmware in the adc driver + */ + +/* ADC defines to be used in sensors.cpp to read from a particular channel */ +#define SYSTEM_ADC_BASE STM32_ADC1_BASE +#define ADC1_CH(n) (n) + +/* Define GPIO pins used as ADC N.B. Channel numbers must match below */ +#define PX4_ADC_GPIO \ + /* PC0 */ GPIO_ADC123_INP10, \ + /* PC1 */ GPIO_ADC123_INP11 + + +/* Define Channel numbers must match above GPIO pin IN(n)*/ +#define ADC_BATTERY_VOLTAGE_CHANNEL /* PC0 */ ADC1_CH(10) +#define ADC_BATTERY_CURRENT_CHANNEL /* PC1 */ ADC1_CH(11) + + +#define ADC_CHANNELS \ + ((1 << ADC_BATTERY_VOLTAGE_CHANNEL) | \ + (1 << ADC_BATTERY_CURRENT_CHANNEL)) + + +/* Define Battery 1 Voltage Divider and A per V + */ + +// #define BOARD_BATTERY1_V_DIV (11.0f) /* measured with the provided PM board */ +// #define BOARD_BATTERY1_A_PER_V (40.0f) +// #define BOARD_BATTERY2_V_DIV (11.0f) /* measured with the provided PM board */ + + +/* PWM + */ +#define DIRECT_PWM_OUTPUT_CHANNELS 14 +#define DIRECT_INPUT_TIMER_CHANNELS 14 + +#define BOARD_HAS_PWM DIRECT_PWM_OUTPUT_CHANNELS + +#define GPIO_TONE_ALARM_IDLE /* PD15 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN15) +#define GPIO_TONE_ALARM_GPIO /* PD15 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN15) + +/* USB OTG FS + * + * PA8 OTG_FS_VBUS VBUS sensing + */ + +#define GPIO_OTGFS_VBUS /* PA8 */ (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_100MHz|GPIO_PORTA|GPIO_PIN8) + + +/* High-resolution timer */ +#define HRT_TIMER 8 /* use timer8 for the HRT */ +#define HRT_TIMER_CHANNEL 3 /* use capture/compare channel 3 */ + + +/* RC Serial port */ +#define RC_SERIAL_PORT "/dev/ttyS5" +#define BOARD_SUPPORTS_RC_SERIAL_PORT_OUTPUT + +//#define GPIO_I2C2_DRDY1_SPA06 /* PD0 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTD|GPIO_PIN0) + + +/* SD Card */ +#define SDIO_SLOTNO 0 /* Only one slot */ +#define SDIO_MINOR 0 + +/* This board provides a DMA pool and APIs */ +#define BOARD_DMA_ALLOC_POOL_SIZE 5120 + +/* This board provides the board_on_reset interface */ +#define BOARD_HAS_ON_RESET 1 + +#define PX4_GPIO_INIT_LIST { \ + PX4_ADC_GPIO, \ + GPIO_TONE_ALARM_IDLE, \ + } + +#define BOARD_ENABLE_CONSOLE_BUFFER + + +#define BOARD_NUM_IO_TIMERS 6 + + +__BEGIN_DECLS + +/**************************************************************************************************** + * Public Types + ****************************************************************************************************/ + +/**************************************************************************************************** + * Public data + ****************************************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************************************** + * Public Functions + ****************************************************************************************************/ + +/**************************************************************************** + * Name: stm32_sdio_initialize + * + * Description: + * Initialize SDIO-based MMC/SD card support + * + ****************************************************************************/ + +int stm32_sdio_initialize(void); + +/**************************************************************************************************** + * Name: stm32_spiinitialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the board. + * + ****************************************************************************************************/ + +extern void stm32_spiinitialize(void); + +extern void stm32_usbinitialize(void); + +extern void board_peripheral_reset(int ms); + +#include + +#endif /* __ASSEMBLY__ */ + +__END_DECLS diff --git a/boards/micoair/h743-lite/src/bootloader_main.c b/boards/micoair/h743-lite/src/bootloader_main.c new file mode 100644 index 0000000000..5670308a29 --- /dev/null +++ b/boards/micoair/h743-lite/src/bootloader_main.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * + * Copyright (c) 2021 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 bootloader_main.c + * + * FMU-specific early startup code for bootloader +*/ + +#include "board_config.h" +#include "bl.h" + +#include +#include +#include +#include +#include +#include "arm_internal.h" +#include + +extern int sercon_main(int c, char **argv); + +__EXPORT void board_on_reset(int status) {} + +__EXPORT void stm32_boardinitialize(void) +{ + /* configure USB interfaces */ + stm32_usbinitialize(); +} + +__EXPORT int board_app_initialize(uintptr_t arg) +{ + return 0; +} + +void board_late_initialize(void) +{ + sercon_main(0, NULL); +} + +extern void sys_tick_handler(void); +void board_timerhook(void) +{ + sys_tick_handler(); +} diff --git a/boards/micoair/h743-lite/src/hw_config.h b/boards/micoair/h743-lite/src/hw_config.h new file mode 100644 index 0000000000..ac210d78d4 --- /dev/null +++ b/boards/micoair/h743-lite/src/hw_config.h @@ -0,0 +1,135 @@ +/**************************************************************************** + * + * Copyright (C) 2021 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. + * + ****************************************************************************/ + +#pragma once + +/**************************************************************************** + * 10-8--2016: + * To simplify the ripple effect on the tools, we will be using + * /dev/serial/by-id/PX4 to locate PX4 devices. Therefore + * moving forward all Bootloaders must contain the prefix "PX4 BL " + * in the USBDEVICESTRING + * This Change will be made in an upcoming BL release + ****************************************************************************/ +/* + * Define usage to configure a bootloader + * + * + * Constant example Usage + * APP_LOAD_ADDRESS 0x08004000 - The address in Linker Script, where the app fw is org-ed + * BOOTLOADER_DELAY 5000 - Ms to wait while under USB pwr or bootloader request + * BOARD_FMUV2 + * INTERFACE_USB 1 - (Optional) Scan and use the USB interface for bootloading + * INTERFACE_USART 1 - (Optional) Scan and use the Serial interface for bootloading + * USBDEVICESTRING "PX4 BL FMU v2.x" - USB id string + * USBPRODUCTID 0x0011 - PID Should match defconfig + * BOOT_DELAY_ADDRESS 0x000001a0 - (Optional) From the linker script from Linker Script to get a custom + * delay provided by an APP FW + * BOARD_TYPE 9 - Must match .prototype boad_id + * _FLASH_KBYTES (*(uint16_t *)0x1fff7a22) - Run time flash size detection + * BOARD_FLASH_SECTORS ((_FLASH_KBYTES == 0x400) ? 11 : 23) - Run time determine the physical last sector + * BOARD_FLASH_SECTORS 11 - Hard coded zero based last sector + * BOARD_FLASH_SIZE (_FLASH_KBYTES*1024)- Total Flash size of device, determined at run time. + * (1024 * 1024) - Hard coded Total Flash of device - The bootloader and app reserved will be deducted + * programmatically + * + * BOARD_FIRST_FLASH_SECTOR_TO_ERASE 2 - Optional sectors index in the flash_sectors table (F4 only), to begin erasing. + * This is to allow sectors to be reserved for app fw usage. That will NOT be erased + * during a FW upgrade. + * The default is 0, and selects the first sector to be erased, as the 0th entry in the + * flash_sectors table. Which is the second physical sector of FLASH in the device. + * The first physical sector of FLASH is used by the bootloader, and is not defined + * in the table. + * + * APP_RESERVATION_SIZE (BOARD_FIRST_FLASH_SECTOR_TO_ERASE * 16 * 1024) - Number of bytes reserved by the APP FW. This number plus + * BOOTLOADER_RESERVATION_SIZE will be deducted from + * BOARD_FLASH_SIZE to determine the size of the App FW + * and hence the address space of FLASH to erase and program. + * USBMFGSTRING "PX4 AP" - Optional USB MFG string (default is '3D Robotics' if not defined.) + * SERIAL_BREAK_DETECT_DISABLED - Optional prevent break selection on Serial port from entering or staying in BL + * + * * Other defines are somewhat self explanatory. + */ + +/* Boot device selection list*/ +#define USB0_DEV 0x01 +#define SERIAL0_DEV 0x02 +#define SERIAL1_DEV 0x04 + +#define APP_LOAD_ADDRESS 0x08020000 +#define BOOTLOADER_DELAY 5000 +#define INTERFACE_USB 1 +#define INTERFACE_USB_CONFIG "/dev/ttyACM0" +#define BOARD_VBUS MK_GPIO_INPUT(GPIO_OTGFS_VBUS) + +//#define USE_VBUS_PULL_DOWN +#define INTERFACE_USART 1 +#define INTERFACE_USART_CONFIG "/dev/ttyS0,115200" +#define BOOT_DELAY_ADDRESS 0x000001a0 +#define BOARD_TYPE 1202 +#define _FLASH_KBYTES (*(uint32_t *)0x1FF1E880) +#define BOARD_FLASH_SECTORS (15) +#define BOARD_FLASH_SIZE (_FLASH_KBYTES * 1024) + +#define OSC_FREQ 8 + +#define BOARD_PIN_LED_ACTIVITY GPIO_nLED_BLUE // BLUE +#define BOARD_PIN_LED_BOOTLOADER GPIO_nLED_GREEN // GREEN +#define BOARD_LED_ON 0 +#define BOARD_LED_OFF 1 + +#define SERIAL_BREAK_DETECT_DISABLED 1 + +#if !defined(ARCH_SN_MAX_LENGTH) +# define ARCH_SN_MAX_LENGTH 12 +#endif + +#if !defined(APP_RESERVATION_SIZE) +# define APP_RESERVATION_SIZE 0 +#endif + +#if !defined(BOARD_FIRST_FLASH_SECTOR_TO_ERASE) +# define BOARD_FIRST_FLASH_SECTOR_TO_ERASE 1 +#endif + +#if !defined(USB_DATA_ALIGN) +# define USB_DATA_ALIGN +#endif + +#ifndef BOOT_DEVICES_SELECTION +# define BOOT_DEVICES_SELECTION USB0_DEV|SERIAL0_DEV|SERIAL1_DEV +#endif + +#ifndef BOOT_DEVICES_FILTER_ONUSB +# define BOOT_DEVICES_FILTER_ONUSB USB0_DEV|SERIAL0_DEV|SERIAL1_DEV +#endif diff --git a/boards/micoair/h743-lite/src/i2c.cpp b/boards/micoair/h743-lite/src/i2c.cpp new file mode 100644 index 0000000000..bea7532cc3 --- /dev/null +++ b/boards/micoair/h743-lite/src/i2c.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** + * + * Copyright (C) 2021 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. + * + ****************************************************************************/ + +#include + +constexpr px4_i2c_bus_t px4_i2c_buses[I2C_BUS_MAX_BUS_ITEMS] = { + initI2CBusExternal(1), + initI2CBusExternal(2), +}; diff --git a/boards/micoair/h743-lite/src/init.c b/boards/micoair/h743-lite/src/init.c new file mode 100644 index 0000000000..c0e1f9776c --- /dev/null +++ b/boards/micoair/h743-lite/src/init.c @@ -0,0 +1,208 @@ +/**************************************************************************** + * + * Copyright (c) 2021 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 init.c + * + * FMU-specific early startup code. This file implements the + * board_app_initialize() function that is called early by nsh during startup. + * + * Code here is run before the rcS script is invoked; it should start required + * subsystems and perform board-specific initialisation. + */ + +#include "board_config.h" + +#include + +#include +#include +#include +#include +#include +#include "arm_internal.h" + +#include +#include +#include +#include +#include +#include +#include + +# if defined(FLASH_BASED_PARAMS) +# include +#endif + +__BEGIN_DECLS +extern void led_init(void); +extern void led_on(int led); +extern void led_off(int led); +__END_DECLS + +/************************************************************************************ + * Name: board_peripheral_reset + * + * Description: + * + ************************************************************************************/ +__EXPORT void board_peripheral_reset(int ms) +{ + UNUSED(ms); +} + +/************************************************************************************ + * Name: board_on_reset + * + * Description: + * Optionally provided function called on entry to board_system_reset + * It should perform any house keeping prior to the rest. + * + * status - 1 if resetting to boot loader + * 0 if just resetting + * + ************************************************************************************/ +__EXPORT void board_on_reset(int status) +{ + for (int i = 0; i < DIRECT_PWM_OUTPUT_CHANNELS; ++i) { + px4_arch_configgpio(PX4_MAKE_GPIO_INPUT(io_timer_channel_get_as_pwm_input(i))); + } + + /* + * On resets invoked from system (not boot) ensure we establish a low + * output state on PWM pins to disarm the ESC and prevent the reset from potentially + * spinning up the motors. + */ + if (status >= 0) { + up_mdelay(100); + } +} + +/************************************************************************************ + * Name: stm32_boardinitialize + * + * Description: + * All STM32 architectures must provide the following entry point. This entry point + * is called early in the initialization -- after all memory has been configured + * and mapped but before any devices have been initialized. + * + ************************************************************************************/ +__EXPORT void stm32_boardinitialize(void) +{ + /* Reset PWM first thing */ + board_on_reset(-1); + + /* configure LEDs */ + board_autoled_initialize(); + + /* configure pins */ + const uint32_t gpio[] = PX4_GPIO_INIT_LIST; + px4_gpio_init(gpio, arraySize(gpio)); + + /* configure SPI interfaces */ + stm32_spiinitialize(); + + /* configure USB interfaces */ + stm32_usbinitialize(); + +} + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ +__EXPORT int board_app_initialize(uintptr_t arg) +{ + /* Need hrt running before using the ADC */ + px4_platform_init(); + + /* configure the DMA allocator */ + if (board_dma_alloc_init() < 0) { + syslog(LOG_ERR, "[boot] DMA alloc FAILED\n"); + } + + /* initial LED state */ + drv_led_start(); + led_off(LED_RED); + led_off(LED_BLUE); + + if (board_hardfault_init(2, true) != 0) { + led_on(LED_BLUE); + } + +#ifdef CONFIG_MMCSD + int ret = stm32_sdio_initialize(); + + if (ret != OK) { + led_on(LED_BLUE); + return ret; + } + +#endif + +// TODO:internal flash store parameters +#if defined(FLASH_BASED_PARAMS) + static sector_descriptor_t params_sector_map[] = { + {15, 128 * 1024, 0x081E0000}, + {0, 0, 0}, + }; + + /* Initialize the flashfs layer to use heap allocated memory */ + int result = parameter_flashfs_init(params_sector_map, NULL, 0); + + if (result != OK) { + syslog(LOG_ERR, "[boot] FAILED to init params in FLASH %d\n", result); + led_on(LED_RED); + } + +#endif + + /* Configure the HW based on the manifest */ + px4_platform_configure(); + + return OK; +} diff --git a/boards/micoair/h743-lite/src/led.c b/boards/micoair/h743-lite/src/led.c new file mode 100644 index 0000000000..d7794392db --- /dev/null +++ b/boards/micoair/h743-lite/src/led.c @@ -0,0 +1,114 @@ +/**************************************************************************** + * + * Copyright (c) 2021 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 led.c + * + * LED backend. + */ + +#include + +#include + +#include "chip.h" +#include "stm32_gpio.h" +#include "board_config.h" + +#include +#include + +/* + * Ideally we'd be able to get these from arm_internal.h, + * but since we want to be able to disable the NuttX use + * of leds for system indication at will and there is no + * separate switch, we need to build independent of the + * CONFIG_ARCH_LEDS configuration switch. + */ +__BEGIN_DECLS +extern void led_init(void); +extern void led_on(int led); +extern void led_off(int led); +extern void led_toggle(int led); +__END_DECLS + +# define xlat(p) (p) +static uint32_t g_ledmap[] = { + GPIO_nLED_GREEN, // Indexed by BOARD_LED_GREEN + GPIO_nLED_BLUE, // Indexed by BOARD_LED_BLUE + GPIO_nLED_RED, // Indexed by BOARD_LED_RED +}; + +__EXPORT void led_init(void) +{ + /* Configure LED GPIOs for output */ + for (size_t l = 0; l < (sizeof(g_ledmap) / sizeof(g_ledmap[0])); l++) { + if (g_ledmap[l] != 0) { + stm32_configgpio(g_ledmap[l]); + } + } +} + +static void phy_set_led(int led, bool state) +{ + /* Drive Low to switch on */ + if (g_ledmap[led] != 0) { + stm32_gpiowrite(g_ledmap[led], !state); + } +} + +static bool phy_get_led(int led) +{ + /* If Low it is on */ + if (g_ledmap[led] != 0) { + return !stm32_gpioread(g_ledmap[led]); + } + + return false; +} + + +__EXPORT void led_on(int led) +{ + phy_set_led(xlat(led), true); +} + +__EXPORT void led_off(int led) +{ + phy_set_led(xlat(led), false); +} + +__EXPORT void led_toggle(int led) +{ + phy_set_led(xlat(led), !phy_get_led(xlat(led))); +} diff --git a/boards/micoair/h743-lite/src/sdio.c b/boards/micoair/h743-lite/src/sdio.c new file mode 100644 index 0000000000..869d757756 --- /dev/null +++ b/boards/micoair/h743-lite/src/sdio.c @@ -0,0 +1,177 @@ +/**************************************************************************** + * + * Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 NuttX 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "chip.h" +#include "board_config.h" +#include "stm32_gpio.h" +#include "stm32_sdmmc.h" + +#ifdef CONFIG_MMCSD + + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Card detections requires card support and a card detection GPIO */ + +#define HAVE_NCD 1 +#if !defined(GPIO_SDMMC1_NCD) +# undef HAVE_NCD +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static FAR struct sdio_dev_s *sdio_dev; +#ifdef HAVE_NCD +static bool g_sd_inserted = 0xff; /* Impossible value */ +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_ncd_interrupt + * + * Description: + * Card detect interrupt handler. + * + ****************************************************************************/ + +#ifdef HAVE_NCD +static int stm32_ncd_interrupt(int irq, FAR void *context) +{ + bool present; + + present = !stm32_gpioread(GPIO_SDMMC1_NCD); + + if (sdio_dev && present != g_sd_inserted) { + sdio_mediachange(sdio_dev, present); + g_sd_inserted = present; + } + + return OK; +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_sdio_initialize + * + * Description: + * Initialize SDIO-based MMC/SD card support + * + ****************************************************************************/ + +int stm32_sdio_initialize(void) +{ + int ret; + +#ifdef HAVE_NCD + /* Card detect */ + + bool cd_status; + + /* Configure the card detect GPIO */ + + stm32_configgpio(GPIO_SDMMC1_NCD); + + /* Register an interrupt handler for the card detect pin */ + + stm32_gpiosetevent(GPIO_SDMMC1_NCD, true, true, true, stm32_ncd_interrupt); +#endif + + /* Mount the SDIO-based MMC/SD block driver */ + /* First, get an instance of the SDIO interface */ + + finfo("Initializing SDIO slot %d\n", SDIO_SLOTNO); + + sdio_dev = sdio_initialize(SDIO_SLOTNO); + + if (!sdio_dev) { + syslog(LOG_ERR, "[boot] Failed to initialize SDIO slot %d\n", SDIO_SLOTNO); + return -ENODEV; + } + + /* Now bind the SDIO interface to the MMC/SD driver */ + + finfo("Bind SDIO to the MMC/SD driver, minor=%d\n", SDIO_MINOR); + + ret = mmcsd_slotinitialize(SDIO_MINOR, sdio_dev); + + if (ret != OK) { + syslog(LOG_ERR, "[boot] Failed to bind SDIO to the MMC/SD driver: %d\n", ret); + return ret; + } + + finfo("Successfully bound SDIO to the MMC/SD driver\n"); + +#ifdef HAVE_NCD + /* Use SD card detect pin to check if a card is g_sd_inserted */ + + cd_status = !stm32_gpioread(GPIO_SDMMC1_NCD); + finfo("Card detect : %d\n", cd_status); + + sdio_mediachange(sdio_dev, cd_status); +#else + /* Assume that the SD card is inserted. What choice do we have? */ + + sdio_mediachange(sdio_dev, true); +#endif + + return OK; +} + +#endif /* CONFIG_MMCSD */ diff --git a/boards/3dr/ctrl-zero-h7-oem-revg/src/mtd.cpp b/boards/micoair/h743-lite/src/spi.cpp similarity index 64% rename from boards/3dr/ctrl-zero-h7-oem-revg/src/mtd.cpp rename to boards/micoair/h743-lite/src/spi.cpp index c1b0f1bac3..148534ff85 100644 --- a/boards/3dr/ctrl-zero-h7-oem-revg/src/mtd.cpp +++ b/boards/micoair/h743-lite/src/spi.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2025 PX4 Development Team. All rights reserved. + * Copyright (C) 2021 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 @@ -31,46 +31,15 @@ * ****************************************************************************/ +#include +#include #include -#include -// KiB BS nB -static const px4_mft_device_t spi2 = { // FM25V01A on FMUM native: 32K X 8, emulated as (1024 Blocks of 32) - .bus_type = px4_mft_device_t::SPI, - .devid = SPIDEV_FLASH(0) + + +constexpr px4_spi_bus_t px4_spi_buses[SPI_BUS_MAX_BUS_ITEMS] = { + initSPIBus(SPI::Bus::SPI3, { + initSPIDevice(DRV_IMU_DEVTYPE_ICM45686, SPI::CS{GPIO::PortD, GPIO::Pin4}, SPI::DRDY{GPIO::PortD, GPIO::Pin5}), + }), }; -static const px4_mtd_entry_t fmum_fram = { - .device = &spi2, - .npart = 1, - .partd = { - { - .type = MTD_PARAMETERS, - .path = "/fs/mtd_params", - .nblocks = (32768 / (1 << CONFIG_RAMTRON_EMULATE_PAGE_SHIFT)) - }, - }, -}; - -static const px4_mtd_manifest_t board_mtd_config = { - .nconfigs = 1, - .entries = { - &fmum_fram - } -}; - -static const px4_mft_entry_s mtd_mft = { - .type = MTD, - .pmft = (void *) &board_mtd_config, -}; - -static const px4_mft_s mft = { - .nmft = 1, - .mfts = { - &mtd_mft - } -}; - -const px4_mft_s *board_get_manifest(void) -{ - return &mft; -} +static constexpr bool unused = validateSPIConfig(px4_spi_buses); diff --git a/boards/micoair/h743-lite/src/timer_config.cpp b/boards/micoair/h743-lite/src/timer_config.cpp new file mode 100644 index 0000000000..050d3b0dc4 --- /dev/null +++ b/boards/micoair/h743-lite/src/timer_config.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** + * + * Copyright (C) 2021 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. + * + ****************************************************************************/ + +#include + +constexpr io_timers_t io_timers[MAX_IO_TIMERS] = { + initIOTimer(Timer::Timer1, DMA{DMA::Index1}), + initIOTimer(Timer::Timer3, DMA{DMA::Index1}), + initIOTimer(Timer::Timer4, DMA{DMA::Index1}), + initIOTimer(Timer::Timer12), + initIOTimer(Timer::Timer15), +}; + +constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { + initIOTimerChannel(io_timers, {Timer::Timer1, Timer::Channel4}, {GPIO::PortE, GPIO::Pin14}), + initIOTimerChannel(io_timers, {Timer::Timer1, Timer::Channel3}, {GPIO::PortE, GPIO::Pin13}), + initIOTimerChannel(io_timers, {Timer::Timer1, Timer::Channel2}, {GPIO::PortE, GPIO::Pin11}), + initIOTimerChannel(io_timers, {Timer::Timer1, Timer::Channel1}, {GPIO::PortE, GPIO::Pin9}), + initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel4}, {GPIO::PortB, GPIO::Pin1}), + initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel3}, {GPIO::PortB, GPIO::Pin0}), + initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel2}, {GPIO::PortA, GPIO::Pin7}), + initIOTimerChannel(io_timers, {Timer::Timer3, Timer::Channel1}, {GPIO::PortA, GPIO::Pin6}), + initIOTimerChannel(io_timers, {Timer::Timer15, Timer::Channel1}, {GPIO::PortE, GPIO::Pin5}), + initIOTimerChannel(io_timers, {Timer::Timer15, Timer::Channel2}, {GPIO::PortE, GPIO::Pin6}), + initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel1}, {GPIO::PortD, GPIO::Pin12}), + initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel2}, {GPIO::PortD, GPIO::Pin13}), + initIOTimerChannel(io_timers, {Timer::Timer12, Timer::Channel1}, {GPIO::PortB, GPIO::Pin14}), + initIOTimerChannel(io_timers, {Timer::Timer12, Timer::Channel2}, {GPIO::PortB, GPIO::Pin15}), + +}; + +constexpr io_timers_channel_mapping_t io_timers_channel_mapping = + initIOTimerChannelMapping(io_timers, timer_io_channels); diff --git a/boards/micoair/h743-lite/src/usb.c b/boards/micoair/h743-lite/src/usb.c new file mode 100644 index 0000000000..9591784866 --- /dev/null +++ b/boards/micoair/h743-lite/src/usb.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * + * Copyright (C) 2021 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 usb.c + * + * Board-specific USB functions. + */ + +#include "board_config.h" +#include +#include +#include +#include + +/************************************************************************************ + * Name: stm32_usbinitialize + * + * Description: + * Called to setup USB-related GPIO pins for the board. + * + ************************************************************************************/ + +__EXPORT void stm32_usbinitialize(void) +{ + /* The OTG FS has an internal soft pull-up */ + + /* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */ + +#ifdef CONFIG_STM32H7_OTGFS + stm32_configgpio(GPIO_OTGFS_VBUS); +#endif +} + +/************************************************************************************ + * Name: stm32_usbsuspend + * + * Description: + * Board logic must provide the stm32_usbsuspend logic if the USBDEV driver is + * used. This function is called whenever the USB enters or leaves suspend mode. + * This is an opportunity for the board logic to shutdown clocks, power, etc. + * while the USB is suspended. + * + ************************************************************************************/ +__EXPORT void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume) +{ + uinfo("resume: %d\n", resume); +} diff --git a/boards/micoair/h743-v2/default.px4board b/boards/micoair/h743-v2/default.px4board index 9f6d00a5d0..5276166e42 100644 --- a/boards/micoair/h743-v2/default.px4board +++ b/boards/micoair/h743-v2/default.px4board @@ -36,7 +36,6 @@ CONFIG_DRIVERS_POWER_MONITOR_VOXLPM=y CONFIG_DRIVERS_PPS_CAPTURE=y CONFIG_DRIVERS_PWM_OUT=y CONFIG_COMMON_RC=y -CONFIG_DRIVERS_RC_INPUT=y CONFIG_COMMON_RPM=y CONFIG_DRIVERS_SMART_BATTERY_BATMON=y CONFIG_DRIVERS_TAP_ESC=y diff --git a/boards/micoair/h743/default.px4board b/boards/micoair/h743/default.px4board index d6769fa1d8..abf1cfb4ff 100644 --- a/boards/micoair/h743/default.px4board +++ b/boards/micoair/h743/default.px4board @@ -38,7 +38,6 @@ CONFIG_DRIVERS_POWER_MONITOR_VOXLPM=y CONFIG_DRIVERS_PPS_CAPTURE=y CONFIG_DRIVERS_PWM_OUT=y CONFIG_COMMON_RC=y -CONFIG_DRIVERS_RC_INPUT=y CONFIG_COMMON_RPM=y CONFIG_DRIVERS_SMART_BATTERY_BATMON=y CONFIG_DRIVERS_TAP_ESC=y diff --git a/boards/nxp/mr-canhubk3/nuttx-config/nsh/defconfig b/boards/nxp/mr-canhubk3/nuttx-config/nsh/defconfig index c397305d7e..65e28164f8 100644 --- a/boards/nxp/mr-canhubk3/nuttx-config/nsh/defconfig +++ b/boards/nxp/mr-canhubk3/nuttx-config/nsh/defconfig @@ -206,7 +206,6 @@ CONFIG_NSH_LINELEN=128 CONFIG_NSH_MAXARGUMENTS=15 CONFIG_NSH_MMCSDSPIPORTNO=1 CONFIG_NSH_NESTDEPTH=8 -CONFIG_NSH_READLINE=y CONFIG_NSH_QUOTE=y CONFIG_NSH_ROMFSETC=y CONFIG_NSH_ROMFSSECTSIZE=128 @@ -279,7 +278,6 @@ CONFIG_SCHED_INSTRUMENTATION_SWITCH=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_LPWORKPRIORITY=50 CONFIG_SCHED_LPWORKSTACKSIZE=1768 -CONFIG_SCHED_WAITPID=y CONFIG_SEM_PREALLOCHOLDERS=32 CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS=y CONFIG_SERIAL_TERMIOS=y diff --git a/boards/nxp/mr-tropic/bootloader.px4board b/boards/nxp/mr-tropic/bootloader.px4board new file mode 100644 index 0000000000..19b6e662be --- /dev/null +++ b/boards/nxp/mr-tropic/bootloader.px4board @@ -0,0 +1,3 @@ +CONFIG_BOARD_TOOLCHAIN="arm-none-eabi" +CONFIG_BOARD_ARCHITECTURE="cortex-m7" +CONFIG_BOARD_ROMFSROOT="" diff --git a/boards/nxp/mr-tropic/cmake/upload.cmake b/boards/nxp/mr-tropic/cmake/upload.cmake new file mode 100644 index 0000000000..79da5c60fd --- /dev/null +++ b/boards/nxp/mr-tropic/cmake/upload.cmake @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2024 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. +# +############################################################################ + + +set(PX4_FW_NAME ${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}.hex) + +add_custom_target(upload_teensy + COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/teensy_uploader.py --port ${serial_ports} ${PX4_FW_NAME} --vendor-id 0x1FC9 --product-id 0x0024 + DEPENDS ${PX4_FW_NAME} + COMMENT "uploading px4" + VERBATIM + USES_TERMINAL + WORKING_DIRECTORY ${PX4_BINARY_DIR} +) diff --git a/boards/nxp/mr-tropic/default.px4board b/boards/nxp/mr-tropic/default.px4board new file mode 100644 index 0000000000..2d4888e1aa --- /dev/null +++ b/boards/nxp/mr-tropic/default.px4board @@ -0,0 +1,109 @@ +CONFIG_BOARD_TOOLCHAIN="arm-none-eabi" +CONFIG_BOARD_ARCHITECTURE="cortex-m7" +CONFIG_BOARD_ETHERNET=y +CONFIG_BOARD_SERIAL_GPS1="/dev/ttyS1" +CONFIG_BOARD_SERIAL_TEL1="/dev/ttyS2" +CONFIG_BOARD_SERIAL_TEL2="/dev/ttyS4" +CONFIG_BOARD_SERIAL_TEL3="/dev/ttyS3" +CONFIG_BOARD_SERIAL_RC="/dev/ttyS6" +CONFIG_BOARD_PARAM_FILE="/fs/nor/mtd_params" +CONFIG_DRIVERS_ADC_BOARD_ADC=y +CONFIG_DRIVERS_BAROMETER_BMP388=y +CONFIG_DRIVERS_BAROMETER_INVENSENSE_ICP201XX=y +CONFIG_DRIVERS_BAROMETER_MS5611=y +CONFIG_DRIVERS_CAMERA_CAPTURE=y +CONFIG_DRIVERS_CAMERA_TRIGGER=y +CONFIG_DRIVERS_CDCACM_AUTOSTART=y +CONFIG_COMMON_DIFFERENTIAL_PRESSURE=y +CONFIG_COMMON_DISTANCE_SENSOR=y +CONFIG_DRIVERS_DISTANCE_SENSOR_LIGHTWARE_SF45_SERIAL=y +CONFIG_DRIVERS_DSHOT=y +CONFIG_DRIVERS_GNSS_SEPTENTRIO=y +CONFIG_DRIVERS_GPS=y +CONFIG_DRIVERS_IMU_BOSCH_BMI088=y +CONFIG_DRIVERS_IMU_INVENSENSE_ICM20948=y +CONFIG_DRIVERS_IMU_INVENSENSE_ICM42688P=y +CONFIG_DRIVERS_IMU_INVENSENSE_ICM45686=y +CONFIG_COMMON_INS=y +CONFIG_COMMON_LIGHT=y +CONFIG_DRIVERS_LIGHTS_RGBLED_PWM=y +CONFIG_COMMON_MAGNETOMETER=y +CONFIG_DRIVERS_MAGNETOMETER_BOSCH_BMM350=y +CONFIG_COMMON_OPTICAL_FLOW=y +CONFIG_DRIVERS_OSD_MSP_OSD=y +CONFIG_DRIVERS_POWER_MONITOR_INA226=y +CONFIG_DRIVERS_POWER_MONITOR_INA228=y +CONFIG_DRIVERS_POWER_MONITOR_INA238=y +CONFIG_DRIVERS_PWM_OUT=y +CONFIG_COMMON_RC=y +CONFIG_DRIVERS_SAFETY_BUTTON=y +CONFIG_COMMON_TELEMETRY=y +CONFIG_DRIVERS_TONE_ALARM=y +CONFIG_DRIVERS_UAVCAN=y +CONFIG_BOARD_UAVCAN_INTERFACES=1 +CONFIG_COMMON_UWB=y +CONFIG_MODULES_AIRSPEED_SELECTOR=y +CONFIG_MODULES_BATTERY_STATUS=y +CONFIG_MODULES_CAMERA_FEEDBACK=y +CONFIG_MODULES_COMMANDER=y +CONFIG_MODULES_CONTROL_ALLOCATOR=y +CONFIG_MODULES_DATAMAN=y +CONFIG_MODULES_EKF2=y +CONFIG_MODULES_ESC_BATTERY=y +CONFIG_MODULES_EVENTS=y +CONFIG_MODULES_FLIGHT_MODE_MANAGER=y +CONFIG_MODULES_FW_ATT_CONTROL=y +CONFIG_MODULES_FW_AUTOTUNE_ATTITUDE_CONTROL=y +CONFIG_MODULES_FW_MODE_MANAGER=y +CONFIG_MODULES_FW_LATERAL_LONGITUDINAL_CONTROL=y +CONFIG_MODULES_FW_RATE_CONTROL=y +CONFIG_MODULES_GIMBAL=y +CONFIG_MODULES_GYRO_CALIBRATION=y +CONFIG_MODULES_GYRO_FFT=y +CONFIG_MODULES_LAND_DETECTOR=y +CONFIG_MODULES_LANDING_TARGET_ESTIMATOR=y +CONFIG_MODULES_LOAD_MON=y +CONFIG_MODULES_LOCAL_POSITION_ESTIMATOR=y +CONFIG_MODULES_LOGGER=y +CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y +CONFIG_MODULES_MANUAL_CONTROL=y +CONFIG_MODULES_MAVLINK=y +CONFIG_MODULES_MC_ATT_CONTROL=y +CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y +CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y +CONFIG_MODULES_MC_POS_CONTROL=y +CONFIG_MODULES_MC_RATE_CONTROL=y +CONFIG_MODULES_NAVIGATOR=y +CONFIG_MODE_NAVIGATOR_VTOL_TAKEOFF=y +CONFIG_NUM_MISSION_ITMES_SUPPORTED=1000 +CONFIG_MODULES_RC_UPDATE=y +CONFIG_MODULES_ROVER_POS_CONTROL=y +CONFIG_MODULES_SENSORS=y +CONFIG_MODULES_TEMPERATURE_COMPENSATION=y +CONFIG_MODULES_UXRCE_DDS_CLIENT=y +CONFIG_MODULES_VTOL_ATT_CONTROL=y +CONFIG_MODULES_ZENOH=y +CONFIG_SYSTEMCMDS_ACTUATOR_TEST=y +CONFIG_SYSTEMCMDS_BSONDUMP=y +CONFIG_SYSTEMCMDS_DMESG=y +CONFIG_SYSTEMCMDS_DUMPFILE=y +CONFIG_SYSTEMCMDS_I2C_LAUNCHER=y +CONFIG_SYSTEMCMDS_I2CDETECT=y +CONFIG_SYSTEMCMDS_LED_CONTROL=y +CONFIG_SYSTEMCMDS_MFT=y +CONFIG_SYSTEMCMDS_NETMAN=y +CONFIG_SYSTEMCMDS_NSHTERM=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_TUNE_CONTROL=y +CONFIG_SYSTEMCMDS_UORB=y +CONFIG_SYSTEMCMDS_USB_CONNECTED=y +CONFIG_SYSTEMCMDS_VER=y +CONFIG_SYSTEMCMDS_WORK_QUEUE=y diff --git a/boards/nxp/mr-tropic/extras/nxp_mr-tropic_bootloader.bin b/boards/nxp/mr-tropic/extras/nxp_mr-tropic_bootloader.bin new file mode 100755 index 0000000000..c972de6405 Binary files /dev/null and b/boards/nxp/mr-tropic/extras/nxp_mr-tropic_bootloader.bin differ diff --git a/boards/nxp/mr-tropic/firmware.prototype b/boards/nxp/mr-tropic/firmware.prototype new file mode 100644 index 0000000000..ae7bf83cb1 --- /dev/null +++ b/boards/nxp/mr-tropic/firmware.prototype @@ -0,0 +1,13 @@ +{ + "board_id": 37, + "magic": "PX4FWv1", + "description": "Firmware for the MR-TROPIC board", + "image": "", + "build_time": 0, + "summary": "MR-TROPIC", + "version": "0.1", + "image_size": 0, + "image_maxsize": 3932160, + "git_identity": "", + "board_revision": 0 +} diff --git a/boards/nxp/mr-tropic/init/rc.board_defaults b/boards/nxp/mr-tropic/init/rc.board_defaults new file mode 100644 index 0000000000..5ed2a8e9d5 --- /dev/null +++ b/boards/nxp/mr-tropic/init/rc.board_defaults @@ -0,0 +1,34 @@ +#!/bin/sh +# +# board specific defaults +#------------------------------------------------------------------------------ + +# Mavlink ethernet (CFG 1000) +param set-default MAV_2_CONFIG 1000 +param set-default MAV_2_BROADCAST 1 +param set-default MAV_2_MODE 0 +param set-default MAV_2_RADIO_CTL 0 +param set-default MAV_2_RATE 100000 +param set-default MAV_2_REMOTE_PRT 14550 +param set-default MAV_2_UDP_PRT 14550 + +param set-default RC_CRSF_PRT_CFG 300 +param set-default RC_CRSF_TEL_EN 1 +param set-default RC_SBUS_PRT_CFG 0 + +if [ -f "/fs/microsd/ipcfg-eth0" ] +then +else + netman update -i eth0 +fi + +rgbled_pwm start +safety_button start + +if param greater -s UAVCAN_ENABLE 0 +then + ifup can0 +fi + +# Start the ESC telemetry +dshot telemetry -d /dev/ttyS5 -x diff --git a/boards/nxp/mr-tropic/init/rc.board_mavlink b/boards/nxp/mr-tropic/init/rc.board_mavlink new file mode 100644 index 0000000000..d789d908e8 --- /dev/null +++ b/boards/nxp/mr-tropic/init/rc.board_mavlink @@ -0,0 +1,4 @@ +#!/bin/sh +# +# Tropic Community specific board MAVLink startup script. +#------------------------------------------------------------------------------ diff --git a/boards/nxp/mr-tropic/init/rc.board_sensors b/boards/nxp/mr-tropic/init/rc.board_sensors new file mode 100644 index 0000000000..6dc213cc42 --- /dev/null +++ b/boards/nxp/mr-tropic/init/rc.board_sensors @@ -0,0 +1,68 @@ +#!/bin/sh +# +# PX4 board sensors init +#------------------------------------------------------------------------------ +# +# UART mapping on Tropic Community: +# +# LPUART5 /dev/ttyS0 CONSOLE +# LPUART3 /dev/ttyS1 GPS +# LPUART2 /dev/ttyS2 TELEM1 +# LPUART4 /dev/ttyS3 TELEM2 +# LPUART8 /dev/ttyS4 RC +# +#------------------------------------------------------------------------------ + +set INA_CONFIGURED no + +board_adc start + +if param compare SENS_EN_INA226 1 +then + # Start Digital power monitors + ina226 -X -b 3 -t 1 -k start + set INA_CONFIGURED yes +fi + +if param compare SENS_EN_INA228 1 +then + # Start Digital power monitors + ina228 -X -b 3 -t 1 -k start + set INA_CONFIGURED yes +fi + +if param compare SENS_EN_INA238 1 +then + # Start Digital power monitors + ina238 -X -b 3 -t 1 -k start + set INA_CONFIGURED yes +fi + +if [ $INA_CONFIGURED = no ] +then + # INA226, INA228, INA238 auto-start + i2c_launcher start -b 3 -t 1 +fi + +# Internal SPI bus icm45686 +icm45686 -R 2 -b 3 -s start + +# Internal on IMU SPI BMI088 +bmi088 -A -R 2 -b 4 -s start +bmi088 -G -R 2 -b 4 -s start + +# Internal magnetometer on I2c +bmm350 -I -b 4 -R 6 start + +# External compass on GPS1/I2C1 (the 3rd external bus): standard Holybro Pixhawk 4 or CUAV V5 GPS/compass puck (with lights, safety button, and buzzer) +ist8310 -X -b 1 -R 10 start + +# Possible internal Baro + +# Disable startup of internal baros if param is set to false +if param compare SENS_INT_BARO_EN 1 +then + bmp388 -I -b 4 start +fi + +unset INA_CONFIGURED diff --git a/boards/nxp/mr-tropic/nuttx-config/Kconfig b/boards/nxp/mr-tropic/nuttx-config/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/nxp/mr-tropic/nuttx-config/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/nxp/mr-tropic/nuttx-config/bootloader/defconfig b/boards/nxp/mr-tropic/nuttx-config/bootloader/defconfig new file mode 100644 index 0000000000..b6ab2f6b4b --- /dev/null +++ b/boards/nxp/mr-tropic/nuttx-config/bootloader/defconfig @@ -0,0 +1,107 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_DEV_CONSOLE is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_SPI_EXCHANGE is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD_CUSTOM=y +CONFIG_ARCH_BOARD_CUSTOM_DIR="../../../../boards/nxp/mr-tropic/nuttx-config" +CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y +CONFIG_ARCH_BOARD_CUSTOM_NAME="px4" +CONFIG_ARCH_CHIP="imxrt" +CONFIG_ARCH_CHIP_IMXRT=y +CONFIG_ARCH_CHIP_MIMXRT1064DVL6A=y +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7M_DCACHE=y +CONFIG_ARMV7M_DTCM=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_ARMV7M_ITCM=y +CONFIG_ARMV7M_MEMCPY=y +CONFIG_ARMV7M_USEBASEPRI=y +CONFIG_ARM_MPU=y +CONFIG_ARM_MPU_RESET=y +CONFIG_BOARDCTL=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_ASSERT_RESET_VALUE=0 +CONFIG_BOARD_INITTHREAD_PRIORITY=254 +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=115000 +CONFIG_BOARD_RESET_ON_ASSERT=2 +CONFIG_CDCACM=y +CONFIG_CDCACM_BULKIN_REQLEN=96 +CONFIG_CDCACM_IFLOWCONTROL=y +CONFIG_CDCACM_PRODUCTID=0x0025 +CONFIG_CDCACM_PRODUCTSTR="PX4 BL MR-TROPIC" +CONFIG_CDCACM_RXBUFSIZE=600 +CONFIG_CDCACM_TXBUFSIZE=12000 +CONFIG_CDCACM_VENDORID=0x1FC9 +CONFIG_CDCACM_VENDORSTR="NXP SEMICONDUCTORS" +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_ERROR=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_HARDFAULT_ALERT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEBUG_TCBINFO=y +CONFIG_DEBUG_USAGEFAULT=y +CONFIG_DEFAULT_SMALL=y +CONFIG_EXPERIMENTAL=y +CONFIG_FDCLONE_DISABLE=y +CONFIG_FDCLONE_STDIO=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_IMXRT_EDMA=y +CONFIG_IMXRT_EDMA_EDBG=y +CONFIG_IMXRT_EDMA_ELINK=y +CONFIG_IMXRT_EDMA_NTCD=64 +CONFIG_IMXRT_ITCM=384 +CONFIG_IMXRT_LPUART3=y +CONFIG_IMXRT_SNVS_LPSRTC=y +CONFIG_IMXRT_USBDEV=y +CONFIG_INIT_ENTRYPOINT="bootloader_main" +CONFIG_INIT_STACKSIZE=3194 +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LIBC_LONG_LONG=y +CONFIG_LIBC_STRERROR=y +CONFIG_LPUART3_BAUD=57600 +CONFIG_LPUART3_IFLOWCONTROL=y +CONFIG_LPUART3_OFLOWCONTROL=y +CONFIG_LPUART3_RXBUFSIZE=600 +CONFIG_LPUART3_RXDMA=y +CONFIG_LPUART3_TXBUFSIZE=1500 +CONFIG_LPUART3_TXDMA=y +CONFIG_MEMSET_64BIT=y +CONFIG_MEMSET_OPTSPEED=y +CONFIG_PREALLOC_TIMERS=50 +CONFIG_PTHREAD_MUTEX_ROBUST=y +CONFIG_PTHREAD_STACK_MIN=512 +CONFIG_RAM_SIZE=1048576 +CONFIG_RAM_START=0x20200000 +CONFIG_RAW_BINARY=y +CONFIG_SERIAL_TERMIOS=y +CONFIG_SIG_DEFAULT=y +CONFIG_SIG_SIGALRM_ACTION=y +CONFIG_SIG_SIGUSR1_ACTION=y +CONFIG_SIG_SIGUSR2_ACTION=y +CONFIG_SPI=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=30 +CONFIG_START_MONTH=11 +CONFIG_STDIO_BUFFER_SIZE=32 +CONFIG_SYSTEMTICK_HOOK=y +CONFIG_SYSTEM_CDCACM=y +CONFIG_TASK_NAME_SIZE=24 +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y +CONFIG_USBDEV_DMA=y +CONFIG_USBDEV_DUALSPEED=y +CONFIG_USBDEV_MAXPOWER=500 +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/nxp/mr-tropic/nuttx-config/include/board.h b/boards/nxp/mr-tropic/nuttx-config/include/board.h new file mode 100644 index 0000000000..c096aa9886 --- /dev/null +++ b/boards/nxp/mr-tropic/nuttx-config/include/board.h @@ -0,0 +1,416 @@ +/************************************************************************************ + * nuttx-configs/nxp/nxp_mr-tropic/include/board.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Authors: Gregory Nutt + * David Sidrane + * + * 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 NuttX 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. + * + ************************************************************************************/ + +#ifndef __NUTTX_CONFIG_NXP_TROPIC_INCLUDE_BOARD_H +#define __NUTTX_CONFIG_NXP_TROPIC_INCLUDE_BOARD_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +/* Clocking *************************************************************************/ + +/* Set VDD_SOC to 1.25V */ + +#define IMXRT_VDD_SOC (0x12) + +/* Set Arm PLL (PLL1) to fOut = (24Mhz * ARM_PLL_DIV_SELECT/2) / ARM_PODF_DIVISOR + * 576Mhz = (24Mhz * ARM_PLL_DIV_SELECT/2) / ARM_PODF_DIVISOR + * ARM_PLL_DIV_SELECT = 96 + * ARM_PODF_DIVISOR = 2 + * 576Mhz = (24Mhz * 96/2) / 2 + * + * AHB_CLOCK_ROOT = PLL1fOut / IMXRT_AHB_PODF_DIVIDER + * 1Hz to 600 Mhz = 576Mhz / IMXRT_ARM_CLOCK_DIVIDER + * IMXRT_ARM_CLOCK_DIVIDER = 1 + * 576Mhz = 576Mhz / 1 + * + * PRE_PERIPH_CLK_SEL = PRE_PERIPH_CLK_SEL_PLL1 + * PERIPH_CLK_SEL = 1 (0 select PERIPH_CLK2_PODF, 1 select PRE_PERIPH_CLK_SEL_PLL1) + * PERIPH_CLK = 576Mhz + * + * IPG_CLOCK_ROOT = AHB_CLOCK_ROOT / IMXRT_IPG_PODF_DIVIDER + * IMXRT_IPG_PODF_DIVIDER = 4 + * 144Mhz = 576Mhz / 4 + * + * PRECLK_CLOCK_ROOT = IPG_CLOCK_ROOT / IMXRT_PERCLK_PODF_DIVIDER + * IMXRT_PERCLK_PODF_DIVIDER = 1 + * 16Mhz = 144Mhz / 9 + * + * SEMC_CLK_ROOT = 576Mhz / IMXRT_SEMC_PODF_DIVIDER (labeled AIX_PODF in 18.2) + * IMXRT_SEMC_PODF_DIVIDER = 8 + * 72Mhz = 576Mhz / 8 + * + * Set Sys PLL (PLL2) to fOut = (24Mhz * (20+(2*(DIV_SELECT))) + * 528Mhz = (24Mhz * (20+(2*(1))) + * + * Set USB1 PLL (PLL3) to fOut = (24Mhz * 20) + * 480Mhz = (24Mhz * 20) + * + * Set LPSPI PLL3 PFD0 to fOut = (480Mhz / 12 * 18) + * 720Mhz = (480Mhz / 12 * 18) + * 90Mhz = (720Mhz / LSPI_PODF_DIVIDER) + * + * Set LPI2C PLL3 / 8 to fOut = (480Mhz / 8) + * 60Mhz = (480Mhz / 8) + * 12Mhz = (60Mhz / LSPI_PODF_DIVIDER) + * + * Set USDHC1 PLL2 PFD2 to fOut = (528Mhz / 24 * 18) + * 396Mhz = (528Mhz / 24 * 18) + * 198Mhz = (396Mhz / IMXRT_USDHC1_PODF_DIVIDER) + */ + +#define BOARD_XTAL_FREQUENCY 24000000 +#define IMXRT_PRE_PERIPH_CLK_SEL CCM_CBCMR_PRE_PERIPH_CLK_SEL_PLL1 +#define IMXRT_PERIPH_CLK_SEL CCM_CBCDR_PERIPH_CLK_SEL_PRE_PERIPH +#define IMXRT_ARM_PLL_DIV_SELECT 96 +#define IMXRT_ARM_PODF_DIVIDER 2 +#define IMXRT_AHB_PODF_DIVIDER 1 +#define IMXRT_IPG_PODF_DIVIDER 4 +#define IMXRT_PERCLK_CLK_SEL CCM_CSCMR1_PERCLK_CLK_SEL_IPG_CLK_ROOT +#define IMXRT_PERCLK_PODF_DIVIDER 9 +#define IMXRT_SEMC_PODF_DIVIDER 8 +#define IMXRT_CAN_CLK_SELECT CCM_CSCMR2_CAN_CLK_SEL_PLL3_SW_80 +#define IMXRT_CAN_PODF_DIVIDER 1 + +#define IMXRT_LPSPI_CLK_SELECT CCM_CBCMR_LPSPI_CLK_SEL_PLL3_PFD0 +#define IMXRT_LSPI_PODF_DIVIDER 8 + +#define IMXRT_LPI2C_CLK_SELECT CCM_CSCDR2_LPI2C_CLK_SEL_PLL3_60M +#define IMXRT_LSI2C_PODF_DIVIDER 5 + +#define IMXRT_USDHC1_CLK_SELECT CCM_CSCMR1_USDHC1_CLK_SEL_PLL2_PFD0 +#define IMXRT_USDHC1_PODF_DIVIDER 2 + +#define IMXRT_USB1_PLL_DIV_SELECT CCM_ANALOG_PLL_USB1_DIV_SELECT_20 + +#define IMXRT_SYS_PLL_SELECT CCM_ANALOG_PLL_SYS_DIV_SELECT_22 + +#define IMXRT_USB1_PLL_DIV_SELECT CCM_ANALOG_PLL_USB1_DIV_SELECT_20 + +#define BOARD_CPU_FREQUENCY \ + (BOARD_XTAL_FREQUENCY * (IMXRT_ARM_PLL_DIV_SELECT / 2)) / IMXRT_ARM_PODF_DIVIDER + +#define BOARD_GPT_FREQUENCY \ + (BOARD_CPU_FREQUENCY / IMXRT_IPG_PODF_DIVIDER) / IMXRT_PERCLK_PODF_DIVIDER + + +/* 108Mhz clock for FlexIO using PLL3 PFD2 @ 520 */ +#define CONFIG_FLEXIO1_CLK 1 +#define CONFIG_FLEXIO1_PRED_DIVIDER 5 +#define CONFIG_FLEXIO1_PODF_DIVIDER 1 +#define CONFIG_PLL3_PFD2_FRAC 16 +#define BOARD_FLEXIO_PREQ 108000000 + +/* Define this to enable tracing */ +#if CONFIG_USE_TRACE +# define IMXRT_TRACE_PODF_DIVIDER 1 +# define IMXRT_TRACE_CLK_SELECT CCM_CBCMR_TRACE_CLK_SEL_PLL2_PFD0 +#endif + +/* SDIO *****************************************************************************/ + +/* Pin drive characteristics */ + +#define USDHC1_DATAX_IOMUX (IOMUX_SLEW_FAST | IOMUX_DRIVE_130OHM | IOMUX_PULL_UP_47K | IOMUX_SCHMITT_TRIGGER) +#define USDHC1_CMD_IOMUX (IOMUX_SLEW_FAST | IOMUX_DRIVE_130OHM | IOMUX_PULL_UP_47K | IOMUX_SCHMITT_TRIGGER) +#define USDHC1_CLK_IOMUX (IOMUX_SLEW_FAST | IOMUX_DRIVE_130OHM | IOMUX_SPEED_MAX) +#define USDHC1_CD_IOMUX (IOMUX_PULL_UP_47K | IOMUX_SCHMITT_TRIGGER) + +#define PIN_USDHC1_D0 (GPIO_USDHC1_DATA0_1 | USDHC1_DATAX_IOMUX) /* GPIO_SD_B0_02 */ +#define PIN_USDHC1_D1 (GPIO_USDHC1_DATA1_1 | USDHC1_DATAX_IOMUX) /* GPIO_SD_B0_03 */ +#define PIN_USDHC1_D2 (GPIO_USDHC1_DATA2_1 | USDHC1_DATAX_IOMUX) /* GPIO_SD_B0_04 */ +#define PIN_USDHC1_D3 (GPIO_USDHC1_DATA3_1 | USDHC1_DATAX_IOMUX) /* GPIO_SD_B0_05 */ +#define PIN_USDHC1_DCLK (GPIO_USDHC1_CLK_1 | USDHC1_CLK_IOMUX) /* GPIO_SD_B0_01 */ +#define PIN_USDHC1_CMD (GPIO_USDHC1_CMD_1 | USDHC1_CMD_IOMUX) /* GPIO_SD_B0_00 */ +#define PIN_USDHC1_CD (PIN_USDHC1_D3) + +/* #define PIN_USDHC1_CD (GPIO_USDHC1_CD_3 | USDHC1_CD_IOMUX) + * CD_B Pin works fine but somehow the driver has a timing issue with + * Thus use D3 instead + */ + +/* Ideal 400Khz for initial inquiry. + * Given input clock 198 Mhz. + * 386.71875 KHz = 198 Mhz / (256 * 2) + */ + +#define BOARD_USDHC_IDMODE_PRESCALER USDHC_SYSCTL_SDCLKFS_DIV256 +#define BOARD_USDHC_IDMODE_DIVISOR USDHC_SYSCTL_DVS_DIV(2) + +/* Ideal 25 Mhz for other modes + * Given input clock 198 Mhz. + * 24.75 MHz = 198 Mhz / (8 * 1) + */ + +#define BOARD_USDHC_MMCMODE_PRESCALER USDHC_SYSCTL_SDCLKFS_DIV8 +#define BOARD_USDHC_MMCMODE_DIVISOR USDHC_SYSCTL_DVS_DIV(1) + +#define BOARD_USDHC_SD1MODE_PRESCALER USDHC_SYSCTL_SDCLKFS_DIV8 +#define BOARD_USDHC_SD1MODE_DIVISOR USDHC_SYSCTL_DVS_DIV(1) + +#define BOARD_USDHC_SD4MODE_PRESCALER USDHC_SYSCTL_SDCLKFS_DIV8 +#define BOARD_USDHC_SD4MODE_DIVISOR USDHC_SYSCTL_DVS_DIV(1) + +/* ETH Disambiguation *******************************************************/ + +/* Ethernet Interrupt: GPIO_B0_15 + * + * This pin has a week pull-up within the PHY, is open-drain, and requires + * an external 1k ohm pull-up resistor (present on the EVK). A falling + * edge then indicates a change in state of the PHY. + */ + +#define GPIO_ENET_INT (IOMUX_ENET_INT_DEFAULT | \ + GPIO_PORT2 | GPIO_PIN15) /* B0_15 */ +#define GPIO_ENET_IRQ IMXRT_IRQ_GPIO2_15 + +/* Ethernet Reset: GPIO_B0_14 + * + * The #RST uses inverted logic. The initial value of zero will put the + * PHY into the reset state. + */ + +#define GPIO_ENET_RST (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | \ + GPIO_PORT2 | GPIO_PIN14 | IOMUX_ENET_RST_DEFAULT) /* B0_14 */ + +#define GPIO_ENET_TX_DATA00 (GPIO_ENET_TX_DATA00_1| \ + IOMUX_ENET_DATA_DEFAULT) /* GPIO_B1_07 */ +#define GPIO_ENET_TX_DATA01 (GPIO_ENET_TX_DATA01_1| \ + IOMUX_ENET_DATA_DEFAULT) /* GPIO_B1_08 */ +#define GPIO_ENET_RX_DATA00 (GPIO_ENET_RX_DATA00_1| \ + IOMUX_ENET_DATA_DEFAULT) /* GPIO_B1_04 */ +#define GPIO_ENET_RX_DATA01 (GPIO_ENET_RX_DATA01_1| \ + IOMUX_ENET_DATA_DEFAULT) /* GPIO_B1_05 */ +#define GPIO_ENET_MDIO (GPIO_ENET_MDIO_1|IOMUX_ENET_MDIO_DEFAULT) /* GPIO_B1_15 */ +#define GPIO_ENET_MDC (GPIO_ENET_MDC_1|IOMUX_ENET_MDC_DEFAULT) /* GPIO_B1_14 */ +#define GPIO_ENET_RX_EN (GPIO_ENET_RX_EN_1|IOMUX_ENET_EN_DEFAULT) /* GPIO_B1_06 */ +#define GPIO_ENET_RX_ER (GPIO_ENET_RX_ER_1|IOMUX_ENET_RXERR_DEFAULT) /* GPIO_B1_11 */ +#define GPIO_ENET_TX_CLK (GPIO_ENET_REF_CLK_2|\ + IOMUX_ENET_TX_CLK_DEFAULT) /* GPIO_B1_10 */ +#define GPIO_ENET_TX_EN (GPIO_ENET_TX_EN_1|IOMUX_ENET_EN_DEFAULT) /* GPIO_B1_09 */ + +/* LED definitions ******************************************************************/ +/* The nxp fmutr1062 board has numerous LEDs but only three, LED_GREEN a Green LED, + * LED_BLUE a Blue LED and LED_RED a Red LED, that can be controlled by software. + * + * If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any way. + * The following definitions are used to access individual LEDs. + */ + +/* LED index values for use with board_userled() */ + +#define BOARD_LED1 0 +#define BOARD_LED2 1 +#define BOARD_LED3 2 +#define BOARD_NLEDS 3 + +#define BOARD_LED_RED BOARD_LED1 +#define BOARD_LED_GREEN BOARD_LED2 +#define BOARD_LED_BLUE BOARD_LED3 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) +#define BOARD_LED2_BIT (1 << BOARD_LED2) +#define BOARD_LED3_BIT (1 << BOARD_LED3) + +/* If CONFIG_ARCH_LEDS is defined, the usage by the board port is defined in + * include/board.h and src/stm32_leds.c. The LEDs are used to encode OS-related + * events as follows: + * + * + * SYMBOL Meaning LED state + * Red Green Blue + * ---------------------- -------------------------- ------ ------ ----*/ + +#define LED_STARTED 0 /* NuttX has been started OFF OFF OFF */ +#define LED_HEAPALLOCATE 1 /* Heap has been allocated OFF OFF ON */ +#define LED_IRQSENABLED 2 /* Interrupts enabled OFF ON OFF */ +#define LED_STACKCREATED 3 /* Idle stack created OFF ON ON */ +#define LED_INIRQ 4 /* In an interrupt N/C N/C GLOW */ +#define LED_SIGNAL 5 /* In a signal handler N/C GLOW N/C */ +#define LED_ASSERTION 6 /* An assertion failed GLOW N/C GLOW */ +#define LED_PANIC 7 /* The system has crashed Blink OFF N/C */ +#define LED_IDLE 8 /* MCU is is sleep mode ON OFF OFF */ + +/* Thus if the Green LED is statically on, NuttX has successfully booted and + * is, apparently, running normally. If the Red LED is flashing at + * approximately 2Hz, then a fatal error has been detected and the system + * has halted. + */ + +/* PIO Disambiguation ***************************************************************/ +/* LPUARTs + */ +#define LPUART_IOMUX (IOMUX_PULL_UP_22K | IOMUX_DRIVE_40OHM | IOMUX_SLEW_SLOW | IOMUX_SPEED_LOW | IOMUX_SCHMITT_TRIGGER) +#define IOMUX_UART_CTS_DEFAULT (IOMUX_PULL_DOWN_100K | IOMUX_DRIVE_40OHM | IOMUX_SLEW_SLOW) + +/* Debug */ + +#define GPIO_LPUART6_RX (GPIO_LPUART6_RX_2 | LPUART_IOMUX) /* GPIO_EMC_26 */ +#define GPIO_LPUART6_TX (GPIO_LPUART6_TX_2 | LPUART_IOMUX) /* GPIO_EMC_25 */ + + +/* Telem 2 */ + +#define GPIO_LPUART5_RX (GPIO_LPUART5_RX_1 | LPUART_IOMUX) /* GPIO_B1_13 */ +#define GPIO_LPUART5_TX (GPIO_LPUART5_TX_1 | LPUART_IOMUX) /* GPIO_B1_12 */ +#define GPIO_LPUART5_CTS (GPIO_LPUART5_CTS_1 | IOMUX_UART_CTS_DEFAULT | PADMUX_SION) /* GPIO_EMC_28 GPIO4_IO27 */ +#define GPIO_LPUART5_RTS (GPIO_PORT4 | GPIO_PIN27 | GPIO_OUTPUT | GPIO_OUTPUT_ZERO | IOMUX_UART_DEFAULT) /* GPIO_EMC_27 GPIO4_IO27 (GPIO only, no HW Flow control) */ + +/* AUX */ + +#define GPIO_LPUART4_RX (GPIO_LPUART4_RX_1 | LPUART_IOMUX) /* GPIO_B1_01 */ +#define GPIO_LPUART4_TX (GPIO_LPUART4_TX_1 | LPUART_IOMUX) /* GPIO_B1_00 */ +#define GPIO_LPUART4_CTS (GPIO_PORT1 | GPIO_PIN15 | GPIO_INPUT | PADMUX_SION | IOMUX_UART_CTS_DEFAULT) /* GPIO_AD_B0_15 GPIO1_IO14 (Fixme Add GPIO Flow support in LPUART) */ +#define GPIO_LPUART4_RTS (GPIO_PORT1 | GPIO_PIN14 | GPIO_OUTPUT | GPIO_OUTPUT_ZERO | IOMUX_UART_DEFAULT) /* GPIO_AD_B0_14 GPIO1_IO14 (GPIO only, no HW Flow control) */ + +/* GPS 1 */ + +#define GPIO_LPUART2_RX (GPIO_LPUART2_RX_1 | LPUART_IOMUX) /* GPIO_AD_B1_03 */ +#define GPIO_LPUART2_TX (GPIO_LPUART2_TX_1 | LPUART_IOMUX) /* GPIO_AD_B1_02 */ + +/* Telem 1 */ + +#define GPIO_LPUART3_RX (GPIO_LPUART3_RX_1 | LPUART_IOMUX) /* GPIO_AD_B1_07 */ +#define GPIO_LPUART3_TX (GPIO_LPUART3_TX_1 | LPUART_IOMUX) /* GPIO_AD_B1_06 */ +#define GPIO_LPUART3_CTS (GPIO_LPUART3_CTS_1 | IOMUX_UART_CTS_DEFAULT | PADMUX_SION) /* GPIO_AD_B1_04 GPIO1_IO20 */ +#define GPIO_LPUART3_RTS (GPIO_PORT1 | GPIO_PIN21 | GPIO_OUTPUT | GPIO_OUTPUT_ZERO | IOMUX_UART_DEFAULT) /* GPIO_AD_B1_05 GPIO1_IO21 (GPIO only, no HW Flow control) */ +//TODO check RT7 partial HW handshake + +/* ESC ONEWIRE */ +#define GPIO_LPUART7_RX (GPIO_LPUART7_TX_1 | LPUART_IOMUX) /* GPIO_EMC_31 */ +#define GPIO_LPUART7_TX (GPIO_LPUART7_TX_1 | LPUART_IOMUX) /* GPIO_EMC_31 */ + + +/* RC INPUT single wire mode on Input on TX, for CRSF use TX and RX */ + +#define GPIO_LPUART8_RX (GPIO_LPUART8_RX_1 | LPUART_IOMUX) /* GPIO_AD_B1_11 */ +#define GPIO_LPUART8_TX (GPIO_LPUART8_TX_1 | LPUART_IOMUX) /* GPIO_AD_B1_10 */ + +/* CAN + * + * CAN1 is routed to transceiver. + * CAN2 is routed to transceiver. + * CAN3 is routed to transceiver. + */ +#define FLEXCAN_IOMUX (IOMUX_PULL_UP_100K | IOMUX_DRIVE_40OHM | IOMUX_SLEW_FAST | IOMUX_SPEED_MEDIUM) + +#define GPIO_FLEXCAN3_RX (GPIO_FLEXCAN3_RX_3 | FLEXCAN_IOMUX) /* GPIO_EMC_37 */ +#define GPIO_FLEXCAN3_TX (GPIO_FLEXCAN3_TX_3 | FLEXCAN_IOMUX) /* GPIO_EMC_36 */ + +/* LPSPI */ +#define LPSPI_IOMUX (IOMUX_PULL_UP_100K | IOMUX_DRIVE_33OHM | IOMUX_SLEW_FAST | IOMUX_SPEED_MAX) + + +#define GPIO_LPSPI3_SCK (GPIO_LPSPI3_SCK_1 | LPSPI_IOMUX) /* GPIO_AD_B1_15 */ +#define GPIO_LPSPI3_MISO (GPIO_LPSPI3_SDI_1 | LPSPI_IOMUX) /* GPIO_AD_B1_13 */ +#define GPIO_LPSPI3_MOSI (GPIO_LPSPI3_SDO_1 | LPSPI_IOMUX) /* GPIO_AD_B1_14 */ + +#define GPIO_LPSPI4_SCK (GPIO_LPSPI4_SCK_2 | LPSPI_IOMUX) /* GPIO_B0_03 */ +#define GPIO_LPSPI4_MISO (GPIO_LPSPI4_SDI_2 | LPSPI_IOMUX) /* GPIO_B0_01 */ +#define GPIO_LPSPI4_MOSI (GPIO_LPSPI4_SDO_2 | LPSPI_IOMUX) /* GPIO_B0_02 */ + +#define BOARD_SPI_BUS_MAX_BUS_ITEMS 2 + +/* LPI2Cs */ + +#define LPI2C_IOMUX (IOMUX_SPEED_MEDIUM | IOMUX_DRIVE_33OHM | IOMUX_OPENDRAIN | GPIO_SION_ENABLE) +#define LPI2C_IO_IOMUX (IOMUX_SPEED_MAX | IOMUX_SLEW_FAST | IOMUX_DRIVE_33OHM | IOMUX_OPENDRAIN | IOMUX_PULL_NONE) + +#define GPIO_LPI2C1_SDA (GPIO_LPI2C1_SDA_2 | LPI2C_IOMUX) /* EVK J24-9 R276 */ /* GPIO_AD_B1_01 */ +#define GPIO_LPI2C1_SCL (GPIO_LPI2C1_SCL_2 | LPI2C_IOMUX) /* EVK J24-10 R277 */ /* GPIO_AD_B1_00 */ + +#define GPIO_LPI2C1_SDA_RESET (GPIO_PORT1 | GPIO_PIN17 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | LPI2C_IO_IOMUX) /* GPIO_AD_B1_01 GPIO1_IO17 */ +#define GPIO_LPI2C1_SCL_RESET (GPIO_PORT1 | GPIO_PIN16 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | LPI2C_IO_IOMUX) /* GPIO_AD_B1_00 GPIO1_IO16 */ + +#define GPIO_LPI2C3_SDA (GPIO_LPI2C3_SDA_2 | LPI2C_IOMUX) /* GPIO_EMC_21 */ +#define GPIO_LPI2C3_SCL (GPIO_LPI2C3_SCL_2 | LPI2C_IOMUX) /* GPIO_EMC_22 */ + +#define GPIO_LPI2C3_SDA_RESET (GPIO_PORT4 | GPIO_PIN21 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | LPI2C_IO_IOMUX) /* GPIO_EMC_21 */ +#define GPIO_LPI2C3_SCL_RESET (GPIO_PORT4 | GPIO_PIN22 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | LPI2C_IO_IOMUX) /* GPIO_EMC_22 */ + +#define GPIO_LPI2C4_SDA (GPIO_LPI2C4_SDA_1 | LPI2C_IOMUX) /* GPIO_AD_B0_13 */ +#define GPIO_LPI2C4_SCL (GPIO_LPI2C4_SCL_1 | LPI2C_IOMUX) /* GPIO_AD_B0_12 */ + +#define GPIO_LPI2C4_SDA_RESET (GPIO_PORT1 | GPIO_PIN13 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | LPI2C_IO_IOMUX) /* GPIO_AD_B0_13 */ +#define GPIO_LPI2C4_SCL_RESET (GPIO_PORT1 | GPIO_PIN12 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | LPI2C_IO_IOMUX) /* GPIO_AD_B0_12 */ + +#define BOARD_PHY_ADDR (18) + +/* Board doesn't provide GPIO or other Hardware for signaling to timing analyzer */ + +#define PROBE_INIT(mask) +#define PROBE(n,s) +#define PROBE_MARK(n) + +/************************************************************************************ + * Public Types + ************************************************************************************/ + +/************************************************************************************ + * Public Data + ************************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __NUTTX_CONFIG_NXP_TROPIC_INCLUDE_BOARD_H */ diff --git a/boards/nxp/mr-tropic/nuttx-config/nsh/defconfig b/boards/nxp/mr-tropic/nuttx-config/nsh/defconfig new file mode 100644 index 0000000000..1811763a82 --- /dev/null +++ b/boards/nxp/mr-tropic/nuttx-config/nsh/defconfig @@ -0,0 +1,270 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NSH_DISABLE_MB is not set +# CONFIG_NSH_DISABLE_MH is not set +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_SPI_CALLBACK is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD_CUSTOM=y +CONFIG_ARCH_BOARD_CUSTOM_DIR="../../../../boards/nxp/mr-tropic/nuttx-config" +CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y +CONFIG_ARCH_BOARD_CUSTOM_NAME="px4" +CONFIG_ARCH_CHIP="imxrt" +CONFIG_ARCH_CHIP_IMXRT=y +CONFIG_ARCH_CHIP_MIMXRT1064DVL6A=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7M_DCACHE=y +CONFIG_ARMV7M_DTCM=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_ARMV7M_ITCM=y +CONFIG_ARMV7M_MEMCPY=y +CONFIG_ARMV7M_USEBASEPRI=y +CONFIG_ARM_MPU=y +CONFIG_ARM_MPU_RESET=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_ASSERT_RESET_VALUE=0 +CONFIG_BOARD_LOOPSPERMSEC=115000 +CONFIG_BOARD_RESET_ON_ASSERT=2 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_BULKIN_REQLEN=96 +CONFIG_CDCACM_PRODUCTID=0x0025 +CONFIG_CDCACM_PRODUCTSTR="PX4 MR-TROPIC" +CONFIG_CDCACM_RXBUFSIZE=600 +CONFIG_CDCACM_TXBUFSIZE=12000 +CONFIG_CDCACM_VENDORID=0x1FC9 +CONFIG_CDCACM_VENDORSTR="NXP SEMICONDUCTORS" +CONFIG_DEBUG_ERROR=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_HARDFAULT_ALERT=y +CONFIG_DEBUG_MEMFAULT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEBUG_TCBINFO=y +CONFIG_DEV_FIFO_SIZE=0 +CONFIG_DEV_PIPE_SIZE=70 +CONFIG_DEV_URANDOM=y +CONFIG_ETH0_PHY_TJA1103=y +CONFIG_FAT_DMAMEMORY=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FAT_LFN_ALIAS_HASH=y +CONFIG_FDCLONE_STDIO=y +CONFIG_FSUTILS_IPCFG=y +CONFIG_FS_BINFS=y +CONFIG_FS_CROMFS=y +CONFIG_FS_FAT=y +CONFIG_FS_FATTIME=y +CONFIG_FS_LITTLEFS=y +CONFIG_FS_LITTLEFS_CACHE_SIZE_FACTOR=2 +CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE=64 +CONFIG_FS_LITTLEFS_PROGRAM_SIZE_FACTOR=1 +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_MAX_TASKS=64 +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_FS_ROMFS=y +CONFIG_GRAN=y +CONFIG_GRAN_INTR=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_I2C=y +CONFIG_I2C_RESET=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_IMXRT_DTCM_HEAP=y +CONFIG_IMXRT_DTCM_HEAP_SIZE=127 +CONFIG_IMXRT_EDMA=y +CONFIG_IMXRT_EDMA_EDBG=y +CONFIG_IMXRT_EDMA_ELINK=y +CONFIG_IMXRT_EDMA_NTCD=64 +CONFIG_IMXRT_ENET=y +CONFIG_IMXRT_ENET_NTXBUFFERS=8 +CONFIG_IMXRT_ENET_PHYINIT=y +CONFIG_IMXRT_FLEXCAN3=y +CONFIG_IMXRT_FLEXCAN_TXMB=1 +CONFIG_IMXRT_GPIO1_0_15_IRQ=y +CONFIG_IMXRT_GPIO1_16_31_IRQ=y +CONFIG_IMXRT_GPIO2_0_15_IRQ=y +CONFIG_IMXRT_GPIO2_16_31_IRQ=y +CONFIG_IMXRT_GPIO_IRQ=y +CONFIG_IMXRT_INIT_FLEXRAM=y +CONFIG_IMXRT_ITCM=384 +CONFIG_IMXRT_LPI2C1=y +CONFIG_IMXRT_LPI2C3=y +CONFIG_IMXRT_LPI2C4=y +CONFIG_IMXRT_LPI2C_DMA=y +CONFIG_IMXRT_LPI2C_DMA_MAXMSG=16 +CONFIG_IMXRT_LPI2C_DYNTIMEO=y +CONFIG_IMXRT_LPI2C_DYNTIMEO_STARTSTOP=10 +CONFIG_IMXRT_LPSPI3=y +CONFIG_IMXRT_LPSPI3_DMA=y +CONFIG_IMXRT_LPSPI4=y +CONFIG_IMXRT_LPSPI4_DMA=y +CONFIG_IMXRT_LPSPI_DMA=y +CONFIG_IMXRT_LPUART2=y +CONFIG_IMXRT_LPUART3=y +CONFIG_IMXRT_LPUART4=y +CONFIG_IMXRT_LPUART5=y +CONFIG_IMXRT_LPUART6=y +CONFIG_IMXRT_LPUART7=y +CONFIG_IMXRT_LPUART8=y +CONFIG_IMXRT_LPUART_INVERT=y +CONFIG_IMXRT_LPUART_SINGLEWIRE=y +CONFIG_IMXRT_PHY_POLLING=y +CONFIG_IMXRT_SNVS_LPSRTC=y +CONFIG_IMXRT_USBDEV=y +CONFIG_IMXRT_USDHC1=y +CONFIG_IMXRT_USDHC1_INVERT_CD=y +CONFIG_IMXRT_USDHC1_WIDTH_D1_D4=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=2944 +CONFIG_IOB_NBUFFERS=24 +CONFIG_IOB_THROTTLE=0 +CONFIG_IPCFG_BINARY=y +CONFIG_IPCFG_PATH="/fs/nor" +CONFIG_LIBC_MAX_EXITFUNS=1 +CONFIG_LIBC_STRERROR=y +CONFIG_LPI2C1_DMA=y +CONFIG_LPI2C3_DMA=y +CONFIG_LPI2C4_DMA=y +CONFIG_LPUART2_RXDMA=y +CONFIG_LPUART2_TXDMA=y +CONFIG_LPUART3_BAUD=57600 +CONFIG_LPUART3_IFLOWCONTROL=y +CONFIG_LPUART3_OFLOWCONTROL=y +CONFIG_LPUART3_RXBUFSIZE=600 +CONFIG_LPUART3_RXDMA=y +CONFIG_LPUART3_TXBUFSIZE=3000 +CONFIG_LPUART3_TXDMA=y +CONFIG_LPUART4_BAUD=57600 +CONFIG_LPUART4_IFLOWCONTROL=y +CONFIG_LPUART4_RXBUFSIZE=600 +CONFIG_LPUART4_RXDMA=y +CONFIG_LPUART4_TXBUFSIZE=3000 +CONFIG_LPUART4_TXDMA=y +CONFIG_LPUART5_BAUD=57600 +CONFIG_LPUART5_IFLOWCONTROL=y +CONFIG_LPUART5_OFLOWCONTROL=y +CONFIG_LPUART5_RXBUFSIZE=600 +CONFIG_LPUART5_RXDMA=y +CONFIG_LPUART5_TXBUFSIZE=3000 +CONFIG_LPUART5_TXDMA=y +CONFIG_LPUART6_BAUD=57600 +CONFIG_LPUART6_SERIAL_CONSOLE=y +CONFIG_LPUART7_RXDMA=y +CONFIG_LPUART7_TXBUFSIZE=128 +CONFIG_LPUART8_BAUD=420000 +CONFIG_LPUART8_RXBUFSIZE=600 +CONFIG_LPUART8_RXDMA=y +CONFIG_LPUART8_TXDMA=y +CONFIG_MEMSET_64BIT=y +CONFIG_MEMSET_OPTSPEED=y +CONFIG_MMCSD=y +CONFIG_MMCSD_SDIO=y +CONFIG_MM_REGIONS=2 +CONFIG_MTD=y +CONFIG_MTD_BYTE_WRITE=y +CONFIG_MTD_PARTITION=y +CONFIG_NAME_MAX=40 +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSSERVER_NOADDR=y +CONFIG_NETDEV_CAN_BITRATE_IOCTL=y +CONFIG_NETDEV_CAN_FILTER_IOCTL=y +CONFIG_NETDEV_LATEINIT=y +CONFIG_NETDEV_PHY_IOCTL=y +CONFIG_NETINIT_DHCPC=y +CONFIG_NETINIT_DNS=y +CONFIG_NETINIT_DNSIPADDR=0XC0A800FE +CONFIG_NETINIT_DRIPADDR=0XC0A800FE +CONFIG_NETINIT_MONITOR=y +CONFIG_NETINIT_RETRY_MOUNTPATH=10 +CONFIG_NETINIT_THREAD=y +CONFIG_NETINIT_THREAD_PRIORITY=49 +CONFIG_NETUTILS_TELNETD=y +CONFIG_NET_ARP_IPIN=y +CONFIG_NET_ARP_SEND=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_CAN=y +CONFIG_NET_CAN_EXTID=y +CONFIG_NET_CAN_NOTIFIER=y +CONFIG_NET_CAN_RAW_TX_DEADLINE=y +CONFIG_NET_CAN_SOCK_OPTS=y +CONFIG_NET_ETH_PKTSIZE=1518 +CONFIG_NET_ICMP=y +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_IGMP=y +CONFIG_NET_SOLINGER=y +CONFIG_NET_TCP=y +CONFIG_NET_TCPBACKLOG=y +CONFIG_NET_TCP_DELAYED_ACK=y +CONFIG_NET_TCP_KEEPALIVE=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_TIMESTAMP=y +CONFIG_NET_UDP=y +CONFIG_NET_UDP_CHECKSUMS=y +CONFIG_NET_UDP_WRITE_BUFFERS=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_CROMFSETC=y +CONFIG_NSH_LINELEN=128 +CONFIG_NSH_MAXARGUMENTS=15 +CONFIG_NSH_NESTDEPTH=8 +CONFIG_NSH_READLINE=y +CONFIG_NSH_ROMFSETC=y +CONFIG_NSH_ROMFSSECTSIZE=128 +CONFIG_NSH_STRERROR=y +CONFIG_NSH_TELNET_LOGIN=y +CONFIG_NSH_VARS=y +CONFIG_PIPES=y +CONFIG_PREALLOC_TIMERS=50 +CONFIG_PRIORITY_INHERITANCE=y +CONFIG_PTHREAD_MUTEX_TYPES=y +CONFIG_PTHREAD_STACK_MIN=512 +CONFIG_RAM_SIZE=1048576 +CONFIG_RAM_START=0x20200000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_READLINE_TABCOMPLETION=y +CONFIG_RTC=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=249 +CONFIG_SCHED_HPWORKSTACKSIZE=1800 +CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_SCHED_INSTRUMENTATION_EXTERNAL=y +CONFIG_SCHED_INSTRUMENTATION_SWITCH=y +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_LPWORKPRIORITY=50 +CONFIG_SCHED_LPWORKSTACKSIZE=2032 +CONFIG_SDIO_BLOCKSETUP=y +CONFIG_SEM_PREALLOCHOLDERS=32 +CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS=y +CONFIG_SERIAL_TERMIOS=y +CONFIG_SIG_DEFAULT=y +CONFIG_SIG_SIGALRM_ACTION=y +CONFIG_SIG_SIGUSR1_ACTION=y +CONFIG_SIG_SIGUSR2_ACTION=y +CONFIG_SIG_SIGWORK=4 +CONFIG_SPI=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=30 +CONFIG_START_MONTH=11 +CONFIG_STDIO_BUFFER_SIZE=256 +CONFIG_SYSTEM_CDCACM=y +CONFIG_SYSTEM_CLE=y +CONFIG_SYSTEM_DHCPC_RENEW=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING=y +CONFIG_SYSTEM_SYSTEM=y +CONFIG_TASK_NAME_SIZE=24 +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y +CONFIG_USBDEV_DUALSPEED=y +CONFIG_USBDEV_MAXPOWER=500 +CONFIG_USEC_PER_TICK=1000 +CONFIG_WATCHDOG=y diff --git a/boards/nxp/mr-tropic/nuttx-config/scripts/bootloader_script.ld b/boards/nxp/mr-tropic/nuttx-config/scripts/bootloader_script.ld new file mode 100644 index 0000000000..81fb1e0c40 --- /dev/null +++ b/boards/nxp/mr-tropic/nuttx-config/scripts/bootloader_script.ld @@ -0,0 +1,177 @@ +/**************************************************************************** + * boards/nxp/mr-tropic/nuttx-config/scripts/bootloader_script.ld + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* Specify the memory areas */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x70000000, LENGTH = 128K + sram (rwx) : ORIGIN = 0x20200000, LENGTH = 512K + itcm (rwx) : ORIGIN = 0x00000000, LENGTH = 384K + dtcm (rwx) : ORIGIN = 0x20000000, LENGTH = 128K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +EXTERN(g_flash_config) +EXTERN(g_image_vector_table) +EXTERN(g_boot_data) +EXTERN(board_get_manifest) +EXTERN(_bootdelay_signature) + +ENTRY(_stext) + +SECTIONS +{ + /* Image Vector Table and Boot Data for booting from external flash */ + + .boot_hdr : ALIGN(4) + { + FILL(0xff) + __boot_hdr_start__ = ABSOLUTE(.) ; + KEEP(*(.boot_hdr.conf)) + . = 0x1000 ; + KEEP(*(.boot_hdr.ivt)) + . = 0x1020 ; + KEEP(*(.boot_hdr.boot_data)) + . = 0x1030 ; + KEEP(*(.boot_hdr.dcd_data)) + __boot_hdr_end__ = ABSOLUTE(.) ; + . = 0x2000 ; + } >flash + + .vectors : + { + KEEP(*(.vectors)) + *(.text .text.__start) + } >flash + + .itcmfunc : + { + . = ALIGN(8); + _sitcmfuncs = ABSOLUTE(.); + FILL(0xFF) + . = 0x40 ; + *(.ram_vectors) + . = ALIGN(8); + _eitcmfuncs = ABSOLUTE(.); + } > itcm AT > flash + + _fitcmfuncs = LOADADDR(.itcmfunc); + + .text : ALIGN(4) + { + _stext = ABSOLUTE(.); + *(.vectors) + . = ALIGN(32); + /* + This signature provides the bootloader with a way to delay booting + */ + _bootdelay_signature = ABSOLUTE(.); + FILL(0xffecc2925d7d05c5) + . += 8; + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + . = ALIGN(4096); + _etext = ABSOLUTE(.); + _srodata = ABSOLUTE(.); + *(.rodata .rodata.*) + . = ALIGN(4096); + _erodata = ABSOLUTE(.); + } > flash + + .init_section : + { + _sinit = ABSOLUTE(.); + KEEP(*(.init_array .init_array.*)) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : + { + *(.ARM.extab*) + } > flash + + .ARM.exidx : + { + __exidx_start = ABSOLUTE(.); + *(.ARM.exidx*) + __exidx_end = ABSOLUTE(.); + } > flash + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + .ramfunc ALIGN(4): + { + _sramfuncs = ABSOLUTE(.); + *(.ramfunc .ramfunc.*) + _eramfuncs = ABSOLUTE(.); + } > sram AT > flash + + _framfuncs = LOADADDR(.ramfunc); + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } + + _boot_loadaddr = ORIGIN(flash); + _boot_size = LENGTH(flash); + _ram_size = LENGTH(sram); + _sdtcm = ORIGIN(dtcm); + _edtcm = ORIGIN(dtcm) + LENGTH(dtcm); +} diff --git a/boards/nxp/mr-tropic/nuttx-config/scripts/itcm_functions_includes.ld b/boards/nxp/mr-tropic/nuttx-config/scripts/itcm_functions_includes.ld new file mode 100644 index 0000000000..36330c1e85 --- /dev/null +++ b/boards/nxp/mr-tropic/nuttx-config/scripts/itcm_functions_includes.ld @@ -0,0 +1,719 @@ +*(.text._ZN4uORB7Manager27orb_add_internal_subscriberE6ORB_IDhPj) +*(.text._ZN13MavlinkStream6updateERKy) +*(.text._ZN7Mavlink16update_rate_multEv) +*(.text._ZN3sym17PredictCovarianceIfEEN6matrix6MatrixIT_Lj23ELj23EEERKNS2_IS3_Lj24ELj1EEERKS4_RKNS2_IS3_Lj3ELj1EEES3_SC_SC_S3_S3_) /* itcm-check-ignore */ +*(.text._ZN13MavlinkStream12get_size_avgEv) +*(.text._ZN16ControlAllocator3RunEv) +*(.text._ZN22MulticopterRateControl3RunEv.part.0) +*(.text._ZN7Mavlink9task_mainEiPPc) +*(.text._ZN7sensors22VehicleAngularVelocity3RunEv) +*(.text._ZN4uORB12Subscription9subscribeEv.part.0) +*(.text._ZN4uORB7Manager13orb_data_copyEPvS1_Rjb) +*(.text._ZN4uORB10DeviceNode5writeEP4filePKcj) +*(.text._ZN4uORB10DeviceNode7publishEPK12orb_metadataPvPKv) +*(.text._ZN4uORB12DeviceMaster19getDeviceNodeLockedEPK12orb_metadatah) +*(.text._Z12get_orb_meta6ORB_ID) +*(.text._ZN9ICM42688P12ProcessAccelERKyPKN20InvenSense_ICM42688P4FIFO4DATAEh) +*(.text._ZN3px49WorkQueue3RunEv) +*(.text._ZN9ICM42688P11ProcessGyroERKyPKN20InvenSense_ICM42688P4FIFO4DATAEh) +*(.text._ZN4EKF23RunEv) +*(.text._ZN7sensors10VehicleIMU7PublishEv) +*(.text._ZN4math17WelfordMeanVectorIfLj3EE6updateERKN6matrix6VectorIfLj3EEE) +*(.text._ZN7sensors10VehicleIMU10UpdateGyroEv) +*(.text._ZN9ICM42688P8FIFOReadERKyh) +*(.text._ZN3Ekf20controlGravityFusionERKN9estimator9imuSampleE) +*(.text._ZN16PX4Accelerometer10updateFIFOER19sensor_accel_fifo_s) +*(.text._ZN7sensors22VehicleAngularVelocity19CalibrateAndPublishERKyRKN6matrix7Vector3IfEES7_) +*(.text._ZN4uORB12Subscription10advertisedEv) +*(.text._ZNK15AttitudeControl6updateERKN6matrix10QuaternionIfEE) +*(.text._ZN7sensors10VehicleIMU11UpdateAccelEv) +*(.text.perf_set_elapsed.part.0) +*(.text._ZN4uORB12Subscription6updateEPv) +*(.text._ZN12PX4Gyroscope10updateFIFOER18sensor_gyro_fifo_s) +*(.text._ZN7sensors10VehicleIMU3RunEv) +*(.text.__aeabi_l2f) +*(.text._ZN39ControlAllocationSequentialDesaturation23computeDesaturationGainERKN6matrix6VectorIfLj16EEES4_) +*(.text.pthread_mutex_timedlock) +*(.text._ZN7sensors22VehicleAngularVelocity21FilterAngularVelocityEiPfi) +*(.text._ZN26MulticopterAttitudeControl3RunEv.part.0) +*(.text._ZN6device3SPI9_transferEPhS1_j) +*(.text._ZN15OutputPredictor21calculateOutputStatesEyRKN6matrix7Vector3IfEEfS4_f) +*(.text._ZN7sensors18VotedSensorsUpdate7imuPollER17sensor_combined_s) +*(.text._Z9rotate_3i8RotationRsS0_S0_) +*(.text.fs_getfilep) +*(.text.MEM_DataCopy0_1) +*(.text._ZN7sensors19VehicleAcceleration3RunEv) +*(.text.uart_ioctl) +*(.text._ZN26MulticopterPositionControl3RunEv.part.0) +*(.text.pthread_mutex_take) +*(.text._ZN14ImuDownSampler6updateERKN9estimator9imuSampleE) +*(.text._ZN39ControlAllocationSequentialDesaturation6mixYawEv) +*(.text._ZN16ControlAllocator25publish_actuator_controlsEv.part.0) +*(.text._ZN9ICM42688P7RunImplEv) +*(.text._ZN4uORB12Subscription9subscribeEv) +*(.text.param_get) +*(.text._ZN7sensors22VehicleAngularVelocity21SensorSelectionUpdateERKyb) +*(.text._ZN3px49WorkQueue3AddEPNS_8WorkItemE) +*(.text._ZN4EKF220PublishLocalPositionERKy) +*(.text._mav_finalize_message_chan_send) +*(.text._ZN7sensors22VehicleAngularVelocity16ParametersUpdateEb) +*(.text._ZN6events12SendProtocol6updateERKy) +*(.text._ZN6device3SPI8transferEPhS1_j) +*(.text._ZN27MavlinkStreamDistanceSensor4sendEv) +*(.text.hrt_call_internal) +*(.text._ZN39ControlAllocationSequentialDesaturation18mixAirmodeDisabledEv) +*(.text._ZN7Mavlink15get_free_tx_bufEv) +*(.text.nx_poll) +*(.text._ZN15MavlinkReceiver3runEv) +*(.text._ZN9ICM42688P18ProcessTemperatureEPKN20InvenSense_ICM42688P4FIFO4DATAEh) +*(.text._ZN15OutputPredictor19correctOutputStatesEyRKN6matrix10QuaternionIfEERKNS0_7Vector3IfEERK9LatLonAltS8_S8_) +*(.text._ZN3Ekf12predictStateERKN9estimator9imuSampleE) +*(.text._ZN3px46logger6Logger3runEv) +*(.text._ZN4uORB20SubscriptionInterval7updatedEv) +*(.text._ZN24MavlinkStreamCommandLong4sendEv) +*(.text._ZN9Commander3runEv) +*(.text._ZN3Ekf17predictCovarianceERKN9estimator9imuSampleE) +*(.text.wd_cancel) +*(.text._ZN7Sensors3RunEv) +*(.text.perf_end) +*(.text._ZN4uORB12Subscription7updatedEv) +*(.text._ZN13land_detector12LandDetector3RunEv) +*(.text.sched_idletask) +*(.text.atanf) +*(.text.uart_write) +*(.text.pthread_mutex_unlock) +*(.text.__ieee754_asinf) +*(.text.MEM_DataCopy0_2) +*(.text._ZN20MavlinkCommandSender13check_timeoutE17mavlink_channel_t) +*(.text._ZN16ControlAllocator32publish_control_allocator_statusEi) +*(.text.__ieee754_atan2f) +*(.text._ZNK18DynamicSparseLayer3getEt) +*(.text.__udivmoddi4) +*(.text._ZN8Failsafe17checkStateAndModeERKyRKN12FailsafeBase5StateERK16failsafe_flags_s) +*(.text._ZN29MavlinkStreamHygrometerSensor4sendEv) +*(.text.pthread_mutex_give) +*(.text._ZN3Ekf18controlFusionModesERKN9estimator9imuSampleE) +*(.text._ZN4cdev4CDev11poll_notifyEm) +*(.text.file_vioctl) +*(.text._ZN7sensors18VotedSensorsUpdate11sensorsPollER17sensor_combined_s) +*(.text.nxsig_nanosleep) +*(.text.sem_wait) +*(.text.perf_count_interval.part.0) +*(.text._ZN16ControlAllocator37update_effectiveness_matrix_if_neededE25EffectivenessUpdateReason) +*(.text.MEM_LongCopyJump) +*(.text.px4_arch_adc_sample) +*(.text._ZN31MulticopterHoverThrustEstimator3RunEv) +*(.text._ZNK17ControlAllocation20clipActuatorSetpointERN6matrix6VectorIfLj16EEE) +*(.text._ZN4uORB7Manager17get_device_masterEv) +*(.text._ZN13DataValidator3putEyPKfmh) +*(.text.cdcuart_ioctl) +*(.text.cdcacm_sndpacket) +*(.text._ZN7sensors22VehicleAngularVelocity16SensorBiasUpdateEb) +*(.text._ZN13MavlinkStream11update_dataEv) +*(.text._ZN7sensors18VotedSensorsUpdate21calcGyroInconsistencyEv) +*(.text.param_set_used) +*(.text._ZN18EstimatorInterface10setIMUDataERKN9estimator9imuSampleE) +*(.text._ZN18DataValidatorGroup8get_bestEyPi) +*(.text._ZN4EKF218PublishInnovationsERKy) +*(.text._ZN21MavlinkMissionManager4sendEv) +*(.text._ZN22MulticopterRateControl28updateActuatorControlsStatusERK25vehicle_torque_setpoint_sf) +*(.text._ZN11RateControl6updateERKN6matrix7Vector3IfEES4_S4_fb) +*(.text._ZN39ControlAllocationSequentialDesaturation19desaturateActuatorsERN6matrix6VectorIfLj16EEERKS2_b) +*(.text.imxrt_lpi2c_transfer) +*(.text.uart_putxmitchar) +*(.text.clock_nanosleep) +*(.text.up_release_pending) +*(.text.MEM_DataCopy0) +*(.text._ZN22MavlinkStreamGPSRawInt4sendEv) +*(.text.dq_rem) +*(.text._ZN15GyroCalibration3RunEv.part.0) +*(.text._ZN7sensors18VotedSensorsUpdate22calcAccelInconsistencyEv) +*(.text._ZN24MavlinkStreamADSBVehicle4sendEv) +*(.text.sinf) +*(.text.hrt_call_after) +*(.text._ZN39ControlAllocationSequentialDesaturation8allocateEv) +*(.text.up_invalidate_dcache) +*(.text._ZN15PositionControl16_velocityControlEf) +*(.text._ZN4EKF222PublishAidSourceStatusERKy) +*(.text._ZN4ListIP13MavlinkStreamE8IteratorppEv) +*(.text._ZN20MavlinkStreamESCInfo4sendEv) +*(.text.sem_post) +*(.text._ZN3px417ScheduledWorkItem15ScheduleDelayedEm) +*(.text._ZN10FlightTaskC1Ev) +*(.text.usleep) +*(.text._ZN14FlightTaskAutoC1Ev) +*(.text.sem_getvalue) +*(.text._ZN23MavlinkStreamHighresIMU4sendEv) +*(.text.imxrt_gpio_write) +*(.text._ZN3Ekf6updateEv) +*(.text.__ieee754_acosf) +*(.text._ZN3Ekf20updateIMUBiasInhibitERKN9estimator9imuSampleE) +*(.text._ZN9Commander13dataLinkCheckEv) +*(.text._ZN17FlightModeManager10switchTaskE15FlightTaskIndex) +*(.text._ZN12PX4Gyroscope9set_scaleEf) +*(.text._ZN12FailsafeBase6updateERKyRKNS_5StateEbbRK16failsafe_flags_s) +*(.text._ZN18MavlinkStreamDebug4sendEv) +*(.text._ZN27MavlinkStreamServoOutputRawILi0EE4sendEv) +*(.text.asinf) +*(.text._ZN6matrix5EulerIfEC1ERKNS_3DcmIfEE) +*(.text._ZN4EKF227PublishInnovationTestRatiosERKy) +*(.text._ZN4EKF213PublishStatusERKy) +*(.text._ZN4EKF226PublishInnovationVariancesERKy) +*(.text._ZN13land_detector23MulticopterLandDetector25_get_ground_contact_stateEv) +*(.text.imxrt_dmach_start) +*(.text._ZN3ADC19update_system_powerEy) +*(.text._ZNK3Ekf19get_ekf_soln_statusEv) +*(.text._ZN3px46logger15watchdog_updateERNS0_15watchdog_data_tEb) +*(.text.imxrt_gpio_read) +*(.text._ZN32MavlinkStreamNavControllerOutput4sendEv) +*(.text._ZN39MavlinkStreamGimbalDeviceAttitudeStatus4sendEv) +*(.text._ZNK10ConstLayer3getEt) +*(.text.__aeabi_uldivmod) +*(.text.up_udelay) +*(.text.up_idle) +*(.text._ZN20MavlinkStreamGPS2Raw4sendEv) +*(.text._ZN4EKF217UpdateCalibrationERKyRNS_19InFlightCalibrationERKN6matrix7Vector3IfEES8_fbb) +*(.text._ZN28MavlinkStreamGpsGlobalOrigin4sendEv) +*(.text._ZN11ControlMath15bodyzToAttitudeEN6matrix7Vector3IfEEfR27vehicle_attitude_setpoint_s) +*(.text._ZN4EKF217UpdateRangeSampleER17ekf2_timestamps_s) +*(.text._ZN3Ekf24controlOpticalFlowFusionERKN9estimator9imuSampleE) +*(.text._ZN19MavlinkStreamRawRpm4sendEv) +*(.text._ZN13MavlinkStream10const_rateEv) +*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleE) +*(.text._ZN15FailureDetector20updateAttitudeStatusERK16vehicle_status_s) +*(.text._ZN7Mavlink19configure_sik_radioEv) +*(.text._ZN13BatteryStatus8adc_pollEv) +*(.text.getpid) +*(.text._ZN13DataValidator10confidenceEy) +*(.text._ZN22MavlinkStreamGPSStatus4sendEv) +*(.text._ZN4EKF220UpdateAirspeedSampleER17ekf2_timestamps_s) +*(.text._ZN23MavlinkStreamStatustext4sendEv) +*(.text.uart_poll) +*(.text._ZN24MavlinkParametersManager4sendEv) +*(.text._ZN26MulticopterPositionControl18set_vehicle_statesERK24vehicle_local_position_sf) +*(.text.file_poll) +*(.text.hrt_elapsed_time) +*(.text._ZN7Mavlink11send_finishEv) +*(.text._ZNK3Ekf36estimateInertialNavFallingLikelihoodEv) +*(.text._ZN15PositionControl16_positionControlEv) +*(.text._ZN28MavlinkStreamDebugFloatArray4sendEv) +*(.text._ZN11ControlMath9limitTiltERN6matrix7Vector3IfEERKS2_f) +*(.text.pthread_mutex_lock) +*(.text._ZN21MavlinkStreamAltitude8get_sizeEv) +*(.text._ZN7Mavlink29check_requested_subscriptionsEv) +*(.text.imxrt_lpspi_setmode) +*(.text._ZN3Ekf34controlZeroInnovationHeadingUpdateEv) +*(.text.perf_begin) +*(.text.imxrt_lpspi_setfrequency) +*(.text._ZN17FlightModeManager9_initTaskE15FlightTaskIndex) +*(.text._ZN22MulticopterRateControl3RunEv) +*(.text.cosf) +*(.text._ZN22MavlinkStreamESCStatus4sendEv) +*(.text._ZN26MavlinkStreamCameraTrigger4sendEv) +*(.text._ZN36MavlinkStreamPositionTargetGlobalInt4sendEv) +*(.text._ZN4uORB12Subscription4copyEPv) +*(.text._ZN7sensors19VehicleAcceleration21SensorSelectionUpdateEb) +*(.text.crc_accumulate) +*(.text._ZN3px46logger6Logger13update_paramsEv) +*(.text._ZN11calibration14DeviceExternalEm) +*(.text._ZN25MavlinkStreamHomePosition8get_sizeEv) +*(.text.imxrt_lpspi_modifyreg32) +*(.text._ZN7sensors19VehicleAcceleration16SensorBiasUpdateEb) +*(.text.modifyreg32) +*(.text._ZNK6matrix6MatrixIfLj3ELj1EEmlEf) +*(.text._ZN6matrix5EulerIfEC1ERKNS_10QuaternionIfEE) +*(.text.imxrt_queuedtd) +*(.text._ZN27MavlinkStreamDistanceSensor8get_sizeEv) +*(.text._ZN3Ekf23controlBaroHeightFusionERKN9estimator9imuSampleE) +*(.text._ZN16PX4Accelerometer9set_scaleEf) +*(.text._ZN11ControlMath11constrainXYERKN6matrix7Vector2IfEES4_RKf) +*(.text._ZN22MavlinkStreamEfiStatus4sendEv) +*(.text._ZN22MavlinkStreamDebugVect4sendEv) +*(.text._ZN4EKF217PublishSensorBiasERKy) +*(.text._ZN17FlightModeManager3RunEv) +*(.text._ZN15PositionControl11_inputValidEv) +*(.text._ZN7sensors14VehicleAirData3RunEv) +*(.text.perf_count) +*(.text._ZN3Ekf16controlMagFusionERKN9estimator9imuSampleE) +*(.text.pthread_sem_give) +*(.text._ZN7sensors10VehicleIMU16ParametersUpdateEb) +*(.text._ZN4uORB20SubscriptionInterval4copyEPv) +*(.text._ZN12I2CSPIDriverI9ICM42688PE3RunEv) +*(.text.imxrt_epcomplete.constprop.0) +*(.text._ZNK6matrix6MatrixIfLj3ELj1EEmiERKS1_) +*(.text._ZN9Commander30handleModeIntentionAndFailsafeEv) +*(.text.perf_event_count) +*(.text._ZN4EKF215PublishAttitudeERKy) +*(.text._ZN19MavlinkStreamRawRpm8get_sizeEv) +*(.text._ZNK3px46atomicIbE4loadEv) +*(.text._ZN29MavlinkStreamHygrometerSensor8get_sizeEv) +*(.text.pthread_mutex_add) +*(.text._ZN12HomePosition6updateEbb) +*(.text.poll_fdsetup) +*(.text._ZN15PositionControl20_accelerationControlEv) +*(.text._ZN3Ekf19controlHeightFusionERKN9estimator9imuSampleE) +*(.text._ZN9Commander19control_status_ledsEbh) +*(.text._ZN6device3I2C8transferEPKhjPhj) +*(.text.orb_publish) +*(.text._ZN7sensors19VehicleAcceleration16ParametersUpdateEb) +*(.text._ZN22MavlinkStreamVibration8get_sizeEv) +*(.text._ZN15MavlinkReceiver15CheckHeartbeatsERKyb) +*(.text._ZNK6matrix7Vector3IfEmiES1_) +*(.text.__aeabi_f2ulz) +*(.text._ZN9ICM42688P26DataReadyInterruptCallbackEiPvS0_) +*(.text._ZN13land_detector23MulticopterLandDetector23_get_maybe_landed_stateEv) +*(.text.acosf) +*(.text._ZN14ImuDownSampler5resetEv) +*(.text._ZN3Ekf31checkVerticalAccelerationHealthERKN9estimator9imuSampleE) +*(.text._ZN6matrix6MatrixIfLj3ELj1EEC1ERKS1_) +*(.text.udp_pollsetup) +*(.text._ZL14timer_callbackPv) +*(.text._ZN3Ekf4fuseERKN6matrix6VectorIfLj24EEEf) +*(.text._ZN13land_detector23MulticopterLandDetector22_set_hysteresis_factorEi) +*(.text.nxsem_wait_irq) +*(.text._ZN20MavlinkCommandSender4lockEv) +*(.text.MEM_LongCopyEnd) +*(.text._ZThn24_N16ControlAllocator3RunEv) +*(.text._ZN15TimestampedListIN20MavlinkCommandSender14command_item_sELi3EE8get_nextEv) +*(.text._ZNK3Ekf21get_ekf_lpos_accuracyEPfS0_) +*(.text._ZN17FlightModeManager17start_flight_taskEv) +*(.text.MEM_DataCopyBytes) +*(.text._ZN29MavlinkStreamLocalPositionNED8get_sizeEv) +*(.text._ZN6SticksC1EP12ModuleParams) +*(.text._ZN27MavlinkStreamServoOutputRawILi1EE4sendEv) +*(.text._ZN3Ekf35updateHorizontalDeadReckoningstatusEv) +*(.text._ZN3Ekf20controlAirDataFusionERKN9estimator9imuSampleE) +*(.text._ZN24FlightTaskManualAltitudeC1Ev) +*(.text._ZN25MavlinkStreamHomePosition4sendEv) +*(.text._ZN24MavlinkParametersManager8send_oneEv) +*(.text._ZN15OutputPredictor29applyCorrectionToOutputBufferERKN6matrix7Vector3IfEES4_) +*(.text._ZN21HealthAndArmingChecks6updateEbb) +*(.text._ZThn24_N22MulticopterRateControl3RunEv) +*(.text._ZN26MavlinkStreamManualControl4sendEv) +*(.text._ZN27MavlinkStreamOpticalFlowRad4sendEv) +*(.text._ZN18mag_bias_estimator16MagBiasEstimator3RunEv) +*(.text._ZN4uORB7Manager11orb_publishEPK12orb_metadataPvPKv) +*(.text._ZN24MavlinkParametersManager18send_untransmittedEv) +*(.text._ZN10MavlinkFTP4sendEv) +*(.text._ZN3Ekf27controlExternalVisionFusionERKN9estimator9imuSampleE) +*(.text.clock_gettime) +*(.text._ZN3ADC17update_adc_reportEy) +*(.text._ZN32MavlinkStreamGimbalManagerStatus4sendEv) +*(.text._ZN9LockGuardD1Ev) /* itcm-check-ignore */ +*(.text._ZN4EKF213PublishStatesERKy) +*(.text._ZN3ADC3RunEv) +*(.text._ZN6BMP38815compensate_dataEhPK16bmp3_uncomp_dataP9bmp3_data) +*(.text._ZN3Ekf20controlFakePosFusionEv) +*(.text._ZN11calibration9Gyroscope13set_device_idEm) +*(.text._ZN24MavlinkStreamOrbitStatus8get_sizeEv) +*(.text.imxrt_progressep) +*(.text.imxrt_gpio_configinput) +*(.text._ZN17FlightModeManager26generateTrajectorySetpointEfRK24vehicle_local_position_s) +*(.text._ZN7Sensors14diff_pres_pollEv) +*(.text._ZN21MavlinkStreamAttitude4sendEv) +*(.text._ZN4EKF220UpdateMagCalibrationERKy) +*(.text._ZN22MavlinkStreamEfiStatus8get_sizeEv) +*(.text._ZN9ICM42688P9DataReadyEv) +*(.text._ZN21MavlinkMissionManager20check_active_missionEv) +*(.text._ZNK3Ekf20get_ekf_vel_accuracyEPfS0_) +*(.text._ZN4EKF216UpdateBaroSampleER17ekf2_timestamps_s) +*(.text._ZN4EKF223UpdateSystemFlagsSampleER17ekf2_timestamps_s) +*(.text._ZThn16_N7sensors22VehicleAngularVelocity3RunEv) +*(.text._ZN29MavlinkStreamObstacleDistance4sendEv) +*(.text._ZN24MavlinkStreamOrbitStatus4sendEv) +*(.text._ZN9Navigator3runEv) +*(.text._ZN24MavlinkParametersManager11send_paramsEv) +*(.text._ZN17MavlinkLogHandler4sendEv) +*(.text._ZN7control10SuperBlock5setDtEf) +*(.text._ZN29MavlinkStreamMountOrientation8get_sizeEv) +*(.text._ZN26MulticopterAttitudeControl3RunEv) +*(.text._ZThn16_N31ActuatorEffectivenessMultirotor22getEffectivenessMatrixERN21ActuatorEffectiveness13ConfigurationE25EffectivenessUpdateReason) +*(.text._ZN4EKF218PublishStatusFlagsERKy) +*(.text._ZN11WeatherVaneC1EP12ModuleParams) +*(.text._ZN15FailureDetector6updateERK16vehicle_status_sRK22vehicle_control_mode_s) +*(.text._ZN7Mavlink10send_startEi) +*(.text.imxrt_lpspi_setbits) +*(.text._ZN15OutputPredictor37applyCorrectionToVerticalOutputBufferEff) +*(.text._ZN4EKF222UpdateAccelCalibrationERKy) +*(.text._ZN7sensors19VehicleMagnetometer3RunEv) +*(.text._ZN29MavlinkStreamMountOrientation4sendEv) +*(.text._ZN13land_detector12LandDetector19UpdateVehicleAtRestEv) +*(.text._ZN10FlightTask29_evaluateVehicleLocalPositionEv) +*(.text.__aeabi_f2lz) +*(.text._ZN32MavlinkStreamCameraImageCaptured4sendEv) +*(.text._ZN21MavlinkStreamOdometry8get_sizeEv) +*(.text._ZN28MavlinkStreamNamedValueFloat4sendEv) +*(.text.__aeabi_ul2f) +*(.text.poll) +*(.text._ZN14FlightTaskAutoD1Ev) +*(.text._ZN4uORB10DeviceNode22get_initial_generationEv) +*(.text._ZN3Ekf23controlGnssHeightFusionERKN9estimator10gnssSampleE) +*(.text._ZN3Ekf40updateOnGroundMotionForOpticalFlowChecksEv) +*(.text._ZN6matrix6MatrixIfLj3ELj1EEC1Ev) +*(.text._ZN14ZeroGyroUpdate6updateER3EkfRKN9estimator9imuSampleE) +*(.text._ZN30MavlinkStreamOpenDroneIdSystem4sendEv) +*(.text._ZN22MavlinkStreamScaledIMU4sendEv) +*(.text.imxrt_ioctl) +*(.text._ZN36MavlinkStreamGimbalDeviceSetAttitude4sendEv) +*(.text._ZN4math13expo_deadzoneIfEEKT_RS2_S3_S3_.isra.0) +*(.text._ZN19StickAccelerationXYC1EP12ModuleParams) +*(.text.imxrt_epsubmit) +*(.text._ZN15PositionControl6updateEf) +*(.text._ZN23MavlinkStreamScaledIMU24sendEv) +*(.text.imxrt_dma_send) +*(.text._ZN20MavlinkStreamWindCov4sendEv) +*(.text._ZN7sensors18VotedSensorsUpdate13checkFailoverERNS0_10SensorDataEPKcN6events3px45enums13sensor_type_tE) +*(.text._ZN21MavlinkStreamOdometry4sendEv) +*(.text.vsprintf_internal.constprop.0) +*(.text.udp_pollteardown) +*(.text._ZN12MixingOutput6updateEv) +*(.text.clock_abstime2ticks) +*(.text._ZN13BatteryStatus3RunEv) +*(.text._ZN32MavlinkStreamGimbalManagerStatus8get_sizeEv) +*(.text._ZN10FlightTask15_resetSetpointsEv) +*(.text._ZN9systemlib10Hysteresis20set_state_and_updateEbRKy) +*(.text.devif_callback_free.part.0) +*(.text._ZN6Sticks25checkAndUpdateStickInputsEv) +*(.text.atan2f) +*(.text._ZN23MavlinkStreamRCChannels4sendEv) +*(.text._ZN4EKF221UpdateExtVisionSampleER17ekf2_timestamps_s) +*(.text.imxrt_dmach_stop) +*(.text._ZN9Commander16handleAutoDisarmEv) +*(.text._ZN9Commander11updateTunesEv) +*(.text._ZN4EKF215UpdateMagSampleER17ekf2_timestamps_s) +*(.text._ZN18DataValidatorGroup3putEjyPKfmh) +*(.text._ZNK3Ekf19get_ekf_ctrl_limitsEPfS0_S0_S0_S0_) +*(.text._ZN12FailsafeBase13checkFailsafeEibbRKNS_13ActionOptionsE) +*(.text._ZN17FlightTaskDescendD1Ev) +*(.text._ZN30MavlinkStreamOpenDroneIdSystem8get_sizeEv) +*(.text._ZNK3px46logger9LogWriter10is_startedENS0_7LogTypeE) +*(.text._ZN24FlightTaskManualAltitudeD1Ev) +*(.text._Z35px4_indicate_external_reset_lockout16LockoutComponentb) +*(.text.uart_pollnotify) +*(.text._ZN4EKF215PublishBaroBiasERKy) +*(.text._ZN4EKF221UpdateGyroCalibrationERKy) +*(.text._ZN6matrix9constrainIfLj3ELj1EEENS_6MatrixIT_XT0_EXT1_EEERKS3_S2_S2_) +*(.text._ZN4uORB22SubscriptionMultiArrayI16battery_status_sLh3EE16advertised_countEv) +*(.text._ZN23MavlinkStreamScaledIMU34sendEv) +*(.text.__aeabi_ldivmod) +*(.text._ZN15PositionControl16setInputSetpointERK21trajectory_setpoint_s) +*(.text.nxsig_pendingset) +*(.text.psock_poll) +*(.text._ZN15FailureInjector6updateEv) +*(.text.imxrt_writedtd) +*(.text.cdcacm_wrcomplete) +*(.text.cdcuart_txint) +*(.text._ZN3Ekf33updateVerticalDeadReckoningStatusEv) +*(.text._ZN33FlightTaskManualAltitudeSmoothVelC1Ev) +*(.text.powf) +*(.text._ZN4EKF217PublishEventFlagsERKy) +*(.text._ZN17FlightTaskDescend6updateEv) +*(.text.imxrt_iomux_configure) +*(.text.hrt_store_absolute_time) +*(.text.nxsem_set_protocol) +*(.text.write) +*(.text._ZN22MavlinkStreamSysStatus4sendEv) +*(.text._ZN4EKF216UpdateFlowSampleER17ekf2_timestamps_s) +*(.text._ZN4cdevL10cdev_ioctlEP4fileim) +*(.text._ZN7Mavlink10send_bytesEPKhj) +*(.text._ZNK8Failsafe17checkModeFallbackERK16failsafe_flags_sh) +*(.text.clock_systime_timespec) +*(.text._ZN4uORB10DeviceNode26remove_internal_subscriberEv) +*(.text._ZThn16_N4EKF23RunEv) +*(.text._ZNK3Ekf22computeYawInnovVarAndHEfRfRN6matrix6VectorIfLj24EEE) +*(.text._ZN12ActuatorTest6updateEif) +*(.text._ZN17VelocitySmoothingC1Efff) +*(.text._ZN13AnalogBattery19get_voltage_channelEv) +*(.text._ZN10FlightTask37_evaluateVehicleLocalPositionSetpointEv) +*(.text._ZN4uORB12Subscription11unsubscribeEv) +*(.text.net_lock) +*(.text.clock_time2ticks) +*(.text._ZN12FailsafeBase16updateStartDelayERKyb) +*(.text._ZN23MavlinkStreamStatustext8get_sizeEv) +*(.text._ZN11calibration13Accelerometer13set_device_idEm) +*(.text._ZN3px46logger6Logger18start_stop_loggingEv) +*(.text._ZN14FlightTaskAuto17_evaluateTripletsEv) +*(.text._ZN11calibration9Gyroscope23SensorCorrectionsUpdateEb) +*(.text._ZN25MavlinkStreamMagCalReport4sendEv) +*(.text.imxrt_config_gpio) +*(.text.nxsig_timeout) +*(.text._ZN11RateControl19setSaturationStatusERKN6matrix7Vector3IbEES4_) +*(.text._ZN3Ekf17measurementUpdateERN6matrix6VectorIfLj24EEERKS2_ff) +*(.text.dq_addlast) +*(.text._ZN19MavlinkStreamVFRHUD4sendEv) +*(.text.hrt_call_reschedule) +*(.text.nxsem_boost_priority) +*(.text._ZN4EKF215UpdateGpsSampleER17ekf2_timestamps_s) +*(.text._ZN8StickYawC1EP12ModuleParams) +*(.text._ZN7control12BlockLowPass6updateEf) +*(.text._ZN15FailureDetector26updateImbalancedPropStatusEv) +*(.text._ZN9systemlib10Hysteresis6updateERKy) +*(.text.nxsem_tickwait_uninterruptible) +*(.text._ZN12HomePosition31hasMovedFromCurrentHomeLocationEv) +*(.text.devif_callback_alloc) +*(.text._ZN28MavlinkStreamNamedValueFloat8get_sizeEv) +*(.text._ZN24MavlinkStreamADSBVehicle8get_sizeEv) +*(.text._ZN26MavlinkStreamBatteryStatus8get_sizeEv) +*(.text._ZN26MulticopterPositionControl17parameters_updateEb) +*(.text._ZN3px46logger6Logger29handle_vehicle_command_updateEv) +*(.text.imxrt_lpspi_send) +*(.text._ZN4uORB10DeviceNode23add_internal_subscriberEv) +*(.text._ZN6matrix6MatrixIfLj3ELj1EEaSERKS1_) +*(.text._ZNK6matrix6MatrixIfLj3ELj1EE5emultERKS1_) +*(.text.mallinfo_handler) +*(.text._ZN13land_detector23MulticopterLandDetector14_update_topicsEv) +*(.text._ZN24ManualVelocitySmoothingZC1Ev) /* itcm-check-ignore */ +*(.text._ZN3ADC6sampleEj) +*(.text._ZNK3Ekf22isTerrainEstimateValidEv) +*(.text._ZN15EstimatorChecks23setModeRequirementFlagsERK7ContextbbbRK24vehicle_local_position_sRK12sensor_gps_sR16failsafe_flags_sR6Report) +*(.text._ZN11ControlMath11addIfNotNanERff) +*(.text._ZN9Commander21checkForMissionUpdateEv) +*(.text._Z8set_tunei) +*(.text._ZNK6matrix7Vector3IfE5crossERKNS_6MatrixIfLj3ELj1EEE) +*(.text._ZN10FlightTask22_checkEkfResetCountersEv) +*(.text._ZNK6matrix6MatrixIfLj3ELj1EE11isAllFiniteEv) +*(.text._ZN14FlightTaskAuto24_evaluateGlobalReferenceEv) +*(.text._ZN6matrix9constrainIfLj2ELj1EEENS_6MatrixIT_XT0_EXT1_EEERKS3_S2_S2_) +*(.text._ZN3px46logger6Logger23handle_file_write_errorEv) +*(.text._ZN10FlightTask16updateInitializeEv) +*(.text._ZN11calibration9Gyroscope10set_offsetERKN6matrix7Vector3IfEE) +*(.text._ZNK6matrix6VectorIfLj3EE4normEv) +*(.text._ZN14FlightTaskAuto16updateInitializeEv) +*(.text.fabsf) +*(.text._ZN27MavlinkStreamAttitudeTarget8get_sizeEv) +*(.text.nxsem_get_value) +*(.text._ZN13AnalogBattery8is_validEv) +*(.text._ZN4uORB16SubscriptionDataI15home_position_sEC1EPK12orb_metadatah) +*(.text._ZN22MavlinkStreamGPSStatus8get_sizeEv) +*(.text.nxsem_destroyholder) +*(.text.psock_udp_cansend) +*(.text.MEM_DataCopy2_2) +*(.text._ZN10FlightTask8activateERK21trajectory_setpoint_s) +*(.text.sock_file_poll) +*(.text._ZN10Ringbuffer9pop_frontEPhj) +*(.text.nx_write) +*(.text._ZN9Commander18manualControlCheckEv) +*(.text._ZN31MavlinkStreamAttitudeQuaternion4sendEv) +*(.text.nxsem_canceled) +*(.text._ZN10FlightTask21getTrajectorySetpointEv) +*(.text.imxrt_dmach_getcount) +*(.text.sem_clockwait) +*(.text.inet_poll) +*(.text._ZN6BMP3887collectEv) +*(.text._ZNK15PositionControl24getLocalPositionSetpointER33vehicle_local_position_setpoint_s) +*(.text._ZN3Ekf16controlGpsFusionERKN9estimator9imuSampleE) +*(.text._ZN23MavlinkStreamRCChannels8get_sizeEv) +*(.text._ZN20MavlinkStreamESCInfo8get_sizeEv) +*(.text._ZNK6matrix6VectorIfLj2EE4normEv) +*(.text._Z15arm_auth_updateyb) +*(.text._ZN3LED5ioctlEP4fileim) /* itcm-check-ignore */ +*(.text._ZNK3px46logger9LogWriter20had_file_write_errorEv) +*(.text._ZN29MavlinkStreamLocalPositionNED4sendEv) +*(.text._ZNK6matrix6VectorIfLj3EE3dotERKNS_6MatrixIfLj3ELj1EEE) +*(.text.imxrt_lpi2c_setclock) +*(.text._ZN6matrix12typeFunction9constrainIfEET_S2_S2_S2_.part.0) +*(.text._ZN13MapProjection13initReferenceEddy) +*(.text._ZN11calibration13Accelerometer23SensorCorrectionsUpdateEb) +*(.text._ZN31MavlinkStreamAttitudeQuaternion8get_sizeEv) +*(.text._ZN30MavlinkStreamGlobalPositionInt4sendEv) +*(.text._ZN6SticksD1Ev) +*(.text._ZN13NavigatorMode3runEb) +*(.text._ZL19param_find_internalPKcb) +*(.text.uart_datasent) +*(.text._ZN4EKF221PublishOpticalFlowVelERKy) +*(.text.nxsem_destroy) +*(.text.file_write) +*(.text._ZN21MavlinkStreamAltitude4sendEv) +*(.text._ZN7sensors14VehicleAirData12UpdateStatusEv) +*(.text.imxrt_padmux_map) +*(.text._ZN6BMP38815get_sensor_dataEhP9bmp3_data) +*(.text._ZN18MavlinkRateLimiter5checkERKy) +*(.text._ZThn24_N26MulticopterAttitudeControl3RunEv) +*(.text.imxrt_periphclk_configure) +*(.text._ZN4EKF218UpdateAuxVelSampleER17ekf2_timestamps_s) +*(.text._ZN3RTL11on_inactiveEv) +*(.text._ZN12FailsafeBase10modeCanRunERK16failsafe_flags_sh) +*(.text._ZN4EKF216PublishEvPosBiasERKy) +*(.text._ZN21MavlinkStreamAttitude8get_sizeEv) +*(.text._ZThn16_N7sensors19VehicleAcceleration3RunEv) +*(.text._ZN33MavlinkStreamTimeEstimateToTarget4sendEv) +*(.text._ZN6matrix6MatrixIfLj3ELj1EE6setAllEf) +*(.text._ZN12ModuleParamsD1Ev) +*(.text._ZN3Ekf20controlFakeHgtFusionEv) +*(.text.imxrt_reqcomplete) +*(.text._ZNK6matrix7Vector3IfEmlEf) +*(.text._ZN18ZeroVelocityUpdate6updateER3EkfRKN9estimator9imuSampleE) +*(.text._ZN11ControlMath19addIfNotNanVector3fERN6matrix7Vector3IfEERKS2_) +*(.text._ZN11ControlMath16thrustToAttitudeERKN6matrix7Vector3IfEEfR27vehicle_attitude_setpoint_s) +*(.text.cos) +*(.text.net_unlock) +*(.text._ZN7sensors18VotedSensorsUpdate21setRelativeTimestampsER17sensor_combined_s) +*(.text._ZN12FailsafeBase13ActionOptionsC1ENS_6ActionE) +*(.text._ZN24FlightTaskManualAltitude16updateInitializeEv) +*(.text._ZN26MulticopterPositionControl3RunEv) +*(.text._ZN8Failsafe21fromQuadchuteActParamEi) +*(.text._ZN24VariableLengthRingbuffer9pop_frontEPhj) +*(.text._ZN7control15BlockDerivative6updateEf) /* itcm-check-ignore */ +*(.text._ZN9Commander18safetyButtonUpdateEv) +*(.text._ZN13BatteryChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN18DataValidatorGroup16get_sensor_stateEj) +*(.text.uart_xmitchars_done) +*(.text._ZN4EKF225PublishYawEstimatorStatusERKy) +*(.text.sin) +*(.text._ZN6Safety19safetyButtonHandlerEv) +*(.text._ZN3Ekf19controlAuxVelFusionERKN9estimator9imuSampleE) +*(.text._ZNK6matrix6MatrixIfLj2ELj1EEplERKS1_) +*(.text._ZThn24_N7Sensors3RunEv) +*(.text._ZN6matrix6MatrixIfLj2ELj1EEC1ERKS1_) +*(.text._ZN10FlightTask10reActivateEv) +*(.text._ZNK15PositionControl19getAttitudeSetpointER27vehicle_attitude_setpoint_s) +*(.text._ZN4cdev4CDev4pollEP4fileP6pollfdb) +*(.text._ZN9Commander20offboardControlCheckEv) +*(.text._ZN4EKF216PublishGpsStatusERKy) +*(.text._ZN4uORB12SubscriptionaSEOS0_) +*(.text._ZN15TakeoffHandling18updateTakeoffStateEbbbfbRKy) +*(.text._ZN10ModeChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN14FlightTaskAuto24_updateInternalWaypointsEv) +*(.text._ZN8Failsafe17updateArmingStateERKybRK16failsafe_flags_s) +*(.text.imxrt_lpi2c_modifyreg) +*(.text.up_flush_dcache) +*(.text._ZN15GyroCalibration3RunEv) +*(.text.mavlink_start_uart_send) +*(.text.MEM_DataCopy2) +*(.text._ZNK9Commander14getPrearmStateEv) +*(.text._ZN15EstimatorChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN28FlightTaskManualAccelerationD1Ev) +*(.text._ZN11RateControl20getRateControlStatusER18rate_ctrl_status_s) +*(.text._ZN4uORB10DeviceNode15poll_notify_oneEP6pollfdm) +*(.text._ZN3GPS21handleInjectDataTopicEv.part.0) +*(.text._ZN9Commander17systemPowerUpdateEv) +*(.text._ZN4EKF221PublishGlobalPositionERKy) +*(.text._ZNK12FailsafeBase17getSelectedActionERKNS_5StateERK16failsafe_flags_sbbRNS_19SelectedActionStateE) +*(.text.imxrt_padctl_address) +*(.text._ZNK6matrix6VectorIfLj2EE4unitEv) +*(.text._ZN19RcCalibrationChecks14checkAndReportERK7ContextR6Report) +*(.text.devif_conn_callback_free) +*(.text._ZN13InnovationLpf6updateEfff.isra.0) +*(.text._ZN9Commander18landDetectorUpdateEv) +*(.text._ZN3Ekf18updateGroundEffectEv) +*(.text.nxsem_init) +*(.text._ZN9Commander16vtolStatusUpdateEv) +*(.text._ZN6matrix6MatrixIfLj4ELj1EEC1EPKf) +*(.text._ZN11ControlMath20setZeroIfNanVector3fERN6matrix7Vector3IfEE) +*(.text._ZThn8_N3ADC3RunEv) +*(.text._ZN11StickTiltXYC1EP12ModuleParams) +*(.text._ZN12SafetyButton3RunEv) +*(.text._ZN6BMP38811set_op_modeEh) +*(.text._ZN3GPS8callbackE15GPSCallbackTypePviS1_) +*(.text._ZN13AnalogBattery19get_current_channelEv) +*(.text._ZN15EstimatorChecks20checkEstimatorStatusERK7ContextR6ReportRK18estimator_status_s8NavModes) +*(.text._ZN12FailsafeBase11updateDelayERKy) +*(.text._ZN10FlightTask25_evaluateDistanceToGroundEv) +*(.text._ZN4EKF218PublishGnssHgtBiasERKy) +*(.text._ZN6matrix6VectorIfLj3EE9normalizeEv) +*(.text._ZThn16_N7sensors10VehicleIMU3RunEv) +*(.text.__kernel_cos) +*(.text._ZN12SafetyButton19CheckPairingRequestEb) +*(.text.imxrt_dma_txavailable) +*(.text.perf_set_elapsed) +*(.text.pthread_sem_take) +*(.text._ZN8StickYawD1Ev) +*(.text._Z15blink_msg_statev) +*(.text._ZN19AccelerometerChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN8Failsafe14fromGfActParamEi) +*(.text._ZN3Ekf17controlBetaFusionERKN9estimator9imuSampleE) +*(.text._ZN36do_not_explicitly_use_this_namespace5ParamIfLN3px46paramsE919EEC1Ev) /* itcm-check-ignore */ +*(.text._ZN22MavlinkStreamHeartbeat8get_sizeEv) +*(.text._ZN6matrix6MatrixIfLj3ELj1EEdVEf) +*(.text._ZN17FlightTaskDescendC1Ev) +*(.text._ZN26MavlinkStreamCameraTrigger8get_sizeEv) +*(.text.iob_navail) +*(.text._ZN12FailsafeBase25removeNonActivatedActionsEv) +*(.text._ZN15TakeoffHandling10updateRampEff) +*(.text._Z7led_offi) +*(.text.led_off) +*(.text.udp_wrbuffer_test) +*(.text._ZNK4math17WelfordMeanVectorIfLj3EE8varianceEv) +*(.text._ZN27MavlinkStreamAttitudeTarget4sendEv) +*(.text._ZN12MixingOutput19updateSubscriptionsEb) +*(.text._ZN10FlightTaskD1Ev) +*(.text._ZThn24_N13land_detector12LandDetector3RunEv) +*(.text._ZN18MavlinkStreamDebug8get_sizeEv) +*(.text._ZN12GPSDriverUBX7receiveEj) +*(.text._ZN13BatteryStatus21parameter_update_pollEb) +*(.text._ZN3RTL18updateDatamanCacheEv) +*(.text.__ieee754_sqrtf) +*(.text._ZThn24_N18mag_bias_estimator16MagBiasEstimator3RunEv) +*(.text.__kernel_sin) +*(.text._ZN11MissionBase17parameters_updateEv) +*(.text.nx_start) +*(.text._ZN3Ekf17controlDragFusionERKN9estimator9imuSampleE) +*(.text._ZNK8Failsafe22modifyUserIntendedModeEN12FailsafeBase6ActionES1_h) +*(.text._ZN3px417ScheduledWorkItem19schedule_trampolineEPv) +*(.text.uart_xmitchars_dma) +*(.text._ZN13land_detector23MulticopterLandDetector19_get_freefall_stateEv) +*(.text._ZThn24_N31MulticopterHoverThrustEstimator3RunEv) +*(.text._ZN11MissionBase11on_inactiveEv) +*(.text._ZN21FailureDetectorChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN12SystemChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN6matrix6MatrixIfLj3ELj1EEC1EPKf) +*(.text.imxrt_padmux_address) +*(.text._ZN19MavlinkStreamVFRHUD8get_sizeEv) +*(.text._ZN15EstimatorChecks15checkSensorBiasERK7ContextR6Report8NavModes) +*(.text._ZN20ImuConsistencyChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN28MavlinkStreamGpsGlobalOrigin8get_sizeEv) +*(.text.MEM_DataCopy2_1) +*(.text._ZN6BMP3887measureEv) +*(.text._ZN4EKF217PublishRngHgtBiasERKy) +*(.text._ZN36MavlinkStreamPositionTargetGlobalInt8get_sizeEv) +*(.text._ZN28MavlinkStreamEstimatorStatus8get_sizeEv) +*(.text.up_clean_dcache) +*(.text._ZThn24_N26MulticopterPositionControl3RunEv) +*(.text._ZN16FlightTimeChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN13ManualControl12processInputEy) +*(.text._ZN17CpuResourceChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN10GyroChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN8Failsafe26fromImbalancedPropActParamEi) +*(.text._ZThn24_N13BatteryStatus3RunEv) +*(.text.mm_foreach) +*(.text._ZN35MavlinkStreamPositionTargetLocalNed8get_sizeEv) +*(.text._ZN32MavlinkStreamNavControllerOutput8get_sizeEv) +*(.text._ZN6matrix8wrap_2piIfEET_S1_) +*(.text._ZN4uORB7Manager30orb_remove_internal_subscriberEPv) +*(.text._ZN10BMP388_I2C7get_regEhPh) +*(.text._ZN4math17WelfordMeanVectorIfLj3EE5resetEv) +*(.text._ZN27MavlinkStreamScaledPressure8get_sizeEv) +*(.text._ZN3RTL17parameters_updateEv) +*(.text._ZN18EstimatorInterface11setBaroDataERKN9estimator10baroSampleE.part.0) +*(.text._ZN32MavlinkStreamOpenDroneIdLocation8get_sizeEv) +*(.text._ZN21MavlinkStreamTimesync4sendEv) +*(.text._ZN9Navigator23reset_position_setpointER19position_setpoint_s) +*(.text._ZN19RcAndDataLinkChecks14checkAndReportERK7ContextR6Report) +*(.text.imxrt_dma_txcallback) +*(.text._ZN24MavlinkParametersManager11send_uavcanEv) +*(.text._ZN4uORB10DeviceNode4readEP4filePcj) +*(.text._ZN4uORB10DeviceNode10poll_stateEP4file) +*(.text._ZN4uORB7Manager8orb_copyEPK12orb_metadataiPv) +*(.text._ZN27MavlinkStreamServoOutputRawILi0EE8get_sizeEv) +*(.text._ZN8Geofence3runEv) +*(.text._ZN15EstimatorChecks25checkEstimatorStatusFlagsERK7ContextR6ReportRK18estimator_status_sRK24vehicle_local_position_s) +*(.text._ZN18MagnetometerChecks14checkAndReportERK7ContextR6Report) +*(.text._ZN6events9SendEvent3RunEv) +*(.text._ZN30MavlinkStreamGlobalPositionInt8get_sizeEv) +*(.text._ZN22MavlinkStreamESCStatus8get_sizeEv) +*(.text._Z20px4_spi_bus_externalRK13px4_spi_bus_t) +*(.text.read) +*(.text._ZN4uORB15PublicationBaseD1Ev) +*(.text._ZN22MavlinkStreamDebugVect8get_sizeEv) +*(.text._ZN7Mission11on_inactiveEv) +*(.text._ZN7sensors19VehicleMagnetometer20UpdateMagCalibrationEv) +*(.text._ZN11calibration27FindCurrentCalibrationIndexEPKcm) +*(.text._ZN4cdevL9cdev_readEP4filePcj) +*(.text.sem_timedwait) +*(.text.snprintf) +*(.text._ZN27MavlinkStreamOpticalFlowRad8get_sizeEv) +*(.text._ZNK6matrix6MatrixIfLj3ELj1EE6copyToEPf) +*(.text._ZN6Report13healthFailureIJhEEEv8NavModes20HealthComponentIndexmRKN6events9LogLevelsEPKcDpT_.isra.0.constprop.0) +*(.text._ZN13BatteryChecks16rtlEstimateCheckERK7ContextR6Reportf) +*(.text.sigemptyset) +*(.text.nx_read) diff --git a/boards/nxp/mr-tropic/nuttx-config/scripts/itcm_static_functions.ld b/boards/nxp/mr-tropic/nuttx-config/scripts/itcm_static_functions.ld new file mode 100644 index 0000000000..bc0b57099c --- /dev/null +++ b/boards/nxp/mr-tropic/nuttx-config/scripts/itcm_static_functions.ld @@ -0,0 +1,163 @@ +/* Static */ +*(.text.arm_ack_irq) +*(.text.arm_doirq) +*(.text.arm_svcall) +*(.text.arm_switchcontext) +*(.text.clock_timer) +*(.text.exception_common) +*(.text.flexio_irq_handler) +*(.text.hrt_absolute_time) +*(.text.hrt_call_enter) +*(.text.hrt_tim_isr) +*(.text.imxrt_configwaitints) +*(.text.imxrt_dma_callback) +*(.text.imxrt_dmach_interrupt) +*(.text.imxrt_dmach_xfrsetup) +*(.text.imxrt_dmaterminate) +*(.text.imxrt_dispatch) +*(.text.imxrt_edma_interrupt) +*(.text.imxrt_endwait) +*(.text.imxrt_enet_interrupt) +*(.text.imxrt_enet_interrupt_work) +*(.text.imxrt_interrupt) +*(.text.imxrt_gpio1_16_31_interrupt) +*(.text.imxrt_gpio2_0_15_interrupt) +*(.text.imxrt_lpi2c_isr) +*(.text.imxrt_lpspi3select) +*(.text.imxrt_lpspi4select) +*(.text.imxrt_lpspi_exchange) +*(.text.imxrt_recvdma) +*(.text.imxrt_tcd_free) +*(.text.imxrt_timerisr) +*(.text.imxrt_transmit) +*(.text.imxrt_txdone) +*(.text.imxrt_txtimeout_work) +*(.text.imxrt_txtimeout_expiry) +*(.text.imxrt_txpoll) +*(.text.imxrt_txringfull) +*(.text.imxrt_txavail_work) +*(.text.imxrt_txavail) +*(.text.imxrt_usbinterrupt) +*(.text.irq_dispatch) +*(.text.ioctl) +*(.text.memcpy) +*(.text.memset) +*(.text.nxsched_add_blocked) +*(.text.nxsched_add_prioritized) +*(.text.nxsched_add_readytorun) +*(.text.nxsched_get_files) +*(.text.nxsched_get_tcb) +*(.text.nxsched_merge_pending) +*(.text.nxsched_process_timer) +*(.text.nxsched_remove_blocked) +*(.text.nxsched_remove_readytorun) +*(.text.nxsched_resume_scheduler) +*(.text.nxsched_suspend_scheduler) +*(.text.nxsem_add_holder) +*(.text.nxsem_add_holder_tcb) +*(.text.nxsem_clockwait) +*(.text.nxsem_foreachholder) +*(.text.nxsem_freecount0holder) +*(.text.nxsem_freeholder) +*(.text.nxsem_post) +*(.text.nxsem_release_holder) +*(.text.nxsem_restore_baseprio) +*(.text.nxsem_tickwait) +*(.text.nxsem_timeout) +*(.text.nxsem_trywait) +*(.text.nxsem_wait) +*(.text.nxsem_wait_uninterruptible) +*(.text.nxsig_timedwait) +*(.text.sched_lock) +*(.text.sched_note_resume) +*(.text.sched_note_suspend) +*(.text.sched_unlock) +*(.text.strcmp) +*(.text.sq_addafter) +*(.text.sq_addlast) +*(.text.sq_rem) +*(.text.sq_remafter) +*(.text.sq_remfirst) +*(.text.uart_connected) +*(.text.up_block_task) +*(.text.up_unblock_task) +*(.text.wd_timer) +*(.text.wd_start) +*(.text.work_thread) +*(.text.work_queue) +*(.text._do_memcpy) + +/* Tropic Eth tune */ +*(.text.devif_poll) +*(.text.devif_poll_tcp_connections) +*(.text.tcp_poll) +*(.text.devif_poll_udp_connections) +*(.text.udp_nextconn) +*(.text.udp_poll) +*(.text.udp_ipv4_select) +*(.text.udp_callback) +*(.text.udp_datahandler) +*(.text.udp_send) +*(.text.udp_active) +*(.text.udp_ipv4_active) +*(.text.psock_udp_sendto) +*(.text.sendto_eventhandler) +*(.text.net_dataevent) +*(.text.devif_conn_event) +*(.text.devif_event_trigger) +*(.text.devif_poll_icmp) +*(.text.icmp_poll) +*(.text.arp_out) +*(.text.arp_find) +*(.text.arp_format) +*(.text.net_ipv4addr_hdrcmp) /* itcm-check-ignore */ +*(.text.net_ipv4addr_copy) /* itcm-check-ignore */ +*(.text.net_ipv4addr_broadcast) /* itcm-check-ignore */ +*(.text.wd_start) +*(.text.arp_arpin) +*(.text.ipv4_input) +*(.text.work_thread) +*(.text.work_queue) + +/* ICM45686 */ +*(.text._ZN8ICM4568612ProcessAccelERKyPKN19InvenSense_ICM456864FIFO4DATAEh) +*(.text._ZN8ICM4568611ProcessGyroERKyPKN19InvenSense_ICM456864FIFO4DATAEh) +*(.text._ZN8ICM456868FIFOReadERKy) +*(.text._ZN8ICM456867RunImplEv) +*(.text._ZN8ICM4568618ProcessTemperatureEPKN19InvenSense_ICM456864FIFO4DATAEh) +*(.text._ZN12I2CSPIDriverI8ICM45686E3RunEv) +*(.text._ZN8ICM4568613FIFOReadCountEv) + +/* BMI088 */ +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer12RegisterReadENS1_8RegisterE) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer13FIFOReadCountEv) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer8FIFOReadERKyh) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer13RegisterCheckERKNS2_17register_config_tE) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer13RegisterWriteENS1_8RegisterEh) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer17UpdateTemperatureEv) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer23RegisterSetAndClearBitsENS1_8RegisterEhh) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer26DataReadyInterruptCallbackEiPvS3_) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer7RunImplEv) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer9DataReadyEv) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_AccelerometerD0Ev) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_AccelerometerD1Ev) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_AccelerometerD2Ev) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope12RegisterReadENS1_8RegisterE) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope13RegisterCheckERKNS2_17register_config_tE) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope13RegisterWriteENS1_8RegisterEh) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope23RegisterSetAndClearBitsENS1_8RegisterEhh) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope26DataReadyInterruptCallbackEiPvS3_) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope7RunImplEv) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope8FIFOReadERKyh) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope9DataReadyEv) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_GyroscopeD0Ev) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_GyroscopeD1Ev) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_GyroscopeD2Ev) +*(.text._ZN12I2CSPIDriverI6BMI088E3RunEv) + +/* BMM350 */ +*(.text._ZN12I2CSPIDriverI6BMM350E3RunEv) +*(.text._ZN6BMM3507RunImplEv) +*(.text._ZN6BMM35013RegisterWriteEN12Bosch_BMM3508RegisterEh) +*(.text._ZN6BMM35012RegisterReadEN12Bosch_BMM3508RegisterEPh) +*(.text._ZN6BMM35014ReadOutRawDataEPf) diff --git a/boards/nxp/mr-tropic/nuttx-config/scripts/script.ld b/boards/nxp/mr-tropic/nuttx-config/scripts/script.ld new file mode 100644 index 0000000000..8e5f852a82 --- /dev/null +++ b/boards/nxp/mr-tropic/nuttx-config/scripts/script.ld @@ -0,0 +1,187 @@ +/**************************************************************************** + * boards/nxp/mr-tropic/nuttx-config/scripts/script.ld + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* Specify the memory areas */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x70020000, LENGTH = 4194304 - 256K + sram (rwx) : ORIGIN = 0x20200000, LENGTH = 512K + itcm (rwx) : ORIGIN = 0x00000000, LENGTH = 384K + dtcm (rwx) : ORIGIN = 0x20000000, LENGTH = 127K + dtcm_nocache (rwx) : ORIGIN = 0x2001FC00, LENGTH = 1K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +EXTERN(g_flash_config) +EXTERN(g_image_vector_table) +EXTERN(g_boot_data) +EXTERN(board_get_manifest) +EXTERN(_bootdelay_signature) + +ENTRY(_stext) + +SECTIONS +{ + /* Image Vector Table and Boot Data for booting from external flash */ + + .boot_hdr : ALIGN(4) + { + FILL(0xff) + __boot_hdr_start__ = ABSOLUTE(.) ; + KEEP(*(.boot_hdr.conf)) + . = 0x1000 ; + KEEP(*(.boot_hdr.ivt)) + . = 0x1020 ; + KEEP(*(.boot_hdr.boot_data)) + . = 0x1030 ; + KEEP(*(.boot_hdr.dcd_data)) + __boot_hdr_end__ = ABSOLUTE(.) ; + . = 0x2000 ; + } >flash + + /* Workaround for ethernet issue, by placing g_desc_pool into DTCM, + which effectively puts it into a no-cache region */ + .dtcm_nocache : { + *(.bss.g_desc_pool) + } > dtcm_nocache + + .vectors : + { + KEEP(*(.vectors)) + *(.text .text.__start) + } >flash + + .itcmfunc : + { + . = ALIGN(8); + _sitcmfuncs = ABSOLUTE(.); + FILL(0xFF) + . = 0x40 ; + *(.ram_vectors) + INCLUDE "itcm_static_functions.ld" + INCLUDE "itcm_functions_includes.ld" + . = ALIGN(8); + _eitcmfuncs = ABSOLUTE(.); + } > itcm AT > flash + + _fitcmfuncs = LOADADDR(.itcmfunc); + + .text : + { + _stext = ABSOLUTE(.); + *(.vectors) + . = ALIGN(32); + /* + This signature provides the bootloader with a way to delay booting + */ + _bootdelay_signature = ABSOLUTE(.); + FILL(0xffecc2925d7d05c5) + . += 8; + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + . = ALIGN(4096); + _etext = ABSOLUTE(.); + _srodata = ABSOLUTE(.); + *(.rodata .rodata.*) + . = ALIGN(4096); + _erodata = ABSOLUTE(.); + } > flash + + .init_section : + { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : + { + *(.ARM.extab*) + } > flash + + .ARM.exidx : + { + __exidx_start = ABSOLUTE(.); + *(.ARM.exidx*) + __exidx_end = ABSOLUTE(.); + } > flash + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + .ramfunc ALIGN(4): + { + _sramfuncs = ABSOLUTE(.); + *(.ramfunc .ramfunc.*) + _eramfuncs = ABSOLUTE(.); + } > sram AT > flash + + _framfuncs = LOADADDR(.ramfunc); + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } + + _boot_loadaddr = ORIGIN(flash); + _boot_size = LENGTH(flash); + _ram_size = LENGTH(sram); + _sdtcm = ORIGIN(dtcm); + _edtcm = ORIGIN(dtcm) + LENGTH(dtcm); +} diff --git a/boards/nxp/mr-tropic/src/CMakeLists.txt b/boards/nxp/mr-tropic/src/CMakeLists.txt new file mode 100644 index 0000000000..4f0710f546 --- /dev/null +++ b/boards/nxp/mr-tropic/src/CMakeLists.txt @@ -0,0 +1,86 @@ +############################################################################ +# +# Copyright (c) 2024 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. +# +############################################################################ +if("${PX4_BOARD_LABEL}" STREQUAL "bootloader") + add_compile_definitions(BOOTLOADER) + add_library(drivers_board + bootloader_main.c + init.c + usb.c + imxrt_flexspi_nor_boot.c + imxrt_flexspi_nor_flash.c + timer_config.cpp + ) + target_link_libraries(drivers_board + PRIVATE + nuttx_arch # sdio + nuttx_drivers # sdio + px4_layer #gpio + arch_io_pins # iotimer + arch_board_romapi + bootloader + ) + target_include_directories(drivers_board PRIVATE ${PX4_SOURCE_DIR}/platforms/nuttx/src/bootloader/common) + +else() + + px4_add_library(drivers_board + i2c.cpp + init.c + sdhc.c + spi.cpp + timer_config.cpp + tropic_led_pwm.cpp + usb.c + imxrt_flexspi_nor_boot.c + imxrt_flexspi_nor_flash.c + imxrt_flexspi_storage.c + imxrt_ocram_initialize.c + hw_rev_ver_tropic.c + manifest.c + ) + + + # Force compiler not to use builtin functions (like memcpy) + # to optimize for loops in init.c (imxrt_ocram_initialize) + set_source_files_properties(imxrt_ocram_initialize.c PROPERTIES COMPILE_FLAGS -fno-builtin) + + target_link_libraries(drivers_board + PRIVATE + arch_board_romapi + arch_spi + nuttx_arch # sdio + nuttx_drivers # sdio + px4_layer + ) + +endif() diff --git a/boards/nxp/mr-tropic/src/board_config.h b/boards/nxp/mr-tropic/src/board_config.h new file mode 100644 index 0000000000..45e6eecd54 --- /dev/null +++ b/boards/nxp/mr-tropic/src/board_config.h @@ -0,0 +1,355 @@ +/**************************************************************************** + * + * Copyright (c) 2024 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 board_config.h + * + * Tropic Community internal definitions + */ + +#pragma once + +/**************************************************************************************************** + * Included Files + ****************************************************************************************************/ + +#include +#include +#include +#include + +#include "imxrt_gpio.h" +#include "imxrt_iomuxc.h" +#include "hardware/imxrt_pinmux.h" +#include "hardware/imxrt_usb_analog.h" + +#include +#include + +/**************************************************************************************************** + * Definitions + ****************************************************************************************************/ + +/* Configuration ************************************************************************************/ + +/* FMURT1062 GPIOs ***********************************************************************************/ +/* LEDs */ +/* An RGB LED is connected through GPIO as shown below: + */ +#define LED_IOMUX (IOMUX_OPENDRAIN | IOMUX_PULL_NONE | IOMUX_DRIVE_33OHM | IOMUX_SPEED_MEDIUM | IOMUX_SLEW_SLOW) +#define GPIO_nLED_RED /* GPIO_EMC_33 GPIO3_IO19 */ (GPIO_PORT3 | GPIO_PIN19 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | LED_IOMUX) +#define GPIO_nLED_BLUE /* GPIO_EMC_34 GPIO3_IO20 */ (GPIO_PORT3 | GPIO_PIN20 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | LED_IOMUX) +#define GPIO_nLED_GREEN /* GPIO_EMC_38 GPIO3_IO24 */ (GPIO_PORT3 | GPIO_PIN24 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | LED_IOMUX) + +#define BOARD_HAS_CONTROL_STATUS_LEDS 1 +#define BOARD_OVERLOAD_LED LED_RED +#define BOARD_ARMED_STATE_LED LED_BLUE + +/* + * Define the ability to shut off off the sensor signals + * by changing the signals to inputs + */ + +#define _PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT | IOMUX_PULL_DOWN_100K | IOMUX_CMOS_INPUT)) + +/* Define the Chip Selects, Data Ready and Control signals per SPI bus */ + +#define CS_IOMUX (IOMUX_CMOS_OUTPUT | IOMUX_PULL_UP_100K | IOMUX_DRIVE_33OHM | IOMUX_SPEED_LOW | IOMUX_SLEW_FAST) +#define OUT_IOMUX (IOMUX_CMOS_OUTPUT | IOMUX_PULL_UP_100K | IOMUX_DRIVE_50OHM | IOMUX_SPEED_MEDIUM | IOMUX_SLEW_FAST) + + +/* SPI1 off */ + +#define _GPIO_LPSPI1_SCK /* GPIO_EMC_27 GPIO4_IO27 */ (GPIO_PORT4 | GPIO_PIN27 | CS_IOMUX) +#define _GPIO_LPSPI1_MISO /* GPIO_EMC_29 GPIO4_IO29 */ (GPIO_PORT4 | GPIO_PIN29 | CS_IOMUX) +#define _GPIO_LPSPI1_MOSI /* GPIO_EMC_28 GPIO4_IO28 */ (GPIO_PORT4 | GPIO_PIN28 | CS_IOMUX) + +#define GPIO_SPI1_SCK_OFF _PIN_OFF(_GPIO_LPSPI1_SCK) +#define GPIO_SPI1_MISO_OFF _PIN_OFF(_GPIO_LPSPI1_MISO) +#define GPIO_SPI1_MOSI_OFF _PIN_OFF(_GPIO_LPSPI1_MOSI) + +#define _GPIO_LPSPI3_SCK /* GPIO_AD_B1_15 GPIO1_IO27 */ (GPIO_PORT1 | GPIO_PIN31 | CS_IOMUX) +#define _GPIO_LPSPI3_MISO /* GPIO_AD_B1_13 GPIO1_IO27 */ (GPIO_PORT1 | GPIO_PIN29 | CS_IOMUX) +#define _GPIO_LPSPI3_MOSI /* GPIO_AD_B1_14 GPIO1_IO27 */ (GPIO_PORT1 | GPIO_PIN30 | CS_IOMUX) + +#define GPIO_SPI3_SCK_OFF _PIN_OFF(_GPIO_LPSPI3_SCK) +#define GPIO_SPI3_MISO_OFF _PIN_OFF(_GPIO_LPSPI3_MISO) +#define GPIO_SPI3_MOSI_OFF _PIN_OFF(_GPIO_LPSPI3_MOSI) + +/* Define the SPI4 Data Ready and Control signals */ + +#define GPIO_SPI4_DRDY7_EXTERNAL1 /* GPIO_EMC_35 GPIO3_IO21*/ (GPIO_PORT3 | GPIO_PIN21 | GPIO_INPUT | DRDY_IOMUX) + +#define GPIO_DRDY_OFF_SPI4_DRDY7_EXTERNAL1 _PIN_OFF(GPIO_SPI4_DRDY7_EXTERNAL1) + +#define ADC_IOMUX (IOMUX_CMOS_INPUT | IOMUX_PULL_NONE | IOMUX_DRIVE_HIZ) + +#define ADC1_CH(n) (n) +#define ADC1_GPIO(n, p) (GPIO_PORT1 | GPIO_PIN##p | ADC_IOMUX) // + +/* Define GPIO pins used as ADC N.B. Channel numbers are for reference, */ + +#define PX4_ADC_GPIO \ + /* ADC_5V_RAIL_SENSE GPIO_AD_B1_08 GPIO1 Pin 24 */ ADC1_GPIO(0, 24) + +/* Define Channel numbers must match above GPIO pin IN(n)*/ + +#define ADC_5V_RAIL_SENSE /* GPIO_AD_B1_08 GPIO1 Pin 24 */ ADC1_CH(13) + +#define ADC_CHANNELS (1 << ADC_5V_RAIL_SENSE) + +/* Power supply control and monitoring GPIOs */ + +#define GENERAL_INPUT_IOMUX (IOMUX_CMOS_INPUT | IOMUX_PULL_UP_47K | IOMUX_DRIVE_HIZ) +#define GENERAL_OUTPUT_IOMUX (IOMUX_CMOS_OUTPUT | IOMUX_PULL_KEEP | IOMUX_DRIVE_33OHM | IOMUX_SPEED_MEDIUM | IOMUX_SLEW_FAST) + + +/* PWM + */ + +#define DIRECT_PWM_OUTPUT_CHANNELS 8 +#define BOARD_NUM_IO_TIMERS 4 + +// Input Capture not supported on MVP + +#define BOARD_HAS_NO_CAPTURE + +//#define BOARD_HAS_UI_LED_PWM 1 Not ported yet (Still Kinetis driver) +#define BOARD_HAS_LED_PWM 1 +#define BOARD_LED_PWM_DRIVE_ACTIVE_LOW 1 +#define BOARD_HAS_CUSTOM_LED_PWM 1 + +#define PWM_LED_RED /* GPIO_EMC_33 */ (GPIO_FLEXPWM3_PWMA02_1 | GENERAL_OUTPUT_IOMUX) +#define PWM_LED_BLUE /* GPIO_EMC_34 */ (GPIO_FLEXPWM3_PWMB02_1 | GENERAL_OUTPUT_IOMUX) +#define PWM_LED_GREEN /* GPIO_EMC_38 */ (GPIO_FLEXPWM1_PWMA03_2 | GENERAL_OUTPUT_IOMUX) + + +/* ETHERNET GPIO */ + +#define GPIO_ENET_RX_ER_CONFIG1 /* GPIO_B1_11 GPIO2_IO27 PHYAD18 Open */ (GPIO_PORT2 | GPIO_PIN27 | GPIO_INPUT | IOMUX_PULL_NONE) +#define GPIO_ENET_RX_DATA01_CONFIG4 /* GPIO_B1_05 GPIO2_IO21 (RMII-clkmode) High */ (GPIO_PORT2 | GPIO_PIN21 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | GENERAL_OUTPUT_IOMUX) +#define GPIO_ENET_RX_DATA00_CONFIG5 /* GPIO_B1_04 GPIO2_IO20 SLAVE:Auto Open */ (GPIO_PORT2 | GPIO_PIN20 | GPIO_INPUT | IOMUX_PULL_NONE) +#define GPIO_ENET_CRS_DV_CONFIG6 /* GPIO_B1_06 GPIO4_IO22 SLAVE:POl Corr Low */ (GPIO_PORT2 | GPIO_PIN22 | GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GENERAL_OUTPUT_IOMUX) + +/* Tone alarm output */ + +//FIXME FlexPWM TONE DRIVER +#define TONE_ALARM_FLEXPWM PWMA_VAL +#define TONE_ALARM_TIMER 1 /* FlexPWM 3 */ +#define TONE_ALARM_CHANNEL 0 /* GPIO_EMC_23 PWM1_PWMA00 */ + +#define GPIO_BUZZER_1 /* GPIO_EMC_23 GPIO4_IO23 */ (GPIO_PORT4 | GPIO_PIN23 | GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GENERAL_OUTPUT_IOMUX) + +#define GPIO_TONE_ALARM_IDLE GPIO_BUZZER_1 +#define GPIO_TONE_ALARM (GPIO_FLEXPWM1_PWMA00_1 | GENERAL_OUTPUT_IOMUX) + +/* USB OTG FS + * + * VBUS_VALID is detected in USB_ANALOG_USB1_VBUS_DETECT_STAT + */ + +/* High-resolution timer */ +#define HRT_TIMER 1 /* use GPT1 for the HRT */ +#define HRT_TIMER_CHANNEL 1 /* use capture/compare channel 1 */ + +#define RC_SERIAL_PORT "/dev/ttyS6" +//#define RC_SERIAL_SINGLEWIRE 1 // Suport Single wire wiring +//#define RC_SERIAL_SWAP_RXTX 1 // Set Swap (but not supported in HW) to use Single wire +//#define RC_SERIAL_SWAP_USING_SINGLEWIRE 1 // Set to use Single wire swap as HW does not support swap +#define BOARD_SUPPORTS_RC_SERIAL_PORT_OUTPUT + +/* Safety Switch is HW version dependent on having an PX4IO + * So we init to a benign state with the _INIT definition + * and provide the the non _INIT one for the driver to make a run time + * decision to use it. + */ +#define SAFETY_INIT_IOMUX (IOMUX_CMOS_INPUT | IOMUX_PULL_NONE | IOMUX_DRIVE_HIZ) +#define SAFETY_IOMUX (IOMUX_CMOS_OUTPUT | IOMUX_PULL_NONE | IOMUX_DRIVE_33OHM | IOMUX_SPEED_MEDIUM | IOMUX_SLEW_SLOW) +#define SAFETY_SW_IOMUX (IOMUX_CMOS_INPUT | IOMUX_PULL_UP_22K | IOMUX_DRIVE_HIZ) + +/* Safety Switch is HW version dependent on having an PX4IO + * So we init to a benign state with the _INIT definition + * and provide the the non _INIT one for the driver to make a run time + * decision to use it. + */ +#define GPIO_nSAFETY_SWITCH_LED_OUT_INIT /* EMC_39 */ (GPIO_PORT3 | GPIO_PIN25 | GPIO_INPUT | SAFETY_INIT_IOMUX) +#define GPIO_nSAFETY_SWITCH_LED_OUT /* EMC_39 */ (GPIO_PORT3 | GPIO_PIN25 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | SAFETY_IOMUX) + +/* Enable the FMU to control it if there is no px4io fixme:This should be BOARD_SAFETY_LED(__ontrue) */ +#define GPIO_LED_SAFETY GPIO_nSAFETY_SWITCH_LED_OUT + +#define GPIO_SAFETY_SWITCH_IN /* GPIO_B0_12 GPIO2_IO12 */ (GPIO_PORT2 | GPIO_PIN12 | GPIO_INPUT | SAFETY_SW_IOMUX) +/* Enable the FMU to use the switch it if there is no px4io fixme:This should be BOARD_SAFTY_BUTTON() */ +#define GPIO_BTN_SAFETY GPIO_SAFETY_SWITCH_IN /* Enable the FMU to control it if there is no px4io */ + +#define SDIO_SLOTNO 0 /* Only one slot */ +#define SDIO_MINOR 0 + +/* SD card bringup does not work if performed on the IDLE thread because it + * will cause waiting. Use either: + * + * CONFIG_BOARDCTL=y, OR + * CONFIG_BOARD_INITIALIZE=y && CONFIG_BOARD_INITTHREAD=y + */ + +#if defined(CONFIG_BOARD_INITIALIZE) && !defined(CONFIG_BOARDCTL) && \ + !defined(CONFIG_BOARD_INITTHREAD) +# warning SDIO initialization cannot be perfomed on the IDLE thread +#endif + +/* By Providing BOARD_ADC_USB_CONNECTED (using the px4_arch abstraction) + * this board support the ADC system_power interface, and therefore + * provides the true logic GPIO BOARD_ADC_xxxx macros. + */ + +#define BOARD_NUMBER_BRICKS 1 +#define BOARD_NUMBER_DIGITAL_BRICKS 1 + +#define BOARD_ADC_BRICK_VALID 1 + +#define BOARD_ADC_USB_CONNECTED (board_read_VBUS_state() == 0) + +/* FMUv5 never powers odd the Servo rail */ + +#define BOARD_ADC_SERVO_VALID (1) + + +/* This board provides a DMA pool and APIs */ +#define BOARD_DMA_ALLOC_POOL_SIZE 5120 + +/* This board provides the board_on_reset interface */ + +#define BOARD_HAS_ON_RESET 1 +#define BOARD_HAS_ISP_BOOTLOADER 1 + +#define PX4_GPIO_INIT_LIST { \ + GPIO_FLEXCAN3_TX, \ + GPIO_FLEXCAN3_RX, \ + GPIO_TONE_ALARM_IDLE, \ + GPIO_SAFETY_SWITCH_IN, \ + GPIO_ENET_RX_ER_CONFIG1, \ + GPIO_ENET_RX_DATA01_CONFIG4, \ + GPIO_ENET_RX_DATA00_CONFIG5, \ + GPIO_ENET_CRS_DV_CONFIG6, \ + GPIO_ENET_RST \ + } + +#define BOARD_ENABLE_CONSOLE_BUFFER + +/* To detect IMU */ +#define BOARD_HAS_HW_VERSIONING 1 +#define BOARD_HAS_HW_SPLIT_VERSIONING 1 +#define HW_INFO_INIT_PREFIX "TROPIC" + +#define BOARD_NUM_SPI_CFG_HW_VERSIONS 3 +// Base/FMUM +#define TROPIC_0 HW_FMUM_ID(0x0) // ICM45686 +#define TROPIC_1 HW_FMUM_ID(0x1) // ICM42688 +#define TROPIC_2 HW_FMUM_ID(0x2) // ICM42686 + +/* Flash instance for storage */ +#define NOR_INSTANCE 1 + +__BEGIN_DECLS + +/**************************************************************************************************** + * Public Types + ****************************************************************************************************/ + +/**************************************************************************************************** + * Public data + ****************************************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************************************** + * Public Functions + ****************************************************************************************************/ + +/**************************************************************************** + * Name: fmurt1062_usdhc_initialize + * + * Description: + * Initialize SDIO-based MMC/SD card support + * + ****************************************************************************/ + +int fmurt1062_usdhc_initialize(void); + +/**************************************************************************************************** + * Name: imxrt_spidev_initialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the PX4FMU board. + * + ****************************************************************************************************/ + +extern void imxrt_spidev_initialize(void); + +/************************************************************************************ + * Name: imxrt_spi_bus_initialize + * + * Description: + * Called to configure SPI Buses. + * + ************************************************************************************/ + +extern int imxrt1062_spi_bus_initialize(void); + +/************************************************************************************ + * Name: imxrt_usb_initialize + * + * Description: + * Called to configure USB. + * + ************************************************************************************/ + +extern void imxrt_spiinitialize(void); + +extern int imxrt_usb_initialize(void); + +extern void imxrt_usbinitialize(void); + +extern void board_peripheral_reset(int ms); + +extern void fmurt1062_timer_initialize(void); + +#include + +void imxrt_flash_romapi_initialize(void); + +int imxrt_flexspi_storage_initialize(void); + +#endif /* __ASSEMBLY__ */ + +__END_DECLS diff --git a/boards/nxp/mr-tropic/src/bootloader_main.c b/boards/nxp/mr-tropic/src/bootloader_main.c new file mode 100644 index 0000000000..04008aa2ff --- /dev/null +++ b/boards/nxp/mr-tropic/src/bootloader_main.c @@ -0,0 +1,61 @@ +/**************************************************************************** + * + * Copyright (c) 2023 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 bootloader_main.c + * + * FMU-specific early startup code for bootloader +*/ + +#include "board_config.h" +#include "bl.h" + +#include +#include +#include +#include +#include "arm_internal.h" +#include + +extern int sercon_main(int c, char **argv); + +void board_late_initialize(void) +{ + sercon_main(0, NULL); +} + +extern void sys_tick_handler(void); +void board_timerhook(void) +{ + sys_tick_handler(); +} diff --git a/boards/nxp/mr-tropic/src/hw_config.h b/boards/nxp/mr-tropic/src/hw_config.h new file mode 100644 index 0000000000..22e0680203 --- /dev/null +++ b/boards/nxp/mr-tropic/src/hw_config.h @@ -0,0 +1,130 @@ +/* + * hw_config.h + * + * Created on: May 17, 2015 + * Author: david_s5 + */ + +#ifndef HW_CONFIG_H_ +#define HW_CONFIG_H_ + +/**************************************************************************** + * 10-8--2016: + * To simplify the ripple effect on the tools, we will be using + * /dev/serial/by-id/PX4 to locate PX4 devices. Therefore + * moving forward all Bootloaders must contain the prefix "PX4 BL " + * in the USBDEVICESTRING + * This Change will be made in an upcoming BL release + ****************************************************************************/ +/* + * Define usage to configure a bootloader + * + * + * Constant example Usage + * APP_LOAD_ADDRESS 0x08004000 - The address in Linker Script, where the app fw is org-ed + * BOOTLOADER_DELAY 5000 - Ms to wait while under USB pwr or bootloader request + * BOARD_FMUV2 + * INTERFACE_USB 1 - (Optional) Scan and use the USB interface for bootloading + * INTERFACE_USART 1 - (Optional) Scan and use the Serial interface for bootloading + * USBDEVICESTRING "PX4 BL FMU v2.x" - USB id string + * USBPRODUCTID 0x0011 - PID Should match defconfig + * BOOT_DELAY_ADDRESS 0x000001a0 - (Optional) From the linker script from Linker Script to get a custom + * delay provided by an APP FW + * BOARD_TYPE 9 - Must match .prototype boad_id + * _FLASH_KBYTES (*(uint16_t *)0x1fff7a22) - Run time flash size detection + * BOARD_FLASH_SECTORS ((_FLASH_KBYTES == 0x400) ? 11 : 23) - Run time determine the physical last sector + * BOARD_FLASH_SECTORS 11 - Hard coded zero based last sector + * BOARD_FLASH_SIZE (_FLASH_KBYTES*1024)- Total Flash size of device, determined at run time. + * (1024 * 1024) - Hard coded Total Flash of device - The bootloader and app reserved will be deducted + * programmatically + * + * BOARD_FIRST_FLASH_SECTOR_TO_ERASE 2 - Optional sectors index in the flash_sectors table (F4 only), to begin erasing. + * This is to allow sectors to be reserved for app fw usage. That will NOT be erased + * during a FW upgrade. + * The default is 0, and selects the first sector to be erased, as the 0th entry in the + * flash_sectors table. Which is the second physical sector of FLASH in the device. + * The first physical sector of FLASH is used by the bootloader, and is not defined + * in the table. + * + * APP_RESERVATION_SIZE (BOARD_FIRST_FLASH_SECTOR_TO_ERASE * 16 * 1024) - Number of bytes reserved by the APP FW. This number plus + * BOOTLOADER_RESERVATION_SIZE will be deducted from + * BOARD_FLASH_SIZE to determine the size of the App FW + * and hence the address space of FLASH to erase and program. + * USBMFGSTRING "PX4 AP" - Optional USB MFG string (default is '3D Robotics' if not defined.) + * SERIAL_BREAK_DETECT_DISABLED - Optional prevent break selection on Serial port from entering or staying in BL + * + * * Other defines are somewhat self explanatory. + */ + +/* Boot device selection list*/ +#define USB0_DEV 0x01 +#define SERIAL0_DEV 0x02 +#define SERIAL1_DEV 0x04 + +#define APP_LOAD_ADDRESS 0x70020000 +#define APP_VECTOR_OFFSET 0x2000 +#define BOOTLOADER_DELAY 5000 +#define INTERFACE_USB 1 +#define INTERFACE_USB_CONFIG "/dev/ttyACM0" + +//#define USE_VBUS_PULL_DOWN +#define INTERFACE_USART 1 +#define INTERFACE_USART_CONFIG "/dev/ttyS0,1500000" +#define BOOT_DELAY_ADDRESS 0x00039FA0 +#define BOARD_TYPE 37 +// The board has a 64 Mb part with 16384, 4K secors, but we artificialy limit it to 4 Mb +// as 1024, 4K sectors +#define BOARD_FLASH_SECTORS 960 // 1024 * 4k sectors, 128k for bootloader, 128k for storage +#define BOARD_FIRST_FLASH_SECTOR_TO_ERASE 32 // We resreve 128K for the bootloader +#define BOARD_FLASH_SIZE (BOARD_FLASH_SECTORS * 4096) + +#define OSC_FREQ 24 + +#define BOARD_PIN_LED_ACTIVITY GPIO_nLED_BLUE // BLUE +#define BOARD_PIN_LED_BOOTLOADER GPIO_nLED_GREEN // GREEN +#define BOARD_LED_ON 0 +#define BOARD_LED_OFF 1 + +#define SERIAL_BREAK_DETECT_DISABLED 1 + +/* + * Uncommenting this allows to force the bootloader through + * a PWM output pin. As this can accidentally initialize + * an ESC prematurely, it is not recommended. This feature + * has not been used and hence defaults now to off. + * + * # define BOARD_FORCE_BL_PIN_OUT (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN14) + * # define BOARD_FORCE_BL_PIN_IN (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN11) + * + * # define BOARD_POWER_PIN_OUT (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4) + * # define BOARD_POWER_ON 1 + * # define BOARD_POWER_OFF 0 + * # undef BOARD_POWER_PIN_RELEASE // Leave pin enabling Power - un comment to release (disable power) + * +*/ + +#if !defined(ARCH_SN_MAX_LENGTH) +# define ARCH_SN_MAX_LENGTH 12 +#endif + +#if !defined(APP_RESERVATION_SIZE) +# define APP_RESERVATION_SIZE 0 +#endif + +#if !defined(BOARD_FIRST_FLASH_SECTOR_TO_ERASE) +# define BOARD_FIRST_FLASH_SECTOR_TO_ERASE 1 +#endif + +#if !defined(USB_DATA_ALIGN) +# define USB_DATA_ALIGN +#endif + +#ifndef BOOT_DEVICES_SELECTION +# define BOOT_DEVICES_SELECTION USB0_DEV|SERIAL0_DEV|SERIAL1_DEV +#endif + +#ifndef BOOT_DEVICES_FILTER_ONUSB +# define BOOT_DEVICES_FILTER_ONUSB USB0_DEV|SERIAL0_DEV|SERIAL1_DEV +#endif + +#endif /* HW_CONFIG_H_ */ diff --git a/boards/nxp/mr-tropic/src/hw_rev_ver_tropic.c b/boards/nxp/mr-tropic/src/hw_rev_ver_tropic.c new file mode 100644 index 0000000000..7414c21a32 --- /dev/null +++ b/boards/nxp/mr-tropic/src/hw_rev_ver_tropic.c @@ -0,0 +1,165 @@ +/**************************************************************************** + * + * Copyright (C) 2023 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 hw_rev_ver_canhubk3.c + * CANHUBK3 Hardware Revision and Version ID API + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#if defined(BOARD_HAS_HW_VERSIONING) + +#define HW_INFO_SIZE HW_INFO_VER_DIGITS + HW_INFO_REV_DIGITS + +/**************************************************************************** + * Private Data + ****************************************************************************/ +static int hw_revision = 0; +static char hw_info[HW_INFO_SIZE] = {0}; +#if defined(BOARD_HAS_HW_SPLIT_VERSIONING) +static char hw_base_info[HW_INFO_SIZE] = {0}; +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ +/************************************************************************************ + * Name: board_get_hw_type + * + * Description: + * Optional returns a 0 terminated string defining the HW type. + * + * Input Parameters: + * None + * + * Returned Value: + * a 0 terminated string defining the HW type. This my be a 0 length string "" + * + ************************************************************************************/ + +__EXPORT const char *board_get_hw_type_name() +{ + return (const char *) hw_info; +} + +#if defined(BOARD_HAS_HW_SPLIT_VERSIONING) +/************************************************************************************ + * Name: board_get_hw_base_type_name + * + * Description: + * Optional returns a 0 terminated string defining the base type. + * + * Input Parameters: + * None + * + * Returned Value: + * a 0 terminated string defining the HW type. This my be a 0 length string "" + * + ************************************************************************************/ + +__EXPORT const char *board_get_hw_base_type_name() +{ + return (const char *) hw_base_info; +} +#endif + +/************************************************************************************ + * Name: board_get_hw_version + * + * Description: + * Optional returns a integer HW version + * + * Input Parameters: + * None + * + * Returned Value: + * An integer value of this boards hardware version. + * A value of -1 is the default for boards not supporting the BOARD_HAS_VERSIONING API. + * A value of 0 is the default for boards supporting the API but not having version. + * + ************************************************************************************/ + +__EXPORT int board_get_hw_version() +{ + return 0; +} + +/************************************************************************************ + * Name: board_get_hw_revision + * + * Description: + * Optional returns a integer HW revision + * + * Input Parameters: + * None + * + * Returned Value: + * An integer value of this boards hardware revision. + * A value of -1 is the default for boards not supporting the BOARD_HAS_VERSIONING API. + * A value of 0 is the default for boards supporting the API but not having revision. + * + ************************************************************************************/ + +__EXPORT int board_get_hw_revision() +{ + return hw_revision; +} + +/************************************************************************************ + * Name: board_determine_hw_info + * + * Description: + * Uses GPIO to detect MR-CANHUBK3-ADAP + * + ************************************************************************************/ + +int board_determine_hw_info() +{ + hw_revision = 0; //TODO Read fuses + + sprintf(hw_info, "%03d", hw_revision); + + return 0; +} +#endif diff --git a/boards/nxp/mr-tropic/src/i2c.cpp b/boards/nxp/mr-tropic/src/i2c.cpp new file mode 100644 index 0000000000..a118a69d0f --- /dev/null +++ b/boards/nxp/mr-tropic/src/i2c.cpp @@ -0,0 +1,40 @@ +/**************************************************************************** + * + * Copyright (C) 2024 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. + * + ****************************************************************************/ + +#include + +constexpr px4_i2c_bus_t px4_i2c_buses[I2C_BUS_MAX_BUS_ITEMS] = { + initI2CBusExternal(1), + initI2CBusExternal(3), + initI2CBusInternal(4), +}; diff --git a/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_boot.c b/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_boot.c new file mode 100644 index 0000000000..894c959d33 --- /dev/null +++ b/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_boot.c @@ -0,0 +1,55 @@ +/**************************************************************************** + * boards/arm/imxrt/imxrt1064-evk/src/imxrt_flexspi_nor_boot.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "imxrt_flexspi_nor_boot.h" + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +locate_data(".boot_hdr.ivt") +const struct ivt_s g_image_vector_table = { + IVT_HEADER, /* IVT Header */ + IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ + IVT_RSVD, /* Reserved = 0 */ + (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ + (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ + (uint32_t)IMAG_VECTOR_TABLE, /* Pointer to IVT Self (absolute address */ + (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ + IVT_RSVD /* Reserved = 0 */ +}; + +locate_data(".boot_hdr.boot_data") +const struct boot_data_s g_boot_data = { + IMAGE_DEST, /* boot start location */ + (IMAGE_DEST_END - IMAGE_DEST), /* size */ + PLUGIN_FLAG, /* Plugin flag */ + 0xffffffff /* empty - extra data word */ +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/* None */ diff --git a/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_boot.h b/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_boot.h new file mode 100644 index 0000000000..ca6b9cf8b3 --- /dev/null +++ b/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_boot.h @@ -0,0 +1,166 @@ +/**************************************************************************** + * boards/arm/imxrt/imxrt1064-evk/src/imxrt_flexspi_nor_boot.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_IMXRT_IMXRT1060_EVK_SRC_IMXRT_FLEXSPI_NOR_BOOT_H +#define __BOARDS_ARM_IMXRT_IMXRT1060_EVK_SRC_IMXRT_FLEXSPI_NOR_BOOT_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* IVT Data */ + +#define IVT_MAJOR_VERSION 0x4 +#define IVT_MAJOR_VERSION_SHIFT 0x4 +#define IVT_MAJOR_VERSION_MASK 0xf +#define IVT_MINOR_VERSION 0x1 +#define IVT_MINOR_VERSION_SHIFT 0x0 +#define IVT_MINOR_VERSION_MASK 0xf + +#define IVT_VERSION(major, minor) \ + ((((major) & IVT_MAJOR_VERSION_MASK) << IVT_MAJOR_VERSION_SHIFT) | \ + (((minor) & IVT_MINOR_VERSION_MASK) << IVT_MINOR_VERSION_SHIFT)) + +#define IVT_TAG_HEADER (0xd1) /* Image Vector Table */ +#define IVT_SIZE 0x2000 +#define IVT_PAR IVT_VERSION(IVT_MAJOR_VERSION, IVT_MINOR_VERSION) + +#define IVT_HEADER (IVT_TAG_HEADER | (IVT_SIZE << 8) | (IVT_PAR << 24)) +#define IVT_RSVD (uint32_t)(0x00000000) + +/* DCD Data */ + +#define DCD_TAG_HEADER (0xd2) +#define DCD_TAG_HEADER_SHIFT (24) +#define DCD_VERSION (0x40) +#define DCD_ARRAY_SIZE 1 + +#define FLASH_BASE 0x70000000 +#define FLASH_END 0x70400000 + +/* This needs to take into account the memory configuration at boot + * bootloader + */ + +#define ROM_BOOTLOADER_OCRAM_RES 0x8000 +#define OCRAM_BASE (0x20200000 + ROM_BOOTLOADER_OCRAM_RES) +#define OCRAM_END (OCRAM_BASE + (512 * 1024) + (256 * 1024) \ + - ROM_BOOTLOADER_OCRAM_RES) + +#define SCLK 1 +#if defined(CONFIG_BOOT_RUNFROMFLASH) +# define IMAGE_DEST FLASH_BASE +# define IMAGE_DEST_END FLASH_END +# define IMAGE_DEST_OFFSET 0 +#else +# define IMAGE_DEST OCRAM_BASE +# define IMAGE_DEST_END OCRAM_END +# define IMAGE_DEST_OFFSET IVT_SIZE +#endif + +#define LOCATE_IN_DEST(x) (((uint32_t)(x)) - FLASH_BASE + IMAGE_DEST) +#define LOCATE_IN_SRC(x) (((uint32_t)(x)) - IMAGE_DEST + FLASH_BASE) + +#ifdef CONFIG_IMXRT1064_EVK_SDRAM +# define DCD_ADDRESS &g_dcd_data +#else +# define DCD_ADDRESS 0 +#endif +#define BOOT_DATA_ADDRESS LOCATE_IN_DEST(&g_boot_data) +#define CSF_ADDRESS 0 +#define PLUGIN_FLAG (uint32_t)0 + +/* Located in Destination Memory */ + +#define IMAGE_ENTRY_ADDRESS ((uint32_t)&_vectors) +#define IMAG_VECTOR_TABLE LOCATE_IN_DEST(&g_image_vector_table) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* IVT Data */ + +struct ivt_s { + /* Header with tag #HAB_TAG_IVT, length and HAB version fields + * (see data) + */ + + uint32_t hdr; + + /* Absolute address of the first instruction to execute from the + * image + */ + + uint32_t entry; + + /* Reserved in this version of HAB: should be NULL. */ + + uint32_t reserved1; + + /* Absolute address of the image DCD: may be NULL. */ + + uint32_t dcd; + + /* Absolute address of the Boot Data: may be NULL, but not interpreted + * any further by HAB + */ + + uint32_t boot_data; + + /* Absolute address of the IVT. */ + + uint32_t self; + + /* Absolute address of the image CSF. */ + + uint32_t csf; + + /* Reserved in this version of HAB: should be zero. */ + + uint32_t reserved2; +}; + +/* Boot Data */ + +struct boot_data_s { + uint32_t start; /* boot start location */ + uint32_t size; /* size */ + uint32_t plugin; /* plugin flag - 1 if downloaded application is plugin */ + uint32_t placeholder; /* placeholder to make even 0x10 size */ +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +extern const struct boot_data_s g_boot_data; +#ifdef CONFIG_IMXRT1064_EVK_SDRAM +extern const uint8_t g_dcd_data[]; +#endif +extern const uint32_t _vectors[]; + +#endif /* __BOARDS_ARM_IMXRT_IMXRT1060_EVK_SRC_IMXRT_FLEXSPI_NOR_BOOT_H */ diff --git a/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_flash.c b/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_flash.c new file mode 100644 index 0000000000..25fcd2e2a1 --- /dev/null +++ b/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_flash.c @@ -0,0 +1,107 @@ +/**************************************************************************** + * boards/arm/imxrt/teensy-4.x/src/imxrt_flexspi_nor_flash.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "imxrt_flexspi_nor_flash.h" + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +enum { + /* SPI instructions */ + + READ_FAST = 0, + READ_STATUS_REG = 1, + WRITE_ENABLE = 3, + SECTOR_ERASE_4K = 5, + READ_FAST_QUAD_OUTPUT = 6, + PAGE_PROGRAM_QUAD_INPUT = 7, + ERASE_BLOCK = 8, + PAGE_PROGRAM = 9, + CHIP_ERASE = 11, +}; + +locate_data(".boot_hdr.conf") +const struct flexspi_nor_config_s g_flash_config = { + .mem_config = + { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .read_sample_clksrc = FLASH_READ_SAMPLE_CLK_LOOPBACK_FROM_DQSPAD, + .cs_hold_time = 3u, + .cs_setup_time = 3u, + .column_address_width = 0u, + .device_type = FLEXSPI_DEVICE_TYPE_SERIAL_NOR, + .sflash_pad_type = SERIAL_FLASH_4PADS, + .serial_clk_freq = FLEXSPI_SERIAL_CLKFREQ_133MHz, + .sflash_a1size = 4u * 1024u * 1024u, + .lookup_table = + { + [4 * READ_FAST] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xeb, + RADDR_SDR, FLEXSPI_4PAD, 0x18), + [4 * READ_FAST + 1] = FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, + READ_SDR, FLEXSPI_4PAD, 0x04), + + [4 * READ_STATUS_REG] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05, + READ_SDR, FLEXSPI_1PAD, 0x04), + + [4 * WRITE_ENABLE] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06, + STOP, FLEXSPI_1PAD, 0), + + [4 * SECTOR_ERASE_4K] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20, + RADDR_SDR, FLEXSPI_1PAD, 0x18), + + [4 * CHIP_ERASE] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60, + STOP, FLEXSPI_1PAD, 0), + + [4 * ERASE_BLOCK] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xd8, + RADDR_SDR, FLEXSPI_1PAD, 0x18), + + [4 * PAGE_PROGRAM] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02, + RADDR_SDR, FLEXSPI_1PAD, 0x18), + [4 * PAGE_PROGRAM + 1] = FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04, + STOP, FLEXSPI_1PAD, 0x0), + + [4 * READ_FAST_QUAD_OUTPUT] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x6b, + RADDR_SDR, FLEXSPI_1PAD, 0x18), + [4 * READ_FAST_QUAD_OUTPUT + 1] = FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x08, + READ_SDR, FLEXSPI_4PAD, 0x04), + + [4 * PAGE_PROGRAM_QUAD_INPUT] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x32, + RADDR_SDR, FLEXSPI_1PAD, 0x18), + [4 * PAGE_PROGRAM_QUAD_INPUT + 1] = FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_4PAD, 0x04, + STOP, FLEXSPI_1PAD, 0), + + }, + }, + + .page_size = 256u, + .sector_size = 4u * 1024u, + .blocksize = 64u * 1024u, + .is_uniform_blocksize = false, +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ diff --git a/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_flash.h b/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_flash.h new file mode 100644 index 0000000000..1fb3f41cce --- /dev/null +++ b/boards/nxp/mr-tropic/src/imxrt_flexspi_nor_flash.h @@ -0,0 +1,349 @@ +/**************************************************************************** + * boards/arm/imxrt/imxrt1064-evk/src/imxrt_flexspi_nor_flash.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_IMXRT_IMXRT1064_EVK_SRC_IMXRT_FLEXSPI_NOR_FLASH_H +#define __BOARDS_ARM_IMXRT_IMXRT1064_EVK_SRC_IMXRT_FLEXSPI_NOR_FLASH_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* FLEXSPI memory config block related definitions */ + +#define FLEXSPI_CFG_BLK_TAG (0x42464346ul) +#define FLEXSPI_CFG_BLK_VERSION (0x56010400ul) +#define FLEXSPI_CFG_BLK_SIZE (512) + +/* FLEXSPI Feature related definitions */ + +#define FLEXSPI_FEATURE_HAS_PARALLEL_MODE 1 + +/* Lookup table related definitions */ + +#define CMD_INDEX_READ 0 +#define CMD_INDEX_READSTATUS 1 +#define CMD_INDEX_WRITEENABLE 2 +#define CMD_INDEX_WRITE 4 + +#define CMD_LUT_SEQ_IDX_READ 0 +#define CMD_LUT_SEQ_IDX_READSTATUS 1 +#define CMD_LUT_SEQ_IDX_WRITEENABLE 3 +#define CMD_LUT_SEQ_IDX_WRITE 9 + +#define CMD_SDR 0x01 +#define CMD_DDR 0x21 +#define RADDR_SDR 0x02 +#define RADDR_DDR 0x22 +#define CADDR_SDR 0x03 +#define CADDR_DDR 0x23 +#define MODE1_SDR 0x04 +#define MODE1_DDR 0x24 +#define MODE2_SDR 0x05 +#define MODE2_DDR 0x25 +#define MODE4_SDR 0x06 +#define MODE4_DDR 0x26 +#define MODE8_SDR 0x07 +#define MODE8_DDR 0x27 +#define WRITE_SDR 0x08 +#define WRITE_DDR 0x28 +#define READ_SDR 0x09 +#define READ_DDR 0x29 +#define LEARN_SDR 0x0a +#define LEARN_DDR 0x2a +#define DATSZ_SDR 0x0b +#define DATSZ_DDR 0x2b +#define DUMMY_SDR 0x0c +#define DUMMY_DDR 0x2c +#define DUMMY_RWDS_SDR 0x0d +#define DUMMY_RWDS_DDR 0x2d +#define JMP_ON_CS 0x1f +#define STOP 0 + +#define FLEXSPI_1PAD 0 +#define FLEXSPI_2PAD 1 +#define FLEXSPI_4PAD 2 +#define FLEXSPI_8PAD 3 + +#define FLEXSPI_LUT_OPERAND0_MASK (0xffu) +#define FLEXSPI_LUT_OPERAND0_SHIFT (0U) +#define FLEXSPI_LUT_OPERAND0(x) (((uint32_t) \ + (((uint32_t)(x)) << FLEXSPI_LUT_OPERAND0_SHIFT)) & \ + FLEXSPI_LUT_OPERAND0_MASK) +#define FLEXSPI_LUT_NUM_PADS0_MASK (0x300u) +#define FLEXSPI_LUT_NUM_PADS0_SHIFT (8u) +#define FLEXSPI_LUT_NUM_PADS0(x) (((uint32_t) \ + (((uint32_t)(x)) << FLEXSPI_LUT_NUM_PADS0_SHIFT)) & \ + FLEXSPI_LUT_NUM_PADS0_MASK) +#define FLEXSPI_LUT_OPCODE0_MASK (0xfc00u) +#define FLEXSPI_LUT_OPCODE0_SHIFT (10u) +#define FLEXSPI_LUT_OPCODE0(x) (((uint32_t) \ + (((uint32_t)(x)) << FLEXSPI_LUT_OPCODE0_SHIFT)) & \ + FLEXSPI_LUT_OPCODE0_MASK) +#define FLEXSPI_LUT_OPERAND1_MASK (0xff0000u) +#define FLEXSPI_LUT_OPERAND1_SHIFT (16U) +#define FLEXSPI_LUT_OPERAND1(x) (((uint32_t) \ + (((uint32_t)(x)) << FLEXSPI_LUT_OPERAND1_SHIFT)) & \ + FLEXSPI_LUT_OPERAND1_MASK) +#define FLEXSPI_LUT_NUM_PADS1_MASK (0x3000000u) +#define FLEXSPI_LUT_NUM_PADS1_SHIFT (24u) +#define FLEXSPI_LUT_NUM_PADS1(x) (((uint32_t) \ + (((uint32_t)(x)) << FLEXSPI_LUT_NUM_PADS1_SHIFT)) & \ + FLEXSPI_LUT_NUM_PADS1_MASK) +#define FLEXSPI_LUT_OPCODE1_MASK (0xfc000000u) +#define FLEXSPI_LUT_OPCODE1_SHIFT (26u) +#define FLEXSPI_LUT_OPCODE1(x) (((uint32_t)(((uint32_t)(x)) << FLEXSPI_LUT_OPCODE1_SHIFT)) & \ + FLEXSPI_LUT_OPCODE1_MASK) + +#define FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) \ + (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | \ + FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \ + FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1)) + +/* */ + +#define NOR_CMD_INDEX_READ CMD_INDEX_READ +#define NOR_CMD_INDEX_READSTATUS CMD_INDEX_READSTATUS +#define NOR_CMD_INDEX_WRITEENABLE CMD_INDEX_WRITEENABLE +#define NOR_CMD_INDEX_ERASESECTOR 3 +#define NOR_CMD_INDEX_PAGEPROGRAM CMD_INDEX_WRITE +#define NOR_CMD_INDEX_CHIPERASE 5 +#define NOR_CMD_INDEX_DUMMY 6 +#define NOR_CMD_INDEX_ERASEBLOCK 7 + +/* READ LUT sequence id in lookupTable stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_READ CMD_LUT_SEQ_IDX_READ + +/* Read Status LUT sequence id in lookupTable stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_READSTATUS CMD_LUT_SEQ_IDX_READSTATUS + +/* 2 Read status DPI/QPI/OPI sequence id in LUT stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI 2 + +/* 3 Write Enable sequence id in lookupTable stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE CMD_LUT_SEQ_IDX_WRITEENABLE + +/* 4 Write Enable DPI/QPI/OPI sequence id in LUT stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI 4 + +/* 5 Erase Sector sequence id in lookupTable stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5 + +/* 8 Erase Block sequence id in lookupTable stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8 + +/* 9 Program sequence id in lookupTable stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM CMD_LUT_SEQ_IDX_WRITE + +/* 11 Chip Erase sequence in lookupTable id stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11 + +/* 13 Read SFDP sequence in lookupTable id stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13 + +/* 14 Restore 0-4-4/0-8-8 mode sequence id in LUT stored in config block */ + +#define NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD 14 + +/* 15 Exit 0-4-4/0-8-8 mode sequence id in LUT stored in config blobk */ + +#define NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD 15 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* Definitions for FlexSPI Serial Clock Frequency */ + +enum flexspi_serial_clkfreq_e { + FLEXSPI_SERIAL_CLKFREQ_30MHz = 1, + FLEXSPI_SERIAL_CLKFREQ_50MHz = 2, + FLEXSPI_SERIAL_CLKFREQ_60MHz = 3, + FLEXSPI_SERIAL_CLKFREQ_75MHz = 4, + FLEXSPI_SERIAL_CLKFREQ_80MHz = 5, + FLEXSPI_SERIAL_CLKFREQ_100MHz = 6, + FLEXSPI_SERIAL_CLKFREQ_120MHz = 7, + FLEXSPI_SERIAL_CLKFREQ_133MHz = 8, + FLEXSPI_SERIAL_CLKFREQ_166MHz = 9, +}; + +/* FlexSPI clock configuration type */ + +enum flexspi_serial_clockmode_e { + FLEXSPI_CLKMODE_SDR, + FLEXSPI_CLKMODE_DDR, +}; + +/* FlexSPI Read Sample Clock Source definition */ + +enum flash_read_sample_clk_e { + FLASH_READ_SAMPLE_CLK_LOOPBACK_INTERNELLY = 0, + FLASH_READ_SAMPLE_CLK_LOOPBACK_FROM_DQSPAD = 1, + FLASH_READ_SAMPLE_CLK_LOOPBACK_FROM_SCKPAD = 2, + FLASH_READ_SAMPLE_CLK_EXT_INPUT_FROM_DQSPAD = 3, +}; + +/* Misc feature bit definitions */ + +enum flash_misc_feature_e { + FLEXSPIMISC_OFFSET_DIFFCLKEN = 0, /* Bit for Differential clock enable */ + FLEXSPIMISC_OFFSET_CK2EN = 1, /* Bit for CK2 enable */ + FLEXSPIMISC_OFFSET_PARALLELEN = 2, /* Bit for Parallel mode enable */ + FLEXSPIMISC_OFFSET_WORD_ADDRESSABLE_EN = 3, /* Bit for Word Addressable enable */ + FLEXSPIMISC_OFFSET_SAFECONFIG_FREQ_EN = 4, /* Bit for Safe Configuration Frequency enable */ + FLEXSPIMISC_OFFSET_PAD_SETTING_OVERRIDE_EN = 5, /* Bit for Pad setting override enable */ + FLEXSPIMISC_OFFSET_DDR_MODE_EN = 6, /* Bit for DDR clock confiuration indication. */ +}; + +/* Flash Type Definition */ + +enum flash_flash_type_e { + FLEXSPI_DEVICE_TYPE_SERIAL_NOR = 1, /* Flash devices are Serial NOR */ + FLEXSPI_DEVICE_TYPE_SERIAL_NAND = 2, /* Flash devices are Serial NAND */ + FLEXSPI_DEVICE_TYPE_SERIAL_RAM = 3, /* Flash devices are Serial RAM/HyperFLASH */ + FLEXSPI_DEVICE_TYPE_MCP_NOR_NAND = 0x12, /* Flash device is MCP device, A1 is Serial NOR, A2 is Serial NAND */ + FLEXSPI_DEVICE_TYPE_MCP_NOR_RAM = 0x13, /* Flash device is MCP device, A1 is Serial NOR, A2 is Serial RAMs */ +}; + +/* Flash Pad Definitions */ + +enum flash_flash_pad_e { + SERIAL_FLASH_1PAD = 1, + SERIAL_FLASH_2PADS = 2, + SERIAL_FLASH_4PADS = 4, + SERIAL_FLASH_8PADS = 8, +}; + +/* Flash Configuration Command Type */ + +enum flash_config_cmd_e { + DEVICE_CONFIG_CMD_TYPE_GENERIC, /* Generic command, for example: configure dummy cycles, drive strength, etc */ + DEVICE_CONFIG_CMD_TYPE_QUADENABLE, /* Quad Enable command */ + DEVICE_CONFIG_CMD_TYPE_SPI2XPI, /* Switch from SPI to DPI/QPI/OPI mode */ + DEVICE_CONFIG_CMD_TYPE_XPI2SPI, /* Switch from DPI/QPI/OPI to SPI mode */ + DEVICE_CONFIG_CMD_TYPE_SPI2NO_CMD, /* Switch to 0-4-4/0-8-8 mode */ + DEVICE_CONFIG_CMD_TYPE_RESET, /* Reset device command */ +}; + +/* FlexSPI LUT Sequence structure */ + +struct flexspi_lut_seq_s { + uint8_t seq_num; /* Sequence Number, valid number: 1-16 */ + uint8_t seq_id; /* Sequence Index, valid number: 0-15 */ + uint16_t reserved; +}; + +/* FlexSPI Memory Configuration Block */ + +struct flexspi_mem_config_s { + uint32_t tag; + uint32_t version; + uint32_t reserved0; + uint8_t read_sample_clksrc; + uint8_t cs_hold_time; + uint8_t cs_setup_time; + uint8_t column_address_width; /* [0x00f-0x00f] Column Address with, for + * HyperBus protocol, it is fixed to 3, + * For Serial NAND, need to refer to + * datasheet + */ + uint8_t device_mode_cfg_enable; + uint8_t device_mode_type; + uint16_t wait_time_cfg_commands; + struct flexspi_lut_seq_s device_mode_seq; + uint32_t device_mode_arg; + uint8_t config_cmd_enable; + uint8_t config_mode_type[3]; + struct flexspi_lut_seq_s config_cmd_seqs[3]; + uint32_t reserved1; + uint32_t config_cmd_args[3]; + uint32_t reserved2; + uint32_t controller_misc_option; + uint8_t device_type; + uint8_t sflash_pad_type; + uint8_t serial_clk_freq; + uint8_t lut_custom_seq_enable; + uint32_t reserved3[2]; + uint32_t sflash_a1size; + uint32_t sflash_a2size; + uint32_t sflash_b1size; + uint32_t sflash_b2size; + uint32_t cspad_setting_override; + uint32_t sclkpad_setting_override; + uint32_t datapad_setting_override; + uint32_t dqspad_setting_override; + uint32_t timeout_in_ms; + uint32_t command_interval; + uint16_t data_valid_time[2]; + uint16_t busy_offset; + uint16_t busybit_polarity; + uint32_t lookup_table[64]; + struct flexspi_lut_seq_s lut_customseq[12]; + uint32_t reserved4[4]; +}; + +/* Serial NOR configuration block */ + +struct flexspi_nor_config_s { + struct flexspi_mem_config_s mem_config; /* Common memory configuration info + * via FlexSPI + */ + + uint32_t page_size; /* Page size of Serial NOR */ + uint32_t sector_size; /* Sector size of Serial NOR */ + uint8_t ipcmd_serial_clkfreq; /* Clock frequency for IP command */ + uint8_t is_uniform_blocksize; /* Sector/Block size is the same */ + uint8_t reserved0[2]; /* Reserved for future use */ + uint8_t serial_nor_type; /* Serial NOR Flash type: 0/1/2/3 */ + uint8_t need_exit_nocmdmode; /* Need to exit NoCmd mode before + * other IP command + */ + + uint8_t halfclk_for_nonreadcmd; /* Half the Serial Clock for non-read + * command: true/false + */ + + uint8_t need_restore_nocmdmode; /* Need to Restore NoCmd mode after IP + * command execution + */ + + uint32_t blocksize; /* Block size */ + uint32_t reserve2[11]; /* Reserved for future use */ +}; + +extern const struct flexspi_nor_config_s g_flash_config; + +#endif /* __BOARDS_ARM_IMXRT_IMXRT1064_EVK_SRC_IMXRT_FLEXSPI_NOR_FLASH_H */ diff --git a/boards/nxp/mr-tropic/src/imxrt_flexspi_storage.c b/boards/nxp/mr-tropic/src/imxrt_flexspi_storage.c new file mode 100644 index 0000000000..2b505176b4 --- /dev/null +++ b/boards/nxp/mr-tropic/src/imxrt_flexspi_storage.c @@ -0,0 +1,411 @@ +/**************************************************************************** + * boards/nxp/mr-tropic/src/imxrt_flexspi_storage.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include "px4_log.h" + +#include +#include +#include "board_config.h" +#include "hardware/imxrt_pinmux.h" +#include "barriers.h" + +/* Used sectors must be multiple of the flash block size + * i.e. W25Q32JV has a block size of 64KB +*/ + +#define NOR_USED_SECTORS (0x40U) /* 64 * 4KB = 256KB */ +#define NOR_TOTAL_SECTORS (0x0400U) +#define NOR_PAGE_SIZE (0x0100U) /* 256 bytes */ +#define NOR_SECTOR_SIZE (0x1000U) /* 4KB */ +#define NOR_START_SECTOR (NOR_TOTAL_SECTORS - NOR_USED_SECTORS) +#define NOR_START_PAGE ((NOR_START_SECTOR * NOR_SECTOR_SIZE) / NOR_PAGE_SIZE) +#define NOR_STORAGE_ADDR (IMXRT_FLEX2CIPHER_BASE + NOR_START_SECTOR * NOR_SECTOR_SIZE) +#define NOR_STORAGE_END (IMXRT_FLEX2CIPHER_BASE + (NOR_START_SECTOR + NOR_TOTAL_SECTORS) * NOR_SECTOR_SIZE) + +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) + +extern struct flexspi_nor_config_s g_bootConfig; + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* FlexSPI NOR device private data */ + +struct imxrt_flexspi_storage_dev_s { + struct mtd_dev_s mtd; + uint8_t *ahb_base; +}; + +/**************************************************************************** + * Private Functions Prototypes + ****************************************************************************/ + +/* MTD driver methods */ + +static int imxrt_flexspi_storage_erase(struct mtd_dev_s *dev, + off_t startblock, + size_t nblocks); +static ssize_t imxrt_flexspi_storage_read(struct mtd_dev_s *dev, + off_t offset, + size_t nbytes, + uint8_t *buffer); +static ssize_t imxrt_flexspi_storage_bread(struct mtd_dev_s *dev, + off_t startblock, + size_t nblocks, + uint8_t *buffer); +static ssize_t imxrt_flexspi_storage_bwrite(struct mtd_dev_s *dev, + off_t startblock, + size_t nblocks, + const uint8_t *buffer); +static int imxrt_flexspi_storage_ioctl(struct mtd_dev_s *dev, + int cmd, + unsigned long arg); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct imxrt_flexspi_storage_dev_s g_flexspi_nor = { + .mtd = + { + .erase = imxrt_flexspi_storage_erase, + .bread = imxrt_flexspi_storage_bread, + .bwrite = imxrt_flexspi_storage_bwrite, + .read = imxrt_flexspi_storage_read, + .ioctl = imxrt_flexspi_storage_ioctl, +#ifdef CONFIG_MTD_BYTE_WRITE + .write = NULL, +#endif + .name = "imxrt_flexspi_storage" + }, + .ahb_base = (uint8_t *) NOR_STORAGE_ADDR, +}; + +/* Ensure exclusive access to the driver */ + +static sem_t g_exclsem = SEM_INITIALIZER(1); + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int imxrt_flexspi_storage_erase_chip( + const struct imxrt_flexspi_storage_dev_s *dev) +{ + /* We can't erase the chip we're executing from */ + return -EINVAL; +} + +static ssize_t imxrt_flexspi_storage_read(struct mtd_dev_s *dev, + off_t offset, + size_t nbytes, + uint8_t *buffer) +{ + ssize_t ret; + struct imxrt_flexspi_storage_dev_s *priv = + (struct imxrt_flexspi_storage_dev_s *)dev; + uint8_t *src; + + finfo("offset: %08lx nbytes: %d\n", (long)offset, (int)nbytes); + + if (offset < 0) { + return -EIO; + } + + src = priv->ahb_base + offset; + + if (src + nbytes > (uint8_t *)NOR_STORAGE_END) { + return -EIO; + } + + ret = nxsem_wait(&g_exclsem); + + if (ret < 0) { + return ret; + } + + memcpy(buffer, src, nbytes); + + nxsem_post(&g_exclsem); + + finfo("return nbytes: %d\n", (int)nbytes); + return (ssize_t)nbytes; +} + +static ssize_t imxrt_flexspi_storage_bread(struct mtd_dev_s *dev, + off_t startblock, + size_t nblocks, + uint8_t *buffer) +{ + ssize_t nbytes; + + finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); + + /* On this device, we can handle the block read just like the byte-oriented + * read + */ + + nbytes = imxrt_flexspi_storage_read(dev, startblock * NOR_PAGE_SIZE, + nblocks * NOR_PAGE_SIZE, buffer); + + if (nbytes > 0) { + nbytes /= NOR_PAGE_SIZE; + } + + return nbytes; +} + +locate_code(".ramfunc") +static ssize_t imxrt_flexspi_storage_bwrite(struct mtd_dev_s *dev, + off_t startblock, + size_t nblocks, + const uint8_t *buffer) +{ + ssize_t ret; + struct flexspi_nor_config_s *pConfig = &g_bootConfig; + size_t len = nblocks * NOR_PAGE_SIZE; + off_t offset = (startblock + NOR_START_PAGE) * NOR_PAGE_SIZE; + uint8_t *src = (uint8_t *) buffer; +#ifdef CONFIG_ARMV7M_DCACHE + struct imxrt_flexspi_storage_dev_s *priv = + (struct imxrt_flexspi_storage_dev_s *)dev; + uint8_t *dst = priv->ahb_base + startblock * NOR_PAGE_SIZE; +#endif + int i; + + if (((uintptr_t)buffer % 4) != 0) { + return -EINVAL; // Byte aligned write not supported + } + + finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); + + ret = nxsem_wait(&g_exclsem); + + if (ret < 0) { + return ret; + } + + while (len) { + i = MIN(NOR_PAGE_SIZE, len); + cpsid(); // Disable interrupts +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" + volatile uint32_t status = ROM_FLEXSPI_NorFlash_ProgramPage(NOR_INSTANCE, pConfig, offset, (const uint32_t *)src); +#pragma GCC diagnostic pop + cpsie(); // Enable interrupts + usleep(0); // Yield to scheduler + UNUSED(status); + + offset += i; + src += i; + len -= i; + } + +#ifdef CONFIG_ARMV7M_DCACHE + up_invalidate_dcache((uintptr_t)dst, + (uintptr_t)dst + nblocks * NOR_PAGE_SIZE); +#endif + + nxsem_post(&g_exclsem); + + return nblocks; +} + +locate_code(".ramfunc") +static int imxrt_flexspi_storage_erase(struct mtd_dev_s *dev, + off_t startblock, + size_t nblocks) +{ + struct flexspi_nor_config_s *pConfig = &g_bootConfig; + size_t blocksleft = nblocks; +#ifdef CONFIG_ARMV7M_DCACHE + struct imxrt_flexspi_storage_dev_s *priv = + (struct imxrt_flexspi_storage_dev_s *)dev; + uint8_t *dst = priv->ahb_base + startblock * NOR_SECTOR_SIZE; +#endif + ssize_t ret; + + startblock += NOR_START_SECTOR; + + finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); + + ret = nxsem_wait(&g_exclsem); + + if (ret < 0) { + return ret; + } + + while (blocksleft-- > 0) { + /* Erase each sector */ + cpsid(); // Disable interrupts + volatile uint32_t status = ROM_FLEXSPI_NorFlash_Erase(NOR_INSTANCE, pConfig, + (startblock * NOR_SECTOR_SIZE), NOR_SECTOR_SIZE); + cpsie(); // Enable interrupts + usleep(0); // Yield to scheduler + UNUSED(status); + startblock++; + } + +#ifdef CONFIG_ARMV7M_DCACHE + up_invalidate_dcache((uintptr_t)dst, + (uintptr_t)dst + nblocks * NOR_SECTOR_SIZE); +#endif + nxsem_post(&g_exclsem); + + return (int)nblocks; +} + +static int imxrt_flexspi_storage_ioctl(struct mtd_dev_s *dev, + int cmd, + unsigned long arg) +{ + struct imxrt_flexspi_storage_dev_s *priv = + (struct imxrt_flexspi_storage_dev_s *)dev; + int ret = -EINVAL; /* Assume good command with bad parameters */ + + finfo("cmd: %d\n", cmd); + + switch (cmd) { + case MTDIOC_GEOMETRY: { + struct mtd_geometry_s *geo = + (struct mtd_geometry_s *)((uintptr_t)arg); + + if (geo) { + /* Populate the geometry structure with information need to + * know the capacity and how to access the device. + * + * NOTE: + * that the device is treated as though it where just an array + * of fixed size blocks. That is most likely not true, but the + * client will expect the device logic to do whatever is + * necessary to make it appear so. + */ + + geo->blocksize = (NOR_PAGE_SIZE); + geo->erasesize = (NOR_SECTOR_SIZE); + geo->neraseblocks = (NOR_USED_SECTORS); + + ret = OK; + + finfo("blocksize: %lu erasesize: %lu neraseblocks: %lu\n", + geo->blocksize, geo->erasesize, geo->neraseblocks); + } + } + break; + + case BIOC_PARTINFO: { + struct partition_info_s *info = + (struct partition_info_s *)arg; + + if (info != NULL) { + info->numsectors = (NOR_USED_SECTORS * NOR_SECTOR_SIZE) / NOR_PAGE_SIZE; + info->sectorsize = NOR_PAGE_SIZE; + info->startsector = 0; + info->parent[0] = '\0'; + ret = OK; + } + } + break; + + case MTDIOC_BULKERASE: { + /* Erase the entire device */ + + imxrt_flexspi_storage_erase_chip(priv); + ret = OK; + } + break; + + default: + ret = -ENOTTY; /* Bad/unsupported command */ + break; + } + + finfo("return %d\n", ret); + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + + +/**************************************************************************** + * Name: imxrt_flexspi_storage_initialize + * + * Description: + * This function is called by board-bringup logic to configure the + * flash device. + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +int imxrt_flexspi_storage_initialize(void) +{ + struct mtd_dev_s *mtd_dev = &g_flexspi_nor.mtd; + int ret = -ENODEV; + + /* Register the MTD driver so that it can be accessed from the + * VFS. + */ + + ret = register_mtddriver("/dev/nor", mtd_dev, 0755, NULL); + + if (ret < 0) { + syslog(LOG_ERR, "ERROR: Failed to register MTD driver: %d\n", + ret); + } + +#ifdef CONFIG_FS_LITTLEFS + + /* Mount the LittleFS file system */ + + ret = nx_mount("/dev/nor", "/fs/nor", "littlefs", 0, + "autoformat"); + + if (ret < 0) { + syslog(LOG_ERR, + "ERROR: Failed to mount LittleFS at /mnt/lfs: %d\n", + ret); + } + +#endif + + return ret; +} diff --git a/boards/nxp/mr-tropic/src/imxrt_ocram_initialize.c b/boards/nxp/mr-tropic/src/imxrt_ocram_initialize.c new file mode 100644 index 0000000000..67c1a4ca36 --- /dev/null +++ b/boards/nxp/mr-tropic/src/imxrt_ocram_initialize.c @@ -0,0 +1,102 @@ +/**************************************************************************** + * + * Copyright (c) 2018-2019, 2023 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 imxrt_ocram_initialize.c + * + * PX4 fmu-v6xrt RAM startup early startup code. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "arm_internal.h" +#include "imxrt_iomuxc.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +__BEGIN_DECLS +extern const uint64_t _fitcmfuncs; /* Copy source address in FLASH */ +extern uint64_t _sitcmfuncs; /* Copy destination start address in ITCM */ +extern uint64_t _eitcmfuncs; /* Copy destination end address in ITCM */ +extern uint64_t _sdtcm; /* Copy destination start address in DTCM */ +extern uint64_t _edtcm; /* Copy destination end address in DTCM */ +__END_DECLS + +/**************************************************************************** + * Name: imxrt_ocram_initialize + * + * Description: + * Called off reset vector to reconfigure the flexRAM + * and finish the FLASH to RAM Copy. + * CMakeLists.txt Forces compiler not to use builtin functions using -fno-builtin + * + ****************************************************************************/ + +__EXPORT void imxrt_ocram_initialize(void) +{ + uint32_t regval; + register uint64_t *src; + register uint64_t *dest; + + /* FlexRAM Configuration + * F = 64K ITCM + * A = 64K DTCM + * 5 = 64K OCRAM + * So 0xFFFFFFAA is + * 384K FlexRAM ITCM + * 128K FlexRAM DTCM + * */ + + putreg32(0xFFFFFFAA, IMXRT_IOMUXC_GPR_GPR17); + regval = getreg32(IMXRT_IOMUXC_GPR_GPR16); + putreg32(regval | GPR_GPR16_FLEXRAM_BANK_CFG_SEL, IMXRT_IOMUXC_GPR_GPR16); + + /* Copy any necessary code sections from FLASH to ITCM. The process is the + * same as the code copying from FLASH to RAM above. */ + for (src = (uint64_t *)&_fitcmfuncs, dest = (uint64_t *)&_sitcmfuncs; + dest < (uint64_t *)&_eitcmfuncs;) { + *dest++ = *src++; + } + + /* Clear .dtcm. We'll do this inline (vs. calling memset) just to be + * certain that there are no issues with the state of global variables. + */ + + for (dest = &_sdtcm; dest < &_edtcm;) { + *dest++ = 0; + } +} diff --git a/boards/nxp/mr-tropic/src/init.c b/boards/nxp/mr-tropic/src/init.c new file mode 100644 index 0000000000..7c71fbbef0 --- /dev/null +++ b/boards/nxp/mr-tropic/src/init.c @@ -0,0 +1,400 @@ +/**************************************************************************** + * + * Copyright (c) 2024 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 init.c + * + * NXP imxrt1062-v1 specific early startup code. This file implements the + * board_app_initialize() function that is called early by nsh during startup. + * + * Code here is run before the rcS script is invoked; it should start required + * subsystems and perform board-specific initialization. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "board_config.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "arm_internal.h" +#include "imxrt_flexspi_nor_boot.h" +#include +#include "imxrt_iomuxc.h" +#include "imxrt_flexcan.h" +#include "imxrt_enet.h" +#include +#include "board_config.h" + +#include +#undef FLEXSPI_LUT_COUNT +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Configuration ************************************************************/ + +/* + * Ideally we'd be able to get these from arm_internal.h, + * but since we want to be able to disable the NuttX use + * of leds for system indication at will and there is no + * separate switch, we need to build independent of the + * CONFIG_ARCH_LEDS configuration switch. + */ +__BEGIN_DECLS +extern void led_init(void); +extern void led_on(int led); +extern void led_off(int led); + +extern uint32_t _srodata; /* Start of .rodata */ +extern uint32_t _erodata; /* End of .rodata */ +__END_DECLS + +/************************************************************************************ + * Name: board_peripheral_reset + * + * Description: + * + ************************************************************************************/ +__EXPORT void board_peripheral_reset(int ms) +{ + +} +/************************************************************************************ + * Name: board_on_reset + * + * Description: + * Optionally provided function called on entry to board_system_reset + * It should perform any house keeping prior to the rest. + * + * status - 1 if resetting to boot loader + * 0 if just resetting + * + ************************************************************************************/ + +__EXPORT void board_on_reset(int status) +{ + for (int i = 0; i < DIRECT_PWM_OUTPUT_CHANNELS; ++i) { + px4_arch_configgpio(PX4_MAKE_GPIO_INPUT(io_timer_channel_get_gpio_output(i))); + } + + /* + * On resets invoked from system (not boot) ensure we establish a low + * output state on PWM pins to disarm the ESC and prevent the reset from potentially + * spinning up the motors. + */ + if (status >= 0) { + up_mdelay(100); + } +} + +/**************************************************************************** + * Name: imxrt_flash_romapi_initialize + * + * Description: + * + ****************************************************************************/ +struct flexspi_nor_config_s g_bootConfig; + +locate_code(".ramfunc") +void imxrt_flash_romapi_initialize(void) +{ + memcpy((struct flexspi_nor_config_s *)&g_bootConfig, &g_flash_config, + sizeof(struct flexspi_nor_config_s)); + g_bootConfig.memConfig.tag = FLEXSPI_CFG_BLK_TAG; + + ROM_API_Init(); + + ROM_FLEXSPI_NorFlash_Init(NOR_INSTANCE, (struct flexspi_nor_config_s *)&g_bootConfig); + ROM_FLEXSPI_NorFlash_ClearCache(NOR_INSTANCE); + + ARM_DSB(); + ARM_ISB(); + ARM_DMB(); +} + +locate_code(".ramfunc") +void imxrt_flash_setup_prefetch_partition(void) +{ +//Prefetch tuning to be determined +#if 0 + putreg32((uint32_t)&_srodata, IMXRT_FLEXSPI1_AHBBUFREGIONSTART0); + putreg32((uint32_t)&_erodata, IMXRT_FLEXSPI1_AHBBUFREGIONEND0); + /*putreg32((uint32_t)&_stext, IMXRT_FLEXSPI1_AHBBUFREGIONSTART1); + putreg32((uint32_t)&_etext, IMXRT_FLEXSPI1_AHBBUFREGIONEND1); + putreg32((uint32_t)&_stext, IMXRT_FLEXSPI1_AHBBUFREGIONSTART2); + putreg32((uint32_t)&_etext, IMXRT_FLEXSPI1_AHBBUFREGIONEND2); + putreg32((uint32_t)&_stext, IMXRT_FLEXSPI1_AHBBUFREGIONSTART3); + putreg32((uint32_t)&_etext, IMXRT_FLEXSPI1_AHBBUFREGIONEND3);*/ +#endif +#if 0 + struct flexspi_type_s *g_flexspi = (struct flexspi_type_s *)IMXRT_FLEXSPIC_BASE; + /* RODATA */ + g_flexspi->AHBRXBUFCR0[0] = FLEXSPI_AHBRXBUFCR0_BUFSZ(48) | + FLEXSPI_AHBRXBUFCR0_MSTRID(0) | + FLEXSPI_AHBRXBUFCR0_PREFETCHEN(1) | + FLEXSPI_AHBRXBUFCR0_REGIONEN(1); + + + /* All Text */ + g_flexspi->AHBRXBUFCR0[1] = FLEXSPI_AHBRXBUFCR0_BUFSZ(80) | + FLEXSPI_AHBRXBUFCR0_MSTRID(0) | + FLEXSPI_AHBRXBUFCR0_PREFETCHEN(1) | + FLEXSPI_AHBRXBUFCR0_REGIONEN(1); + + /* Disable 2 */ + g_flexspi->AHBRXBUFCR0[2] = FLEXSPI_AHBRXBUFCR0_BUFSZ(0) | + FLEXSPI_AHBRXBUFCR0_MSTRID(0) | + FLEXSPI_AHBRXBUFCR0_PREFETCHEN(1) | + FLEXSPI_AHBRXBUFCR0_REGIONEN(0); + + /* Disable 3 */ + g_flexspi->AHBRXBUFCR0[3] = FLEXSPI_AHBRXBUFCR0_BUFSZ(0) | + FLEXSPI_AHBRXBUFCR0_MSTRID(0) | + FLEXSPI_AHBRXBUFCR0_PREFETCHEN(1) | + FLEXSPI_AHBRXBUFCR0_REGIONEN(0); +#endif + + ARM_DSB(); + ARM_ISB(); + ARM_DMB(); +} + +/**************************************************************************** + * Name: imxrt_boardinitialize + * + * Description: + * All i.MX RT architectures must provide the following entry point. This + * entry point is called early in the initialization -- after clocking and + * memory have been configured but before caches have been enabled and + * before any devices have been initialized. + * + ****************************************************************************/ + +__EXPORT void imxrt_boardinitialize(void) +{ + imxrt_flash_setup_prefetch_partition(); + + imxrt_flash_romapi_initialize(); + + board_on_reset(-1); /* Reset PWM first thing */ + + /* configure LEDs */ + + board_autoled_initialize(); + + /* configure pins */ + + const uint32_t gpio[] = PX4_GPIO_INIT_LIST; + px4_gpio_init(gpio, arraySize(gpio)); + + imxrt_usb_initialize(); + + fmurt1062_timer_initialize(); +} + +/**************************************************************************** + * Function: imxrt_phy_boardinitialize + * + * Description: + * Some boards require specialized initialization of the PHY before it can + * be used. This may include such things as configuring GPIOs, resetting + * the PHY, etc. + * If CONFIG_IMXRT_ENET_PHYINIT is defined in the configuration then the + * board specific logic must provide imxrt_phyinitialize(); + * The i.MX RT Ethernet driver will call this function one time before it + * first uses the PHY. + * + * Input Parameters: + * intf - Always zero for now. + * + * Returned Value: + * OK on success; Negated errno on failure. + * + ****************************************************************************/ + +int imxrt_phy_boardinitialize(int intf) +{ +#ifdef CONFIG_IMXRT_GPIO1_0_15_IRQ + /* Configure the PHY interrupt pin */ + + printf("Configuring interrupt: %08x\n", GPIO_ENET_INT); + imxrt_config_gpio(GPIO_ENET_INT); +#endif + return OK; +} + +void imxrt_flexio_clocking(void) +{ + uint32_t reg; + + /* Init USB PLL3 PFD2 */ + + reg = getreg32(IMXRT_CCM_ANALOG_PFD_480); + + while ((getreg32(IMXRT_CCM_ANALOG_PLL_USB1) & + CCM_ANALOG_PLL_USB1_LOCK) == 0) { + } + + reg &= ~CCM_ANALOG_PFD_480_PFD2_FRAC_MASK; + + /* Set PLL3 PFD2 to 480 * 18 / CONFIG_PLL3_PFD2_FRAC */ + + reg |= ((uint32_t)(CONFIG_PLL3_PFD2_FRAC) << CCM_ANALOG_PFD_480_PFD3_FRAC_SHIFT); + + putreg32(reg, IMXRT_CCM_ANALOG_PFD_480); + + reg = getreg32(IMXRT_CCM_CDCDR); + reg &= ~(CCM_CDCDR_FLEXIO1_CLK_SEL_MASK | + CCM_CDCDR_FLEXIO1_CLK_PODF_MASK | + CCM_CDCDR_FLEXIO1_CLK_PRED_MASK); + reg |= CCM_CDCDR_FLEXIO1_CLK_SEL(CONFIG_FLEXIO1_CLK); + reg |= CCM_CDCDR_FLEXIO1_CLK_PODF + (CCM_PODF_FROM_DIVISOR(CONFIG_FLEXIO1_PODF_DIVIDER)); + reg |= CCM_CDCDR_FLEXIO1_CLK_PRED + (CCM_PRED_FROM_DIVISOR(CONFIG_FLEXIO1_PRED_DIVIDER)); + putreg32(reg, IMXRT_CCM_CDCDR); +} + + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initalization logic and the the + * matching application logic. The value cold be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ +__EXPORT int board_app_initialize(uintptr_t arg) +{ + int ret = OK; + +#if !defined(BOOTLOADER) + + imxrt_flexio_clocking(); + + /* Power on Interfaces */ + + px4_platform_init(); + + imxrt_spiinitialize(); + + board_determine_hw_info(); + + /* configure the DMA allocator */ + + if (board_dma_alloc_init() < 0) { + syslog(LOG_ERR, "[boot] DMA alloc FAILED\n"); + } + +#if defined(SERIAL_HAVE_RXDMA) + // set up the serial DMA polling at 1ms intervals for received bytes that have not triggered a DMA event. + static struct hrt_call serial_dma_call; + hrt_call_every(&serial_dma_call, 1000, 1000, (hrt_callout)imxrt_serial_dma_poll, NULL); +#endif + +#if defined(CONFIG_IMXRT_USDHC) + ret = fmurt1062_usdhc_initialize(); +#endif + + imxrt_spiinitialize(); + + board_spi_reset(10, 0xffff); + +#ifdef CONFIG_IMXRT_ENET + imxrt_gpio_write(GPIO_ENET_RST, true); + + usleep(2000); + + imxrt_netinitialize(0); +#endif + +#ifdef CONFIG_IMXRT_FLEXCAN3 + imxrt_caninitialize(3); +#endif + + ret = imxrt_flexspi_storage_initialize(); + + if (ret < 0) { + syslog(LOG_ERR, + "ERROR: imxrt_flexspi_nor_initialize failed: %d\n", ret); + } + +#endif /* !defined(BOOTLOADER) */ + + return ret; +} diff --git a/boards/nxp/mr-tropic/src/manifest.c b/boards/nxp/mr-tropic/src/manifest.c new file mode 100644 index 0000000000..afd3de58e5 --- /dev/null +++ b/boards/nxp/mr-tropic/src/manifest.c @@ -0,0 +1,79 @@ +/**************************************************************************** + * + * Copyright (c) 2023 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 manifest.c + * + * This module supplies the interface to the manifest of hardware that is + * optional and dependent on the HW REV and HW VER IDs + * + * The manifest allows the system to know whether a hardware option + * say for example the PX4IO is an no-pop option vs it is broken. + * + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include "systemlib/px4_macros.h" +#include "px4_log.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + + +/************************************************************************************ + * Name: board_query_manifest + * + * Description: + * Optional returns manifest item. + * + * Input Parameters: + * manifest_id - the ID for the manifest item to retrieve + * + * Returned Value: + * 0 - item is not in manifest => assume legacy operations + * pointer to a manifest item + * + ************************************************************************************/ + +__EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id) +{ + return px4_hw_mft_unsupported; +} diff --git a/boards/nxp/mr-tropic/src/sdhc.c b/boards/nxp/mr-tropic/src/sdhc.c new file mode 100644 index 0000000000..df2f92cc1c --- /dev/null +++ b/boards/nxp/mr-tropic/src/sdhc.c @@ -0,0 +1,128 @@ +/**************************************************************************** + * + * Copyright (C) 2016-2018 Gregory Nutt. All rights reserved. + * Authors: Gregory Nutt + * David Sidrane + * + * 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 NuttX 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. + * + ****************************************************************************/ +/* A micro Secure Digital (SD) card slot is available on the board connected to + * the SD Host Controller (USDHC1) signals of the MCU. This slot will accept + * micro format SD memory cards. + * + * ------------ ------------- -------- + * SD Card Slot Board Signal IMXRT Pin + * ------------ ------------- -------- + * DAT0 USDHC1_DATA0 GPIO_SD_B0_02 + * DAT1 USDHC1_DATA1 GPIO_SD_B0_03 + * DAT2 USDHC1_DATA2 GPIO_SD_B0_04 + * CD/DAT3 USDHC1_DATA3 GPIO_SD_B0_05 + * CMD USDHC1_CMD GPIO_SD_B0_00 + * CLK USDHC1_CLK GPIO_SD_B0_01 + * CD USDHC1_CD GPIO_B1_12 + * ------------ ------------- -------- + * + * There are no Write Protect available to the IMXRT. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "chip.h" +#include "imxrt_usdhc.h" + +#include "board_config.h" + +#ifdef CONFIG_IMXRT_USDHC +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ +/**************************************************************************** + * Private Data + ****************************************************************************/ +/**************************************************************************** + * Private Functions + ****************************************************************************/ +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: fmurt1062_usdhc_initialize + * + * Description: + * Inititialize the SDHC SD card slot + * + ****************************************************************************/ + +int fmurt1062_usdhc_initialize(void) +{ + int ret; + + /* Mount the SDHC-based MMC/SD block driver */ + /* First, get an instance of the SDHC interface */ + + struct sdio_dev_s *sdhc = imxrt_usdhc_initialize(CONFIG_NSH_MMCSDSLOTNO); + + if (!sdhc) { + PX4_ERR("ERROR: Failed to initialize SDHC slot %d\n", CONFIG_NSH_MMCSDSLOTNO); + return -ENODEV; + } + + /* Now bind the SDHC interface to the MMC/SD driver */ + + ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdhc); + + if (ret != OK) { + PX4_ERR("ERROR: Failed to bind SDHC to the MMC/SD driver: %d\n", ret); + return ret; + } + + syslog(LOG_INFO, "Successfully bound SDHC to the MMC/SD driver\n"); + + return OK; +} +#endif /* CONFIG_IMXRT_USDHC */ diff --git a/boards/nxp/mr-tropic/src/spi.cpp b/boards/nxp/mr-tropic/src/spi.cpp new file mode 100644 index 0000000000..afea0032a5 --- /dev/null +++ b/boards/nxp/mr-tropic/src/spi.cpp @@ -0,0 +1,95 @@ +/************************************************************************************ + * + * Copyright (C) 2016, 2018 Gregory Nutt. All rights reserved. + * Authors: Gregory Nutt + * David Sidrane + * + * 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. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include "imxrt_lpspi.h" +#include "imxrt_gpio.h" +#include "board_config.h" +#include + +constexpr px4_spi_bus_all_hw_t px4_spi_buses_all_hw[BOARD_NUM_SPI_CFG_HW_VERSIONS] = { + initSPIFmumID(TROPIC_0, { + initSPIBus(SPI::Bus::LPSPI3, { + initSPIDevice(DRV_IMU_DEVTYPE_ICM45686, SPI::CS{GPIO::Port1, GPIO::Pin28}, SPI::DRDY{GPIO::Port3, GPIO::Pin18}), /* GPIO_AD_B1_12 GPIO1_IO28 */ + }), + initSPIBus(SPI::Bus::LPSPI4, { + initSPIDevice(DRV_GYR_DEVTYPE_BMI088, SPI::CS{GPIO::Port2, GPIO::Pin18}, SPI::DRDY{GPIO::Port2, GPIO::Pin10}), /* GPIO_B1_02 GPIO2_IO18 */ + initSPIDevice(DRV_ACC_DEVTYPE_BMI088, SPI::CS{GPIO::Port2, GPIO::Pin0}, SPI::DRDY{GPIO::Port1, GPIO::Pin25}), /* GPIO_B0_00 GPIO2_IO00 */ + }), + }), + + initSPIFmumID(TROPIC_1, { + initSPIBus(SPI::Bus::LPSPI3, { + initSPIDevice(DRV_IMU_DEVTYPE_ICM42688P, SPI::CS{GPIO::Port1, GPIO::Pin28}), /* GPIO_AD_B1_12 GPIO1_IO28 */ + }), + initSPIBus(SPI::Bus::LPSPI4, { + initSPIDevice(DRV_GYR_DEVTYPE_BMI088, SPI::CS{GPIO::Port2, GPIO::Pin18}), /* GPIO_B1_02 GPIO2_IO18 */ + initSPIDevice(DRV_ACC_DEVTYPE_BMI088, SPI::CS{GPIO::Port2, GPIO::Pin0}), /* GPIO_B0_00 GPIO2_IO00 */ + }), + }), + + initSPIFmumID(TROPIC_2, { + initSPIBus(SPI::Bus::LPSPI3, { + initSPIDevice(DRV_IMU_DEVTYPE_ICM42686P, SPI::CS{GPIO::Port1, GPIO::Pin28}), /* GPIO_AD_B1_12 GPIO1_IO28 */ + }), + initSPIBus(SPI::Bus::LPSPI4, { + initSPIDevice(DRV_GYR_DEVTYPE_BMI088, SPI::CS{GPIO::Port2, GPIO::Pin18}), /* GPIO_B1_02 GPIO2_IO18 */ + initSPIDevice(DRV_ACC_DEVTYPE_BMI088, SPI::CS{GPIO::Port2, GPIO::Pin0}), /* GPIO_B0_00 GPIO2_IO00 */ + }), + }), +}; + +static constexpr bool unused = validateSPIConfig(px4_spi_buses_all_hw); diff --git a/boards/nxp/mr-tropic/src/timer_config.cpp b/boards/nxp/mr-tropic/src/timer_config.cpp new file mode 100644 index 0000000000..a15a7e83fb --- /dev/null +++ b/boards/nxp/mr-tropic/src/timer_config.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** + * + * Copyright (C) 2024 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. + * + ****************************************************************************/ +#include + +#include +#include "hardware/imxrt_tmr.h" +#include "hardware/imxrt_flexpwm.h" +#include "imxrt_gpio.h" +#include "imxrt_iomuxc.h" +#include "hardware/imxrt_pinmux.h" +#include "imxrt_xbar.h" +#include "imxrt_periphclks.h" + +#include +#include + +#include "board_config.h" + +/**************************************************************************************************** + * Definitions + ****************************************************************************************************/ + +/* Register accessors */ + +#define _REG(_addr) (*(volatile uint16_t *)(_addr)) + +/* QTimer3 register accessors */ + +#define REG(_reg) _REG(IMXRT_QTIMER3_BASE + IMXRT_TMR_OFFSET(IMXRT_TMR_CH0,(_reg))) + +#define rCOMP1 REG(IMXRT_TMR_COMP1_OFFSET) +#define rCOMP2 REG(IMXRT_TMR_COMP2_OFFSET) +#define rCAPT REG(IMXRT_TMR_CAPT_OFFSET) +#define rLOAD REG(IMXRT_TMR_LOAD_OFFSET) +#define rHOLD REG(IMXRT_TMR_HOLD_OFFSET) +#define rCNTR REG(IMXRT_TMR_CNTR_OFFSET) +#define rCTRL REG(IMXRT_TMR_CTRL_OFFSET) +#define rSCTRL REG(IMXRT_TMR_SCTRL_OFFSET) +#define rCMPLD1 REG(IMXRT_TMR_CMPLD1_OFFSET) +#define rCMPLD2 REG(IMXRT_TMR_CMPLD2_OFFSET) +#define rCSCTRL REG(IMXRT_TMR_CSCTRL_OFFSET) +#define rFILT REG(IMXRT_TMR_FILT_OFFSET) +#define rDMA REG(IMXRT_TMR_DMA_OFFSET) +#define rENBL REG(IMXRT_TMR_ENBL_OFFSET) + + +constexpr io_timers_t io_timers[MAX_IO_TIMERS] = { + initIOPWMDshot(PWM::FlexPWM2, PWM::Submodule0), // PWM_1, PMW_2 + initIOPWMDshot(PWM::FlexPWM2, PWM::Submodule1), // PWM_3, PWM_4 + initIOPWMDshot(PWM::FlexPWM4, PWM::Submodule1), // PWM_5, PWM_6 + initIOPWMDshot(PWM::FlexPWM4, PWM::Submodule2), // PWM_7, PWM_8 +}; + +#define FXIO_IOMUX (IOMUX_SLEW_FAST | IOMUX_DRIVE_130OHM | IOMUX_PULL_UP_47K | IOMUX_SCHMITT_TRIGGER) + +constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { + initIOTimerChannelDshot(io_timers, {PWM::PWM2_PWM_A, PWM::Submodule0}, IOMUX::Pad::GPIO_EMC_06, GPIO_FLEXIO1_FLEXIO06_1 | FXIO_IOMUX, 6), + initIOTimerChannelDshot(io_timers, {PWM::PWM2_PWM_B, PWM::Submodule0}, IOMUX::Pad::GPIO_EMC_07, GPIO_FLEXIO1_FLEXIO07_1 | FXIO_IOMUX, 7), + initIOTimerChannelDshot(io_timers, {PWM::PWM2_PWM_A, PWM::Submodule1}, IOMUX::Pad::GPIO_EMC_08, GPIO_FLEXIO1_FLEXIO08_1 | FXIO_IOMUX, 8), + initIOTimerChannelDshot(io_timers, {PWM::PWM2_PWM_B, PWM::Submodule1}, IOMUX::Pad::GPIO_EMC_09, GPIO_FLEXIO1_FLEXIO09_1 | FXIO_IOMUX, 9), + initIOTimerChannelDshot(io_timers, {PWM::PWM4_PWM_A, PWM::Submodule1}, IOMUX::Pad::GPIO_EMC_02, GPIO_FLEXIO1_FLEXIO02_1 | FXIO_IOMUX, 2), + initIOTimerChannelDshot(io_timers, {PWM::PWM4_PWM_B, PWM::Submodule1}, IOMUX::Pad::GPIO_EMC_03, GPIO_FLEXIO1_FLEXIO03_1 | FXIO_IOMUX, 3), + initIOTimerChannelDshot(io_timers, {PWM::PWM4_PWM_A, PWM::Submodule2}, IOMUX::Pad::GPIO_EMC_04, GPIO_FLEXIO1_FLEXIO04_1 | FXIO_IOMUX, 4), + initIOTimerChannelDshot(io_timers, {PWM::PWM4_PWM_B, PWM::Submodule2}, IOMUX::Pad::GPIO_EMC_05, GPIO_FLEXIO1_FLEXIO05_1 | FXIO_IOMUX, 5), +}; + +constexpr io_timers_channel_mapping_t io_timers_channel_mapping = + initIOTimerChannelMapping(io_timers, timer_io_channels); + +constexpr io_timers_t led_pwm_timers[MAX_LED_TIMERS] = { +}; + +constexpr timer_io_channels_t led_pwm_channels[MAX_TIMER_LED_CHANNELS] = { +}; + +#include +void fmurt1062_timer_initialize(void) +{ + /* We must configure Qtimer 3 as the IPG divide by to yield 16 Mhz + * and deliver that clock to the eFlexPWM234 via XBAR + * + * IPG = 144 Mhz + * 16Mhz = 144 / 9 + * COMP 1 = 5, COMP2 = 4 + * + * */ + + /* Enable Block Clocks for Qtimer and XBAR1 */ + + imxrt_clockall_timer3(); + imxrt_clockall_xbar1(); + + /* Disable Timer */ + + rCTRL = 0; + rCOMP1 = 5 - 1; // N - 1 + rCOMP2 = 4 - 1; + + rCAPT = 0; + rLOAD = 0; + rCNTR = 0; + + rSCTRL = TMR_SCTRL_OEN; + + rCMPLD1 = 0; + rCMPLD2 = 0; + rCSCTRL = 0; + rFILT = 0; + rDMA = 0; + + /* Count rising edges of primary source, + * Prescaler is /1 + * Count UP until compare, then re-initialize. a successful compare occurs when the counter reaches a COMP1 value. + * Toggle OFLAG output using alternating compare registers + */ + rCTRL = (TMR_CTRL_CM_MODE1 | TMR_CTRL_PCS_DIV1 | TMR_CTRL_LENGTH | TMR_CTRL_OUTMODE_TOG_ALT); + + /* QTIMER3_TIMER0 -> Flexpwm234ExtClk */ + + imxrt_xbar_connect(IMXRT_XBARA1_OUT_FLEXPWM234_EXT_CLK_SEL_OFFSET, IMXRT_XBARA1_IN_QTIMER3_TMR0_OUT); + imxrt_xbar_connect(IMXRT_XBARA1_OUT_FLEXPWM1_EXT_CLK_SEL_OFFSET, IMXRT_XBARA1_IN_QTIMER3_TMR0_OUT); +} diff --git a/boards/nxp/mr-tropic/src/tropic_led_pwm.cpp b/boards/nxp/mr-tropic/src/tropic_led_pwm.cpp new file mode 100644 index 0000000000..45598fc787 --- /dev/null +++ b/boards/nxp/mr-tropic/src/tropic_led_pwm.cpp @@ -0,0 +1,182 @@ +/**************************************************************************** + * + * Copyright (c) 2024 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 Airmind 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 tropic_led_pwm.cpp +*/ + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include "imxrt_xbar.h" +#include "imxrt_periphclks.h" +#include "hardware/imxrt_tmr.h" +#include "hardware/imxrt_flexpwm.h" + +#define LED_PWM_FREQ 1000 +#define FLEXPWM_FREQ 1000000 +#define QTMR_FREQ (144000000/128) + +#define SM_SPACING (IMXRT_FLEXPWM_SM1CNT_OFFSET-IMXRT_FLEXPWM_SM0CNT_OFFSET) + +#define FLEXPWM_TIMER_BASE IMXRT_FLEXPWM2_BASE + +/* Register accessors */ +#define _REG(_addr) (*(volatile uint16_t *)(_addr)) +#define _REG16(_base, _reg) (*(volatile uint16_t *)(_base + _reg)) +#define FLEXPWMREG(_tmr, _sm, _reg) _REG16(_tmr + ((_sm) * SM_SPACING), (_reg)) + +/* FlexPWM Registers for LED_G */ +#define rINIT(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0INIT_OFFSET) /* Initial Count Register */ +#define rCTRL(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0CTRL_OFFSET) /* Control Register */ +#define rCTRL2(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0CTRL2_OFFSET) /* Control 2 Register */ +#define rFSTS0(_tim) FLEXPWMREG(_tim, 0, IMXRT_FLEXPWM_FSTS0_OFFSET) /* Fault Status Register */ +#define rVAL0(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0VAL0_OFFSET) /* Value Register 0 */ +#define rVAL1(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0VAL1_OFFSET) /* Value Register 1 */ +#define rVAL2(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0VAL2_OFFSET) /* Value Register 2 */ +#define rVAL3(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0VAL3_OFFSET) /* Value Register 3 */ +#define rVAL4(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0VAL4_OFFSET) /* Value Register 4 */ +#define rVAL5(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0VAL5_OFFSET) /* Value Register 5 */ +#define rFFILT0(_tim) FLEXPWMREG(_tim, 0, IMXRT_FLEXPWM_FFILT0_OFFSET) /* Fault Filter Register */ +#define rDISMAP0(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0DISMAP0_OFFSET) /* Fault Disable Mapping Register 0 */ +#define rDISMAP1(_tim, _sm) FLEXPWMREG(_tim, _sm,IMXRT_FLEXPWM_SM0DISMAP1_OFFSET) /* Fault Disable Mapping Register 1 */ +#define rOUTEN(_tim) FLEXPWMREG(_tim, 0, IMXRT_FLEXPWM_OUTEN_OFFSET) /* Output Enable Register */ +#define rDTSRCSEL(_tim) FLEXPWMREG(_tim, 0, IMXRT_FLEXPWM_DTSRCSEL_OFFSET) /* PWM Source Select Register */ +#define rMCTRL(_tim) FLEXPWMREG(_tim, 0, IMXRT_FLEXPWM_MCTRL_OFFSET) /* Master Control Register */ + +#define OUTEN_A_MASK 0x1 +#define OUTEN_B_MASK 0x2 + +#define FREQ + +static void flexpwm_led(uint32_t timer, uint32_t sm, uint16_t cvalue, uint32_t gpio_mux, uint32_t pwm_mux, + uint32_t out_mask) +{ + if (cvalue == 0) { + //rMCTRL(timer) &= ~MCTRL_RUN(1 << sm); + px4_arch_configgpio(gpio_mux); + + } else { + rMCTRL(timer) |= (1 << (sm + MCTRL_CLDOK_SHIFT)); + rVAL1(timer, sm) = (FLEXPWM_FREQ / LED_PWM_FREQ) - 1; + + if (out_mask & OUTEN_A_MASK) { + rVAL3(timer, sm) = (FLEXPWM_FREQ / LED_PWM_FREQ) - (cvalue); + + } else if (out_mask & OUTEN_B_MASK) { + rVAL5(timer, sm) = (FLEXPWM_FREQ / LED_PWM_FREQ) - (cvalue); + } + + rMCTRL(timer) |= MCTRL_LDOK(1 << sm) | MCTRL_RUN(1 << sm); + px4_arch_configgpio(pwm_mux); + } +} + +int +led_pwm_servo_set(unsigned channel, uint8_t cvalue) +{ + if (channel == 0) { + flexpwm_led(IMXRT_FLEXPWM3_BASE, 2, cvalue, GPIO_nLED_RED, PWM_LED_RED, OUTEN_A_MASK); + + } else if (channel == 1) { + flexpwm_led(IMXRT_FLEXPWM1_BASE, 3, cvalue, GPIO_nLED_GREEN, PWM_LED_GREEN, OUTEN_A_MASK); + + } else if (channel == 2) { + flexpwm_led(IMXRT_FLEXPWM3_BASE, 2, cvalue * 3, GPIO_nLED_BLUE, PWM_LED_BLUE, OUTEN_B_MASK); + } + + return 0; +} + +void flexpwm_init(uint32_t timer, uint32_t sm, uint32_t out_mask) +{ + /* Clear all Faults */ + rFSTS0(timer) = FSTS_FFLAG_MASK; + rMCTRL(timer) |= (1 << (sm + MCTRL_CLDOK_SHIFT)); + + rCTRL2(timer, sm) = SMCTRL2_CLK_SEL_EXT_CLK | SMCTRL2_DBGEN | SMCTRL2_INDEP; + rCTRL(timer, sm) = SMCTRL_PRSC_DIV16 | SMCTRL_FULL; + /* Edge aligned at 0 */ + rINIT(timer, sm) = 0; + rVAL0(timer, sm) = 0; + rVAL2(timer, sm) = 0; + rVAL4(timer, sm) = 0; + rFFILT0(timer) &= ~FFILT_FILT_PER_MASK; + rDISMAP0(timer, sm) = 0xf000; + rDISMAP1(timer, sm) = 0xf000; + + + if (out_mask & OUTEN_A_MASK) { + rOUTEN(timer) |= OUTEN_PWMA_EN(1 << sm); + } + + if (out_mask & OUTEN_B_MASK) { + rOUTEN(timer) |= OUTEN_PWMB_EN(1 << sm); + } + + rDTSRCSEL(timer) = 0; + rMCTRL(timer) |= MCTRL_LDOK(1 << sm); +} + +int led_pwm_servo_init() +{ + /* PWM_LED_GREEN - FLEXPWM2_PWMB03 */ + imxrt_clockall_pwm1(); + imxrt_clockall_pwm3(); + + flexpwm_init(IMXRT_FLEXPWM3_BASE, 2, OUTEN_A_MASK | OUTEN_B_MASK); // GPIO_FLEXPWM3_PWMA02_1 + flexpwm_init(IMXRT_FLEXPWM1_BASE, 3, OUTEN_A_MASK); // GPIO_FLEXPWM1_PWMA03_2 + + + + return OK; +} diff --git a/boards/nxp/mr-tropic/src/usb.c b/boards/nxp/mr-tropic/src/usb.c new file mode 100644 index 0000000000..cae9750e9c --- /dev/null +++ b/boards/nxp/mr-tropic/src/usb.c @@ -0,0 +1,129 @@ +/**************************************************************************** + * + * Copyright (C) 2024 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 usb.c + * + * Board-specific USB functions. + */ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include "board_config.h" +#include "imxrt_periphclks.h" + +/************************************************************************************ + * Definitions + ************************************************************************************/ + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ +int imxrt_usb_initialize(void) +{ + imxrt_clockall_usboh3(); + return 0; +} +/************************************************************************************ + * Name: imxrt_usbpullup + * + * Description: + * If USB is supported and the board supports a pullup via GPIO (for USB software + * connect and disconnect), then the board software must provide imxrt_usbpullup. + * See include/nuttx/usb/usbdev.h for additional description of this method. + * Alternatively, if no pull-up GPIO the following EXTERN can be redefined to be + * NULL. + * + ************************************************************************************/ + +__EXPORT +int imxrt_usbpullup(FAR struct usbdev_s *dev, bool enable) +{ + usbtrace(TRACE_DEVPULLUP, (uint16_t)enable); + + return OK; +} + +/************************************************************************************ + * Name: imxrt_usbsuspend + * + * Description: + * Board logic must provide the imxrt_usbsuspend logic if the USBDEV driver is + * used. This function is called whenever the USB enters or leaves suspend mode. + * This is an opportunity for the board logic to shutdown clocks, power, etc. + * while the USB is suspended. + * + ************************************************************************************/ + +__EXPORT +void imxrt_usbsuspend(FAR struct usbdev_s *dev, bool resume) +{ + uinfo("resume: %d\n", resume); +} + +/************************************************************************************ + * Name: board_read_VBUS_state + * + * Description: + * All boards must provide a way to read the state of VBUS, this my be simple + * digital input on a GPIO. Or something more complicated like a Analong input + * or reading a bit from a USB controller register. + * + * Returns - 0 if connected. + * + ************************************************************************************/ + +int board_read_VBUS_state(void) +{ + + return (getreg32(IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT) & USB_ANALOG_USB_VBUS_DETECT_STAT_VBUS_VALID) ? 0 : 1; +} diff --git a/boards/nxp/tropic-community/default.px4board b/boards/nxp/tropic-community/default.px4board index abbef2d0c0..04687d4a47 100644 --- a/boards/nxp/tropic-community/default.px4board +++ b/boards/nxp/tropic-community/default.px4board @@ -14,6 +14,7 @@ CONFIG_DRIVERS_CAMERA_TRIGGER=y CONFIG_DRIVERS_CDCACM_AUTOSTART=y CONFIG_COMMON_DIFFERENTIAL_PRESSURE=y CONFIG_COMMON_DISTANCE_SENSOR=y +CONFIG_DRIVERS_DISTANCE_SENSOR_LIGHTWARE_SF45_SERIAL=y CONFIG_DRIVERS_DSHOT=y CONFIG_DRIVERS_GNSS_SEPTENTRIO=y CONFIG_DRIVERS_GPS=y @@ -26,12 +27,12 @@ CONFIG_COMMON_LIGHT=y CONFIG_DRIVERS_LIGHTS_RGBLED_PWM=y CONFIG_COMMON_MAGNETOMETER=y CONFIG_COMMON_OPTICAL_FLOW=y -CONFIG_COMMON_OSD=y +CONFIG_DRIVERS_OSD_MSP_OSD=y CONFIG_DRIVERS_POWER_MONITOR_INA226=y CONFIG_DRIVERS_POWER_MONITOR_INA228=y CONFIG_DRIVERS_POWER_MONITOR_INA238=y CONFIG_DRIVERS_PWM_OUT=y -CONFIG_DRIVERS_RC_INPUT=y +CONFIG_COMMON_RC=y CONFIG_DRIVERS_SAFETY_BUTTON=y CONFIG_COMMON_TELEMETRY=y CONFIG_DRIVERS_TONE_ALARM=y @@ -44,13 +45,15 @@ CONFIG_MODULES_CAMERA_FEEDBACK=y CONFIG_MODULES_COMMANDER=y CONFIG_MODULES_CONTROL_ALLOCATOR=y CONFIG_MODULES_DATAMAN=y +CONFIG_NUM_MISSION_ITMES_SUPPORTED=1000 CONFIG_MODULES_EKF2=y CONFIG_MODULES_ESC_BATTERY=y CONFIG_MODULES_EVENTS=y CONFIG_MODULES_FLIGHT_MODE_MANAGER=y CONFIG_MODULES_FW_ATT_CONTROL=y CONFIG_MODULES_FW_AUTOTUNE_ATTITUDE_CONTROL=y -CONFIG_MODULES_FW_POS_CONTROL=y +CONFIG_MODULES_FW_LATERAL_LONGITUDINAL_CONTROL=y +CONFIG_MODULES_FW_MODE_MANAGER=y CONFIG_MODULES_FW_RATE_CONTROL=y CONFIG_MODULES_GIMBAL=y CONFIG_MODULES_GYRO_CALIBRATION=y @@ -100,3 +103,4 @@ CONFIG_SYSTEMCMDS_UORB=y CONFIG_SYSTEMCMDS_USB_CONNECTED=y CONFIG_SYSTEMCMDS_VER=y CONFIG_SYSTEMCMDS_WORK_QUEUE=y +CONFIG_ARCH_CHIP_IMXRT=y diff --git a/boards/nxp/tropic-community/init/rc.board_defaults b/boards/nxp/tropic-community/init/rc.board_defaults index 8a49eca594..31ed136105 100644 --- a/boards/nxp/tropic-community/init/rc.board_defaults +++ b/boards/nxp/tropic-community/init/rc.board_defaults @@ -12,10 +12,6 @@ param set-default MAV_2_RATE 100000 param set-default MAV_2_REMOTE_PRT 14550 param set-default MAV_2_UDP_PRT 14550 -param set-default SENS_EN_INA238 0 -param set-default SENS_EN_INA228 0 -param set-default SENS_EN_INA226 0 - param set-default BAT1_V_DIV 18.000000000 param set-default BAT1_A_PER_V 38.462030303 diff --git a/boards/nxp/tropic-community/nuttx-config/nsh/defconfig b/boards/nxp/tropic-community/nuttx-config/nsh/defconfig index 051887c166..4c2720028b 100644 --- a/boards/nxp/tropic-community/nuttx-config/nsh/defconfig +++ b/boards/nxp/tropic-community/nuttx-config/nsh/defconfig @@ -62,7 +62,9 @@ CONFIG_FS_CROMFS=y CONFIG_FS_FAT=y CONFIG_FS_FATTIME=y CONFIG_FS_LITTLEFS=y -CONFIG_FS_LITTLEFS_PROGRAM_SIZE_FACTOR=2 +CONFIG_FS_LITTLEFS_CACHE_SIZE_FACTOR=2 +CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE=64 +CONFIG_FS_LITTLEFS_PROGRAM_SIZE_FACTOR=1 CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS_MAX_TASKS=64 CONFIG_FS_PROCFS_REGISTER=y @@ -75,6 +77,7 @@ CONFIG_I2C=y CONFIG_I2C_RESET=y CONFIG_IDLETHREAD_STACKSIZE=2048 CONFIG_IMXRT_DTCM_HEAP=y +CONFIG_IMXRT_DTCM_HEAP_SIZE=127 CONFIG_IMXRT_EDMA=y CONFIG_IMXRT_EDMA_EDBG=y CONFIG_IMXRT_EDMA_ELINK=y @@ -84,8 +87,6 @@ CONFIG_IMXRT_ENET_NTXBUFFERS=8 CONFIG_IMXRT_ENET_PHYINIT=y CONFIG_IMXRT_FLEXCAN3=y CONFIG_IMXRT_FLEXCAN_TXMB=1 -CONFIG_IMXRT_FLEXSPI1=y -CONFIG_IMXRT_FLEXSPI1_XIP=y CONFIG_IMXRT_GPIO1_0_15_IRQ=y CONFIG_IMXRT_GPIO1_16_31_IRQ=y CONFIG_IMXRT_GPIO2_0_15_IRQ=y diff --git a/boards/nxp/tropic-community/nuttx-config/scripts/itcm_static_functions.ld b/boards/nxp/tropic-community/nuttx-config/scripts/itcm_static_functions.ld index a14521a6b5..509d820fd4 100644 --- a/boards/nxp/tropic-community/nuttx-config/scripts/itcm_static_functions.ld +++ b/boards/nxp/tropic-community/nuttx-config/scripts/itcm_static_functions.ld @@ -115,18 +115,29 @@ *(.text.work_thread) *(.text.work_queue) -/* Flash Storage */ -*(.text.imxrt_flexspi_transfer_blocking) -*(.text.imxrt_flexspi_transfer_blocking_private) -*(.text.imxrt_flexspi_write_blocking) -*(.text.imxrt_flexspi_read_blocking) -*(.text.imxrt_flexspi_check_and_clear_error) -*(.text.imxrt_flexspi_get_bus_idle_status) -*(.text.imxrt_flexspi_configure_prefetch) -*(.text.imxrt_flexspi_configure_prefetch_private) -*(.text.imxrt_flexspi_storage_write_enable) -*(.text.imxrt_flexspi_storage_wait_bus_busy) -*(.text.imxrt_flexspi_storage_read_status) -*(.text.imxrt_flexspi_storage_erase) -*(.text.imxrt_flexspi_storage_bwrite) -*(.text.imxrt_flexspi_storage_page_program) +/* BMI088 */ +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer12RegisterReadENS1_8RegisterE) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer13FIFOReadCountEv) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer8FIFOReadERKyh) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer13RegisterCheckERKNS2_17register_config_tE) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer13RegisterWriteENS1_8RegisterEh) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer17UpdateTemperatureEv) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer23RegisterSetAndClearBitsENS1_8RegisterEhh) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer26DataReadyInterruptCallbackEiPvS3_) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer7RunImplEv) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_Accelerometer9DataReadyEv) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_AccelerometerD0Ev) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_AccelerometerD1Ev) +*(.text._ZN5Bosch6BMI08813Accelerometer20BMI088_AccelerometerD2Ev) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope12RegisterReadENS1_8RegisterE) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope13RegisterCheckERKNS2_17register_config_tE) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope13RegisterWriteENS1_8RegisterEh) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope23RegisterSetAndClearBitsENS1_8RegisterEhh) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope26DataReadyInterruptCallbackEiPvS3_) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope7RunImplEv) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope8FIFOReadERKyh) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_Gyroscope9DataReadyEv) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_GyroscopeD0Ev) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_GyroscopeD1Ev) +*(.text._ZN5Bosch6BMI0889Gyroscope16BMI088_GyroscopeD2Ev) +*(.text._ZN12I2CSPIDriverI6BMI088E3RunEv) diff --git a/boards/nxp/tropic-community/nuttx-config/scripts/script.ld b/boards/nxp/tropic-community/nuttx-config/scripts/script.ld index 9c25a7e1a2..1e4ae18285 100644 --- a/boards/nxp/tropic-community/nuttx-config/scripts/script.ld +++ b/boards/nxp/tropic-community/nuttx-config/scripts/script.ld @@ -22,10 +22,11 @@ MEMORY { - flash (rx) : ORIGIN = 0x60000000, LENGTH = 7936K - 128K + flash (rx) : ORIGIN = 0x60000000, LENGTH = 7936K - 256K sram (rwx) : ORIGIN = 0x20200000, LENGTH = 512K itcm (rwx) : ORIGIN = 0x00000000, LENGTH = 384K - dtcm (rwx) : ORIGIN = 0x20000000, LENGTH = 128K + dtcm (rwx) : ORIGIN = 0x20000000, LENGTH = 127K + dtcm_nocache (rwx) : ORIGIN = 0x2001FC00, LENGTH = 1K } OUTPUT_ARCH(arm) @@ -55,6 +56,12 @@ SECTIONS . = 0x2000 ; } >flash + /* Workaround for ethernet issue, by placing g_desc_pool into DTCM, + which effectively puts it into a no-cache region */ + .dtcm_nocache : { + *(.bss.g_desc_pool) + } > dtcm_nocache + .vectors : { KEEP(*(.vectors)) @@ -162,6 +169,10 @@ SECTIONS .debug_line 0 : { *(.debug_line) } .debug_pubnames 0 : { *(.debug_pubnames) } .debug_aranges 0 : { *(.debug_aranges) } + + _boot_loadaddr = ORIGIN(flash); + _boot_size = LENGTH(flash); + _ram_size = LENGTH(sram); _sdtcm = ORIGIN(dtcm); _edtcm = ORIGIN(dtcm) + LENGTH(dtcm); } diff --git a/boards/nxp/tropic-community/src/CMakeLists.txt b/boards/nxp/tropic-community/src/CMakeLists.txt index 6c37994652..f77e6b4a84 100644 --- a/boards/nxp/tropic-community/src/CMakeLists.txt +++ b/boards/nxp/tropic-community/src/CMakeLists.txt @@ -51,6 +51,8 @@ set_source_files_properties(imxrt_ocram_initialize.c PROPERTIES COMPILE_FLAGS -f target_link_libraries(drivers_board PRIVATE + arch_board_romapi + arch_spi nuttx_arch # sdio nuttx_drivers # sdio px4_layer diff --git a/boards/nxp/tropic-community/src/board_config.h b/boards/nxp/tropic-community/src/board_config.h index 83bbd101e2..4d422f9650 100644 --- a/boards/nxp/tropic-community/src/board_config.h +++ b/boards/nxp/tropic-community/src/board_config.h @@ -112,7 +112,6 @@ #define GPIO_DRDY_OFF_SPI4_DRDY7_EXTERNAL1 _PIN_OFF(GPIO_SPI4_DRDY7_EXTERNAL1) - #define ADC_IOMUX (IOMUX_CMOS_INPUT | IOMUX_PULL_NONE | IOMUX_DRIVE_HIZ) #define ADC1_CH(n) (n) @@ -262,6 +261,10 @@ static inline int board_read_usb2_vbus_state(void) } #define BOARD_ENABLE_CONSOLE_BUFFER + +/* Flash instance for storage */ +#define NOR_INSTANCE 0 + __BEGIN_DECLS /**************************************************************************************************** @@ -316,6 +319,8 @@ extern int imxrt1062_spi_bus_initialize(void); * ************************************************************************************/ +extern void imxrt_spiinitialize(void); + extern int imxrt_usb_initialize(void); extern void imxrt_usbinitialize(void); @@ -326,6 +331,8 @@ extern void fmurt1062_timer_initialize(void); #include +void imxrt_flash_romapi_initialize(void); + int imxrt_flexspi_storage_initialize(void); #endif /* __ASSEMBLY__ */ diff --git a/boards/nxp/tropic-community/src/imxrt_flexspi_nor_flash.c b/boards/nxp/tropic-community/src/imxrt_flexspi_nor_flash.c index f7ffe4e46d..39460ffaf9 100644 --- a/boards/nxp/tropic-community/src/imxrt_flexspi_nor_flash.c +++ b/boards/nxp/tropic-community/src/imxrt_flexspi_nor_flash.c @@ -28,55 +28,71 @@ * Public Data ****************************************************************************/ +enum { + /* SPI instructions */ + + READ_FAST = 0, + READ_STATUS_REG = 1, + WRITE_ENABLE = 3, + SECTOR_ERASE_4K = 5, + READ_FAST_QUAD_OUTPUT = 6, + PAGE_PROGRAM_QUAD_INPUT = 7, + ERASE_BLOCK = 8, + PAGE_PROGRAM = 9, + CHIP_ERASE = 11, +}; + locate_data(".boot_hdr.conf") const struct flexspi_nor_config_s g_flash_config = { .mem_config = { - .tag = FLEXSPI_CFG_BLK_TAG, - .version = FLEXSPI_CFG_BLK_VERSION, - .read_sample_clksrc = FLASH_READ_SAMPLE_CLK_LOOPBACK_FROM_SCKPAD, - .cs_hold_time = 1u, - .cs_setup_time = 1u, - .column_address_width = 0u, - .device_type = FLEXSPI_DEVICE_TYPE_SERIAL_NOR, - .sflash_pad_type = SERIAL_FLASH_4PADS, - .serial_clk_freq = FLEXSPI_SERIAL_CLKFREQ_133MHz, - .sflash_a1size = 8u * 1024u * 1024u, - .data_valid_time = + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .read_sample_clksrc = FLASH_READ_SAMPLE_CLK_LOOPBACK_FROM_SCKPAD, + .cs_hold_time = 1u, + .cs_setup_time = 1u, + .column_address_width = 0u, + .device_type = FLEXSPI_DEVICE_TYPE_SERIAL_NOR, + .sflash_pad_type = SERIAL_FLASH_4PADS, + .serial_clk_freq = FLEXSPI_SERIAL_CLKFREQ_133MHz, + .sflash_a1size = 8u * 1024u * 1024u, + .lookup_table = { - 0u, 0u - }, - .lookup_table = - { - /* Fast Read Quad I/O */ - [0 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xeb, - RADDR_SDR, FLEXSPI_4PAD, 0x18), - [0 + 1] = FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, - READ_SDR, FLEXSPI_4PAD, 0x04), + [4 * READ_FAST] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xeb, + RADDR_SDR, FLEXSPI_4PAD, 0x18), + [4 * READ_FAST + 1] = FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, + READ_SDR, FLEXSPI_4PAD, 0x04), - /* Read Status Register-1 */ - [4 * 1 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05, - READ_SDR, FLEXSPI_1PAD, 0x04), + [4 * READ_STATUS_REG] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05, + READ_SDR, FLEXSPI_1PAD, 0x04), - /* Write Status Register-1 */ - [4 * 3 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x01, STOP, FLEXSPI_1PAD, 0x0), + [4 * WRITE_ENABLE] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06, + STOP, FLEXSPI_1PAD, 0), - /* Sector Erase (4KB) */ - [4 * 5 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20, - RADDR_SDR, FLEXSPI_1PAD, 0x18), + [4 * SECTOR_ERASE_4K] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20, + RADDR_SDR, FLEXSPI_1PAD, 0x18), - /* Block Erase (64KB) */ - [4 * 8 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xd8, - RADDR_SDR, FLEXSPI_1PAD, 0x18), + [4 * CHIP_ERASE] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60, + STOP, FLEXSPI_1PAD, 0), - /* Page Program */ - [4 * 9 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02, - RADDR_SDR, FLEXSPI_1PAD, 0x18), - [4 * 9 + 1] = FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04, - STOP, FLEXSPI_1PAD, 0x0), + [4 * ERASE_BLOCK] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xd8, + RADDR_SDR, FLEXSPI_1PAD, 0x18), + + [4 * PAGE_PROGRAM] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02, + RADDR_SDR, FLEXSPI_1PAD, 0x18), + [4 * PAGE_PROGRAM + 1] = FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04, + STOP, FLEXSPI_1PAD, 0x0), + + [4 * READ_FAST_QUAD_OUTPUT] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x6b, + RADDR_SDR, FLEXSPI_1PAD, 0x18), + [4 * READ_FAST_QUAD_OUTPUT + 1] = FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x08, + READ_SDR, FLEXSPI_4PAD, 0x04), + + [4 * PAGE_PROGRAM_QUAD_INPUT] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x32, + RADDR_SDR, FLEXSPI_1PAD, 0x18), + [4 * PAGE_PROGRAM_QUAD_INPUT + 1] = FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_4PAD, 0x04, + STOP, FLEXSPI_1PAD, 0), - /* Chip Erase */ - [4 * 11 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60, STOP, FLEXSPI_1PAD, 0x0), }, }, diff --git a/boards/nxp/tropic-community/src/imxrt_flexspi_storage.c b/boards/nxp/tropic-community/src/imxrt_flexspi_storage.c index f3ac06804f..605688afa4 100644 --- a/boards/nxp/tropic-community/src/imxrt_flexspi_storage.c +++ b/boards/nxp/tropic-community/src/imxrt_flexspi_storage.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/px4/fmu-v6xrt/src/imxrt_flexspi_storage.c + * boards/nxp/tropic-community/src/imxrt_flexspi_storage.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -36,104 +36,28 @@ #include #include "px4_log.h" -#include "imxrt_flexspi.h" +#include +#include #include "board_config.h" #include "hardware/imxrt_pinmux.h" - -#ifdef CONFIG_IMXRT_FLEXSPI +#include "barriers.h" /* Used sectors must be multiple of the flash block size * i.e. W25Q32JV has a block size of 64KB */ -#define NOR_USED_SECTORS (0x20U) /* 32 * 4KB = 128KB */ +#define NOR_USED_SECTORS (0x40U) /* 64 * 4KB = 256KB */ #define NOR_TOTAL_SECTORS (0x0800U) #define NOR_PAGE_SIZE (0x0100U) /* 256 bytes */ #define NOR_SECTOR_SIZE (0x1000U) /* 4KB */ #define NOR_START_SECTOR (NOR_TOTAL_SECTORS - NOR_USED_SECTORS) #define NOR_START_PAGE ((NOR_START_SECTOR * NOR_SECTOR_SIZE) / NOR_PAGE_SIZE) #define NOR_STORAGE_ADDR (IMXRT_FLEXCIPHER_BASE + NOR_START_SECTOR * NOR_SECTOR_SIZE) +#define NOR_STORAGE_END (IMXRT_FLEXCIPHER_BASE + (NOR_START_SECTOR + NOR_TOTAL_SECTORS) * NOR_SECTOR_SIZE) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) -enum { - /* SPI instructions */ - - READ_FAST = 0, - READ_STATUS_REG = 1, - WRITE_STATUS_REG = 3, - WRITE_ENABLE = 4, - SECTOR_ERASE_4K = 5, - READ_FAST_QUAD_OUTPUT = 6, - PAGE_PROGRAM_QUAD_INPUT = 7, - PAGE_PROGRAM = 9, - CHIP_ERASE = 11, -}; - -static const uint32_t g_flexspi_nor_lut[][4] = { - [READ_FAST] = - { - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_SDR, FLEXSPI_1PAD, 0xeb, - FLEXSPI_COMMAND_RADDR_SDR, FLEXSPI_4PAD, 0x18), - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_DUMMY_SDR, FLEXSPI_4PAD, 0x06, - FLEXSPI_COMMAND_READ_SDR, FLEXSPI_4PAD, 0x04), - }, - - [READ_STATUS_REG] = - { - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_SDR, FLEXSPI_1PAD, 0x05, - FLEXSPI_COMMAND_READ_SDR, FLEXSPI_1PAD, 0x04), - }, - - [WRITE_STATUS_REG] = - { - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_SDR, FLEXSPI_1PAD, 0x01, - FLEXSPI_COMMAND_WRITE_SDR, FLEXSPI_1PAD, 0x04), - }, - - [WRITE_ENABLE] = - { - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_SDR, FLEXSPI_1PAD, 0x06, - FLEXSPI_COMMAND_STOP, FLEXSPI_1PAD, 0), - }, - - [SECTOR_ERASE_4K] = - { - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_SDR, FLEXSPI_1PAD, 0x20, - FLEXSPI_COMMAND_RADDR_SDR, FLEXSPI_1PAD, 0x18), - }, - - [CHIP_ERASE] = - { - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_SDR, FLEXSPI_1PAD, 0xc7, - FLEXSPI_COMMAND_STOP, FLEXSPI_1PAD, 0), - }, - - [PAGE_PROGRAM] = - { - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_SDR, FLEXSPI_1PAD, 0x02, - FLEXSPI_COMMAND_RADDR_SDR, FLEXSPI_1PAD, 0x18), - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_WRITE_SDR, FLEXSPI_1PAD, 0x04, - FLEXSPI_COMMAND_STOP, FLEXSPI_1PAD, 0x0), - }, - - [READ_FAST_QUAD_OUTPUT] = - { - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_SDR, FLEXSPI_1PAD, 0x6b, - FLEXSPI_COMMAND_RADDR_SDR, FLEXSPI_1PAD, 0x18), - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_DUMMY_SDR, FLEXSPI_4PAD, 0x08, - FLEXSPI_COMMAND_READ_SDR, FLEXSPI_4PAD, 0x04), - }, - - [PAGE_PROGRAM_QUAD_INPUT] = - { - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_SDR, FLEXSPI_1PAD, 0x32, - FLEXSPI_COMMAND_RADDR_SDR, FLEXSPI_1PAD, 0x18), - FLEXSPI_LUT_SEQ(FLEXSPI_COMMAND_WRITE_SDR, FLEXSPI_4PAD, 0x04, - FLEXSPI_COMMAND_STOP, FLEXSPI_1PAD, 0), - }, - -}; +extern struct flexspi_nor_config_s g_bootConfig; /**************************************************************************** * Private Types @@ -143,10 +67,7 @@ static const uint32_t g_flexspi_nor_lut[][4] = { struct imxrt_flexspi_storage_dev_s { struct mtd_dev_s mtd; - struct flexspi_dev_s *flexspi; /* Saved FlexSPI interface instance */ uint8_t *ahb_base; - enum flexspi_port_e port; - struct flexspi_device_config_s *config; }; /**************************************************************************** @@ -178,26 +99,6 @@ static int imxrt_flexspi_storage_ioctl(struct mtd_dev_s *dev, * Private Data ****************************************************************************/ -static struct flexspi_device_config_s g_flexspi_device_config = { - .flexspi_root_clk = 4000000, - .is_sck2_enabled = 0, - .flash_size = NOR_USED_SECTORS * NOR_SECTOR_SIZE / 4, - .cs_interval_unit = FLEXSPI_CS_INTERVAL_UNIT1_SCK_CYCLE, - .cs_interval = 0, - .cs_hold_time = 3, - .cs_setup_time = 3, - .data_valid_time = 0, - .columnspace = 0, - .enable_word_address = 0, - .awr_seq_index = 0, - .awr_seq_number = 0, - .ard_seq_index = READ_FAST, - .ard_seq_number = 1, - .ahb_write_wait_unit = FLEXSPI_AHB_WRITE_WAIT_UNIT2_AHB_CYCLE, - .ahb_write_wait_interval = 0, - .rx_sample_clock = FLEXSPI_READ_SAMPLE_CLK_LOOPBACK_FROM_DQS_PAD, -}; - static struct imxrt_flexspi_storage_dev_s g_flexspi_nor = { .mtd = { @@ -211,90 +112,17 @@ static struct imxrt_flexspi_storage_dev_s g_flexspi_nor = { #endif .name = "imxrt_flexspi_storage" }, - .flexspi = (void *)0, .ahb_base = (uint8_t *) NOR_STORAGE_ADDR, - .port = FLEXSPI_PORT_A1, - .config = &g_flexspi_device_config }; +/* Ensure exclusive access to the driver */ + +static sem_t g_exclsem = SEM_INITIALIZER(1); + /**************************************************************************** * Private Functions ****************************************************************************/ -static int imxrt_flexspi_storage_read_status( - const struct imxrt_flexspi_storage_dev_s *dev, - uint32_t *status) -{ - int stat; - - struct flexspi_transfer_s transfer = { - .device_address = 0, - .port = dev->port, - .cmd_type = FLEXSPI_READ, - .seq_number = 1, - .seq_index = READ_STATUS_REG, - .data = status, - .data_size = 1, - }; - - stat = FLEXSPI_TRANSFER(dev->flexspi, &transfer); - - if (stat != 0) { - return -EIO; - } - - return 0; -} - -static int imxrt_flexspi_storage_write_enable( - const struct imxrt_flexspi_storage_dev_s *dev) -{ - int stat; - - struct flexspi_transfer_s transfer = { - .device_address = 0, - .port = dev->port, - .cmd_type = FLEXSPI_COMMAND, - .seq_number = 1, - .seq_index = WRITE_ENABLE, - .data = NULL, - .data_size = 0, - }; - - stat = FLEXSPI_TRANSFER(dev->flexspi, &transfer); - - if (stat != 0) { - return -EIO; - } - - return 0; -} - -static int imxrt_flexspi_storage_erase_sector( - const struct imxrt_flexspi_storage_dev_s *dev, - off_t offset) -{ - int stat; - struct flexspi_transfer_s transfer = { - .device_address = offset, - .port = dev->port, - .cmd_type = FLEXSPI_COMMAND, - .seq_number = 1, - .seq_index = SECTOR_ERASE_4K, - .data = NULL, - .data_size = 0, - }; - - stat = FLEXSPI_TRANSFER(dev->flexspi, &transfer); - - if (stat != 0) { - return -EIO; - } - - - return 0; -} - static int imxrt_flexspi_storage_erase_chip( const struct imxrt_flexspi_storage_dev_s *dev) { @@ -302,69 +130,38 @@ static int imxrt_flexspi_storage_erase_chip( return -EINVAL; } -static int imxrt_flexspi_storage_page_program( - const struct imxrt_flexspi_storage_dev_s *dev, - off_t offset, - const void *buffer, - size_t len) -{ - int stat; - - struct flexspi_transfer_s transfer = { - .device_address = offset, - .port = dev->port, - .cmd_type = FLEXSPI_WRITE, - .seq_number = 1, - .seq_index = PAGE_PROGRAM_QUAD_INPUT, - .data = (uint32_t *) buffer, - .data_size = len, - }; - - stat = FLEXSPI_TRANSFER(dev->flexspi, &transfer); - - if (stat != 0) { - return -EIO; - } - - return 0; -} - -static int imxrt_flexspi_storage_wait_bus_busy( - const struct imxrt_flexspi_storage_dev_s *dev) -{ - uint32_t status = 0; - int ret; - - do { - ret = imxrt_flexspi_storage_read_status(dev, &status); - - if (ret) { - return ret; - } - } while (status & 1); - - return 0; -} - static ssize_t imxrt_flexspi_storage_read(struct mtd_dev_s *dev, off_t offset, size_t nbytes, uint8_t *buffer) { + ssize_t ret; struct imxrt_flexspi_storage_dev_s *priv = (struct imxrt_flexspi_storage_dev_s *)dev; uint8_t *src; finfo("offset: %08lx nbytes: %d\n", (long)offset, (int)nbytes); - if (priv->port >= FLEXSPI_PORT_COUNT) { + if (offset < 0) { return -EIO; } src = priv->ahb_base + offset; + if (src + nbytes > (uint8_t *)NOR_STORAGE_END) { + return -EIO; + } + + ret = nxsem_wait(&g_exclsem); + + if (ret < 0) { + return ret; + } + memcpy(buffer, src, nbytes); + nxsem_post(&g_exclsem); + finfo("return nbytes: %d\n", (int)nbytes); return (ssize_t)nbytes; } @@ -392,85 +189,102 @@ static ssize_t imxrt_flexspi_storage_bread(struct mtd_dev_s *dev, return nbytes; } +locate_code(".ramfunc") static ssize_t imxrt_flexspi_storage_bwrite(struct mtd_dev_s *dev, off_t startblock, size_t nblocks, const uint8_t *buffer) { - struct imxrt_flexspi_storage_dev_s *priv = - (struct imxrt_flexspi_storage_dev_s *)dev; + ssize_t ret; + struct flexspi_nor_config_s *pConfig = &g_bootConfig; size_t len = nblocks * NOR_PAGE_SIZE; off_t offset = (startblock + NOR_START_PAGE) * NOR_PAGE_SIZE; uint8_t *src = (uint8_t *) buffer; #ifdef CONFIG_ARMV7M_DCACHE + struct imxrt_flexspi_storage_dev_s *priv = + (struct imxrt_flexspi_storage_dev_s *)dev; uint8_t *dst = priv->ahb_base + startblock * NOR_PAGE_SIZE; #endif int i; + if (((uintptr_t)buffer % 4) != 0) { + return -EINVAL; // Byte aligned write not supported + } + finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); - FLEXSPI_CONFIGURE_PREFETCH(priv->flexspi, false); + ret = nxsem_wait(&g_exclsem); - irqstate_t flags = enter_critical_section(); + if (ret < 0) { + return ret; + } while (len) { i = MIN(NOR_PAGE_SIZE, len); - imxrt_flexspi_storage_write_enable(priv); - imxrt_flexspi_storage_page_program(priv, offset, src, i); - imxrt_flexspi_storage_wait_bus_busy(priv); + cpsid(); // Disable interrupts +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" + volatile uint32_t status = ROM_FLEXSPI_NorFlash_ProgramPage(NOR_INSTANCE, pConfig, offset, (const uint32_t *)src); +#pragma GCC diagnostic pop + cpsie(); // Enable interrupts + usleep(0); // Yield to scheduler + UNUSED(status); + offset += i; src += i; len -= i; } - FLEXSPI_CONFIGURE_PREFETCH(priv->flexspi, true); - - leave_critical_section(flags); - #ifdef CONFIG_ARMV7M_DCACHE up_invalidate_dcache((uintptr_t)dst, (uintptr_t)dst + nblocks * NOR_PAGE_SIZE); #endif + nxsem_post(&g_exclsem); + return nblocks; } +locate_code(".ramfunc") static int imxrt_flexspi_storage_erase(struct mtd_dev_s *dev, off_t startblock, size_t nblocks) { - struct imxrt_flexspi_storage_dev_s *priv = - (struct imxrt_flexspi_storage_dev_s *)dev; + struct flexspi_nor_config_s *pConfig = &g_bootConfig; size_t blocksleft = nblocks; #ifdef CONFIG_ARMV7M_DCACHE + struct imxrt_flexspi_storage_dev_s *priv = + (struct imxrt_flexspi_storage_dev_s *)dev; uint8_t *dst = priv->ahb_base + startblock * NOR_SECTOR_SIZE; #endif + ssize_t ret; startblock += NOR_START_SECTOR; finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); - FLEXSPI_CONFIGURE_PREFETCH(priv->flexspi, false); + ret = nxsem_wait(&g_exclsem); - irqstate_t flags = enter_critical_section(); + if (ret < 0) { + return ret; + } while (blocksleft-- > 0) { /* Erase each sector */ - - imxrt_flexspi_storage_write_enable(priv); - imxrt_flexspi_storage_erase_sector(priv, startblock * NOR_SECTOR_SIZE); - imxrt_flexspi_storage_wait_bus_busy(priv); + cpsid(); // Disable interrupts + volatile uint32_t status = ROM_FLEXSPI_NorFlash_Erase(NOR_INSTANCE, pConfig, + (startblock * NOR_SECTOR_SIZE), NOR_SECTOR_SIZE); + cpsie(); // Enable interrupts + usleep(0); // Yield to scheduler + UNUSED(status); startblock++; } - FLEXSPI_CONFIGURE_PREFETCH(priv->flexspi, true); - - leave_critical_section(flags); - #ifdef CONFIG_ARMV7M_DCACHE up_invalidate_dcache((uintptr_t)dst, (uintptr_t)dst + nblocks * NOR_SECTOR_SIZE); #endif + nxsem_post(&g_exclsem); return (int)nblocks; } @@ -530,9 +344,7 @@ static int imxrt_flexspi_storage_ioctl(struct mtd_dev_s *dev, case MTDIOC_BULKERASE: { /* Erase the entire device */ - imxrt_flexspi_storage_write_enable(priv); imxrt_flexspi_storage_erase_chip(priv); - imxrt_flexspi_storage_wait_bus_busy(priv); ret = OK; } break; @@ -569,20 +381,6 @@ int imxrt_flexspi_storage_initialize(void) struct mtd_dev_s *mtd_dev = &g_flexspi_nor.mtd; int ret = -ENODEV; - /* Select FlexSPI1 */ - - g_flexspi_nor.flexspi = imxrt_flexspi_initialize(0); - - if (g_flexspi_nor.flexspi) { - ret = OK; - - - FLEXSPI_UPDATE_LUT(g_flexspi_nor.flexspi, - 0, - (const uint32_t *)g_flexspi_nor_lut, - sizeof(g_flexspi_nor_lut) / 4); - } - /* Register the MTD driver so that it can be accessed from the * VFS. */ @@ -611,4 +409,3 @@ int imxrt_flexspi_storage_initialize(void) return ret; } -#endif /* CONFIG_IMXRT_FLEXSPI */ diff --git a/boards/nxp/tropic-community/src/init.c b/boards/nxp/tropic-community/src/init.c index a9c326f39c..f6caf0c816 100644 --- a/boards/nxp/tropic-community/src/init.c +++ b/boards/nxp/tropic-community/src/init.c @@ -64,9 +64,9 @@ #include #include -#include "arm_internal.h" #include "arm_internal.h" #include "imxrt_flexspi_nor_boot.h" +#include #include "imxrt_iomuxc.h" #include "imxrt_flexcan.h" #include "imxrt_enet.h" @@ -84,6 +84,7 @@ #include #include #include +#include #include #include #include @@ -144,6 +145,30 @@ __EXPORT void board_on_reset(int status) } } +/**************************************************************************** + * Name: imxrt_flash_romapi_initialize + * + * Description: + * + ****************************************************************************/ +struct flexspi_nor_config_s g_bootConfig; + +locate_code(".ramfunc") +void imxrt_flash_romapi_initialize(void) +{ + memcpy((struct flexspi_nor_config_s *)&g_bootConfig, &g_flash_config, + sizeof(struct flexspi_nor_config_s)); + g_bootConfig.memConfig.tag = FLEXSPI_CFG_BLK_TAG; + + ROM_API_Init(); + + ROM_FLEXSPI_NorFlash_Init(NOR_INSTANCE, (struct flexspi_nor_config_s *)&g_bootConfig); + ROM_FLEXSPI_NorFlash_ClearCache(NOR_INSTANCE); + + ARM_DSB(); + ARM_ISB(); + ARM_DMB(); +} locate_code(".ramfunc") void imxrt_flash_setup_prefetch_partition(void) @@ -207,6 +232,8 @@ __EXPORT void imxrt_boardinitialize(void) { imxrt_flash_setup_prefetch_partition(); + imxrt_flash_romapi_initialize(); + board_on_reset(-1); /* Reset PWM first thing */ /* configure LEDs */ @@ -218,10 +245,6 @@ __EXPORT void imxrt_boardinitialize(void) const uint32_t gpio[] = PX4_GPIO_INIT_LIST; px4_gpio_init(gpio, arraySize(gpio)); - /* configure SPI interfaces */ - - imxrt_spidev_initialize(); - imxrt_usb_initialize(); fmurt1062_timer_initialize(); @@ -330,14 +353,18 @@ void imxrt_flexio_clocking(void) ****************************************************************************/ __EXPORT int board_app_initialize(uintptr_t arg) { + int ret = OK; + +#if !defined(BOOTLOADER) + imxrt_flexio_clocking(); /* Power on Interfaces */ - board_spi_reset(10, 0xffff); - px4_platform_init(); + imxrt_spiinitialize(); + /* configure the DMA allocator */ if (board_dma_alloc_init() < 0) { @@ -350,14 +377,13 @@ __EXPORT int board_app_initialize(uintptr_t arg) hrt_call_every(&serial_dma_call, 1000, 1000, (hrt_callout)imxrt_serial_dma_poll, NULL); #endif - int ret = OK; #if defined(CONFIG_IMXRT_USDHC) ret = fmurt1062_usdhc_initialize(); #endif - /* Configure SPI-based devices */ + imxrt_spiinitialize(); - ret = imxrt1062_spi_bus_initialize(); + board_spi_reset(10, 0xffff); #ifdef CONFIG_IMXRT_ENET imxrt_netinitialize(0); @@ -367,7 +393,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) imxrt_caninitialize(3); #endif -#ifdef CONFIG_IMXRT_FLEXSPI ret = imxrt_flexspi_storage_initialize(); if (ret < 0) { @@ -375,7 +400,7 @@ __EXPORT int board_app_initialize(uintptr_t arg) "ERROR: imxrt_flexspi_nor_initialize failed: %d\n", ret); } -#endif +#endif /* !defined(BOOTLOADER) */ return ret; } diff --git a/boards/nxp/tropic-community/src/spi.cpp b/boards/nxp/tropic-community/src/spi.cpp index b267b18d06..a5e0f847b6 100644 --- a/boards/nxp/tropic-community/src/spi.cpp +++ b/boards/nxp/tropic-community/src/spi.cpp @@ -62,7 +62,6 @@ #if defined(CONFIG_IMXRT_LPSPI3) || defined(CONFIG_IMXRT_LPSPI4) - constexpr px4_spi_bus_t px4_spi_buses[SPI_BUS_MAX_BUS_ITEMS] = { initSPIBus(SPI::Bus::LPSPI3, { initSPIDevice(DRV_IMU_DEVTYPE_ICM42688P, SPI::CS{GPIO::Port1, GPIO::Pin28}), /* GPIO_AD_B1_12 GPIO1_IO28 */ @@ -75,241 +74,4 @@ constexpr px4_spi_bus_t px4_spi_buses[SPI_BUS_MAX_BUS_ITEMS] = { static constexpr bool unused = validateSPIConfig(px4_spi_buses); -#define _PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT | IOMUX_PULL_DOWN_100K | IOMUX_CMOS_INPUT)) - -/************************************************************************************ - * Public Functions - ************************************************************************************/ -/************************************************************************************ - * Name: fmurt1062_spidev_initialize - * - * Description: - * Called to configure SPI chip select GPIO pins for the NXP FMUKRT1062-V1 board. - * - ************************************************************************************/ - -void imxrt_spidev_initialize(void) -{ - for (int bus = 0; bus < SPI_BUS_MAX_BUS_ITEMS; ++bus) { - for (int i = 0; i < SPI_BUS_MAX_DEVICES; ++i) { - if (px4_spi_buses[bus].devices[i].cs_gpio != 0) { - px4_arch_configgpio(px4_spi_buses[bus].devices[i].cs_gpio); - } - } - } -} - -/************************************************************************************ - * Name: imxrt_spi_bus_initialize - * - * Description: - * Called to configure SPI chip select GPIO pins for the NXP FMUKRT1062-V1 board. - * - ************************************************************************************/ - -static const px4_spi_bus_t *_spi_bus3; -static const px4_spi_bus_t *_spi_bus4; - -__EXPORT int imxrt1062_spi_bus_initialize(void) -{ - for (int i = 0; i < SPI_BUS_MAX_BUS_ITEMS; ++i) { - switch (px4_spi_buses[i].bus) { - case 3: _spi_bus3 = &px4_spi_buses[i]; break; - - case 4: _spi_bus4 = &px4_spi_buses[i]; break; - } - } - - /* Configure SPI-based devices */ - - struct spi_dev_s *spi_icm = px4_spibus_initialize(3); - - if (!spi_icm) { - PX4_ERR("[boot] FAILED to initialize SPI port %d\n", 1); - return -ENODEV; - } - - /* Default bus 1 to 8MHz and de-assert the known chip selects. - */ - - SPI_SETFREQUENCY(spi_icm, 8 * 1000 * 1000); - SPI_SETBITS(spi_icm, 8); - SPI_SETMODE(spi_icm, SPIDEV_MODE3); - - /* Get the SPI port for the BMI088 */ - - struct spi_dev_s *spi_bmi = px4_spibus_initialize(4); - - if (!spi_bmi) { - PX4_ERR("[boot] FAILED to initialize SPI port %d\n", 4); - return -ENODEV; - } - - /* Default ext bus to 8MHz and de-assert the known chip selects. - */ - - SPI_SETFREQUENCY(spi_bmi, 8 * 1000 * 1000); - SPI_SETBITS(spi_bmi, 8); - SPI_SETMODE(spi_bmi, SPIDEV_MODE3); - - /* deselect all */ - for (int bus = 0; bus < SPI_BUS_MAX_BUS_ITEMS; ++bus) { - for (int i = 0; i < SPI_BUS_MAX_DEVICES; ++i) { - if (px4_spi_buses[bus].devices[i].cs_gpio != 0) { - SPI_SELECT(spi_bmi, px4_spi_buses[bus].devices[i].devid, false); - } - } - } - - return OK; - -} - -/**************************************************************************** - * Name: imxrt_lpspi1/2/3select and imxrt_lpspi1/2/3status - * - * Description: - * The external functions, imxrt_lpspi1/2/3select and imxrt_lpspi1/2/3status must be - * provided by board-specific logic. They are implementations of the select - * and status methods of the SPI interface defined by struct spi_ops_s (see - * include/nuttx/spi/spi.h). All other methods (including imxrt_lpspibus_initialize()) - * are provided by common STM32 logic. To use this common SPI logic on your - * board: - * - * 1. Provide logic in imxrt_boardinitialize() to configure SPI chip select - * pins. - * 2. Provide imxrt_lpspi1/2/3select() and imxrt_lpspi1/2/3status() functions in your - * board-specific logic. These functions will perform chip selection and - * status operations using GPIOs in the way your board is configured. - * 3. Add a calls to imxrt_lpspibus_initialize() in your low level application - * initialization logic - * 4. The handle returned by imxrt_lpspibus_initialize() may then be used to bind the - * SPI driver to higher level logic (e.g., calling - * mmcsd_spislotinitialize(), for example, will bind the SPI driver to - * the SPI MMC/SD driver). - * - ****************************************************************************/ - -static inline void imxrt_spixselect(const px4_spi_bus_t *bus, struct spi_dev_s *dev, uint32_t devid, bool selected) -{ - for (int i = 0; i < SPI_BUS_MAX_DEVICES; ++i) { - if (bus->devices[i].cs_gpio == 0) { - break; - } - - if (devid == bus->devices[i].devid) { - // SPI select is active low, so write !selected to select the device - imxrt_gpio_write(bus->devices[i].cs_gpio, !selected); - } - } -} - -#if defined(CONFIG_IMXRT_LPSPI3) -__EXPORT void imxrt_lpspi3select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) -{ - imxrt_spixselect(_spi_bus3, dev, devid, selected); -} - -__EXPORT uint8_t imxrt_lpspi3status(FAR struct spi_dev_s *dev, uint32_t devid) -{ - return SPI_STATUS_PRESENT; -} -#endif - -#if defined(CONFIG_IMXRT_LPSPI4) -__EXPORT void imxrt_lpspi4select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) -{ - imxrt_spixselect(_spi_bus4, dev, devid, selected); -} - -__EXPORT uint8_t imxrt_lpspi4status(FAR struct spi_dev_s *dev, uint32_t devid) -{ - return SPI_STATUS_PRESENT; -} -#endif - -/************************************************************************************ - * Name: board_spi_reset - * - * Description: - * - * - ************************************************************************************/ - -__EXPORT void board_spi_reset(int ms, int bus_mask) -{ -#ifdef CONFIG_IMXRT_LPSPI1 - - /* Goal not to back feed the chips on the bus via IO lines */ - for (int bus = 0; bus < SPI_BUS_MAX_BUS_ITEMS; ++bus) { - if (px4_spi_buses[bus].bus == 1 || px4_spi_buses[bus].bus == 3) { - for (int i = 0; i < SPI_BUS_MAX_DEVICES; ++i) { - if (px4_spi_buses[bus].devices[i].cs_gpio != 0) { - imxrt_config_gpio(_PIN_OFF(px4_spi_buses[bus].devices[i].cs_gpio)); - } - - if (px4_spi_buses[bus].devices[i].drdy_gpio != 0) { - imxrt_config_gpio(_PIN_OFF(px4_spi_buses[bus].devices[i].drdy_gpio)); - } - } - } - } - - imxrt_config_gpio(GPIO_SPI1_SCK_OFF); - imxrt_config_gpio(GPIO_SPI1_MISO_OFF); - imxrt_config_gpio(GPIO_SPI1_MOSI_OFF); - - imxrt_config_gpio(GPIO_SPI3_SCK_OFF); - imxrt_config_gpio(GPIO_SPI3_MISO_OFF); - imxrt_config_gpio(GPIO_SPI3_MOSI_OFF); - - - imxrt_config_gpio(_PIN_OFF(GPIO_LPI2C3_SDA_RESET)); - imxrt_config_gpio(_PIN_OFF(GPIO_LPI2C3_SCL_RESET)); - - /* set the sensor rail off */ - imxrt_gpio_write(GPIO_VDD_3V3_SENSORS_EN, 0); - - /* wait for the sensor rail to reach GND */ - usleep(ms * 1000); - warnx("reset done, %d ms", ms); - - /* re-enable power */ - - /* switch the sensor rail back on */ - imxrt_gpio_write(GPIO_VDD_3V3_SENSORS_EN, 1); - - /* wait a bit before starting SPI, different times didn't influence results */ - usleep(100); - - /* reconfigure the SPI pins */ - for (int bus = 0; bus < SPI_BUS_MAX_BUS_ITEMS; ++bus) { - if (px4_spi_buses[bus].bus == 1 || px4_spi_buses[bus].bus == 3) { - for (int i = 0; i < SPI_BUS_MAX_DEVICES; ++i) { - if (px4_spi_buses[bus].devices[i].cs_gpio != 0) { - imxrt_config_gpio(px4_spi_buses[bus].devices[i].cs_gpio); - } - - if (px4_spi_buses[bus].devices[i].drdy_gpio != 0) { - imxrt_config_gpio(px4_spi_buses[bus].devices[i].drdy_gpio); - } - } - } - } - - imxrt_config_gpio(GPIO_LPSPI1_SCK); - imxrt_config_gpio(GPIO_LPSPI1_MISO); - imxrt_config_gpio(GPIO_LPSPI1_MOSI); - - imxrt_config_gpio(GPIO_LPSPI3_SCK); - imxrt_config_gpio(GPIO_LPSPI3_MISO); - imxrt_config_gpio(GPIO_LPSPI3_MOSI); - - imxrt_config_gpio(GPIO_LPI2C3_SDA); - imxrt_config_gpio(GPIO_LPI2C3_SCL); - -#endif /* CONFIG_IMXRT_LPSPI1 */ - -} - #endif /* CONFIG_IMXRT_LPSPI3 || CONFIG_IMXRT_LPSPI4 */ diff --git a/boards/px4/fmu-v5x/default.px4board b/boards/px4/fmu-v5x/default.px4board index d9aa91eae6..180f479b41 100644 --- a/boards/px4/fmu-v5x/default.px4board +++ b/boards/px4/fmu-v5x/default.px4board @@ -74,7 +74,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/px4/fmu-v5x/init/rc.board_defaults b/boards/px4/fmu-v5x/init/rc.board_defaults index 57f2620cfe..0092ef856d 100644 --- a/boards/px4/fmu-v5x/init/rc.board_defaults +++ b/boards/px4/fmu-v5x/init/rc.board_defaults @@ -3,10 +3,6 @@ # board specific defaults #------------------------------------------------------------------------------ -param set-default SENS_EN_INA238 0 -param set-default SENS_EN_INA228 0 -param set-default SENS_EN_INA226 0 - if ver hwbasecmp 008 009 00a 010 011 then # Skynode: use the "custom participant", IP=10.41.10.1 config for uxrce_dds_client diff --git a/boards/px4/fmu-v6c/neural.px4board b/boards/px4/fmu-v6c/neural.px4board index f54d152869..4fd951d324 100644 --- a/boards/px4/fmu-v6c/neural.px4board +++ b/boards/px4/fmu-v6c/neural.px4board @@ -20,7 +20,6 @@ CONFIG_DRIVERS_HEATER=y CONFIG_DRIVERS_IMU_BOSCH_BMI055=y CONFIG_DRIVERS_IMU_BOSCH_BMI088=y CONFIG_DRIVERS_IMU_INVENSENSE_ICM42688P=y -CONFIG_COMMON_INS=y CONFIG_COMMON_LIGHT=y CONFIG_COMMON_MAGNETOMETER=y CONFIG_COMMON_OPTICAL_FLOW=y diff --git a/boards/px4/fmu-v6x/default.px4board b/boards/px4/fmu-v6x/default.px4board index 4a20430f10..62ee017735 100644 --- a/boards/px4/fmu-v6x/default.px4board +++ b/boards/px4/fmu-v6x/default.px4board @@ -71,7 +71,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/px4/fmu-v6x/init/rc.board_defaults b/boards/px4/fmu-v6x/init/rc.board_defaults index 7dfe7b546a..92da057ef2 100644 --- a/boards/px4/fmu-v6x/init/rc.board_defaults +++ b/boards/px4/fmu-v6x/init/rc.board_defaults @@ -3,12 +3,6 @@ # board specific defaults #------------------------------------------------------------------------------ -# By disabling all 3 INA modules, we use the -# i2c_launcher instead. -param set-default SENS_EN_INA238 0 -param set-default SENS_EN_INA228 0 -param set-default SENS_EN_INA226 0 - # Mavlink ethernet (CFG 1000) param set-default MAV_2_CONFIG 1000 param set-default MAV_2_BROADCAST 1 diff --git a/boards/px4/fmu-v6x/mavlink-dev.px4board b/boards/px4/fmu-v6x/mavlink-dev.px4board new file mode 100644 index 0000000000..83cac6e17b --- /dev/null +++ b/boards/px4/fmu-v6x/mavlink-dev.px4board @@ -0,0 +1 @@ +CONFIG_MAVLINK_DIALECT="development" diff --git a/boards/px4/fmu-v6x/zenoh.px4board b/boards/px4/fmu-v6x/zenoh.px4board index cb14fde935..4cd6071e6d 100644 --- a/boards/px4/fmu-v6x/zenoh.px4board +++ b/boards/px4/fmu-v6x/zenoh.px4board @@ -1,4 +1,5 @@ # CONFIG_BOARD_UAVCAN_TIMER_OVERRIDE is not set CONFIG_DRIVERS_UAVCAN=n CONFIG_MODULES_UXRCE_DDS_CLIENT=n +CONFIG_BOARD_CONSTRAINED_FLASH=y CONFIG_MODULES_ZENOH=y diff --git a/boards/px4/fmu-v6xrt/extras/px4_fmu-v6xrt_bootloader.bin b/boards/px4/fmu-v6xrt/extras/px4_fmu-v6xrt_bootloader.bin index 42e7c4b9d0..5a0bc80093 100755 Binary files a/boards/px4/fmu-v6xrt/extras/px4_fmu-v6xrt_bootloader.bin and b/boards/px4/fmu-v6xrt/extras/px4_fmu-v6xrt_bootloader.bin differ diff --git a/boards/px4/fmu-v6xrt/init/rc.board_defaults b/boards/px4/fmu-v6xrt/init/rc.board_defaults index a5a3dc1016..81ebca27ae 100644 --- a/boards/px4/fmu-v6xrt/init/rc.board_defaults +++ b/boards/px4/fmu-v6xrt/init/rc.board_defaults @@ -12,12 +12,6 @@ param set-default MAV_2_RATE 100000 param set-default MAV_2_REMOTE_PRT 14550 param set-default MAV_2_UDP_PRT 14550 -# By disabling all 3 INA modules, we use the -# i2c_launcher instead. -param set-default SENS_EN_INA238 0 -param set-default SENS_EN_INA228 0 -param set-default SENS_EN_INA226 0 - safety_button start if param greater -s UAVCAN_ENABLE 0 diff --git a/boards/px4/sitl/default.px4board b/boards/px4/sitl/default.px4board index ebe4f4ca5b..e2a3996ca3 100644 --- a/boards/px4/sitl/default.px4board +++ b/boards/px4/sitl/default.px4board @@ -35,7 +35,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/px4/sitl/mavlink-dev.px4board b/boards/px4/sitl/mavlink-dev.px4board new file mode 100644 index 0000000000..83cac6e17b --- /dev/null +++ b/boards/px4/sitl/mavlink-dev.px4board @@ -0,0 +1 @@ +CONFIG_MAVLINK_DIALECT="development" diff --git a/boards/px4/sitl/neural.px4board b/boards/px4/sitl/neural.px4board index c94a8fc12a..c68649e18a 100644 --- a/boards/px4/sitl/neural.px4board +++ b/boards/px4/sitl/neural.px4board @@ -34,7 +34,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/radiolink/PIX6/nuttx-config/nsh/defconfig b/boards/radiolink/PIX6/nuttx-config/nsh/defconfig index 56616a4298..f69b7b84b8 100644 --- a/boards/radiolink/PIX6/nuttx-config/nsh/defconfig +++ b/boards/radiolink/PIX6/nuttx-config/nsh/defconfig @@ -209,8 +209,6 @@ CONFIG_STM32F7_SPI1=y CONFIG_STM32F7_SPI1_DMA=y CONFIG_STM32F7_SPI1_DMA_BUFFER=1024 CONFIG_STM32F7_SPI2=y -#CONFIG_STM32F7_SPI2_DMA=y -#CONFIG_STM32F7_SPI2_DMA_BUFFER=1024 CONFIG_STM32F7_SPI4=y CONFIG_STM32F7_SPI_DMATHRESHOLD=8 CONFIG_STM32F7_TIM5=y diff --git a/boards/svehicle/e2/default.px4board b/boards/svehicle/e2/default.px4board index be198b4f2b..a3e6466eea 100644 --- a/boards/svehicle/e2/default.px4board +++ b/boards/svehicle/e2/default.px4board @@ -63,7 +63,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/svehicle/e2/init/rc.board_defaults b/boards/svehicle/e2/init/rc.board_defaults index 12dbca66c7..98337fdf17 100644 --- a/boards/svehicle/e2/init/rc.board_defaults +++ b/boards/svehicle/e2/init/rc.board_defaults @@ -3,12 +3,6 @@ # board specific defaults #------------------------------------------------------------------------------ -# By disabling all 3 INA modules, we use the -# i2c_launcher instead. -param set-default SENS_EN_INA238 0 -param set-default SENS_EN_INA228 0 -param set-default SENS_EN_INA226 0 - # Mavlink ethernet (CFG 1000) param set-default MAV_2_CONFIG 1000 param set-default MAV_2_BROADCAST 1 diff --git a/boards/zeroone/x6/default.px4board b/boards/zeroone/x6/default.px4board index 809a97f7fa..341d6c5962 100644 --- a/boards/zeroone/x6/default.px4board +++ b/boards/zeroone/x6/default.px4board @@ -61,7 +61,6 @@ CONFIG_MODULES_LOGGER=y CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y CONFIG_MODULES_MANUAL_CONTROL=y CONFIG_MODULES_MAVLINK=y -CONFIG_MAVLINK_DIALECT="development" CONFIG_MODULES_MC_ATT_CONTROL=y CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y diff --git a/boards/zeroone/x6/init/rc.board_defaults b/boards/zeroone/x6/init/rc.board_defaults index 0300654d6a..702a38153d 100644 --- a/boards/zeroone/x6/init/rc.board_defaults +++ b/boards/zeroone/x6/init/rc.board_defaults @@ -3,12 +3,6 @@ # board specific defaults #------------------------------------------------------------------------------ -# By disabling all 3 INA modules, we use the -# i2c_launcher instead. -param set-default SENS_EN_INA238 0 -param set-default SENS_EN_INA228 0 -param set-default SENS_EN_INA226 0 - if ver hwbasecmp 009 010 011 then # Skynode: use the "custom participant", IP=10.41.10.1 config for uxrce_dds_client diff --git a/docs/assets/airframes/multicopter/amovlab_f410/amovlabf410_drone_v1.15.4.params b/docs/assets/airframes/multicopter/amovlab_f410/amovlabf410_drone_v1.15.4.params index 53b68cdeb4..53bb8f5a01 100644 --- a/docs/assets/airframes/multicopter/amovlab_f410/amovlabf410_drone_v1.15.4.params +++ b/docs/assets/airframes/multicopter/amovlab_f410/amovlabf410_drone_v1.15.4.params @@ -325,7 +325,6 @@ 1 1 COM_PREARM_MODE 0 6 1 1 COM_QC_ACT 0 6 1 1 COM_RCL_EXCEPT 0 6 -1 1 COM_RC_ARM_HYST 1000 6 1 1 COM_RC_IN_MODE 3 6 1 1 COM_RC_LOSS_T 0.500000000000000000 9 1 1 COM_RC_OVERRIDE 1 6 diff --git a/docs/assets/config/actuators/pwm_center_output.png b/docs/assets/config/actuators/pwm_center_output.png new file mode 100644 index 0000000000..ef83e96d88 Binary files /dev/null and b/docs/assets/config/actuators/pwm_center_output.png differ diff --git a/docs/assets/config/actuators/servo_pwm_center.png b/docs/assets/config/actuators/servo_pwm_center.png new file mode 100644 index 0000000000..c1d92b7676 Binary files /dev/null and b/docs/assets/config/actuators/servo_pwm_center.png differ diff --git a/docs/assets/config/actuators/servo_pwm_linear.png b/docs/assets/config/actuators/servo_pwm_linear.png new file mode 100644 index 0000000000..176beab77e Binary files /dev/null and b/docs/assets/config/actuators/servo_pwm_linear.png differ diff --git a/docs/assets/config/fw/autotune.png b/docs/assets/config/fw/autotune.png index 768d26787d..6ceb2ed3ba 100644 Binary files a/docs/assets/config/fw/autotune.png and b/docs/assets/config/fw/autotune.png differ diff --git a/docs/assets/config/fw/gain_compression_diagram.png b/docs/assets/config/fw/gain_compression_diagram.png new file mode 100644 index 0000000000..e2ea2f09f7 Binary files /dev/null and b/docs/assets/config/fw/gain_compression_diagram.png differ diff --git a/docs/assets/flight_controller/micoair743_lite/back_view.png b/docs/assets/flight_controller/micoair743_lite/back_view.png new file mode 100644 index 0000000000..eee3282114 Binary files /dev/null and b/docs/assets/flight_controller/micoair743_lite/back_view.png differ diff --git a/docs/assets/flight_controller/micoair743_lite/front_view.png b/docs/assets/flight_controller/micoair743_lite/front_view.png new file mode 100644 index 0000000000..eda05065fe Binary files /dev/null and b/docs/assets/flight_controller/micoair743_lite/front_view.png differ diff --git a/docs/assets/flight_controller/micoair743_lite/interfaces_diagram.png b/docs/assets/flight_controller/micoair743_lite/interfaces_diagram.png new file mode 100644 index 0000000000..d552afbde9 Binary files /dev/null and b/docs/assets/flight_controller/micoair743_lite/interfaces_diagram.png differ diff --git a/docs/assets/flight_controller/micoair743_lite/micoair743_lite_pinout.xlsx b/docs/assets/flight_controller/micoair743_lite/micoair743_lite_pinout.xlsx new file mode 100644 index 0000000000..2324eb064d Binary files /dev/null and b/docs/assets/flight_controller/micoair743_lite/micoair743_lite_pinout.xlsx differ diff --git a/docs/assets/flight_controller/micoair743_lite/size.png b/docs/assets/flight_controller/micoair743_lite/size.png new file mode 100644 index 0000000000..09cfdc00c1 Binary files /dev/null and b/docs/assets/flight_controller/micoair743_lite/size.png differ diff --git a/docs/assets/flight_controller/micoair743_lite/wiring_diagram.png b/docs/assets/flight_controller/micoair743_lite/wiring_diagram.png new file mode 100644 index 0000000000..ca6fd57ea2 Binary files /dev/null and b/docs/assets/flight_controller/micoair743_lite/wiring_diagram.png differ diff --git a/docs/assets/flight_log_analysis/foxglove/foxglove_px4.png b/docs/assets/flight_log_analysis/foxglove/foxglove_px4.png new file mode 100644 index 0000000000..86aeee45fb Binary files /dev/null and b/docs/assets/flight_log_analysis/foxglove/foxglove_px4.png differ diff --git a/docs/assets/hardware/gps/ark/ark_dan_gps.jpg b/docs/assets/hardware/gps/ark/ark_dan_gps.jpg new file mode 100644 index 0000000000..559487abcd Binary files /dev/null and b/docs/assets/hardware/gps/ark/ark_dan_gps.jpg differ diff --git a/docs/assets/hardware/gps/ark/ark_rtk_gps_l1_l5.jpg b/docs/assets/hardware/gps/ark/ark_rtk_gps_l1_l5.jpg new file mode 100644 index 0000000000..3011875389 Binary files /dev/null and b/docs/assets/hardware/gps/ark/ark_rtk_gps_l1_l5.jpg differ diff --git a/docs/assets/hardware/gps/ark/ark_sam_gps_mini.jpg b/docs/assets/hardware/gps/ark/ark_sam_gps_mini.jpg new file mode 100644 index 0000000000..5f540b43a5 Binary files /dev/null and b/docs/assets/hardware/gps/ark/ark_sam_gps_mini.jpg differ diff --git a/docs/assets/hardware/gps/ark/ark_x20_rtk_gps.jpg b/docs/assets/hardware/gps/ark/ark_x20_rtk_gps.jpg new file mode 100644 index 0000000000..b93bf4980a Binary files /dev/null and b/docs/assets/hardware/gps/ark/ark_x20_rtk_gps.jpg differ diff --git a/docs/assets/hardware/power_module/ark_power_modules/ark_12s_payload_power.jpg b/docs/assets/hardware/power_module/ark_power_modules/ark_12s_payload_power.jpg new file mode 100644 index 0000000000..c0ab7670c2 Binary files /dev/null and b/docs/assets/hardware/power_module/ark_power_modules/ark_12s_payload_power.jpg differ diff --git a/docs/assets/hardware/power_module/ark_power_modules/ark_pab_power_no_connector.jpg b/docs/assets/hardware/power_module/ark_power_modules/ark_pab_power_no_connector.jpg new file mode 100644 index 0000000000..5f98f7987f Binary files /dev/null and b/docs/assets/hardware/power_module/ark_power_modules/ark_pab_power_no_connector.jpg differ diff --git a/docs/assets/hardware/sensors/optical_flow/ark_dist.jpg b/docs/assets/hardware/sensors/optical_flow/ark_dist.jpg new file mode 100644 index 0000000000..a1882d2ee6 Binary files /dev/null and b/docs/assets/hardware/sensors/optical_flow/ark_dist.jpg differ diff --git a/docs/en/SUMMARY.md b/docs/en/SUMMARY.md index f6a2784c29..7965ba8c0d 100644 --- a/docs/en/SUMMARY.md +++ b/docs/en/SUMMARY.md @@ -56,11 +56,14 @@ - [DJI F450 (CUAV v5 nano)](frames_multicopter/dji_f450_cuav_5nano.md) - [Planes (Fixed-Wing)](frames_plane/index.md) + - [Features](features_fw/index.md) + - [Gain compression](features_fw/gain_compression.md) - [Assembly](assembly/assembly_fw.md) - [Config/Tuning](config_fw/index.md) - [Auto-tune](config/autotune_fw.md) - [Rate/Attitude Controller Tuning Guide](config_fw/pid_tuning_guide_fixedwing.md) - [Altitude/Position Controller Tuning Guide](config_fw/position_tuning_guide_fixedwing.md) + - [Airspeed Scale Estimate Handling](config_fw/airspeed_scale_handling.md) - [Weight & Altitude Tuning](config_fw/weight_and_altitude_tuning.md) - [Trimming Guide](config_fw/trimming_guide_fixedwing.md) - [Flying (Basics)](flying/basic_flying_fw.md) @@ -182,6 +185,7 @@ - [Wiring Quickstart](assembly/quick_start_durandal.md) - [Holybro Pix32 v5](flight_controller/holybro_pix32_v5.md) - [Wiring Quickstart](assembly/quick_start_holybro_pix32_v5.md) + - [MicoAir H743 Lite](flight_controller/micoair743-lite.md) - [ModalAI VOXL 2](flight_controller/modalai_voxl_2.md) - [mRo Control Zero F7](flight_controller/mro_control_zero_f7.md) - [Radiolink PIX6](flight_controller/radiolink_pix6.md) @@ -240,18 +244,22 @@ - [TFSlot Airspeed Sensor](sensor/airspeed_tfslot.md) - [Barometers](sensor/barometer.md) - [Distance Sensors \(Rangefinders\)](sensor/rangefinders.md) + - [Ainstein US-D1 Standard Radar Altimeter](sensor/ulanding_radar.md) + - [ARK DIST SR (CAN/UART)](dronecan/ark_dist.md) + - [ARK DIST MR (CAN/UART)](dronecan/ark_dist_mr.md) + - [Benewake TFmini Lidar](sensor/tfmini.md) + - [LeddarOne Lidar](sensor/leddar_one.md) + - [Lidar-Lite](sensor/lidar_lite.md) - [Lightware Lidars (SF/LW)](sensor/sfxx_lidar.md) - [Lightware SF45 Rotary Lidar](sensor/sf45_rotating_lidar.md) - - [Ainstein US-D1 Standard Radar Altimeter](sensor/ulanding_radar.md) - - [LeddarOne Lidar](sensor/leddar_one.md) - - [Benewake TFmini Lidar](sensor/tfmini.md) - - [Lidar-Lite](sensor/lidar_lite.md) - [TeraRanger](sensor/teraranger.md) - [✘ Lanbao PSK-CM8JL65-CC5](sensor/cm8jl65_ir_distance_sensor.md) - [Avionics Anonymous Laser Altimeter UAVCAN Interface (CAN)](dronecan/avanon_laser_interface.md) - [GNSS (GPS)](gps_compass/index.md) - [ARK GPS (CAN)](dronecan/ark_gps.md) + - [ARK DAN GPS](gps_compass/ark_dan_gps.md) - [ARK SAM GPS](gps_compass/ark_sam_gps.md) + - [ARK SAM GPS MINI](gps_compass/ark_sam_gps_mini.md) - [ARK TESEO GPS](dronecan/ark_teseo_gps.md) - [CUAV NEO 3 GPS](gps_compass/gps_cuav_neo_3.md) - [CUAV NEO 3 Pro GPS (CAN)](gps_compass/gps_cuav_neo_3pro.md) @@ -263,6 +271,8 @@ - [Sky-Drones SmartAP GPS](gps_compass/gps_smartap.md) - [RTK GNSS](gps_compass/rtk_gps.md) - [ARK RTK GPS (CAN)](dronecan/ark_rtk_gps.md) + - [ARK RTK GPS L1 L5 (CAN)](dronecan/ark_rtk_gps_l1_l2.md) + - [ARK X20 RTK GPS (CAN)](dronecan/ark_x20_rtk_gps.md) - [ARK MOSAIC-X5 RTK GPS (CAN)](dronecan/ark_mosaic__rtk_gps.md) - [RTK GPS Heading with Dual u-blox F9P](gps_compass/u-blox_f9p_heading.md) - [CUAV C-RTK](gps_compass/rtk_gps_cuav_c-rtk.md) @@ -340,13 +350,14 @@ - [Battery Estimation Tuning](config/battery.md) - [Battery Chemistry Overview](power_systems/battery_chemistry.md) - [Power Modules/PDB](power_module/index.md) + - [ARK PAB Power Module](power_module/ark_pab_power_module.md) + - [ARK 12S PAB Power Module](power_module/ark_12s_pab_power_module.md) + - [ARK 12S Payload Power Module](power_module/ark_12s_payload_power_module.md) - [CUAV HV pm](power_module/cuav_hv_pm.md) - [CUAV CAN PMU](dronecan/cuav_can_pmu.md) - [Holybro PM02](power_module/holybro_pm02.md) - [Holybro PM07](power_module/holybro_pm07_pixhawk4_power_module.md) - [Holybro PM06 V2](power_module/holybro_pm06_pixhawk4mini_power_module.md) - - [ARK PAB Power Module](power_module/ark_pab_power_module.md) - - [ARK 12S PAB Power Module](power_module/ark_12s_pab_power_module.md) - [Holybro PM02D (digital)](power_module/holybro_pm02d.md) - [Holybro PM03D (digital)](power_module/holybro_pm03d.md) - [Pomegranate Systems Power Module](dronecan/pomegranate_systems_pm.md) @@ -484,6 +495,7 @@ - [UART/Serial Ports](uart/index.md) - [Port-Configurable Serial Drivers](uart/user_configurable_serial_driver.md) - [RTK GPS (Integration)](advanced/rtk_gps.md) + - [PPS Time Synchronization](advanced/pps_time_sync.md) - [Middleware](middleware/index.md) - [uORB Messaging](middleware/uorb.md) - [uORB Graph](middleware/uorb_graph.md) @@ -670,8 +682,6 @@ - [RoverSpeedStatus](msg_docs/RoverSpeedStatus.md) - [RoverSteeringSetpoint](msg_docs/RoverSteeringSetpoint.md) - [RoverThrottleSetpoint](msg_docs/RoverThrottleSetpoint.md) - - [RoverVelocitySetpoint](msg_docs/RoverVelocitySetpoint.md) - - [RoverVelocityStatus](msg_docs/RoverVelocityStatus.md) - [Rpm](msg_docs/Rpm.md) - [RtlStatus](msg_docs/RtlStatus.md) - [RtlTimeEstimate](msg_docs/RtlTimeEstimate.md) @@ -693,6 +703,7 @@ - [SensorOpticalFlow](msg_docs/SensorOpticalFlow.md) - [SensorPreflightMag](msg_docs/SensorPreflightMag.md) - [SensorSelection](msg_docs/SensorSelection.md) + - [SensorTemp](msg_docs/SensorTemp.md) - [SensorUwb](msg_docs/SensorUwb.md) - [SensorsStatus](msg_docs/SensorsStatus.md) - [SensorsStatusImu](msg_docs/SensorsStatusImu.md) @@ -763,6 +774,7 @@ - [Rpm Sensor](modules/modules_driver_rpm_sensor.md) - [Radio Control](modules/modules_driver_radio_control.md) - [Transponder](modules/modules_driver_transponder.md) + - [adc](modules/modules_driver_adc.md) - [Estimators](modules/modules_estimator.md) - [Simulations](modules/modules_simulation.md) - [System](modules/modules_system.md) diff --git a/docs/en/advanced/pps_time_sync.md b/docs/en/advanced/pps_time_sync.md new file mode 100644 index 0000000000..fcd4291f70 --- /dev/null +++ b/docs/en/advanced/pps_time_sync.md @@ -0,0 +1,133 @@ +# PPS Time Synchronization (PX4 Integration) + +[Pulse Per Second](https://en.wikipedia.org/wiki/Pulse-per-second_signal) (PPS) time synchronization provides high-precision timing for GNSS receivers. +This page explains how PPS is integrated into PX4 and how to configure it. + +## Overview + +PPS (Pulse Per Second) is a timing signal provided by GNSS receivers that outputs an electrical pulse once per second, synchronized to UTC time. +The PPS signal provides a highly accurate timing reference that PX4 can use to: + +- Refine GNSS time measurements and compensate for clock drift +- Provide precise UTC timestamps for camera capture events (for photogrammetry and mapping applications) +- Enable offline position refinement through accurate time correlation + +## Supported Hardware + +PPS time synchronization can be supported on flight controllers that have a hardware timer input pin that can be configured for PPS capture, by [enabling the PPS capture driver](#enable-pps-driver-in-board-configuration) in the board configuration. + +Supported boards include (at time of writing): + +- [Ark FMUv6x](../flight_controller/ark_v6x.md) +- Auterion FMUv6x +- Auterion FMUv6s + +## Setup + +### Enable PPS Driver in Board Configuration + +The [PPS capture driver](../modules/modules_driver.md#pps-capture) must be enabled in the board configuration. +This is done by adding the following to your board's configuration: + +```ini +CONFIG_DRIVERS_PPS_CAPTURE=y +``` + +### Configure PPS Parameters + +The configuration varies depending on your flight controller hardware. + +#### FMUv6X + +For FMUv6X-based flight controllers, configure PWM AUX Timer 3 and Function 9: + +```sh +param set PWM_AUX_TIM3 -2 +param set PWM_AUX_FUNC9 2064 +param set PPS_CAP_ENABLE 1 +``` + +#### FMUv6S + +For FMUv6S-based flight controllers, configure PWM MAIN Timer 3 and Function 10: + +```sh +param set PWM_MAIN_TIM3 -2 +param set PWM_MAIN_FUNC10 2064 +param set PPS_CAP_ENABLE 1 +``` + +### Wiring + +The wiring configuration depends on your specific flight controller. + +#### Skynode X (FMUv6x) + +Connect the PPS signal from your GNSS module to the flight controller using the 11-pin or 6-pin GPS connector: + +For detailed pinout information, refer to: + +- [Skynode GPS Peripherals - Pinouts](https://docs.auterion.com/hardware-integration/skynode/peripherals/gps#pinouts) + +#### Skynode S (FMUv6S) + +For FMUv6S, you need to route the PPS signal separately: + +1. Connect your GNSS module using the standard 6-pin GPS connector: [Skynode S GPS Interface](https://docs.auterion.com/hardware-integration/skynode-s/interfaces#gps) +2. Connect the PPS signal from your GNSS module to the **PPM_IN** pin: [Skynode S Extras 1 Interface](https://docs.auterion.com/hardware-integration/skynode-s/interfaces#extras-1) + +#### ARK Jetson Carrier Board (FMUv6x) + +For ARK FMUv6X on the Jetson carrier board: + +1. Connect your GNSS module using either the 10-pin or 6-pin GPS connector: [ARK PAB GPS1 Interface](../flight_controller/ark_pab#gps1) +2. Connect the PPS signal to the **FMU_CAP** pin: [ARK PAB ADIO Interface](../flight_controller/ark_pab.md#adio) + +## Verification + +After configuring PPS, you can verify that it is working correctly: + +1. Connect to the [PX4 System Console](../debug/system_console.md) (via MAVLink shell or serial console). +2. Wait for GNSS fix. +3. Check the PPS capture status to confirm it is up and running: + + ```sh + pps_capture status + ``` + +4. You can also check the [PpsCapture](../msg_docs/PpsCapture.md) uORB topic + + ```sh + listener pps_capture + ``` + + Where you should see: `timestamp`, `rtc_timestamp`, and `pps_rate_exceeded_counter`. + +### PPS Capture Driver + +The PPS capture driver is located in `src/drivers/pps_capture` and uses hardware timer input capture to precisely measure the arrival time of each PPS pulse. + +Key features: + +- Sub-microsecond pulse capture precision (hardware-dependent) +- Automatic drift calculation and compensation +- Integration with the GNSS driver for refined time stamping + +See also: + +- [PPS Capture Driver Documentation](../modules/modules_driver.md#pps-capture) +- [PpsCapture Message](../msg_docs/PpsCapture.md) + +### Time Synchronization Flow + +1. GNSS module sends position/time data at ~1-20 Hz. +2. GNSS module outputs PPS pulse at 1 Hz, precisely aligned to UTC second boundary. +3. PPS capture driver measures the exact time of the PPS pulse arrival using hardware timer. +4. Driver calculates the offset between GNSS time (from UART data) and autopilot clock (from PPS measurement). +5. This offset is used to correct GNSS timestamps and improve sensor fusion accuracy. + +The PPS signal provides much higher temporal precision than the transmitted time data, which has latency and jitter from serial communication. + +::: warning +If the PPS driver does not sending any data for 5 seconds (despite having `PPS_CAP_ENABLE` set to 1), the `EKF2_GPS_DELAY` will be used instead for estimating the latency. +::: diff --git a/docs/en/advanced_config/airspeed_validation.md b/docs/en/advanced_config/airspeed_validation.md index f2cd82ea6a..7b4a708ea3 100644 --- a/docs/en/advanced_config/airspeed_validation.md +++ b/docs/en/advanced_config/airspeed_validation.md @@ -10,36 +10,13 @@ By default, the [Missing Data](#missing-data-check), [Data Stuck](#data-stuck-ch You can configure which checks are active using the [ASPD_DO_CHECKS](#aspd_do_checks_table) parameter. ::: -## Airspeed in PX4 - -PX4 handles multiple types of airspeed: - -- **IAS (Indicated Airspeed):** The raw measurement from the airspeed sensor, directly influenced by sensor characteristics and installation effects (e.g., pitot-static errors). - -- **CAS (Calibrated Airspeed):** IAS corrected for sensor-specific and installation-related errors. - -- **EAS (Equivalent Airspeed):** _Not explicitly handled by PX4_ - Calibrated airspeed corrected for compressibility effects. - While PX4 does not currently model EAS separately, this correction is negligible at low speeds and altitudes, so EAS is treated as equivalent to CAS for simplicity. - -- **TAS (True Airspeed):** CAS adjusted for atmospheric effects such as air pressure and temperature (i.e., altitude and atmospheric conditions). - -The standard conversion chain used in PX4 is: `IAS → CAS (= EAS) → TAS`. - ## CAS Scale Estimation -PX4 estimates the IAS to CAS scale (referred to as the CAS scale) during flight using GNSS ground speed and wind estimation. -To compute the final TAS, standard environment conversions are applied (CAS → TAS). - -This CAS scaling plays an important role in keeping the [innovation check](#innovation-check) reliable, since a well-estimated CAS is key to spotting inconsistencies between measured and predicted airspeed. +Calibrated Airspeed (CAS) is the measured Indicated Airspeed (IAS) scaled to correct for sensor-specific and installation-related errors. +CAS scaling plays an important role in keeping the [innovation check](#innovation-check) reliable, since a well-estimated CAS is key to spotting inconsistencies between measured and predicted airspeed. If the estimated CAS scale is inaccurate, it can mask real airspeed faults or trigger false positives. -If you observe that the CAS scale estimate is consistently off, or if it is converging too slowly, you can manually set it using [ASPD_SCALE_n](#aspd_scale_n_table) (where `n` is the sensor number). -[ASPD_SCALE_APPLY](#aspd_scale_apply_table) can be used to configure when/if the estimated scale is applied. - -::: info -For a quick manual CAS scale estimate, compare groundspeed minus windspeed (from the [VehicleLocalPosition](../msg_docs/VehicleLocalPosition.md) and [Wind](../msg_docs/Wind.md) messages, respectively) to indicated airspeed values (in the [Airspeed](../msg_docs/Airspeed.md) message). -The ratio of indicated airspeed to groundspeed minus windspeed can provide a reasonable starting estimate for [ASPD_SCALE_n](#aspd_scale_n_table). -::: +If you observe that the CAS scale estimate is consistently off, or if it is converging too slowly, follow the steps outlined in [Airspeed Scale Handling](../config_fw/airspeed_scale_handling.md#recommended-first-flight-process). ## Validation Checks diff --git a/docs/en/advanced_config/bootloader_update_from_betaflight.md b/docs/en/advanced_config/bootloader_update_from_betaflight.md index 8c6cd1c2ad..e2b17103db 100644 --- a/docs/en/advanced_config/bootloader_update_from_betaflight.md +++ b/docs/en/advanced_config/bootloader_update_from_betaflight.md @@ -85,7 +85,7 @@ Flight controllers that have bootloader PX4-Autopilot `make` targets, can build The list of controllers for which this applies can be obtained by running the following `make` command, and noting the `make` targets that end in `_bootloader` ``` -$make list_config_targets +$ make list_config_targets ... cuav_nora_bootloader diff --git a/docs/en/advanced_config/parameter_reference.md b/docs/en/advanced_config/parameter_reference.md index 7eca46d3f3..0c1a843a55 100644 --- a/docs/en/advanced_config/parameter_reference.md +++ b/docs/en/advanced_config/parameter_reference.md @@ -10,6 +10,48 @@ If a listed parameter is missing from the Firmware see: [Finding/Updating Parame +## ADC + +### ADC_ADS7953_EN (`INT32`) {#ADC_ADS7953_EN} + +Enable ADS7953. + +Enable the driver for the ADS7953 board + +| Reboot | minValue | maxValue | increment | default | unit | +| ------- | -------- | -------- | --------- | ------------ | ---- | +| ✓ | | | | Disabled (0) | + +### ADC_ADS7953_REFV (`FLOAT`) {#ADC_ADS7953_REFV} + +Applied reference Voltage. + +The voltage applied to the ADS7953 board as reference + +| Reboot | minValue | maxValue | increment | default | unit | +| ------- | -------- | -------- | --------- | ------- | ---- | +| ✓ | 2.0 | 3.0 | 0.01 | 2.5 | V | + +### ADC_TLA2528_EN (`INT32`) {#ADC_TLA2528_EN} + +Enable TLA2528. + +Enable the driver for the TLA2528 + +| Reboot | minValue | maxValue | increment | default | unit | +| ------- | -------- | -------- | --------- | ------------ | ---- | +| ✓ | | | | Disabled (0) | + +### ADC_TLA2528_REFV (`FLOAT`) {#ADC_TLA2528_REFV} + +Applied reference Voltage. + +The voltage applied to the TLA2528 board as reference + +| Reboot | minValue | maxValue | increment | default | unit | +| ------- | -------- | -------- | --------- | ------- | ---- | +| ✓ | 2.0 | 3.0 | 0.01 | 2.5 | V | + ## ADSB ### ADSB_CALLSIGN_1 (`INT32`) {#ADSB_CALLSIGN_1} @@ -13955,9 +13997,9 @@ Scale of airspeed sensor 1. This is the scale IAS --> CAS of the first airspeed sensor instance -| Reboot | minValue | maxValue | increment | default | unit | -| ------- | -------- | -------- | --------- | ------- | ---- | -| ✓ | 0.5 | 2.0 | | 1.0 | +| Reboot | minValue | maxValue | increment | default | unit | +| ------ | -------- | -------- | --------- | ------- | ---- | +|   | 0.5 | 2.0 | | 1.0 | ### ASPD_SCALE_2 (`FLOAT`) {#ASPD_SCALE_2} @@ -13965,9 +14007,9 @@ Scale of airspeed sensor 2. This is the scale IAS --> CAS of the second airspeed sensor instance -| Reboot | minValue | maxValue | increment | default | unit | -| ------- | -------- | -------- | --------- | ------- | ---- | -| ✓ | 0.5 | 2.0 | | 1.0 | +| Reboot | minValue | maxValue | increment | default | unit | +| ------ | -------- | -------- | --------- | ------- | ---- | +|   | 0.5 | 2.0 | | 1.0 | ### ASPD_SCALE_3 (`FLOAT`) {#ASPD_SCALE_3} @@ -13975,9 +14017,9 @@ Scale of airspeed sensor 3. This is the scale IAS --> CAS of the third airspeed sensor instance -| Reboot | minValue | maxValue | increment | default | unit | -| ------- | -------- | -------- | --------- | ------- | ---- | -| ✓ | 0.5 | 2.0 | | 1.0 | +| Reboot | minValue | maxValue | increment | default | unit | +| ------ | -------- | -------- | --------- | ------- | ---- | +|   | 0.5 | 2.0 | | 1.0 | ### ASPD_SCALE_APPLY (`INT32`) {#ASPD_SCALE_APPLY} @@ -17165,7 +17207,9 @@ Set bits in the following positions to enable: 0 : Longitude and latitude fusion ### EKF2_GPS_DELAY (`FLOAT`) {#EKF2_GPS_DELAY} -GPS measurement delay relative to IMU measurements. +GPS measurement delay relative to IMU measurement. + +GPS measurement delay relative to IMU measurement if PPS time correction is not available/enabled (PPS_CAP_ENABLE). | Reboot | minValue | maxValue | increment | default | unit | | ------- | -------- | -------- | --------- | ------- | ---- | @@ -17175,7 +17219,7 @@ GPS measurement delay relative to IMU measurements. Fusion reset mode. -Automatic: reset on fusion timeout if no other source of position is available Dead-reckoning: reset on fusion timeout if no source of velocity is available +Automatic: reset on fusion timeout if no other source of position is available. Dead-reckoning: reset on fusion timeout if no source of velocity is available. **Values:** @@ -33105,6 +33149,14 @@ Maxbotix Sonar (mb12xx). | ------- | -------- | -------- | --------- | ------------ | ---- | | ✓ | | | | Disabled (0) | +### SENS_EN_MCP9808 (`INT32`) {#SENS_EN_MCP9808} + +Enable MCP9808 temperature sensor (external I2C). + +| Reboot | minValue | maxValue | increment | default | unit | +| ------- | -------- | -------- | --------- | ------------ | ---- | +| ✓ | | | | Disabled (0) | + ### SENS_EN_MPDT (`INT32`) {#SENS_EN_MPDT} Enable Mappydot rangefinder (i2c). @@ -39432,6 +39484,14 @@ Maximum time (in seconds) before resetting setpoint. | ------ | -------- | -------- | --------- | ------- | ---- | |   | | | | 2.0 | +### UUV_STICK_MODE (`INT32`) {#UUV_STICK_MODE} + +Stick mode selector (0=Heave/sway control, roll/pitch leveled; 1=Pitch/roll control). + +| Reboot | minValue | maxValue | increment | default | unit | +| ------ | -------- | -------- | --------- | ------- | ---- | +|   | 0 | 1 | | 0 | + ### UUV_THRUST_SAT (`FLOAT`) {#UUV_THRUST_SAT} UUV Thrust setpoint Saturation. @@ -40135,7 +40195,7 @@ Time in seconds it takes to tilt form VT_TILT_FW to VT_TILT_MC. ### VT_B_DEC_I (`FLOAT`) {#VT_B_DEC_I} -Backtransition deceleration setpoint to pitch I gain. +Backtransition deceleration setpoint to tilt I gain. | Reboot | minValue | maxValue | increment | default | unit | | ------ | -------- | -------- | --------- | ------- | ------- | @@ -40353,7 +40413,7 @@ During landing it can be beneficial to reduce the pitch angle to reduce the gene | Reboot | minValue | maxValue | increment | default | unit | | ------ | -------- | -------- | --------- | ------- | ---- | -|   | -10.0 | 45.0 | 0.1 | -5.0 | deg | +|   | -10.0 | 45.0 | 0.1 | 0.0 | deg | ### VT_PITCH_MIN (`FLOAT`) {#VT_PITCH_MIN} @@ -40364,7 +40424,7 @@ VT_FWD_TRHUST_EN is set. | Reboot | minValue | maxValue | increment | default | unit | | ------ | -------- | -------- | --------- | ------- | ---- | -|   | -10.0 | 45.0 | 0.1 | -5.0 | deg | +|   | -10.0 | 45.0 | 0.1 | 0.0 | deg | ### VT_PSHER_SLEW (`FLOAT`) {#VT_PSHER_SLEW} diff --git a/docs/en/advanced_config/prearm_arm_disarm.md b/docs/en/advanced_config/prearm_arm_disarm.md index e9e01f180f..ec4ce4c7e2 100644 --- a/docs/en/advanced_config/prearm_arm_disarm.md +++ b/docs/en/advanced_config/prearm_arm_disarm.md @@ -52,19 +52,17 @@ RC controllers will use different sticks for throttle and yaw [based on their mo - _Arm:_ Left-stick to right, right-stick to bottom. - _Disarm:_ Left-stick to left, right-stick to the bottom. -The required hold time can be configured using [COM_RC_ARM_HYST](#COM_RC_ARM_HYST). Note that by default ([COM_DISARM_MAN](#COM_DISARM_MAN)) you can also disarm in flight using gestures/buttons: you may choose to disable this to avoid accidental disarming. | Parameter | Description | | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | | [MAN_ARM_GESTURE](../advanced_config/parameter_reference.md#MAN_ARM_GESTURE) | Enable arm/disarm stick guesture. `0`: Disabled, `1`: Enabled (default). | | [COM_DISARM_MAN](../advanced_config/parameter_reference.md#COM_DISARM_MAN) | Enable disarming in flight via switch/stick/button in MC manual thrust modes. `0`: Disabled, `1`: Enabled (default). | -| [COM_RC_ARM_HYST](../advanced_config/parameter_reference.md#COM_RC_ARM_HYST) | Time that RC stick must be held in arm/disarm position before arming/disarming occurs (default: `1` second). | ## Arming Button/Switch {#arm_disarm_switch} An _arming button_ or "momentary switch" can be configured to trigger arm/disarm _instead_ of [gesture-based arming](#arm_disarm_gestures) (setting an arming switch disables arming gestures). -The button should be held down for ([nominally](#COM_RC_ARM_HYST)) one second to arm (when disarmed) or disarm (when armed). +The button should be held down for one second to arm (when disarmed) or disarm (when armed). A two-position switch can also be used for arming/disarming, where the respective arm/disarm commands are sent on switch _transitions_. @@ -77,7 +75,7 @@ The switch or button is assigned (and enabled) using [RC_MAP_ARM_SW](#RC_MAP_ARM | Parameter | Description | | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [RC_MAP_ARM_SW](../advanced_config/parameter_reference.md#RC_MAP_ARM_SW) | RC arm switch channel (default: 0 - unassigned). If defined, the specified RC channel (button/switch) is used for arming instead of a stick gesture.
**Note:**
- This setting _disables the stick gesture_!
- This setting applies to RC controllers. It does not apply to Joystick controllers that are connected via _QGroundControl_. | -| [COM_ARM_SWISBTN](../advanced_config/parameter_reference.md#COM_ARM_SWISBTN) | Arm switch is a momentary button.
- `0`: Arm switch is a 2-position switch where arm/disarm commands are sent on switch transitions.
-`1`: Arm switch is a button or momentary button where the arm/disarm command ae sent after holding down button for set time ([COM_RC_ARM_HYST](#COM_RC_ARM_HYST)). | +| [COM_ARM_SWISBTN](../advanced_config/parameter_reference.md#COM_ARM_SWISBTN) | Arm switch is a momentary button.
- `0`: Arm switch is a 2-position switch where arm/disarm commands are sent on switch transitions.
-`1`: Arm switch is a momentary button where the arm/disarm command is sent after holding down the button for one second. | ::: info The switch can also be set as part of _QGroundControl_ [Flight Mode](../config/flight_mode.md) configuration. diff --git a/docs/en/advanced_config/tuning_the_ecl_ekf.md b/docs/en/advanced_config/tuning_the_ecl_ekf.md index 8a68bc05dc..d2c0ada7fb 100644 --- a/docs/en/advanced_config/tuning_the_ecl_ekf.md +++ b/docs/en/advanced_config/tuning_the_ecl_ekf.md @@ -348,6 +348,60 @@ The `hpos_drift_rate`, `vpos_drift_rate` and `hspd` are calculated over a period Note that `ekf2_gps_drift` is not logged! ::: +#### GNSS Fault Detection + +PX4's GNSS fault detection protects against malicious or erroneous GNSS signals using selective fusion control based on measurement validation. + +The fault detection logic depends on the GPS mode, and also operates differently for horizontal position and altitude measurements. +The mode is set using the [EKF2_GPS_MODE](../advanced_config/parameter_reference.md#EKF2_GPS_MODE) parameter: + +- **Automatic (`0`)** (Default): Assumes that GNSS is generally reliable and is likely to be recovered. + EKF2 resets on fusion timeouts if no other source of position is available. +- **Dead-reckoning (`1`)**: Assumes that GNSS might be lost indefinitely, so resets should be avoided while we have other estimates of position data. + EKF2 may reset if no other sources of position or velocity are available. + If GNSS altitude OR horizontal position data drifts, the system disables fusion of both measurements simultaneously (even if one would still pass validation) and avoids performing resets. + +##### Detection Logic + +Horizontal Position: + +- **Automatic mode**: Horizontal position resets to GNSS data if no other horizontal position source is currently being fused (e.g., Auxiliary Global Position - AGP). +- **Dead-reckoning mode**: Horizontal position resets to GNSS data only if no other horizontal position OR velocity source is currently being fused (e.g., AGP, airspeed, optical flow). + +Altitude: + +- The altitude logic is more complex due to the height reference sensor ([EKF2_HGT_REF](../advanced_config/parameter_reference.md#EKF2_HGT_REF)) parameter, which is typically set to GNSS or baro in GNSS-denied scenarios. +- If height reference is set to baro, GNSS-based height resets are prevented (except when baro fusion fails completely and height reference automatically switches to GNSS). +- When height reference is set to GNSS: +- **Automatic mode**: Resets occur on drifting GNSS altitude measurements. +- **Dead-reckoning mode**: When validation starts failing, the system prevents GNSS altitude resets and labels the GNSS data as faulty. + +##### Faulty GNSS Data During Boot + +The system cannot automatically detect faulty GNSS data during vehicle boot as no baseline comparison exists. + +If GNSS fusion is enabled ([EKF2_GPS_CTRL](../advanced_config/parameter_reference.md#EKF2_GPS_CTRL)), operators will observe incorrect positions on maps and should disable GNSS fusion, then manually set the correct position via ground control station. +The global position gets corrected, and if [SENS_BAR_AUTOCAL](../advanced_config/parameter_reference.md#SENS_BAR_AUTOCAL) was enabled, baro offsets are automatically adjusted (through bias correction, not parameter changes). + +##### Enabling GNSS Fusion Mid-Flight + +With Faulty GNSS Data: + +- **Automatic mode**: Vehicle will reset to faulty position - potentially dangerous. +- **Dead-reckoning mode**: Large measurement differences cause GNSS rejection and fault detection activation. + +With Valid GNSS Data: + +- **Automatic mode**: Vehicle will reset to GNSS measurements. +- **Dead-reckoning mode**: If estimated position/altitude is close enough to measurements, fusion resumes; if too far apart, data gets labeled as faulty. + +##### Notes + +- **Dual Detection**: Horizontal and altitude checks run completely separately but both lead to the same result when triggered - all GNSS fusion gets disabled. +- **Recovery**: Only the specific check that labeled data as invalid can re-enable fusion. +- **Alternative Sources**: Dead-reckoning mode provides enhanced protection by requiring absence of alternative navigation sources before allowing resets. +- **Boot Vulnerability**: Initial faulty GNSS data cannot be detected automatically; requires operator intervention and manual position correction. + ### Range Finder [Range finder](../sensor/rangefinders.md) distance to ground is used by a single state filter to estimate the vertical position of the terrain relative to the height datum. diff --git a/docs/en/config/actuators.md b/docs/en/config/actuators.md index 3eec8f2dd2..e15e5d1608 100644 --- a/docs/en/config/actuators.md +++ b/docs/en/config/actuators.md @@ -160,6 +160,7 @@ The fields are: [Generally you should use the default actuator value](#actuator-roll-pitch-and-yaw-scaling). - `Trim`: An offset added to the actuator so that it is centered without input. This might be determined by trial and error. + Prefer using the improved `PWM_CENT` instead: [PWM control surfaces](actuators.md#pwm-control-surfaces-that-move-both-directions-about-a-neutral-point). - (Advanced) `Slew Rate`: Limits the minimum time in which the motor/servo signal is allowed to pass through its full output range, in seconds. - The setting limits the rate of change of an actuator (if not specified then no rate limit is applied). It is intended for actuators that may be damaged or cause flight disturbance if they move too fast — such as the tilting actuators on a tiltrotor VTOL vehicle, or fast moving flaps, respectively. @@ -535,12 +536,41 @@ If you're using PWM servos, PWM50 is far more common. If a high rate servo is _really_ needed, DShot offers better value. ::: -#### Control surfaces that move both directions about a neutral point +##### PWM: Control surfaces that move both directions about a neutral point + +To facilitate setting the neutral point of the servos, a bilinear curve function can be defined using the following parameters `PWM_MAIN_CENTx` / `PWM_AUX_CENTx` for each servo. This allows for unequal deflections in the positive and negative direction: + +![Asymmetric Servo Deflections](../../assets/config/actuators/servo_pwm_center.png) + +To set this up: + +1. Set all surface `Trim` to `0.00` for all surfaces: + + ![PWM Trimming](../../assets/config/actuators/control_surface_trim.png) + +2. Set the `PWM_MAIN_CENTx` / `PWM_AUX_CENTx` value so that the surface will stay at the neutral (aligned with airfoil) position. + This is usually around `1500` for PWM servos (near the center of the servo range). + + ![Control Surface Trimming](../../assets/config/actuators/pwm_center_output.png) + +3. Gradually increase the `Maximum` for each servo until the desired deflection is reached. Check the deflection with a remote manual mode while [`COM_PREARM_MODE`](../advanced_config/parameter_reference.md#COM_PREARM_MODE) is set to `Always` or use the sliders. +4. Gradually decrease the `Minimum` for each servo, until the desired deflection is reached. +5. Set `Disarmed` value to the desired value. It is usually desirable to have it the same as the `Center` value. + +::: info +If you want to retain the linear behaviour of the servo after setting the `Center`, make sure to adjust the `Minimum` or `Maximum`, such that both intervals (`min` to `cent` & `cent` to `max`) are equally large. + +![Linear PWM Adjustment](../../assets/config/actuators/servo_pwm_linear.png) +::: + +#### Non-PWM: Control surfaces that move both directions about a neutral point Control surfaces that move either direction around a neutral point include: ailerons, elevons, V-tails, A-tails, and rudders. To set these up: +0. Set all `PWM_MAIN_CENTx` and `PWM_AUX_CENTx` to default (-1), or trimming will not be possible. + 1. Set the `Disarmed` value so that the surfaces will stay at neutral position when disarmed. This is usually around `1500` for PWM servos (near the centre of the servo range). @@ -559,14 +589,17 @@ To set these up: 3. Move the slider again to the middle and check if the Control Surfaces are aligned in the neutral position of the wing. - If it is not aligned, you can set the **Trim** value for the control surface. - ::: info - This is done in the `Trim` setting of the Geometry panel, usually by "trial and error". - ![Control Surface Trimming](../../assets/config/actuators/control_surface_trim.png) - ::: - + ::: info + This is done in the `Trim` setting of the Geometry panel, usually by "trial and error". + ![Control Surface Trimming](../../assets/config/actuators/control_surface_trim.png) + ::: - After setting the trim for a control surface, move its slider away from the centre, release, and then back into disarmed (middle) position. Confirm that surface is in the neutral position. +::: tip +If any servo has a `PWM_MAIN_CENTx` or `PWM_AUX_CENTx` not set to default (-1), the system will automatically remove `Trim` from all surfaces. This is done to prevent mixing of old and new trimming tools. +::: + ::: info Another way to test without using the sliders would be to set the [`COM_PREARM_MODE`](../advanced_config/parameter_reference.md#COM_PREARM_MODE) parameter to `Always`: @@ -585,6 +618,7 @@ For a flap, that is when the flap is fully retracted and flush with the wing. One approach for setting these up is: +0. Set all `PWM_MAIN_CENTx` and `PWM_AUX_CENTx` to default (-1), or trimming will not be possible. 1. Set values `Disarmed` to `1500`, `Min` to `1200`, `Max` to `1700` so that the values are around the centre of the servo range. 2. Move the corresponding slider up and check the control moves and that it is extending (moving away from the disarmed position). If not, click on the `Rev Range` checkbox to reverse the range. @@ -594,6 +628,7 @@ One approach for setting these up is: - If the value was increased towards `Max`, then set `Max` to match `Disarmed`. 4. The value that you did _not_ set to match `Disarmed` controls the maximum amount that the control surface can extend. Set the slider to the top of the control, then change the value (`Max` or `Min`) so that the control surface is fully extended when the slider is at top. +5. (Only PWM servos) Set the `Center` value to the middle between `Min` and `Max`. ::: info Special note for flaps In some vehicle builds, flaps may be configured such that both flaps are controlled from a single output. @@ -631,6 +666,11 @@ For each of the tilt servos: - Standard VTOL : Motors defined as multicopter motors will be turned off - Tiltrotors : Motors that have no associated tilt servo will turn off - Tailsitters do not turn off any motors in fixed-wing flight +- The following formula can be used to migrate from surface trim to PWM trim: + + ```plain + PWM_MAIN_CENTx = ((PWM_MAX - PWM_MIN) / 2) * CA_SV_CSx_TRIM + PWM_MIN + ((PWM_MAX - PWM_MIN) / 2) + ``` ### Reversing Motors diff --git a/docs/en/config_fw/airspeed_scale_handling.md b/docs/en/config_fw/airspeed_scale_handling.md new file mode 100644 index 0000000000..fe70a37b38 --- /dev/null +++ b/docs/en/config_fw/airspeed_scale_handling.md @@ -0,0 +1,104 @@ +# Airspeed Scale Handling + +::: info +This section complements the existing [Airspeed Validation](../advanced_config/airspeed_validation.md) documentation. +::: + +The airspeed scale is used by PX4 to convert the measured airspeed (indicated airspeed) to the calibrated airspeed. +This scale can be set by [ASPD_SCALE_n](../advanced_config/parameter_reference.md#ASPD_SCALE_1) (where `n` is the sensor number), and logged in [AirspeedWind.msg](../msg_docs/AirspeedWind.md). + +Note that the airspeed scale is different from the airspeed sensor offset calibration done on the ground at 0 m/s. The airspeed scale accounts for errors in the airspeed measurement during flight, such as those caused by sensor placement or installation effects. + +This topic describes how to set an initial airspeed scale for a new fixed-wing vehicle during its first flight. Correct scale calibration ensures reliable airspeed data, accurate TAS calculation, robust PX4 airspeed validation, and consistent controller performance. + +## Airspeed in PX4 + +PX4 handles multiple types of airspeed: + +- **IAS (Indicated Airspeed):** The raw measurement from the airspeed sensor, directly influenced by sensor characteristics and installation effects (e.g., pitot-static errors). +- **CAS (Calibrated Airspeed):** IAS corrected for sensor-specific and installation-related errors. +- **EAS (Equivalent Airspeed):** _Not explicitly handled by PX4_ - Calibrated airspeed corrected for compressibility effects. + While PX4 does not currently model EAS separately, this correction is negligible at low speeds and altitudes, so EAS is treated as equivalent to CAS for simplicity. +- **TAS (True Airspeed):** CAS adjusted for atmospheric effects such as air pressure and temperature (i.e., altitude and atmospheric conditions). + +The standard conversion chain used in PX4 is: `IAS → CAS (= EAS) → TAS`. + +## CAS Scale Estimation + +PX4 estimates the IAS to CAS scale (referred to as the CAS scale) during flight using GNSS ground speed and wind estimation. +To compute the final TAS, standard environment conversions are applied (CAS → TAS). + +:::warning Important +A GNSS is required for scale estimation. +::: + +PX4 uses a two-stage approach to robustly estimate the scale: + +1. **Continuous EKF Estimation**: A wind estimator constantly compares your measured airspeed against what it expects based on ground velocity (from GNSS) and estimated wind. + If there's a consistent bias, it adjusts the scale estimate. + The estimated scale is logged in the `AirspeedWind.msg` as the `tas_scale_raw`. +2. **Validation**: To ensure robustness, PX4 collects airspeed and ground speed data across 12 different heading segments (every 30°). + This averages out wind estimation errors. + The validated scale is only updated when the new estimate demonstrably reduces the error between predicted and actual ground speeds across all headings. + The validated scale is logged in the `AirspeedWind.msg` as the `tas_scale_validated`. + +### Understanding the Scale: Physical Intuition + +The CAS scale is essentially a correction factor that accounts for systematic errors in your airspeed sensor installation. + +- A scale of 1.0 means your sensor reads perfectly (no correction needed) +- A scale > 1.0 (e.g., 1.1) means your sensor _under-reads_ by 10%, so measured airspeed (IAS) must be multiplied by 1.1 +- A scale < 1.0 (e.g., 0.9) means your sensor _over-reads_ by ~11%, so measured airspeed (IAS) must be multiplied by 0.9 + +### What Affects the Airspeed Scale + +The primary factor influencing the airspeed scale is **sensor placement**. + +Biased readings can be reflected in the scale estimate for pitot tubes installed: + +- In regions experiencing disturbed flow (commonly near blunt aircraft noses) +- Near propellers +- Under aerodynamic surfaces +- At an angle with respect to the airflow + +### Symptoms of Incorrect Scale + +Symptoms of an incorrectly scaled airspeed measurement include: + +- Stalling or overspeeding +- Persistent under- or overestimation of the TAS relative to wind-corrected groundspeed +- False positives or missed detections in [airspeed innovation checks](../advanced_config/airspeed_validation.md#innovation-check) +- Degraded tracking of the rate controllers + +## Recommended First Flight Process + +During the first flight of a new fixed-wing vehicle, allocate time for the CAS scale to converge to a reasonable initial estimate. +Follow these steps: + +1. **Set an Initial Scale** + + Use a conservative starting point: set the CAS scale (`ASPD_SCALE_n`) slightly under 1.0 (for example 0.95). + This biases the system toward over-speed rather than under-speed, reducing stall risk. + +2. **Perform a Flight** + + After takeoff, place the vehicle in loiter for about 15 minutes to allow the scale estimation to converge. + +3. **Check Scale Convergence** + + After the flight, review the estimated scale in logs. + Verify that: + - `tas_scale_validated` in `AirspeedWind.msg` converged during flight. + - `true_airspeed_m_s` (TAS) in [AirspeedValidated.msg](../msg_docs/AirspeedValidated.md) is consistent with groundspeed corrected for wind. + +4. **Update the Airframe Configuration** + + If using an [airframe configuration file](../dev_airframes/adding_a_new_frame.md): update `ASPD_SCALE_n`with the estimated CAS scale for future flights. + For similar vehicles with similarly mounted sensors, this value is typically a reliable starting point. + +::: info +If you are not able to perform the steps outlined above ... + +For a quick manual CAS scale estimate, compare groundspeed minus windspeed (from the [VehicleLocalPosition](../msg_docs/VehicleLocalPosition.md) and [Wind](../msg_docs/Wind.md) messages, respectively) to indicated airspeed values (in the [Airspeed](../msg_docs/Airspeed.md) message). +The ratio of indicated airspeed to groundspeed minus windspeed can provide a reasonable starting estimate for `ASPD_SCALE_n`. +::: diff --git a/docs/en/config_fw/index.md b/docs/en/config_fw/index.md index 4dbc48ecb1..a81760edf6 100644 --- a/docs/en/config_fw/index.md +++ b/docs/en/config_fw/index.md @@ -3,7 +3,7 @@ Fixed-wing configuration and calibration follows the same high level steps as other frames: selection of firmware, configuration of the frame including actuator/motor geometry and output mappings, sensor configuration and calibration, configuration of safety and other features, and finally tuning. ::: info -This topic is the recommended entry point when performing first-time configuration and calibration of a new multicopter frame. +This topic is the recommended entry point when performing first-time configuration and calibration of a new fixed-wing frame. ::: The main steps are: @@ -17,3 +17,4 @@ The main steps are: - [Fixed-wing Altitude/Position Controller Tuning Guide](../config_fw/position_tuning_guide_fixedwing.md) - [Fixed-wing Trimming Guide](../config_fw/trimming_guide_fixedwing.md) +- [Fixed-Wing Airspeed Scale Handling](../config_fw/airspeed_scale_handling.md) diff --git a/docs/en/config_fw/pid_tuning_guide_fixedwing.md b/docs/en/config_fw/pid_tuning_guide_fixedwing.md index 0eb1005a49..df7db1ea00 100644 --- a/docs/en/config_fw/pid_tuning_guide_fixedwing.md +++ b/docs/en/config_fw/pid_tuning_guide_fixedwing.md @@ -17,6 +17,8 @@ Manual tuning is recommended for frames where autotuning does not work, or where - Excessive gains (and rapid servo motion) can violate the maximum forces of your airframe - increase gains carefully. - Roll and pitch tuning follow the same sequence. The only difference is that pitch is more sensitive to trim offsets, so [trimming](../config_fw/trimming_guide_fixedwing.md) has to be done carefully and integrator gains need more attention to compensate this. +- Disable automatic [gain compression](../features_fw/gain_compression.md) ([FW_GC_EN](../advanced_config/parameter_reference.md#FW_GC_EN)) to avoid over-tuning. + Remember to re-enable it when tuning is done. ## Establishing the Airframe Baseline diff --git a/docs/en/config_rover/basic_setup.md b/docs/en/config_rover/basic_setup.md index 328e04950c..e729fc6328 100644 --- a/docs/en/config_rover/basic_setup.md +++ b/docs/en/config_rover/basic_setup.md @@ -88,7 +88,7 @@ Navigate to [Parameters](../advanced_config/parameters.md) in QGroundControl and One approach to determine an appropriate value is: 1. From a standstill, give the rover full throttle until it reaches the maximum speed. - 2. Disarm the rover and plot the `measured_speed_body_x` from [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md). + 2. Disarm the rover and plot the `measured_speed_body_x` from [RoverSpeedStatus](../msg_docs/RoverSpeedStatus.md). 3. Divide the maximum speed by the time it took to reach it and set this as the value for [RO_ACCEL_LIM](#RO_ACCEL_LIM). Some RC rovers have enough torque to lift up if the maximum acceleration is not limited. diff --git a/docs/en/config_rover/position_tuning.md b/docs/en/config_rover/position_tuning.md index 933e528cbe..f5e7f6ae2e 100644 --- a/docs/en/config_rover/position_tuning.md +++ b/docs/en/config_rover/position_tuning.md @@ -19,7 +19,6 @@ To tune the position controller configure the [parameters](../advanced_config/pa $v*{max} = v*{full throttle} \cdot (1 - \theta\_{normalized} \cdot k) $ with - - $v_{max}:$ Maximum speed - $v_{full throttle}:$ Speed at maximum throttle [RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED). - $\theta_{normalized}:$ Course error (Course - bearing setpoint) normalized from $[0\degree, 180\degree]$ to $[0, 1]$ @@ -34,14 +33,13 @@ To tune the position controller configure the [parameters](../advanced_config/pa ::: tip Plan a mission for the rover to drive a square and observe how it slows down when approaching a waypoint: - - If the rover decelerates too quickly decrease the [RO_DECEL_LIM](../advanced_config/parameter_reference.md#RO_DECEL_LIM) parameter, if it starts slowing down too early increase the parameter. - If you observe a jerking motion as the rover slows down, decrease the [RO_JERK_LIM](../advanced_config/parameter_reference.md#RO_JERK_LIM) parameter otherwise increase it as much as possible as it can interfere with the tuning of [RO_DECEL_LIM](../advanced_config/parameter_reference.md#RO_DECEL_LIM). These two parameters have to be tuned as a pair, repeat until you are satisfied with the behaviour. ::: -3. Plot the `adjusted_speed_body_x_setpoint` and `measured_speed_body_x` from the [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) message over each other. +3. Plot the `adjusted_speed_body_x_setpoint` and `measured_speed_body_x` from the [RoverSpeedStatus](../msg_docs/RoverSpeedStatus.md) message over each other. If the tracking of these setpoints is not satisfactory adjust the values for [RO_SPEED_P](../advanced_config/parameter_reference.md#RO_SPEED_P) and [RO_SPEED_I](../advanced_config/parameter_reference.md#RO_SPEED_I). ## Path Following @@ -57,7 +55,6 @@ The following parameters are used to tune the algorithm: Decreasing the parameter makes it more aggressive but can lead to oscillations. To tune this: - 1. Start with a value of 1 for [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) 2. Put the rover in [Position mode](../flight_modes_rover/manual.md#position-mode) and while driving a straight line at approximately half the maximum speed observe its behaviour. 3. If the rover does not drive in a straight line, reduce the value of the parameter, if it oscillates around the path increase the value. diff --git a/docs/en/config_rover/velocity_tuning.md b/docs/en/config_rover/velocity_tuning.md index 04323e7413..bf0429d43f 100644 --- a/docs/en/config_rover/velocity_tuning.md +++ b/docs/en/config_rover/velocity_tuning.md @@ -23,11 +23,10 @@ To tune the velocity controller configure the following [parameters](../advanced ::: tip To further tune this parameter: - 1. Set [RO_SPEED_P](#RO_SPEED_P) and [RO_SPEED_I](#RO_SPEED_I) to zero. This way the speed is only controlled by the feed-forward term, which makes it easier to tune. 2. Put the rover in [Position mode](../flight_modes_rover/manual.md#position-mode) and then move the left stick of your controller up and/or down and hold it at a few different levels for a couple of seconds each. - 3. Disarm the rover and from the flight log plot the `adjusted_speed_body_x_setpoint` and the `measured_speed_body_x` from the [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) message over each other. + 3. Disarm the rover and from the flight log plot the `adjusted_speed_body_x_setpoint` and the `measured_speed_body_x` from the [RoverSpeedStatus](../msg_docs/RoverSpeedStatus.md) message over each other. 4. If the actual speed of the rover is higher than the speed setpoint, increase [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED). If it is the other way around decrease the parameter and repeat until you are satisfied with the setpoint tracking. @@ -64,7 +63,6 @@ These steps are only necessary if you are tuning/want to unlock the manual [Posi Decreasing the parameter makes it more aggressive but can lead to oscillations. To tune this: - 1. Start with a value of 1 for [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) 2. Put the rover in [Position mode](../flight_modes_rover/manual.md#position-mode) and while driving a straight line at approximately half the maximum speed observe its behaviour. 3. If the rover does not drive in a straight line, reduce the value of the parameter, if it oscillates around the path increase the value. diff --git a/docs/en/dev_log/ulog_file_format.md b/docs/en/dev_log/ulog_file_format.md index a1caea44e9..18a065797f 100644 --- a/docs/en/dev_log/ulog_file_format.md +++ b/docs/en/dev_log/ulog_file_format.md @@ -215,7 +215,7 @@ Predefined information messages are: | `char[value_len] ver_sw_branch` | git branch | "master" | | `uint32_t ver_sw_release` | Software version (see below) | 0x010401ff | | `char[value_len] sys_os_name` | Operating System Name | "Linux" | -| `char[value_len] sys_os_ve`r | OS version (git tag) | "9f82919" | +| `char[value_len] sys_os_ver` | OS version (git tag) | "9f82919" | | `uint32_t ver_os_release` | OS version (see below) | 0x010401ff | | `char[value_len] sys_toolchain` | Toolchain Name | "GNU GCC" | | `char[value_len] sys_toolchain_ver` | Toolchain Version | "6.2.1" | diff --git a/docs/en/dronecan/ark_dist.md b/docs/en/dronecan/ark_dist.md new file mode 100644 index 0000000000..b4629445ca --- /dev/null +++ b/docs/en/dronecan/ark_dist.md @@ -0,0 +1,98 @@ +# ARK DIST SR + +ARK DIST SR is a low range, open source [DroneCAN](index.md) [distance sensor](../sensor/rangefinders.md). +It has an approximate range of between 8cm to 30m. + +![ARK DIST SR](../../assets/hardware/sensors/optical_flow/ark_dist.jpg) + +## Where to Buy + +Order this module from: + +- [ARK Electronics](https://arkelectron.com/product/ark-dist-sr/) (US) + +## Hardware Specifications + +- [Open Source Schematic and BOM](https://github.com/ARK-Electronics/ARK_DIST) +- Sensors + - [Broadcom AFBR-S50LV85D Time-of-Flight Distance Sensor](https://www.broadcom.com/products/optical-sensors/time-of-flight-3d-sensors/afbr-s50lv85d) + - Typical distance range up to 30m + - Integrated 850 nm laser light source + - Field-of-View (FoV) of 12.4° x 6.2° with 32 pixels + - Operation of up to 200k Lux ambient light + - Reference Pixel for system health monitoring + - Works well on all surface conditions + - Transmitter beam of 2° x 2° to illuminate between 1 and 3 pixels +- Two Pixhawk Standard CAN Connectors (4 Pin JST GH) +- Pixhawk Standard UART Connector (6 Pin JST SH) +- Pixhawk Standard Debug Connector (6 Pin JST SH) +- Small Form Factor + - 2.0cm x 2.8cm x 1.4cm + - 4g +- LED Indicators +- USA Built +- NDAA Compliant +- Power Requirements + - 5v + - 84mA Average + - 86mA Max + +## Hardware Setup + +### Wiring + +The ARK DIST is connected to the CAN bus using a Pixhawk standard 4 pin JST GH cable. +For more information, refer to the [CAN Wiring](../can/index.md#wiring) instructions. + +The ARK DIST can also be connected with UART and communicates over MAVLink sending the [DISTANCE_SENSOR](https://mavlink.io/en/messages/common.html#DISTANCE_SENSOR) message. + +## Firmware Setup + +ARK DIST SR runs the [PX4 DroneCAN Firmware](px4_cannode_fw.md). +As such, it supports firmware update over the CAN bus and [dynamic node allocation](index.md#node-id-allocation). + +## PX4 Configuration + +### DroneCAN + +#### Enable DroneCAN + +The steps are: + +- In _QGroundControl_ set the parameter [UAVCAN_ENABLE](../advanced_config/parameter_reference.md#UAVCAN_ENABLE) to `2` for dynamic node allocation (or `3` if using [DroneCAN ESCs](../dronecan/escs.md)) and reboot (see [Finding/Updating Parameters](../advanced_config/parameters.md)). +- Connect ARK DIST SR CAN to the Pixhawk CAN. + +Once enabled, the module will be detected on boot. +Distance sensor data should arrive at 40Hz. + +DroneCAN configuration in PX4 is explained in more detail in [DroneCAN > Enabling DroneCAN](../dronecan/index.md#enabling-dronecan). + +#### CAN Configuration + +First set the parameters to [Enable DroneCAN](#enable-dronecan) (as shown above). + +Set the following parameters in _QGroundControl_: + +- Enable [UAVCAN_ENABLE](../advanced_config/parameter_reference.md#UAVCAN_ENABLE) to 2 for dynamic node allocation. +- Enable [UAVCAN_SUB_RNG](../advanced_config/parameter_reference.md#UAVCAN_SUB_RNG). +- Set [EKF2_RNG_A_HMAX](../advanced_config/parameter_reference.md#EKF2_RNG_A_HMAX) to `30`. +- Set [EKF2_RNG_QLTY_T](../advanced_config/parameter_reference.md#EKF2_RNG_QLTY_T) to `0.2`. +- Set [UAVCAN_RNG_MIN](../advanced_config/parameter_reference.md#UAVCAN_RNG_MIN) to `0.08`. +- Set [UAVCAN_RNG_MAX](../advanced_config/parameter_reference.md#UAVCAN_RNG_MAX) to `30`. + +See also [Distance Sensor/Range Finder in _DroneCAN > Subscriptions and Publications_](../dronecan/#distance-sensor-range-finder). + +### UART/MAVLink Configuration + +If connecting via a UART set the following parameters in _QGroundControl_: + +- Set [MAV_X_CONFIG](../advanced_config/parameter_reference.md#MAV_0_CONFIG) to the port the sensor is connected to. +- Set [MAV_X_FORWARD](../advanced_config/parameter_reference.md#MAV_0_FORWARD) to `0` (off). +- Set [MAV_X_MODE](../advanced_config/parameter_reference.md#MAV_0_MODE) to `7` or `13` to (Minimal or Low Bandwidth) to reduce memory usage. +- Set `SER_XXX_BAUD` to `115200`, where `XXX` is specific to the port you are using (such as [SER_GPS2_BAUD](../advanced_config/parameter_reference.md#SER_GPS2_BAUD)). +- Set [EKF2_RNG_A_HMAX](../advanced_config/parameter_reference.md#EKF2_RNG_A_HMAX) to `30`. +- Set [EKF2_RNG_QLTY_T](../advanced_config/parameter_reference.md#EKF2_RNG_QLTY_T) to `0.2`. + +## See Also + +- [ARK DIST SR](https://docs.arkelectron.com/sensor/ark-dist) (ARK Docs) diff --git a/docs/en/dronecan/ark_dist_mr.md b/docs/en/dronecan/ark_dist_mr.md new file mode 100644 index 0000000000..054c27d769 --- /dev/null +++ b/docs/en/dronecan/ark_dist_mr.md @@ -0,0 +1,97 @@ +# ARK DIST MR + +ARK DIST MR is a mid range, open source [DroneCAN](index.md) [distance sensor](../sensor/rangefinders.md). + +![ARK DIST MR](../../assets/hardware/sensors/optical_flow/ark_dist.jpg) + +## Where to Buy + +Order this module from: + +- [ARK Electronics](https://arkelectron.com/product/ark-dist-mr/) (US) + +## Hardware Specifications + +- [Open Source Schematic and BOM](https://github.com/ARK-Electronics/ARK_DIST) +- Sensors + - [Broadcom AFBR-S50LX85D Time-of-Flight Distance Sensor](https://www.broadcom.com/products/optical-sensors/time-of-flight-3d-sensors/afbr-s50lx85d) + - Typical distance range up to 50m + - Integrated 850 nm laser light source + - Field-of-View (FoV) of 12.4° x 6.2° with 32 pixels + - Operation of up to 200k Lux ambient light + - Reference Pixel for system health monitoring + - Works well on all surface conditions + - Transmitter beam of 2° x 2° to illuminate between 1 and 3 pixels +- Two Pixhawk Standard CAN Connectors (4 Pin JST GH) +- Pixhawk Standard UART Connector (6 Pin JST SH) +- Pixhawk Standard Debug Connector (6 Pin JST SH) +- Small Form Factor + - 2.0cm x 2.8cm x 1.4cm + - 4g +- LED Indicators +- USA Built +- NDAA Compliant +- Power Requirements + - 5v + - 78mA Average + - 84mA Max + +## Hardware Setup + +### Wiring + +The ARK DIST is connected to the CAN bus using a Pixhawk standard 4 pin JST GH cable. +For more information, refer to the [CAN Wiring](../can/index.md#wiring) instructions. + +The ARK DIST can also be connected with UART and communicates over MAVLink sending the [DISTANCE_SENSOR](https://mavlink.io/en/messages/common.html#DISTANCE_SENSOR) message. + +## Firmware Setup + +ARK DIST MR runs the [PX4 DroneCAN Firmware](px4_cannode_fw.md). +As such, it supports firmware update over the CAN bus and [dynamic node allocation](index.md#node-id-allocation). + +## PX4 Configuration + +### DroneCAN + +#### Enable DroneCAN + +The steps are: + +- In _QGroundControl_ set the parameter [UAVCAN_ENABLE](../advanced_config/parameter_reference.md#UAVCAN_ENABLE) to `2` for dynamic node allocation (or `3` if using [DroneCAN ESCs](../dronecan/escs.md)) and reboot (see [Finding/Updating Parameters](../advanced_config/parameters.md)). +- Connect ARK DIST SR CAN to the Pixhawk CAN. + +Once enabled, the module will be detected on boot. +Distance sensor data should arrive at 40Hz. + +DroneCAN configuration in PX4 is explained in more detail in [DroneCAN > Enabling DroneCAN](../dronecan/index.md#enabling-dronecan). + +#### CAN Configuration + +First set the parameters to [Enable DroneCAN](#enable-dronecan) (as shown above). + +Set the following parameters in _QGroundControl_: + +- Enable [UAVCAN_ENABLE](../advanced_config/parameter_reference.md#UAVCAN_ENABLE) to 2 for dynamic node allocation. +- Enable [UAVCAN_SUB_RNG](../advanced_config/parameter_reference.md#UAVCAN_SUB_RNG). +- Set [EKF2_RNG_A_HMAX](../advanced_config/parameter_reference.md#EKF2_RNG_A_HMAX) to `50`. +- Set [EKF2_RNG_QLTY_T](../advanced_config/parameter_reference.md#EKF2_RNG_QLTY_T) to `0.2`. +- Set [UAVCAN_RNG_MIN](../advanced_config/parameter_reference.md#UAVCAN_RNG_MIN) to `0.08`. +- Set [UAVCAN_RNG_MAX](../advanced_config/parameter_reference.md#UAVCAN_RNG_MAX) to `50`. + +See also [Distance Sensor/Range Finder in _DroneCAN > Subscriptions and Publications_](../dronecan/#distance-sensor-range-finder). + +### UART/MAVLink Configuration + +If connecting via a UART set the following parameters in _QGroundControl_: + +- Set [MAV_X_CONFIG](../advanced_config/parameter_reference.md#MAV_0_CONFIG) to the port the sensor is connected to. +- Set [MAV_X_FORWARD](../advanced_config/parameter_reference.md#MAV_0_FORWARD) to `0` (off). +- Set [MAV_X_MODE](../advanced_config/parameter_reference.md#MAV_0_MODE) to `7` or `13` to (Minimal or Low Bandwidth) to reduce memory usage. +- Set `SER_XXX_BAUD` to `115200`, where `XXX` is specific to the port you are using (such as [SER_GPS2_BAUD](../advanced_config/parameter_reference.md#SER_GPS2_BAUD)). +- Set [EKF2_RNG_A_HMAX](../advanced_config/parameter_reference.md#EKF2_RNG_A_HMAX) to `50`. +- Set [EKF2_RNG_QLTY_T](../advanced_config/parameter_reference.md#EKF2_RNG_QLTY_T) to `0.2`. + +## See Also + +- [ARK DIST MR](https://docs.arkelectron.com/sensor/ark-dist) (ARK Docs) diff --git a/docs/en/dronecan/ark_rtk_gps.md b/docs/en/dronecan/ark_rtk_gps.md index 472331d7e0..bbb8940fec 100644 --- a/docs/en/dronecan/ark_rtk_gps.md +++ b/docs/en/dronecan/ark_rtk_gps.md @@ -20,6 +20,7 @@ Order this module from: - Multi-band RTK with fast convergence times and reliable performance - High update rate for highly dynamic applications - Centimetre accuracy in a small and energy efficient module + - Moving Base for Heading - Bosch BMM150 Magnetometer - Bosch BMP388 Barometer - Invensense ICM-42688-P 6-Axis IMU diff --git a/docs/en/dronecan/ark_rtk_gps_l1_l2.md b/docs/en/dronecan/ark_rtk_gps_l1_l2.md new file mode 100644 index 0000000000..4e2175a147 --- /dev/null +++ b/docs/en/dronecan/ark_rtk_gps_l1_l2.md @@ -0,0 +1,163 @@ +# ARK RTK GPS L1 L5 + +[ARK RTK GPS L1 L5](https://arkelectron.gitbook.io/ark-documentation/sensors/ark-rtk-gps) is an open source [DroneCAN](index.md) [RTK GPS](../gps_compass/rtk_gps.md), [u-blox F9P](https://www.u-blox.com/en/product/zed-f9p-module), magnetometer, barometer, IMU, buzzer, and safety switch module. + +![ARK RTK GPS L1 L5](../../assets/hardware/gps/ark/ark_rtk_gps_l1_l5.jpg) + +## Where to Buy + +Order this module from: + +- [ARK Electronics](https://arkelectron.com/product/ark-rtk-gps-l1-l5/) (US) + +## Hardware Specifications + +- [Open Source Schematic and BOM](https://github.com/ARK-Electronics/ARK_RTK_GPS) +- Sensors + - Ublox F9P GPS + - Multi-band GNSS receiver delivers centimetre level accuracy in seconds + - Concurrent reception of GPS, GLONASS, Galileo and BeiDou + - Multi-band RTK with fast convergence times and reliable performance + - High update rate for highly dynamic applications + - Centimetre accuracy in a small and energy efficient module + - Does not Support Moving Base for Heading + - Bosch BMM150 Magnetometer + - Bosch BMP388 Barometer + - Invensense ICM-42688-P 6-Axis IMU +- STM32F412CEU6 MCU +- Safety Button +- Buzzer +- Two Pixhawk Standard CAN Connectors (4 Pin JST GH) +- F9P `UART 2` Connector + - 3 Pin JST GH + - TX, RX, GND +- Pixhawk Standard Debug Connector (6 Pin JST SH) +- LED Indicators + - Safety LED + - GPS Fix + - RTK Status + - RGB system status +- USA Built +- Power Requirements + - 5V + - 170mA Average + - 180mA Max + +## Hardware Setup + +### Wiring + +The ARK RTK GPS L1 L5 is connected to the CAN bus using a Pixhawk standard 4 pin JST GH cable. For more information, refer to the [CAN Wiring](../can/index.md#wiring) instructions. + +### Mounting + +The recommended mounting orientation is with the connectors on the board pointing towards the **back of vehicle**. + +The sensor can be mounted anywhere on the frame, but you will need to specify its position, relative to vehicle centre of gravity, during [PX4 configuration](#px4-configuration). + +## Firmware Setup + +ARK RTK GPS L1 L5 runs the [PX4 cannode firmware](px4_cannode_fw.md). As such, it supports firmware update over the CAN bus and [dynamic node allocation](index.md#node-id-allocation). + +ARK RTK GPS L1 L5 boards ship with recent firmware pre-installed, but if you want to build and flash the latest firmware yourself, refer to the [cannode firmware build instructions](px4_cannode_fw.md#building-the-firmware). + +Firmware target: `ark_can-rtk-gps_default` +Bootloader target: `ark_can-rtk-gps_canbootloader` + +## Flight Controller Setup + +### Enabling DroneCAN + +In order to use the ARK RTK GPS L1 L5, connect it to the Pixhawk CAN bus and enable the DroneCAN driver by setting parameter [UAVCAN_ENABLE](../advanced_config/parameter_reference.md#UAVCAN_ENABLE) to `2` for dynamic node allocation (or `3` if using [DroneCAN ESCs](../dronecan/escs.md)). + +The steps are: + +- In _QGroundControl_ set the parameter [UAVCAN_ENABLE](../advanced_config/parameter_reference.md#UAVCAN_ENABLE) to `2` or `3` and reboot (see [Finding/Updating Parameters](../advanced_config/parameters.md)). +- Connect ARK RTK GPS L1 L5 CAN to the Pixhawk CAN. + +Once enabled, the module will be detected on boot. +GPS data should arrive at 10Hz. + +### PX4 Configuration + +You need to set necessary [DroneCAN](index.md) parameters and define offsets if the sensor is not centred within the vehicle: + +- Enable GPS yaw fusion by setting bit 3 of [EKF2_GPS_CTRL](../advanced_config/parameter_reference.md#EKF2_GPS_CTRL) to true. +- Enable GPS blending to ensure the heading is always published by setting [SENS_GPS_MASK](../advanced_config/parameter_reference.md#SENS_GPS_MASK) to 7 (all three bits checked). +- Enable [UAVCAN_SUB_GPS](../advanced_config/parameter_reference.md#UAVCAN_SUB_GPS), [UAVCAN_SUB_MAG](../advanced_config/parameter_reference.md#UAVCAN_SUB_MAG), and [UAVCAN_SUB_BARO](../advanced_config/parameter_reference.md#UAVCAN_SUB_BARO). +- The parameters [EKF2_GPS_POS_X](../advanced_config/parameter_reference.md#EKF2_GPS_POS_X), [EKF2_GPS_POS_Y](../advanced_config/parameter_reference.md#EKF2_GPS_POS_Y) and [EKF2_GPS_POS_Z](../advanced_config/parameter_reference.md#EKF2_GPS_POS_Z) can be set to account for the offset of the ARK RTK GPS L1 L5 from the vehicles centre of gravity. + +### ARK RTK GPS L1 L5 Configuration + +You may need to [configure the following parameters](../dronecan/index.md#qgc-cannode-parameter-configuration) on the ARK RTK GPS L1 L5 itself: + +| Parameter | Description | +| -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | +| [CANNODE_NODE_ID](../advanced_config/parameter_reference.md#CANNODE_NODE_ID) | CAN node ID (0 for dynamic allocation). If set to 0 (default), dynamic node allocation is used. Set to 1-127 to use a static node ID. | +| [CANNODE_TERM](../advanced_config/parameter_reference.md#CANNODE_TERM) | CAN built-in bus termination. Set to `1` if this is the last node on the CAN bus. | + +### Setting Up Rover and Fixed Base + +Position of the rover is established using RTCM messages from the RTK base module (the base module is connected to QGC, which sends the RTCM information to PX4 via MAVLink). + +PX4 DroneCAN parameters: + +- [UAVCAN_PUB_RTCM](../advanced_config/parameter_reference.md#UAVCAN_PUB_RTCM): + - Makes PX4 publish RTCM messages ([RTCMStream](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#rtcmstream)) to the bus (which it gets from the RTK base module via QGC). + +Rover module parameters (also [set using QGC](../dronecan/index.md#qgc-cannode-parameter-configuration)): + +- [CANNODE_SUB_RTCM](../advanced_config/parameter_reference.md#CANNODE_SUB_RTCM) tells the rover that it should subscribe to [RTCMStream](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#rtcmstream) RTCM messages on the bus (from the moving base). + +::: info +Use [UAVCAN_PUB_MBD](../advanced_config/parameter_reference.md#UAVCAN_PUB_MBD) and [CANNODE_SUB_MBD](../advanced_config/parameter_reference.md#CANNODE_SUB_MBD) instead if you want to implement moving base (see below) at the same time. +::: + +For more information see [Rover and Fixed Base](../dronecan/index.md#rover-and-fixed-base) in the DroneCAN guide. + +## LED Meanings + +- The GPS status lights are located to the right of the connectors + - Blinking green is GPS fix + - Blinking blue is received corrections and RTK Float + - Solid blue is RTK Fixed + +- The CAN status lights are located top the left of the connectors + - Slow blinking green is waiting for CAN connection + - Fast blinking green is normal operation + - Slow blinking green and blue is CAN enumeration + - Fast blinking blue and red is firmware update in progress + - Blinking red is error + - If you see a red LED there is an error and you should check the following + - Make sure the flight controller has an SD card installed + - Make sure the ARK RTK GPS L1 L5 has `ark_can-rtk-gps_canbootloader` installed prior to flashing `ark_can-rtk-gps_default` + - Remove binaries from the root and ufw directories of the SD card and try to build and flash again + +### Updating Ublox F9P Module + +ARK RTK GPS L1 L5 comes with the Ublox F9P module up to date with version 1.13 or newer. However, you can check the version and update the firmware if desired. + +The steps are: + +1. [Download u-center from u-blox.com](https://www.u-blox.com/en/product/u-center) and install on your PC (Windows only) +2. Open the [u-blox ZED-F9P website](https://www.u-blox.com/en/product/zed-f9p-module#tab-documentation-resources) +3. Scroll down and click on the "Show Legacy Documents" box +4. Scroll down again to Firmware Update and download your desired firmware (at least version 1.13 is needed) +5. While holding down the safety switch on the ARK RTK GPS L1 L5, connect it to power via one of its CAN ports and hold until all 3 LEDs blink rapidly +6. Connect the ARK RTK GPS L1 L5 to your PC via its debug port with a cable such as the Black Magic Probe or an FTDI +7. Open u-center, select the COM port for the ARK RTK GPS L1 L5 and connect + ![U-Center Connect](../../assets/hardware/gps/ark/ark_rtk_gps_ucenter_connect.png) +8. Check the current firmware version by selecting View, Messages View, UBX, MON, VER + ![Check Version](../../assets/hardware/gps/ark/ark_rtk_gps_ublox_version.png) +9. To update the firmware: + 1. Select Tools, Firmware Update + 2. The Firmware image field should be the .bin file downloaded from the u-blox ZED-F9P website + 3. Check the "Use this baudrate for update" checkbox and select 115200 from the drop-down + 4. Ensure the other checkboxes are as shown below + 5. Push the green GO button on the bottom left + 6. "Firmware Update SUCCESS" should be displayed if it updated successfully + ![Firmware Update](../../assets/hardware/gps/ark/ark_rtk_gps_ublox_f9p_firmware_update.png) + +## See Also + +- [ARK RTK GPS L1 L5 Documentation](https://arkelectron.gitbook.io/ark-documentation/sensors/ark-rtk-gps) (ARK Docs) diff --git a/docs/en/dronecan/ark_x20_rtk_gps.md b/docs/en/dronecan/ark_x20_rtk_gps.md new file mode 100644 index 0000000000..4afc299d5d --- /dev/null +++ b/docs/en/dronecan/ark_x20_rtk_gps.md @@ -0,0 +1,141 @@ +# ARK X20 RTK GPS + +[ARK X20 RTK GPS](https://docs.arkelectron.com/gps/ark-x20-rtk-gps) is an open source [DroneCAN](index.md) [RTK GPS](../gps_compass/rtk_gps.md), [u-blox ZED-X20P all-band high precision GNSS module](https://www.u-blox.com/en/product/zed-x20p-module), magnetometer, barometer, IMU, buzzer, and safety switch module. + +![ARK X20 RTK GPS](../../assets/hardware/gps/ark/ark_x20_rtk_gps.jpg) + +## Where to Buy + +Order this module from: + +- [ARK Electronics](https://arkelectron.com/product/ark-x20-rtk-gps/) (US) + +## Hardware Specifications + +- [Open Source Schematic and BOM](https://github.com/ARK-Electronics/ARK_RTK_GPS) +- Sensors + - Ublox ZED-X20P + - All-band all constellation GNSS receiver + - Best position accuracy and availability in different environments + - RTK, PPP-RTK and PPP algorithms expanding the limits of performance + - Highest quality GNSS raw data + - u-blox end-to-end hardened security + - 25Hz update rate + - ST IIS2MDC Magnetometer + - Bosch BMP390 Barometer + - Invensense ICM-42688-P 6-Axis IMU +- STM32F412VGH6 MCU +- Safety Button +- Buzzer +- Two Pixhawk Standard CAN Connectors (4 Pin JST GH) +- X20 “UART 2” Connector + - 4 Pin JST GH + - TX, RX, PPS, GND +- I2C Expansion Connector + - 4 Pin JST-GH + - 5.0V, SCL, SDA, GND +- Pixhawk Standard Debug Connector (6 Pin JST SH) +- LED Indicators + - Safety LED + - GPS Fix + - RTK Status + - RGB system status +- USA Built +- Power Requirements + - 5V + - 144mA Average + - 157mA Max + +## Hardware Setup + +### Wiring + +The ARK X20 RTK GPS is connected to the CAN bus using a Pixhawk standard 4 pin JST GH cable. For more information, refer to the [CAN Wiring](../can/index.md#wiring) instructions. + +### Mounting + +The recommended mounting orientation is with the connectors on the board pointing towards the **back of vehicle**. + +The sensor can be mounted anywhere on the frame, but you will need to specify its position, relative to vehicle centre of gravity, during [PX4 configuration](#px4-configuration). + +## Firmware Setup + +ARK X20 RTK GPS runs the [PX4 cannode firmware](px4_cannode_fw.md). As such, it supports firmware update over the CAN bus and [dynamic node allocation](index.md#node-id-allocation). + +ARK X20 RTK GPS boards ship with recent firmware pre-installed, but if you want to build and flash the latest firmware yourself, refer to the [cannode firmware build instructions](px4_cannode_fw.md#building-the-firmware). + +Firmware target: `ark_can-rtk-gps_default` +Bootloader target: `ark_can-rtk-gps_canbootloader` + +## Flight Controller Setup + +### Enabling DroneCAN + +In order to use the ARK X20 RTK GPS, connect it to the Pixhawk CAN bus and enable the DroneCAN driver by setting parameter [UAVCAN_ENABLE](../advanced_config/parameter_reference.md#UAVCAN_ENABLE) to `2` for dynamic node allocation (or `3` if using [DroneCAN ESCs](../dronecan/escs.md)). + +The steps are: + +- In _QGroundControl_ set the parameter [UAVCAN_ENABLE](../advanced_config/parameter_reference.md#UAVCAN_ENABLE) to `2` or `3` and reboot (see [Finding/Updating Parameters](../advanced_config/parameters.md)). +- Connect ARK X20 RTK GPS CAN to the Pixhawk CAN. + +Once enabled, the module will be detected on boot. +GPS data should arrive at 10Hz. + +### PX4 Configuration + +You need to set necessary [DroneCAN](index.md) parameters and define offsets if the sensor is not centred within the vehicle: + +- Enable GPS yaw fusion by setting bit 3 of [EKF2_GPS_CTRL](../advanced_config/parameter_reference.md#EKF2_GPS_CTRL) to true. +- Enable GPS blending to ensure the heading is always published by setting [SENS_GPS_MASK](../advanced_config/parameter_reference.md#SENS_GPS_MASK) to 7 (all three bits checked). +- Enable [UAVCAN_SUB_GPS](../advanced_config/parameter_reference.md#UAVCAN_SUB_GPS), [UAVCAN_SUB_MAG](../advanced_config/parameter_reference.md#UAVCAN_SUB_MAG), and [UAVCAN_SUB_BARO](../advanced_config/parameter_reference.md#UAVCAN_SUB_BARO). +- The parameters [EKF2_GPS_POS_X](../advanced_config/parameter_reference.md#EKF2_GPS_POS_X), [EKF2_GPS_POS_Y](../advanced_config/parameter_reference.md#EKF2_GPS_POS_Y) and [EKF2_GPS_POS_Z](../advanced_config/parameter_reference.md#EKF2_GPS_POS_Z) can be set to account for the offset of the ARK X20 RTK GPS from the vehicles centre of gravity. + +### ARK X20 RTK GPS Configuration + +You may need to [configure the following parameters](../dronecan/index.md#qgc-cannode-parameter-configuration) on the ARK X20 RTK GPS itself: + +| Parameter | Description | +| -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | +| [CANNODE_NODE_ID](../advanced_config/parameter_reference.md#CANNODE_NODE_ID) | CAN node ID (0 for dynamic allocation). If set to 0 (default), dynamic node allocation is used. Set to 1-127 to use a static node ID. | +| [CANNODE_TERM](../advanced_config/parameter_reference.md#CANNODE_TERM) | CAN built-in bus termination. Set to `1` if this is the last node on the CAN bus. | + +### Setting Up Rover and Fixed Base + +Position of the rover is established using RTCM messages from the RTK base module (the base module is connected to QGC, which sends the RTCM information to PX4 via MAVLink). + +PX4 DroneCAN parameters: + +- [UAVCAN_PUB_RTCM](../advanced_config/parameter_reference.md#UAVCAN_PUB_RTCM): + - Makes PX4 publish RTCM messages ([RTCMStream](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#rtcmstream)) to the bus (which it gets from the RTK base module via QGC). + +Rover module parameters (also [set using QGC](../dronecan/index.md#qgc-cannode-parameter-configuration)): + +- [CANNODE_SUB_RTCM](../advanced_config/parameter_reference.md#CANNODE_SUB_RTCM) tells the rover that it should subscribe to [RTCMStream](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#rtcmstream) RTCM messages on the bus (from the moving base). + +::: info +Use [UAVCAN_PUB_MBD](../advanced_config/parameter_reference.md#UAVCAN_PUB_MBD) and [CANNODE_SUB_MBD](../advanced_config/parameter_reference.md#CANNODE_SUB_MBD) instead if you want to implement moving base (see below) at the same time. +::: + +For more information see [Rover and Fixed Base](../dronecan/index.md#rover-and-fixed-base) in the DroneCAN guide. + +## LED Meanings + +- The GPS status lights are located to the right of the connectors + - Blinking green is GPS fix + - Blinking blue is received corrections and RTK Float + - Solid blue is RTK Fixed + +- The CAN status lights are located top the left of the connectors + - Slow blinking green is waiting for CAN connection + - Fast blinking green is normal operation + - Slow blinking green and blue is CAN enumeration + - Fast blinking blue and red is firmware update in progress + - Blinking red is error + - If you see a red LED there is an error and you should check the following + - Make sure the flight controller has an SD card installed + - Make sure the ARK X20 RTK GPS has `ark_can-rtk-gps_canbootloader` installed prior to flashing `ark_can-rtk-gps_default` + - Remove binaries from the root and ufw directories of the SD card and try to build and flash again + +## See Also + +- [ARK X20 RTK GPS Documentation](https://docs.arkelectron.com/gps/ark-x20-rtk-gps) (ARK Docs) diff --git a/docs/en/dronecan/index.md b/docs/en/dronecan/index.md index d2262b6944..04dd9e3aa7 100644 --- a/docs/en/dronecan/index.md +++ b/docs/en/dronecan/index.md @@ -62,6 +62,8 @@ Supported hardware includes (this is not an exhaustive list): - [Holybro RM3100 Professional Grade Compass](https://holybro.com/products/dronecan-rm3100-compass) - [RaccoonLab RM3100 Magnetometer](https://docs.raccoonlab.co/guide/gps_mag_baro/mag_rm3100.html) - Distance sensors + - [ARK Dist](ark_dist.md) + - [Ark Dist MR](ark_dist_mr.md) - [ARK Flow](ark_flow.md) - [Ark Flow MR](ark_flow_mr.md) - [Avionics Anonymous Laser Altimeter UAVCAN Interface](../dronecan/avanon_laser_interface.md) diff --git a/docs/en/features_fw/gain_compression.md b/docs/en/features_fw/gain_compression.md new file mode 100644 index 0000000000..7efb48f59c --- /dev/null +++ b/docs/en/features_fw/gain_compression.md @@ -0,0 +1,24 @@ +# Gain compression + + + +Automatic gain compression reduces the gains of the angular-rate PID whenever oscillations are detected. +It monitors the angular-rate controller output through a band-pass filter to identify these oscillations. + +This approach is a safe adaptive mechanism for stable aircraft: the PID gains remain unchanged when no oscillations are present, they are never increased beyond their nominal values, and they are bounded by a minimum limit. + +Gain compression can help prevent actuator damage and even loss of the vehicle in cases such as airspeed-sensor failure (loss of airspeed scaling) or in-flight changes in dynamics (e.g.: CG shifts, inertia changes), or other failures that could cause the angular-rate loop to become oscillatory. + +![Gain compression diagram](../../assets/config/fw/gain_compression_diagram.png) + +## Usage + +Gain compression is enabled by default ([FW_GC_EN](../advanced_config/parameter_reference.md#FW_GC_EN)). + +It should be disabled during fixed wing [manual tuning](../config_fw/pid_tuning_guide_fixedwing.md) to avoid over-tuning. +It does not need to be disabled when autotuning. + +## Parameters + +- [FW_GC_EN](../advanced_config/parameter_reference.md#FW_GC_EN) +- [FW_GC_GAIN_MIN](../advanced_config/parameter_reference.md#FW_GC_GAIN_MIN) diff --git a/docs/en/features_fw/index.md b/docs/en/features_fw/index.md new file mode 100644 index 0000000000..7eab8e9c6c --- /dev/null +++ b/docs/en/features_fw/index.md @@ -0,0 +1,5 @@ +# Fixedwing-Specific Features + +This section lists features that are specific to (or customised for) fixed-wings: + +- [Gain Compression](../features_fw/gain_compression.md) diff --git a/docs/en/flight_controller/autopilot_manufacturer_supported.md b/docs/en/flight_controller/autopilot_manufacturer_supported.md index f5482326a0..46885eaf82 100644 --- a/docs/en/flight_controller/autopilot_manufacturer_supported.md +++ b/docs/en/flight_controller/autopilot_manufacturer_supported.md @@ -30,6 +30,7 @@ The boards in this category are: - [Holybro Kakute H7](../flight_controller/kakuteh7.md) - [Holybro Durandal](../flight_controller/durandal.md) - [Holybro Pix32 v5](../flight_controller/holybro_pix32_v5.md) +- [MicoAir H743 Lite](../flight_controller/micoair743-lite.md) - [ModalAI VOXL 2](../flight_controller/modalai_voxl_2.md) - [mRo Control Zero](../flight_controller/mro_control_zero_f7.md) - [Radiolink PIX6](../flight_controller/radiolink_pix6.md) diff --git a/docs/en/flight_controller/micoair743-lite.md b/docs/en/flight_controller/micoair743-lite.md new file mode 100644 index 0000000000..4f7ac36bc6 --- /dev/null +++ b/docs/en/flight_controller/micoair743-lite.md @@ -0,0 +1,152 @@ +# MicoAir743-Lite + + + +:::warning +PX4 does not manufacture this (or any) autopilot. +Contact the [manufacturer](https://micoair.com/) for hardware support or compliance issues. +::: + +MicoAir743-Lite is an ultra-high performance H743 flight controller with an unbeatable price, featuring the ICM45686 IMU sensor and integrated Bluetooth telemetry. + +![MicoAir743-Lite Front View](../../assets/flight_controller/micoair743_lite/front_view.png) + +Equipped with a high-performance H7 processor, the MicoAir743-Lite features a compact form factor with SH1.0 connectors (which are more suitable than Pixhawk-standard GH1.25 for this board size). +When paired with with Bluetooth telemetry, the board can be debugged with a phone or PC. + +::: info +This flight controller is [manufacturer supported](../flight_controller/autopilot_manufacturer_supported.md). +::: + +## MicoAir743-Lite (v1.1) + +![MicoAir743-Lite Back View](../../assets/flight_controller/micoair743_lite/back_view.png) + +## Quick Summary + +### Processors & Sensors + +- FMU Processor: STM32H743 + - 32 Bit Arm® Cortex®-M7, 480MHz, 2MB flash memory, 1MB RAM +- On-board sensors + - Accel/Gyro: ICM-45686 (with BalancedGyro™ Technology) + - Barometer: SPA06 +- On-board Bluetooth Telemetry + - Connected to UART8 internally, baudrate 115200 + - Connecting to QGC (PC or Android phone) via Bluetooth +- Other Characteristics: + - Operating & storage temperature: -20 ~ 85°c + +### Interfaces + +- 8 UART (TELEM / GPS / RC) +- 14 PWM outputs (10 supports DShot) +- Support multiple RC inputs (SBUS / CRSF / DSM) +- 1 GPS port +- 1 I2C port +- 2 ADC port2 (VBAT, Current) +- 1 DJI O3/O4 VTX connector +- 1 MicroSD Card Slot +- 1 USB Type-C + +### Electrical data + +- VBAT Input: + - 2\~6S (6\~27V) +- USB Power Input: + - 4.75\~5.25V +- BEC Output: + - 5V 2A (for controller, receiver, GPS, optical flow or other devices) + - 9V 2A (for video transmitter, camera) + +### Mechanical data + +- Mounting: 30.5 x 30.5mm, Φ4mm +- Dimensions: 36 x 36 x 8 mm +- Weight: 10g + +![MicoAir743-Lite Size](../../assets/flight_controller/micoair743_lite/size.png) + +## Where to Buy + +Order from [MicoAir Tech Store](https://store.micoair.com/product/micoair743-lite/). + +## Pinouts + +Pinouts definition can be found in the [MicoAir743-Lite_pinout.xlsx](https://raw.githubusercontent.com/PX4/PX4-Autopilot/refs/heads/main/docs/assets/flight_controller/micoair743_lite/micoair743_lite_pinout.xlsx) file. + +## Serial Port Mapping + +| UART | Device | Port | +| ------ | ---------- | ------ | +| USART1 | /dev/ttyS0 | TELEM1 | +| USART2 | /dev/ttyS1 | GPS2 | +| USART3 | /dev/ttyS2 | GPS1 | +| UART4 | /dev/ttyS3 | TELEM2 | +| UART5 | /dev/ttyS4 | TELEM3 | +| USART6 | /dev/ttyS5 | RC | +| UART7 | /dev/ttyS6 | URT6 | +| UART8 | /dev/ttyS7 | TELEM4 | + +## Interfaces Diagram + +::: note +All the connectors used on the board are SH1.0 +::: + +![MicoAir743-Lite Interface Diagram](../../assets/flight_controller/micoair743_lite/interfaces_diagram.png) + +## Sample Wiring Diagram + +![MicoAir743-Lite Wiring Diagram](../../assets/flight_controller/micoair743_lite/wiring_diagram.png) + +## Building Firmware + +To [build PX4](../dev_setup/building_px4.md) for this target: + +```sh +make micoair_h743-lite_default +``` + +## Installing PX4 Firmware + +The firmware can be installed in any of the normal ways: + +- Build and upload the source + + ```sh + make micoair_h743-lite_default upload + ``` + +- [Load the firmware](../config/firmware.md) using _QGroundControl_. + You can use either pre-built firmware or your own custom firmware. + + ::: info + At time of writing the only pre-built software is `PX4 main` (see [Installing PX4 Main, Beta or Custom Firmware](../config/firmware.md#installing-px4-main-beta-or-custom-firmware)). + Release builds will be supported for PX4 v1.17 and later. + ::: + +## Radio Control + +A [Radio Control (RC) system](../getting_started/rc_transmitter_receiver.md) is required if you want to manually control your vehicle (PX4 does not require a radio system for autonomous flight modes). + +The RC port is connected to the FMU and you can attach a receiver that uses the protocols `DSM`, `SBUS`, `CSRF`, `GHST`, or other protocol listed in [Radio Control modules](../modules/modules_driver_radio_control.md). +You will need to enable the protocol by setting the corresponding parameter `RC_xxxx_PRT_CFG`, such as [RC_CRSF_PRT_CFG](../advanced_config/parameter_reference.md#RC_CRSF_PRT_CFG) for a [CRSF receiver](../telemetry/crsf_telemetry.md). + +## Supported Platforms / Airframes + +Any multicopter / airplane / rover or boat that can be controlled with normal RC servos or Futaba S-Bus servos. +The complete set of supported configurations can be seen in the [Airframes Reference](../airframes/airframe_reference.md). + +## Peripherals + +- [MicoAir Telemetry Radio Modules](https://micoair.com/radio_telemetry/) +- [MicoAir Optical & Range Sensor](https://micoair.com/optical_range_sensor/) +- [MicoAir GPS](https://micoair.com/gps/) +- [MicoAir ESC Modules](https://micoair.com/esc/) + +## Further info + +- [MicoAir Tech.](https://micoair.com/) +- [Details about MicoAir743-Lite](https://micoair.com/flightcontroller_micoair743lite/) +- [QGroundControl Download and Install](https://docs.qgroundcontrol.com/Stable_V5.0/en/qgc-user-guide/getting_started/download_and_install.html) diff --git a/docs/en/flight_controller/pixhawk_series.md b/docs/en/flight_controller/pixhawk_series.md index 3091a4afd8..cc92192d48 100644 --- a/docs/en/flight_controller/pixhawk_series.md +++ b/docs/en/flight_controller/pixhawk_series.md @@ -100,6 +100,24 @@ At very high level, the main differences are: +### FMUv6 Comparison + +| Feature | **FMUv6X-RT** | **FMUv6X** | **FMUv6C** | +| ------------------ | --------------------- | ----------------- | ------------------ | +| **FMU MCU** | NXP i.MX RT1176 | STM32H753 | STM32H743V | +| **RAM** | 2 MB | 1 MB | 1 MB | +| **Flash** | 64 MB Octal SPI | 2 MB internal | 2 MB internal | +| **IO MCU** | STM32F103 | STM32F103 | STM32F103 | +| **Secure Element** | NXP SE051 | NXP SE051 | Not supported | +| **PAB Standard** | Supported | Supported | Not supported | +| **Ethernet** | Supported | Supported | Not supported | +| **IMUs** | 3× | 3× | 2× | +| **Barometers** | 2× | 2× | 1× | +| **Magnetometer** | 1× | 1× | 1× | +| **FMU PWM** | 12× | 8× | 8× | +| **IO PWM** | 8× | 8× | 8× | +| **CAN Bus** | 3× | 2× | 2× | + ### Licensing and Trademarks Pixhawk project schematics and reference designs are licensed under [CC BY-SA 3](https://creativecommons.org/licenses/by-sa/3.0/legalcode). diff --git a/docs/en/flight_modes_fw/return.md b/docs/en/flight_modes_fw/return.md index 01ceafe6a4..393d1c6a13 100644 --- a/docs/en/flight_modes_fw/return.md +++ b/docs/en/flight_modes_fw/return.md @@ -25,11 +25,6 @@ The default type is recommended. ::: -::: warning -There is a known issue ([PX4-Autopilot#25436](https://github.com/PX4/PX4-Autopilot/issues/25436)) with fixed-wing approaches and landings while in RTL mode. -Please review the issue and verify in simulation that the behavior you get is safe in an RTL landing scenario (if not, consider using rally points). -::: - ## Technical Summary Fixed-wing vehicles use the _mission landing/rally point_ return type by default. diff --git a/docs/en/gps_compass/ark_dan_gps.md b/docs/en/gps_compass/ark_dan_gps.md new file mode 100644 index 0000000000..78cfd19a95 --- /dev/null +++ b/docs/en/gps_compass/ark_dan_gps.md @@ -0,0 +1,62 @@ +# ARK DAN GPS + +[ARK DAN GPS](https://arkelectron.gitbook.io/ark-documentation/gps/ark-dan-gps) is a made in the USA and NDAA-compliant [GNSS/GPS](../gps_compass/index.md) u-blox DAN-F10N GPS and industrial magnetometer. + +![ARK DAN GPS](../../assets/hardware/gps/ark/ark_dan_gps.jpg) + +## Where to Buy + +Order this module from: + +- [ARK Electronics](https://arkelectron.com/product/ark-dan-gps/) (US) + +## Hardware Specifications + +- [Open Source Schematic and BOM](https://github.com/ARK-Electronics/ARK_DAN_GPS) +- Sensors + - [u-blox DAN-F10N](https://www.u-blox.com/en/product/dan-f10n-module) + - L1/L5/E5a/B2a bands + - Consistently strong performance regardless of installation + - Integrated SAW-LNA-SAW for exceptional out-of-band jamming immunity + - u-blox F10 proprietary dual-band multipath mitigation technology + - [ST IIS2MDC Magnetometer](https://www.st.com/en/mems-and-sensors/iis2mdc.html) +- Pixhawk Standard UART/I2C Connector (6 Pin JST SH) +- Power Requirements + - 5V + - 25mA Average + - 44mA Max +- LED Indicators + - GPS Fix +- USA Built +- NDAA Compliant +- 6 Pin Pixhawk Standard UART/I2C Cable + +## Hardware setup + +The module comes with a Pixhawk-standard 6pin connector that will plug into the `GPS2` port on recent Pixhawk flight controllers. +It should be mounted front facing, as far away from the flight controller and other electronics as possible. + +For more information see [Mounting the GNSS/Compass](../gps_compass/index.md#mounting-the-gnss-compass) and [Hardware Setup](../gps_compass/index.md#hardware-setup). + +## PX4 Configuration + +The module should be plug-n-play when used with the `GPS2` port on most flight controllers. + +[Secondary GPS Configuration (UART)](../gps_compass/index.md#secondary-gps-configuration-uart) explains how you can configure the port if the GPS is not detected (note, that the configuration is the same, even if you are using GPS 2 as the primary compass). + +## Pinout + +### Pixhawk Standard UART/I2C Connector - 6 Pin JST-SH + +| Pin Number | Signal Name | Voltage | +| ---------- | ----------- | ------- | +| 1 | 5V | 5.0V | +| 2 | RX | 3.3V | +| 3 | TX | 3.3V | +| 4 | SCL | 3.3V | +| 5 | SDA | 3.3V | +| 6 | GND | GND | + +## See Also + +- [ARK DAN GPS Documentation](https://arkelectron.gitbook.io/ark-documentation/gps/ark-dan-gps) (ARK Docs) diff --git a/docs/en/gps_compass/ark_sam_gps.md b/docs/en/gps_compass/ark_sam_gps.md index 8a6d11c21a..49a864458e 100644 --- a/docs/en/gps_compass/ark_sam_gps.md +++ b/docs/en/gps_compass/ark_sam_gps.md @@ -1,6 +1,6 @@ # ARK SAM GPS -[ARK SAM GPS](https://arkelectron.gitbook.io/ark-documentation/gps/ark-sam-gps>) is a made in the USA and NDAA-compliant [GNSS/GPS](../gps_compass/index.md) u-blox SAM-M10Q GPS and industrial magnetometer. +[ARK SAM GPS](https://arkelectron.gitbook.io/ark-documentation/gps/ark-sam-gps) is a made in the USA and NDAA-compliant [GNSS/GPS](../gps_compass/index.md) u-blox SAM-M10Q GPS and industrial magnetometer. ![ARK SAM GPS](../../assets/hardware/gps/ark/ark_sam_gps.jpg) @@ -33,7 +33,7 @@ Order this module from: ## Hardware setup The module comes with a Pixhawk-standard 6pin connector that will plug into the `GPS2` port on recent Pixhawk flight controllers. -It should be mounted front facing, as far away from the flight controller and other electronics as possible. +It should be mounted front facing, as far away from the flight controller and other electronics as possible. For more information see [Mounting the GNSS/Compass](../gps_compass/index.md#mounting-the-gnss-compass) and [Hardware Setup](../gps_compass/index.md#hardware-setup). diff --git a/docs/en/gps_compass/ark_sam_gps_mini.md b/docs/en/gps_compass/ark_sam_gps_mini.md new file mode 100644 index 0000000000..3c124c07fe --- /dev/null +++ b/docs/en/gps_compass/ark_sam_gps_mini.md @@ -0,0 +1,61 @@ +# ARK SAM GPS MINI + +[ARK SAM GPS MINI](https://arkelectron.gitbook.io/ark-documentation/gps/ark-sam-gps) is a made in the USA and NDAA-compliant [GNSS/GPS](../gps_compass/index.md) u-blox SAM-M10Q GPS and industrial magnetometer. + +![ARK SAM GPS MINI](../../assets/hardware/gps/ark/ark_sam_gps_mini.jpg) + +## Where to Buy + +Order this module from: + +- [ARK Electronics](https://arkelectron.com/product/ark-sam-gps-mini/) (US) + +## Hardware Specifications + +- [Open Source Schematic and BOM](https://github.com/ARK-Electronics/ARK_SAM_GPS/tree/main) +- Sensors + - [u-blox SAM-M10Q](https://www.u-blox.com/en/product/sam-m10q-module) + - Less than 38 mW power consumption without compromising GNSS performance + - Maximum position availability with 4 concurrent GNSS reception + - Advanced spoofing and jamming detection + - [ST IIS2MDC Magnetometer](https://www.st.com/en/mems-and-sensors/iis2mdc.html) +- Pixhawk Standard UART/I2C Connector (6 Pin JST SH) +- Power Requirements + - 5V + - 15mA Average + - 20mA Max +- LED Indicators + - GPS Fix +- USA Built +- NDAA Compliant +- 6 Pin Pixhawk Standard UART/I2C Cable + +## Hardware setup + +The module comes with a Pixhawk-standard 6pin connector that will plug into the `GPS2` port on recent Pixhawk flight controllers. +It should be mounted front facing, as far away from the flight controller and other electronics as possible. + +For more information see [Mounting the GNSS/Compass](../gps_compass/index.md#mounting-the-gnss-compass) and [Hardware Setup](../gps_compass/index.md#hardware-setup). + +## PX4 Configuration + +The module should be plug-n-play when used with the `GPS2` port on most flight controllers. + +[Secondary GPS Configuration (UART)](../gps_compass/index.md#secondary-gps-configuration-uart) explains how you can configure the port if the GPS is not detected (note, that the configuration is the same, even if you are using GPS 2 as the primary compass). + +## Pinout + +### Pixhawk Standard UART/I2C Connector - 6 Pin JST-SH + +| Pin Number | Signal Name | Voltage | +| ---------- | ----------- | ------- | +| 1 | 5V | 5.0V | +| 2 | RX | 3.3V | +| 3 | TX | 3.3V | +| 4 | SCL | 3.3V | +| 5 | SDA | 3.3V | +| 6 | GND | GND | + +## See Also + +- [ARK SAM GPS MINI Documentation](https://arkelectron.gitbook.io/ark-documentation/gps/ark-sam-gps) (ARK Docs) diff --git a/docs/en/gps_compass/index.md b/docs/en/gps_compass/index.md index dbd9514aec..60b22b9558 100644 --- a/docs/en/gps_compass/index.md +++ b/docs/en/gps_compass/index.md @@ -25,7 +25,9 @@ These have been tested by the PX4 dev team, or which are popular within the PX4 | Device | GPS | Compass | [CAN](../dronecan/index.md) | Buzzer / SafeSw / LED | Notes | | :----------------------------------------------------------- | :---------: | :-----------------------: | :-------------------------: | :-------------------: | :-------------------------- | | [ARK GPS](../dronecan/ark_gps.md) | M9N | BMM150 | ✓ | ✓ | + Baro, IMU | +| [ARK DAN GPS](../gps_compass/ark_dan_gps.md) | DAN-F10N | IIS2MDC | | ✓ | | | [ARK SAM GPS](../gps_compass/ark_sam_gps.md) | SAM-M10Q | IIS2MDC | | ✓ | | +| [ARK SAM GPS MINI ](../gps_compass/ark_sam_gps_mini.md) | SAM-M10Q | IIS2MDC | | ✓ | | | [ARK TESEO GPS](../dronecan/ark_teseo_gps.md) | Teseo-LIV4F | BMM150 | ✓ | ✓ | + Baro, IMU | | [Avionics Anonymous UAVCAN GNSS/Mag][avionics_anon_can_gnss] | SAM-M8Q | MMC5983MA | ✓ | ✘ | | | [CUAV NEO 3 GPS](../gps_compass/gps_cuav_neo_3.md) | M9N | IST8310 | | ✓ | | @@ -196,11 +198,21 @@ It is possible to have low DOP (good satellite geometry) but still have high EPH EPH/EPV values therefore provide a more immediate and practical estimate of the actual GPS accuracy you can expect under current conditions. +### GNSS Position Fusion + +GNSS position fusion will not begin until yaw alignment is established. +If a magnetometer is available, the EKF aligns yaw using the magnetic heading, allowing GPS position fusion to start soon after boot. +If no magnetometer is present, the system must rely on GPS yaw (from a dual-antenna setup) or movement-based yaw estimation. +Until one of these provides a valid heading, the EKF will not start GPS position fusion, and the vehicle will remain in a “no position” state even though attitude data is valid. +This behavior prevents large position errors that could occur when the yaw reference is uncertain. + ## Developer Information - GPS/RTK-GPS - [RTK-GPS](../advanced/rtk_gps.md) + - [PPS Time Synchronization](../advanced/pps_time_sync.md) - [GPS driver](../modules/modules_driver.md#gps) + - [PPS driver](../modules/modules_driver.md#pps-capture) - [DroneCAN Example](../dronecan/index.md) - Compass - [Driver source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/magnetometer) (Compasses) diff --git a/docs/en/gps_compass/magnetometer.md b/docs/en/gps_compass/magnetometer.md index 083985f9d3..2e6ce4f524 100644 --- a/docs/en/gps_compass/magnetometer.md +++ b/docs/en/gps_compass/magnetometer.md @@ -40,6 +40,7 @@ This list contains stand-alone magnetometer modules (without GNSS). | Device | Compass | DroneCan | | :--------------------------------------------------------------------------------------------------------------- | :-----: | :------: | +| [ARK MAG](https://arkelectron.com/product/ark-mag/) | RM3100 | ✓ | | [Avionics Anonymous UAVCAN Magnetometer](https://www.tindie.com/products/avionicsanonymous/uavcan-magnetometer/) | ? | | | [Holybro DroneCAN RM3100 Compass/Magnetometer](https://holybro.com/products/dronecan-rm3100-compass) | RM3100 | ✓ | | [RaccoonLab DroneCAN/Cyphal Magnetometer RM3100](https://holybro.com/products/dronecan-rm3100-compass) | RM3100 | ✓ | diff --git a/docs/en/gps_compass/rtk_gps.md b/docs/en/gps_compass/rtk_gps.md index b24cf96c77..c0e192c4c3 100644 --- a/docs/en/gps_compass/rtk_gps.md +++ b/docs/en/gps_compass/rtk_gps.md @@ -23,7 +23,9 @@ It also highlights devices that connect via the CAN bus, and those which support | Device | GPS | Compass | [DroneCAN](../dronecan/index.md) | [GPS Yaw](#configuring-gps-as-yaw-heading-source) | PPK | | :-------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------: | :------: | :------------------------------: | :-----------------------------------------------: | :-: | | [ARK RTK GPS](../dronecan/ark_rtk_gps.md) | F9P | BMM150 | ✓ | [Dual F9P][DualF9P] | +| [ARK RTK GPS L1 L5](../dronecan/ark_rtk_gps_l1_l2.md) | F9P | BMM150 | ✓ | | | [ARK MOSAIC-X5 RTK GPS](../dronecan/ark_mosaic__rtk_gps.md) | Mosaic-X5 | IIS2MDC | ✓ | [Septentrio Dual Antenna][SeptDualAnt] | +| [ARK X20 RTK GPS](../dronecan/ark_x20_rtk_gps.md) | X20P | BMP390 | ✓ | | | [CUAV C-RTK GPS](../gps_compass/rtk_gps_cuav_c-rtk.md) | M8P/M8N | ✓ | | | | [CUAV C-RTK2](../gps_compass/rtk_gps_cuav_c-rtk2.md) | F9P | ✓ | | [Dual F9P][DualF9P] | | [CUAV C-RTK 9Ps GPS](../gps_compass/rtk_gps_cuav_c-rtk-9ps.md) | F9P | RM3100 | | [Dual F9P][DualF9P] | diff --git a/docs/en/log/flight_log_analysis.md b/docs/en/log/flight_log_analysis.md index 2abf0f4564..88073f60c2 100644 --- a/docs/en/log/flight_log_analysis.md +++ b/docs/en/log/flight_log_analysis.md @@ -41,6 +41,23 @@ Key features: See [Log Analysis using Flight Review](../log/flight_review.md) for an introduction. +### Foxglove + +[Foxglove](https://foxglove.dev/) is a purpose-built robotics observation platform that works natively with ULog. +It allows you to replay your flights and seek through the timeline to find data of interest. + +Key features: + +- Native support for ULog files — open files by dragging and dropping or using the file dialog. +- Multiple visualization panels, including Raw Messages, Plot, 3D, and Map panels. +- [PX4 Converter extension](https://github.com/foxglove/px4_converter) that translates selected uORB messages and creates Foxglove schemas for enhanced visualizations. +- Save and share custom layouts with panels and their settings. +- Cross-platform desktop application (Windows, macOS, Linux). + +See [Foxglove PX4 Docs](https://docs.foxglove.dev/docs/getting-started/frameworks/px4) for more detailed information and instructions. + +![Foxglove](../../assets/flight_log_analysis/foxglove/foxglove_px4.png) + ### PlotJuggler [PlotJuggler](https://github.com/facontidavide/PlotJuggler) is a desktop application that allows users to easily visualize and analyze data expressed in the form of time series. diff --git a/docs/en/middleware/dds_topics.md b/docs/en/middleware/dds_topics.md index 82ec12edcd..07ec63404c 100644 --- a/docs/en/middleware/dds_topics.md +++ b/docs/en/middleware/dds_topics.md @@ -4,75 +4,84 @@ This document is [auto-generated](https://github.com/PX4/PX4-Autopilot/blob/main/Tools/msg/generate_msg_docs.py) from the source code. ::: - -The [dds_topics.yaml](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/uxrce_dds_client/dds_topics.yaml) file specifies which uORB message definitions are compiled into the [uxrce_dds_client](../modules/modules_system.md#uxrce-dds-client) and/or [zenoh](../modules/modules_driver.md#zenoh) module when [PX4 is built](../middleware/uxrce_dds.md#code-generation), and hence which topics are available for ROS 2 applications to subscribe or publish (by default). +The [dds_topics.yaml](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/uxrce_dds_client/dds_topics.yaml) file specifies which uORB message definitions are compiled into the [uxrce_dds_client](../modules/modules_system.md#uxrce-dds-client) module when [PX4 is built](../middleware/uxrce_dds.md#code-generation), and hence which topics are available for ROS 2 applications to subscribe or publish (by default). This document shows a markdown-rendered version of [dds_topics.yaml](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/uxrce_dds_client/dds_topics.yaml), listing the publications, subscriptions, and so on. ## Publications -Topic | Type| Rate Limit ---- | --- | --- -`/fmu/out/register_ext_component_reply` | [px4_msgs::msg::RegisterExtComponentReply](../msg_docs/RegisterExtComponentReply.md) | -`/fmu/out/arming_check_request` | [px4_msgs::msg::ArmingCheckRequest](../msg_docs/ArmingCheckRequest.md) | 5.0 -`/fmu/out/mode_completed` | [px4_msgs::msg::ModeCompleted](../msg_docs/ModeCompleted.md) | 50.0 -`/fmu/out/battery_status` | [px4_msgs::msg::BatteryStatus](../msg_docs/BatteryStatus.md) | 1.0 -`/fmu/out/collision_constraints` | [px4_msgs::msg::CollisionConstraints](../msg_docs/CollisionConstraints.md) | 50.0 -`/fmu/out/estimator_status_flags` | [px4_msgs::msg::EstimatorStatusFlags](../msg_docs/EstimatorStatusFlags.md) | 5.0 -`/fmu/out/failsafe_flags` | [px4_msgs::msg::FailsafeFlags](../msg_docs/FailsafeFlags.md) | 5.0 -`/fmu/out/manual_control_setpoint` | [px4_msgs::msg::ManualControlSetpoint](../msg_docs/ManualControlSetpoint.md) | 25.0 -`/fmu/out/message_format_response` | [px4_msgs::msg::MessageFormatResponse](../msg_docs/MessageFormatResponse.md) | -`/fmu/out/position_setpoint_triplet` | [px4_msgs::msg::PositionSetpointTriplet](../msg_docs/PositionSetpointTriplet.md) | 5.0 -`/fmu/out/sensor_combined` | [px4_msgs::msg::SensorCombined](../msg_docs/SensorCombined.md) | -`/fmu/out/timesync_status` | [px4_msgs::msg::TimesyncStatus](../msg_docs/TimesyncStatus.md) | 10.0 -`/fmu/out/vehicle_land_detected` | [px4_msgs::msg::VehicleLandDetected](../msg_docs/VehicleLandDetected.md) | 5.0 -`/fmu/out/vehicle_attitude` | [px4_msgs::msg::VehicleAttitude](../msg_docs/VehicleAttitude.md) | -`/fmu/out/vehicle_control_mode` | [px4_msgs::msg::VehicleControlMode](../msg_docs/VehicleControlMode.md) | 50.0 -`/fmu/out/vehicle_command_ack` | [px4_msgs::msg::VehicleCommandAck](../msg_docs/VehicleCommandAck.md) | -`/fmu/out/vehicle_global_position` | [px4_msgs::msg::VehicleGlobalPosition](../msg_docs/VehicleGlobalPosition.md) | 50.0 -`/fmu/out/vehicle_gps_position` | [px4_msgs::msg::SensorGps](../msg_docs/SensorGps.md) | 50.0 -`/fmu/out/vehicle_local_position` | [px4_msgs::msg::VehicleLocalPosition](../msg_docs/VehicleLocalPosition.md) | 50.0 -`/fmu/out/vehicle_odometry` | [px4_msgs::msg::VehicleOdometry](../msg_docs/VehicleOdometry.md) | -`/fmu/out/vehicle_status` | [px4_msgs::msg::VehicleStatus](../msg_docs/VehicleStatus.md) | 5.0 -`/fmu/out/airspeed_validated` | [px4_msgs::msg::AirspeedValidated](../msg_docs/AirspeedValidated.md) | 50.0 -`/fmu/out/vtol_vehicle_status` | [px4_msgs::msg::VtolVehicleStatus](../msg_docs/VtolVehicleStatus.md) | -`/fmu/out/home_position` | [px4_msgs::msg::HomePosition](../msg_docs/HomePosition.md) | 5.0 +| Topic | Type | Rate Limit | +| ---------------------------------------- | -------------------------------------------------------------------------------------- | ---------- | +| `/fmu/out/register_ext_component_reply` | [px4_msgs::msg::RegisterExtComponentReply](../msg_docs/RegisterExtComponentReply.md) | +| `/fmu/out/arming_check_request` | [px4_msgs::msg::ArmingCheckRequest](../msg_docs/ArmingCheckRequest.md) | 5.0 | +| `/fmu/out/mode_completed` | [px4_msgs::msg::ModeCompleted](../msg_docs/ModeCompleted.md) | 50.0 | +| `/fmu/out/battery_status` | [px4_msgs::msg::BatteryStatus](../msg_docs/BatteryStatus.md) | 1.0 | +| `/fmu/out/collision_constraints` | [px4_msgs::msg::CollisionConstraints](../msg_docs/CollisionConstraints.md) | 50.0 | +| `/fmu/out/estimator_status_flags` | [px4_msgs::msg::EstimatorStatusFlags](../msg_docs/EstimatorStatusFlags.md) | 5.0 | +| `/fmu/out/failsafe_flags` | [px4_msgs::msg::FailsafeFlags](../msg_docs/FailsafeFlags.md) | 5.0 | +| `/fmu/out/manual_control_setpoint` | [px4_msgs::msg::ManualControlSetpoint](../msg_docs/ManualControlSetpoint.md) | 25.0 | +| `/fmu/out/message_format_response` | [px4_msgs::msg::MessageFormatResponse](../msg_docs/MessageFormatResponse.md) | +| `/fmu/out/position_setpoint_triplet` | [px4_msgs::msg::PositionSetpointTriplet](../msg_docs/PositionSetpointTriplet.md) | 5.0 | +| `/fmu/out/sensor_combined` | [px4_msgs::msg::SensorCombined](../msg_docs/SensorCombined.md) | +| `/fmu/out/timesync_status` | [px4_msgs::msg::TimesyncStatus](../msg_docs/TimesyncStatus.md) | 10.0 | +| `/fmu/out/transponder_report` | [px4_msgs::msg::TransponderReport](../msg_docs/TransponderReport.md) | +| `/fmu/out/vehicle_land_detected` | [px4_msgs::msg::VehicleLandDetected](../msg_docs/VehicleLandDetected.md) | 5.0 | +| `/fmu/out/vehicle_attitude` | [px4_msgs::msg::VehicleAttitude](../msg_docs/VehicleAttitude.md) | 50.0 | +| `/fmu/out/vehicle_control_mode` | [px4_msgs::msg::VehicleControlMode](../msg_docs/VehicleControlMode.md) | 50.0 | +| `/fmu/out/vehicle_command_ack` | [px4_msgs::msg::VehicleCommandAck](../msg_docs/VehicleCommandAck.md) | +| `/fmu/out/vehicle_global_position` | [px4_msgs::msg::VehicleGlobalPosition](../msg_docs/VehicleGlobalPosition.md) | 50.0 | +| `/fmu/out/vehicle_gps_position` | [px4_msgs::msg::SensorGps](../msg_docs/SensorGps.md) | 50.0 | +| `/fmu/out/vehicle_local_position` | [px4_msgs::msg::VehicleLocalPosition](../msg_docs/VehicleLocalPosition.md) | 50.0 | +| `/fmu/out/vehicle_odometry` | [px4_msgs::msg::VehicleOdometry](../msg_docs/VehicleOdometry.md) | 100.0 | +| `/fmu/out/vehicle_status` | [px4_msgs::msg::VehicleStatus](../msg_docs/VehicleStatus.md) | 5.0 | +| `/fmu/out/airspeed_validated` | [px4_msgs::msg::AirspeedValidated](../msg_docs/AirspeedValidated.md) | 50.0 | +| `/fmu/out/vtol_vehicle_status` | [px4_msgs::msg::VtolVehicleStatus](../msg_docs/VtolVehicleStatus.md) | +| `/fmu/out/home_position` | [px4_msgs::msg::HomePosition](../msg_docs/HomePosition.md) | 5.0 | +| `/fmu/out/wind` | [px4_msgs::msg::Wind](../msg_docs/Wind.md) | 1.0 | +| `/fmu/out/gimbal_device_attitude_status` | [px4_msgs::msg::GimbalDeviceAttitudeStatus](../msg_docs/GimbalDeviceAttitudeStatus.md) | 20.0 | ## Subscriptions -Topic | Type ---- | --- -/fmu/in/register_ext_component_request | [px4_msgs::msg::RegisterExtComponentRequest](../msg_docs/RegisterExtComponentRequest.md) -/fmu/in/unregister_ext_component | [px4_msgs::msg::UnregisterExtComponent](../msg_docs/UnregisterExtComponent.md) -/fmu/in/config_overrides_request | [px4_msgs::msg::ConfigOverrides](../msg_docs/ConfigOverrides.md) -/fmu/in/arming_check_reply | [px4_msgs::msg::ArmingCheckReply](../msg_docs/ArmingCheckReply.md) -/fmu/in/message_format_request | [px4_msgs::msg::MessageFormatRequest](../msg_docs/MessageFormatRequest.md) -/fmu/in/mode_completed | [px4_msgs::msg::ModeCompleted](../msg_docs/ModeCompleted.md) -/fmu/in/config_control_setpoints | [px4_msgs::msg::VehicleControlMode](../msg_docs/VehicleControlMode.md) -/fmu/in/distance_sensor | [px4_msgs::msg::DistanceSensor](../msg_docs/DistanceSensor.md) -/fmu/in/manual_control_input | [px4_msgs::msg::ManualControlSetpoint](../msg_docs/ManualControlSetpoint.md) -/fmu/in/offboard_control_mode | [px4_msgs::msg::OffboardControlMode](../msg_docs/OffboardControlMode.md) -/fmu/in/onboard_computer_status | [px4_msgs::msg::OnboardComputerStatus](../msg_docs/OnboardComputerStatus.md) -/fmu/in/obstacle_distance | [px4_msgs::msg::ObstacleDistance](../msg_docs/ObstacleDistance.md) -/fmu/in/sensor_optical_flow | [px4_msgs::msg::SensorOpticalFlow](../msg_docs/SensorOpticalFlow.md) -/fmu/in/goto_setpoint | [px4_msgs::msg::GotoSetpoint](../msg_docs/GotoSetpoint.md) -/fmu/in/telemetry_status | [px4_msgs::msg::TelemetryStatus](../msg_docs/TelemetryStatus.md) -/fmu/in/trajectory_setpoint | [px4_msgs::msg::TrajectorySetpoint](../msg_docs/TrajectorySetpoint.md) -/fmu/in/vehicle_attitude_setpoint | [px4_msgs::msg::VehicleAttitudeSetpoint](../msg_docs/VehicleAttitudeSetpoint.md) -/fmu/in/vehicle_mocap_odometry | [px4_msgs::msg::VehicleOdometry](../msg_docs/VehicleOdometry.md) -/fmu/in/vehicle_rates_setpoint | [px4_msgs::msg::VehicleRatesSetpoint](../msg_docs/VehicleRatesSetpoint.md) -/fmu/in/vehicle_visual_odometry | [px4_msgs::msg::VehicleOdometry](../msg_docs/VehicleOdometry.md) -/fmu/in/vehicle_command | [px4_msgs::msg::VehicleCommand](../msg_docs/VehicleCommand.md) -/fmu/in/vehicle_command_mode_executor | [px4_msgs::msg::VehicleCommand](../msg_docs/VehicleCommand.md) -/fmu/in/vehicle_thrust_setpoint | [px4_msgs::msg::VehicleThrustSetpoint](../msg_docs/VehicleThrustSetpoint.md) -/fmu/in/vehicle_torque_setpoint | [px4_msgs::msg::VehicleTorqueSetpoint](../msg_docs/VehicleTorqueSetpoint.md) -/fmu/in/actuator_motors | [px4_msgs::msg::ActuatorMotors](../msg_docs/ActuatorMotors.md) -/fmu/in/actuator_servos | [px4_msgs::msg::ActuatorServos](../msg_docs/ActuatorServos.md) -/fmu/in/aux_global_position | [px4_msgs::msg::VehicleGlobalPosition](../msg_docs/VehicleGlobalPosition.md) -/fmu/in/fixed_wing_longitudinal_setpoint | [px4_msgs::msg::FixedWingLongitudinalSetpoint](../msg_docs/FixedWingLongitudinalSetpoint.md) -/fmu/in/fixed_wing_lateral_setpoint | [px4_msgs::msg::FixedWingLateralSetpoint](../msg_docs/FixedWingLateralSetpoint.md) -/fmu/in/longitudinal_control_configuration | [px4_msgs::msg::LongitudinalControlConfiguration](../msg_docs/LongitudinalControlConfiguration.md) -/fmu/in/lateral_control_configuration | [px4_msgs::msg::LateralControlConfiguration](../msg_docs/LateralControlConfiguration.md) +| Topic | Type | +| ------------------------------------------ | -------------------------------------------------------------------------------------------------- | +| /fmu/in/register_ext_component_request | [px4_msgs::msg::RegisterExtComponentRequest](../msg_docs/RegisterExtComponentRequest.md) | +| /fmu/in/unregister_ext_component | [px4_msgs::msg::UnregisterExtComponent](../msg_docs/UnregisterExtComponent.md) | +| /fmu/in/config_overrides_request | [px4_msgs::msg::ConfigOverrides](../msg_docs/ConfigOverrides.md) | +| /fmu/in/arming_check_reply | [px4_msgs::msg::ArmingCheckReply](../msg_docs/ArmingCheckReply.md) | +| /fmu/in/message_format_request | [px4_msgs::msg::MessageFormatRequest](../msg_docs/MessageFormatRequest.md) | +| /fmu/in/mode_completed | [px4_msgs::msg::ModeCompleted](../msg_docs/ModeCompleted.md) | +| /fmu/in/config_control_setpoints | [px4_msgs::msg::VehicleControlMode](../msg_docs/VehicleControlMode.md) | +| /fmu/in/distance_sensor | [px4_msgs::msg::DistanceSensor](../msg_docs/DistanceSensor.md) | +| /fmu/in/manual_control_input | [px4_msgs::msg::ManualControlSetpoint](../msg_docs/ManualControlSetpoint.md) | +| /fmu/in/offboard_control_mode | [px4_msgs::msg::OffboardControlMode](../msg_docs/OffboardControlMode.md) | +| /fmu/in/onboard_computer_status | [px4_msgs::msg::OnboardComputerStatus](../msg_docs/OnboardComputerStatus.md) | +| /fmu/in/obstacle_distance | [px4_msgs::msg::ObstacleDistance](../msg_docs/ObstacleDistance.md) | +| /fmu/in/sensor_optical_flow | [px4_msgs::msg::SensorOpticalFlow](../msg_docs/SensorOpticalFlow.md) | +| /fmu/in/goto_setpoint | [px4_msgs::msg::GotoSetpoint](../msg_docs/GotoSetpoint.md) | +| /fmu/in/telemetry_status | [px4_msgs::msg::TelemetryStatus](../msg_docs/TelemetryStatus.md) | +| /fmu/in/trajectory_setpoint | [px4_msgs::msg::TrajectorySetpoint](../msg_docs/TrajectorySetpoint.md) | +| /fmu/in/vehicle_attitude_setpoint | [px4_msgs::msg::VehicleAttitudeSetpoint](../msg_docs/VehicleAttitudeSetpoint.md) | +| /fmu/in/vehicle_mocap_odometry | [px4_msgs::msg::VehicleOdometry](../msg_docs/VehicleOdometry.md) | +| /fmu/in/vehicle_rates_setpoint | [px4_msgs::msg::VehicleRatesSetpoint](../msg_docs/VehicleRatesSetpoint.md) | +| /fmu/in/vehicle_visual_odometry | [px4_msgs::msg::VehicleOdometry](../msg_docs/VehicleOdometry.md) | +| /fmu/in/vehicle_command | [px4_msgs::msg::VehicleCommand](../msg_docs/VehicleCommand.md) | +| /fmu/in/vehicle_command_mode_executor | [px4_msgs::msg::VehicleCommand](../msg_docs/VehicleCommand.md) | +| /fmu/in/vehicle_thrust_setpoint | [px4_msgs::msg::VehicleThrustSetpoint](../msg_docs/VehicleThrustSetpoint.md) | +| /fmu/in/vehicle_torque_setpoint | [px4_msgs::msg::VehicleTorqueSetpoint](../msg_docs/VehicleTorqueSetpoint.md) | +| /fmu/in/actuator_motors | [px4_msgs::msg::ActuatorMotors](../msg_docs/ActuatorMotors.md) | +| /fmu/in/actuator_servos | [px4_msgs::msg::ActuatorServos](../msg_docs/ActuatorServos.md) | +| /fmu/in/aux_global_position | [px4_msgs::msg::VehicleGlobalPosition](../msg_docs/VehicleGlobalPosition.md) | +| /fmu/in/fixed_wing_longitudinal_setpoint | [px4_msgs::msg::FixedWingLongitudinalSetpoint](../msg_docs/FixedWingLongitudinalSetpoint.md) | +| /fmu/in/fixed_wing_lateral_setpoint | [px4_msgs::msg::FixedWingLateralSetpoint](../msg_docs/FixedWingLateralSetpoint.md) | +| /fmu/in/longitudinal_control_configuration | [px4_msgs::msg::LongitudinalControlConfiguration](../msg_docs/LongitudinalControlConfiguration.md) | +| /fmu/in/lateral_control_configuration | [px4_msgs::msg::LateralControlConfiguration](../msg_docs/LateralControlConfiguration.md) | +| /fmu/in/rover_position_setpoint | [px4_msgs::msg::RoverPositionSetpoint](../msg_docs/RoverPositionSetpoint.md) | +| /fmu/in/rover_speed_setpoint | [px4_msgs::msg::RoverSpeedSetpoint](../msg_docs/RoverSpeedSetpoint.md) | +| /fmu/in/rover_attitude_setpoint | [px4_msgs::msg::RoverAttitudeSetpoint](../msg_docs/RoverAttitudeSetpoint.md) | +| /fmu/in/rover_rate_setpoint | [px4_msgs::msg::RoverRateSetpoint](../msg_docs/RoverRateSetpoint.md) | +| /fmu/in/rover_throttle_setpoint | [px4_msgs::msg::RoverThrottleSetpoint](../msg_docs/RoverThrottleSetpoint.md) | +| /fmu/in/rover_steering_setpoint | [px4_msgs::msg::RoverSteeringSetpoint](../msg_docs/RoverSteeringSetpoint.md) | +| /fmu/in/landing_gear | [px4_msgs::msg::LandingGear](../msg_docs/LandingGear.md) | ## Subscriptions Multi @@ -85,192 +94,191 @@ They are not build into the module, and hence are neither published or subscribe ::: details See messages -- [SensorCorrection](../msg_docs/SensorCorrection.md) -- [ActuatorOutputs](../msg_docs/ActuatorOutputs.md) -- [FixedWingRunwayControl](../msg_docs/FixedWingRunwayControl.md) -- [EstimatorInnovations](../msg_docs/EstimatorInnovations.md) -- [FlightPhaseEstimation](../msg_docs/FlightPhaseEstimation.md) -- [PurePursuitStatus](../msg_docs/PurePursuitStatus.md) -- [Px4ioStatus](../msg_docs/Px4ioStatus.md) -- [SatelliteInfo](../msg_docs/SatelliteInfo.md) -- [GeofenceResult](../msg_docs/GeofenceResult.md) -- [GimbalManagerStatus](../msg_docs/GimbalManagerStatus.md) -- [ManualControlSwitches](../msg_docs/ManualControlSwitches.md) -- [OpenDroneIdSelfId](../msg_docs/OpenDroneIdSelfId.md) -- [OpenDroneIdSystem](../msg_docs/OpenDroneIdSystem.md) -- [EventV0](../msg_docs/EventV0.md) -- [QshellRetval](../msg_docs/QshellRetval.md) -- [RoverThrottleSetpoint](../msg_docs/RoverThrottleSetpoint.md) -- [AirspeedValidatedV0](../msg_docs/AirspeedValidatedV0.md) -- [RcChannels](../msg_docs/RcChannels.md) -- [SensorAccel](../msg_docs/SensorAccel.md) -- [GimbalDeviceAttitudeStatus](../msg_docs/GimbalDeviceAttitudeStatus.md) -- [EscStatus](../msg_docs/EscStatus.md) -- [RoverAttitudeSetpoint](../msg_docs/RoverAttitudeSetpoint.md) -- [RateCtrlStatus](../msg_docs/RateCtrlStatus.md) -- [AirspeedWind](../msg_docs/AirspeedWind.md) -- [InputRc](../msg_docs/InputRc.md) -- [GpioIn](../msg_docs/GpioIn.md) -- [LaunchDetectionStatus](../msg_docs/LaunchDetectionStatus.md) -- [VehicleImu](../msg_docs/VehicleImu.md) -- [Event](../msg_docs/Event.md) -- [SensorUwb](../msg_docs/SensorUwb.md) -- [ActuatorServosTrim](../msg_docs/ActuatorServosTrim.md) -- [DatamanResponse](../msg_docs/DatamanResponse.md) -- [OrbTest](../msg_docs/OrbTest.md) -- [VehicleLocalPositionSetpoint](../msg_docs/VehicleLocalPositionSetpoint.md) -- [VehicleAngularVelocity](../msg_docs/VehicleAngularVelocity.md) -- [FollowTargetStatus](../msg_docs/FollowTargetStatus.md) -- [NormalizedUnsignedSetpoint](../msg_docs/NormalizedUnsignedSetpoint.md) -- [YawEstimatorStatus](../msg_docs/YawEstimatorStatus.md) +- [BatteryInfo](../msg_docs/BatteryInfo.md) - [TakeoffStatus](../msg_docs/TakeoffStatus.md) -- [UlogStreamAck](../msg_docs/UlogStreamAck.md) -- [OrbTestLarge](../msg_docs/OrbTestLarge.md) -- [RoverSteeringSetpoint](../msg_docs/RoverSteeringSetpoint.md) +- [SensorGnssStatus](../msg_docs/SensorGnssStatus.md) +- [Airspeed](../msg_docs/Airspeed.md) +- [PpsCapture](../msg_docs/PpsCapture.md) +- [ActuatorControlsStatus](../msg_docs/ActuatorControlsStatus.md) - [CameraCapture](../msg_docs/CameraCapture.md) -- [VehicleRoi](../msg_docs/VehicleRoi.md) -- [ActuatorArmed](../msg_docs/ActuatorArmed.md) -- [FixedWingLateralGuidanceStatus](../msg_docs/FixedWingLateralGuidanceStatus.md) -- [ParameterSetValueResponse](../msg_docs/ParameterSetValueResponse.md) -- [GeofenceStatus](../msg_docs/GeofenceStatus.md) -- [VehicleAngularAccelerationSetpoint](../msg_docs/VehicleAngularAccelerationSetpoint.md) -- [SensorGnssRelative](../msg_docs/SensorGnssRelative.md) -- [PowerMonitor](../msg_docs/PowerMonitor.md) -- [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) -- [ParameterResetRequest](../msg_docs/ParameterResetRequest.md) -- [RoverAttitudeStatus](../msg_docs/RoverAttitudeStatus.md) -- [TecsStatus](../msg_docs/TecsStatus.md) -- [EstimatorSelectorStatus](../msg_docs/EstimatorSelectorStatus.md) -- [CanInterfaceStatus](../msg_docs/CanInterfaceStatus.md) -- [Ping](../msg_docs/Ping.md) -- [LedControl](../msg_docs/LedControl.md) -- [Wind](../msg_docs/Wind.md) -- [VehicleStatusV0](../msg_docs/VehicleStatusV0.md) -- [ActuatorTest](../msg_docs/ActuatorTest.md) -- [IridiumsbdStatus](../msg_docs/IridiumsbdStatus.md) -- [FailureDetectorStatus](../msg_docs/FailureDetectorStatus.md) -- [GimbalManagerSetAttitude](../msg_docs/GimbalManagerSetAttitude.md) -- [Gripper](../msg_docs/Gripper.md) -- [SensorMag](../msg_docs/SensorMag.md) -- [DebugValue](../msg_docs/DebugValue.md) -- [SensorPreflightMag](../msg_docs/SensorPreflightMag.md) -- [RcParameterMap](../msg_docs/RcParameterMap.md) -- [LandingGear](../msg_docs/LandingGear.md) -- [GimbalDeviceInformation](../msg_docs/GimbalDeviceInformation.md) +- [Px4ioStatus](../msg_docs/Px4ioStatus.md) +- [FuelTankStatus](../msg_docs/FuelTankStatus.md) +- [VehicleAngularVelocity](../msg_docs/VehicleAngularVelocity.md) - [VehicleOpticalFlow](../msg_docs/VehicleOpticalFlow.md) -- [UlogStream](../msg_docs/UlogStream.md) -- [GimbalControls](../msg_docs/GimbalControls.md) -- [RoverRateSetpoint](../msg_docs/RoverRateSetpoint.md) -- [LogMessage](../msg_docs/LogMessage.md) -- [RoverVelocitySetpoint](../msg_docs/RoverVelocitySetpoint.md) +- [AirspeedWind](../msg_docs/AirspeedWind.md) +- [OrbTest](../msg_docs/OrbTest.md) +- [GimbalDeviceInformation](../msg_docs/GimbalDeviceInformation.md) - [GpioOut](../msg_docs/GpioOut.md) -- [TaskStackInfo](../msg_docs/TaskStackInfo.md) +- [PurePursuitStatus](../msg_docs/PurePursuitStatus.md) +- [Gripper](../msg_docs/Gripper.md) +- [VehicleAirData](../msg_docs/VehicleAirData.md) +- [TuneControl](../msg_docs/TuneControl.md) +- [DebugVect](../msg_docs/DebugVect.md) +- [HoverThrustEstimate](../msg_docs/HoverThrustEstimate.md) +- [HomePositionV0](../msg_docs/HomePositionV0.md) +- [SensorsStatusImu](../msg_docs/SensorsStatusImu.md) +- [EstimatorAidSource3d](../msg_docs/EstimatorAidSource3d.md) +- [EstimatorBias](../msg_docs/EstimatorBias.md) +- [GpioConfig](../msg_docs/GpioConfig.md) +- [SystemPower](../msg_docs/SystemPower.md) +- [RateCtrlStatus](../msg_docs/RateCtrlStatus.md) +- [MissionResult](../msg_docs/MissionResult.md) +- [PowerButtonState](../msg_docs/PowerButtonState.md) +- [EscStatus](../msg_docs/EscStatus.md) +- [HealthReport](../msg_docs/HealthReport.md) +- [VehicleMagnetometer](../msg_docs/VehicleMagnetometer.md) +- [SensorGyro](../msg_docs/SensorGyro.md) +- [GpioRequest](../msg_docs/GpioRequest.md) +- [DebugKeyValue](../msg_docs/DebugKeyValue.md) +- [DistanceSensorModeChangeRequest](../msg_docs/DistanceSensorModeChangeRequest.md) +- [ParameterUpdate](../msg_docs/ParameterUpdate.md) +- [SensorAirflow](../msg_docs/SensorAirflow.md) +- [UavcanParameterValue](../msg_docs/UavcanParameterValue.md) +- [EstimatorSensorBias](../msg_docs/EstimatorSensorBias.md) +- [CanInterfaceStatus](../msg_docs/CanInterfaceStatus.md) +- [GimbalDeviceSetAttitude](../msg_docs/GimbalDeviceSetAttitude.md) +- [ActionRequest](../msg_docs/ActionRequest.md) +- [LandingTargetInnovations](../msg_docs/LandingTargetInnovations.md) +- [PwmInput](../msg_docs/PwmInput.md) +- [PowerMonitor](../msg_docs/PowerMonitor.md) +- [Mission](../msg_docs/Mission.md) +- [ArmingCheckReplyV0](../msg_docs/ArmingCheckReplyV0.md) +- [FigureEightStatus](../msg_docs/FigureEightStatus.md) +- [RadioStatus](../msg_docs/RadioStatus.md) +- [VehicleRoi](../msg_docs/VehicleRoi.md) +- [RtlTimeEstimate](../msg_docs/RtlTimeEstimate.md) +- [GimbalManagerStatus](../msg_docs/GimbalManagerStatus.md) +- [EstimatorSelectorStatus](../msg_docs/EstimatorSelectorStatus.md) +- [Rpm](../msg_docs/Rpm.md) +- [VehicleAngularAccelerationSetpoint](../msg_docs/VehicleAngularAccelerationSetpoint.md) +- [Ping](../msg_docs/Ping.md) +- [QshellReq](../msg_docs/QshellReq.md) +- [SensorMag](../msg_docs/SensorMag.md) +- [EstimatorStates](../msg_docs/EstimatorStates.md) +- [SensorUwb](../msg_docs/SensorUwb.md) +- [OpenDroneIdArmStatus](../msg_docs/OpenDroneIdArmStatus.md) +- [TiltrotorExtraControls](../msg_docs/TiltrotorExtraControls.md) +- [ControlAllocatorStatus](../msg_docs/ControlAllocatorStatus.md) +- [ParameterResetRequest](../msg_docs/ParameterResetRequest.md) +- [SensorHygrometer](../msg_docs/SensorHygrometer.md) +- [VehicleLocalPositionSetpoint](../msg_docs/VehicleLocalPositionSetpoint.md) +- [AdcReport](../msg_docs/AdcReport.md) +- [DronecanNodeStatus](../msg_docs/DronecanNodeStatus.md) +- [EstimatorAidSource2d](../msg_docs/EstimatorAidSource2d.md) +- [SensorAccelFifo](../msg_docs/SensorAccelFifo.md) +- [RoverAttitudeStatus](../msg_docs/RoverAttitudeStatus.md) +- [SensorCorrection](../msg_docs/SensorCorrection.md) +- [UlogStream](../msg_docs/UlogStream.md) +- [PositionControllerLandingStatus](../msg_docs/PositionControllerLandingStatus.md) +- [GpsInjectData](../msg_docs/GpsInjectData.md) +- [MagnetometerBiasEstimate](../msg_docs/MagnetometerBiasEstimate.md) +- [LoggerStatus](../msg_docs/LoggerStatus.md) +- [ParameterSetValueRequest](../msg_docs/ParameterSetValueRequest.md) +- [SensorBaro](../msg_docs/SensorBaro.md) +- [OrbTestMedium](../msg_docs/OrbTestMedium.md) +- [RoverSpeedStatus](../msg_docs/RoverSpeedStatus.md) +- [FollowTargetStatus](../msg_docs/FollowTargetStatus.md) +- [ParameterSetUsedRequest](../msg_docs/ParameterSetUsedRequest.md) +- [PositionControllerStatus](../msg_docs/PositionControllerStatus.md) +- [UlogStreamAck](../msg_docs/UlogStreamAck.md) +- [DatamanRequest](../msg_docs/DatamanRequest.md) +- [InternalCombustionEngineControl](../msg_docs/InternalCombustionEngineControl.md) +- [PositionSetpoint](../msg_docs/PositionSetpoint.md) +- [DatamanResponse](../msg_docs/DatamanResponse.md) +- [LedControl](../msg_docs/LedControl.md) +- [MavlinkTunnel](../msg_docs/MavlinkTunnel.md) +- [VehicleLocalPositionV0](../msg_docs/VehicleLocalPositionV0.md) +- [Event](../msg_docs/Event.md) +- [ActuatorArmed](../msg_docs/ActuatorArmed.md) +- [GpioIn](../msg_docs/GpioIn.md) +- [SensorGyroFft](../msg_docs/SensorGyroFft.md) +- [SensorAccel](../msg_docs/SensorAccel.md) +- [SensorsStatus](../msg_docs/SensorsStatus.md) +- [VehicleAttitudeSetpointV0](../msg_docs/VehicleAttitudeSetpointV0.md) +- [GeneratorStatus](../msg_docs/GeneratorStatus.md) +- [DifferentialPressure](../msg_docs/DifferentialPressure.md) +- [FixedWingRunwayControl](../msg_docs/FixedWingRunwayControl.md) +- [NormalizedUnsignedSetpoint](../msg_docs/NormalizedUnsignedSetpoint.md) +- [TrajectorySetpoint6dof](../msg_docs/TrajectorySetpoint6dof.md) +- [LaunchDetectionStatus](../msg_docs/LaunchDetectionStatus.md) +- [RoverRateStatus](../msg_docs/RoverRateStatus.md) +- [AirspeedValidatedV0](../msg_docs/AirspeedValidatedV0.md) +- [GimbalManagerSetAttitude](../msg_docs/GimbalManagerSetAttitude.md) - [VelocityLimits](../msg_docs/VelocityLimits.md) - [MagWorkerData](../msg_docs/MagWorkerData.md) -- [ParameterUpdate](../msg_docs/ParameterUpdate.md) -- [TrajectorySetpoint6dof](../msg_docs/TrajectorySetpoint6dof.md) -- [SensorBaro](../msg_docs/SensorBaro.md) -- [VehicleImuStatus](../msg_docs/VehicleImuStatus.md) -- [InternalCombustionEngineStatus](../msg_docs/InternalCombustionEngineStatus.md) -- [VehicleOpticalFlowVel](../msg_docs/VehicleOpticalFlowVel.md) -- [GimbalManagerSetManualControl](../msg_docs/GimbalManagerSetManualControl.md) -- [Rpm](../msg_docs/Rpm.md) -- [MagnetometerBiasEstimate](../msg_docs/MagnetometerBiasEstimate.md) -- [MountOrientation](../msg_docs/MountOrientation.md) -- [ActionRequest](../msg_docs/ActionRequest.md) -- [OpenDroneIdArmStatus](../msg_docs/OpenDroneIdArmStatus.md) -- [SensorAccelFifo](../msg_docs/SensorAccelFifo.md) -- [LoggerStatus](../msg_docs/LoggerStatus.md) -- [GeneratorStatus](../msg_docs/GeneratorStatus.md) -- [InternalCombustionEngineControl](../msg_docs/InternalCombustionEngineControl.md) -- [Ekf2Timestamps](../msg_docs/Ekf2Timestamps.md) -- [LandingTargetPose](../msg_docs/LandingTargetPose.md) -- [PositionControllerLandingStatus](../msg_docs/PositionControllerLandingStatus.md) -- [UavcanParameterValue](../msg_docs/UavcanParameterValue.md) -- [OrbitStatus](../msg_docs/OrbitStatus.md) -- [PositionControllerStatus](../msg_docs/PositionControllerStatus.md) -- [EstimatorStatus](../msg_docs/EstimatorStatus.md) -- [DatamanRequest](../msg_docs/DatamanRequest.md) -- [HoverThrustEstimate](../msg_docs/HoverThrustEstimate.md) -- [FixedWingLateralStatus](../msg_docs/FixedWingLateralStatus.md) -- [NavigatorMissionItem](../msg_docs/NavigatorMissionItem.md) - [Cpuload](../msg_docs/Cpuload.md) -- [EstimatorAidSource3d](../msg_docs/EstimatorAidSource3d.md) -- [RoverRateStatus](../msg_docs/RoverRateStatus.md) -- [EscReport](../msg_docs/EscReport.md) -- [DebugArray](../msg_docs/DebugArray.md) -- [ControlAllocatorStatus](../msg_docs/ControlAllocatorStatus.md) -- [SensorHygrometer](../msg_docs/SensorHygrometer.md) -- [EstimatorSensorBias](../msg_docs/EstimatorSensorBias.md) -- [EstimatorBias3d](../msg_docs/EstimatorBias3d.md) -- [GimbalManagerInformation](../msg_docs/GimbalManagerInformation.md) -- [QshellReq](../msg_docs/QshellReq.md) -- [CameraStatus](../msg_docs/CameraStatus.md) -- [GpsInjectData](../msg_docs/GpsInjectData.md) -- [FigureEightStatus](../msg_docs/FigureEightStatus.md) -- [TransponderReport](../msg_docs/TransponderReport.md) -- [UavcanParameterRequest](../msg_docs/UavcanParameterRequest.md) +- [InternalCombustionEngineStatus](../msg_docs/InternalCombustionEngineStatus.md) +- [SensorGnssRelative](../msg_docs/SensorGnssRelative.md) - [MavlinkLog](../msg_docs/MavlinkLog.md) -- [EstimatorGpsStatus](../msg_docs/EstimatorGpsStatus.md) -- [FuelTankStatus](../msg_docs/FuelTankStatus.md) -- [Mission](../msg_docs/Mission.md) -- [PositionSetpoint](../msg_docs/PositionSetpoint.md) -- [MissionResult](../msg_docs/MissionResult.md) -- [EstimatorEventFlags](../msg_docs/EstimatorEventFlags.md) -- [VehicleMagnetometer](../msg_docs/VehicleMagnetometer.md) -- [MavlinkTunnel](../msg_docs/MavlinkTunnel.md) -- [DifferentialPressure](../msg_docs/DifferentialPressure.md) -- [CellularStatus](../msg_docs/CellularStatus.md) -- [GpsDump](../msg_docs/GpsDump.md) -- [GimbalDeviceSetAttitude](../msg_docs/GimbalDeviceSetAttitude.md) -- [ArmingCheckReplyV0](../msg_docs/ArmingCheckReplyV0.md) -- [NavigatorStatus](../msg_docs/NavigatorStatus.md) -- [RoverPositionSetpoint](../msg_docs/RoverPositionSetpoint.md) -- [FollowTarget](../msg_docs/FollowTarget.md) -- [SensorsStatusImu](../msg_docs/SensorsStatusImu.md) -- [EstimatorStates](../msg_docs/EstimatorStates.md) -- [SensorGyro](../msg_docs/SensorGyro.md) -- [SensorAirflow](../msg_docs/SensorAirflow.md) -- [ButtonEvent](../msg_docs/ButtonEvent.md) -- [DebugKeyValue](../msg_docs/DebugKeyValue.md) -- [GpioConfig](../msg_docs/GpioConfig.md) -- [CameraTrigger](../msg_docs/CameraTrigger.md) +- [SensorTemp](../msg_docs/SensorTemp.md) - [LandingGearWheel](../msg_docs/LandingGearWheel.md) -- [VehicleConstraints](../msg_docs/VehicleConstraints.md) -- [HealthReport](../msg_docs/HealthReport.md) -- [PowerButtonState](../msg_docs/PowerButtonState.md) -- [RadioStatus](../msg_docs/RadioStatus.md) -- [SensorGyroFifo](../msg_docs/SensorGyroFifo.md) -- [EstimatorBias](../msg_docs/EstimatorBias.md) -- [DebugVect](../msg_docs/DebugVect.md) -- [DistanceSensorModeChangeRequest](../msg_docs/DistanceSensorModeChangeRequest.md) -- [RtlTimeEstimate](../msg_docs/RtlTimeEstimate.md) -- [PpsCapture](../msg_docs/PpsCapture.md) -- [SensorSelection](../msg_docs/SensorSelection.md) -- [SystemPower](../msg_docs/SystemPower.md) -- [ActuatorControlsStatus](../msg_docs/ActuatorControlsStatus.md) -- [SensorGyroFft](../msg_docs/SensorGyroFft.md) -- [VehicleAirData](../msg_docs/VehicleAirData.md) +- [OrbTestLarge](../msg_docs/OrbTestLarge.md) - [FollowTargetEstimator](../msg_docs/FollowTargetEstimator.md) -- [ParameterSetUsedRequest](../msg_docs/ParameterSetUsedRequest.md) -- [GpioRequest](../msg_docs/GpioRequest.md) -- [OpenDroneIdOperatorId](../msg_docs/OpenDroneIdOperatorId.md) -- [RtlStatus](../msg_docs/RtlStatus.md) -- [Airspeed](../msg_docs/Airspeed.md) -- [VehicleAcceleration](../msg_docs/VehicleAcceleration.md) -- [ParameterSetValueRequest](../msg_docs/ParameterSetValueRequest.md) -- [IrlockReport](../msg_docs/IrlockReport.md) -- [HeaterStatus](../msg_docs/HeaterStatus.md) -- [AdcReport](../msg_docs/AdcReport.md) -- [PwmInput](../msg_docs/PwmInput.md) -- [TiltrotorExtraControls](../msg_docs/TiltrotorExtraControls.md) -- [EstimatorAidSource1d](../msg_docs/EstimatorAidSource1d.md) -- [OrbTestMedium](../msg_docs/OrbTestMedium.md) -- [VehicleAttitudeSetpointV0](../msg_docs/VehicleAttitudeSetpointV0.md) -- [EstimatorAidSource2d](../msg_docs/EstimatorAidSource2d.md) -- [TuneControl](../msg_docs/TuneControl.md) -- [WheelEncoders](../msg_docs/WheelEncoders.md) +- [CellularStatus](../msg_docs/CellularStatus.md) +- [QshellRetval](../msg_docs/QshellRetval.md) +- [OrbitStatus](../msg_docs/OrbitStatus.md) +- [VehicleStatusV0](../msg_docs/VehicleStatusV0.md) +- [FailureDetectorStatus](../msg_docs/FailureDetectorStatus.md) +- [LogMessage](../msg_docs/LogMessage.md) +- [SatelliteInfo](../msg_docs/SatelliteInfo.md) +- [SensorPreflightMag](../msg_docs/SensorPreflightMag.md) +- [NavigatorMissionItem](../msg_docs/NavigatorMissionItem.md) +- [FixedWingLateralGuidanceStatus](../msg_docs/FixedWingLateralGuidanceStatus.md) +- [BatteryStatusV0](../msg_docs/BatteryStatusV0.md) +- [EstimatorInnovations](../msg_docs/EstimatorInnovations.md) +- [EstimatorStatus](../msg_docs/EstimatorStatus.md) +- [NeuralControl](../msg_docs/NeuralControl.md) +- [TaskStackInfo](../msg_docs/TaskStackInfo.md) +- [RcParameterMap](../msg_docs/RcParameterMap.md) +- [SensorSelection](../msg_docs/SensorSelection.md) +- [FlightPhaseEstimation](../msg_docs/FlightPhaseEstimation.md) +- [ParameterSetValueResponse](../msg_docs/ParameterSetValueResponse.md) +- [ActuatorTest](../msg_docs/ActuatorTest.md) +- [VehicleImuStatus](../msg_docs/VehicleImuStatus.md) +- [MountOrientation](../msg_docs/MountOrientation.md) +- [CameraStatus](../msg_docs/CameraStatus.md) - [AutotuneAttitudeControlStatus](../msg_docs/AutotuneAttitudeControlStatus.md) -- [LandingTargetInnovations](../msg_docs/LandingTargetInnovations.md) -- [SensorsStatus](../msg_docs/SensorsStatus.md) -::: +- [FollowTarget](../msg_docs/FollowTarget.md) +- [EstimatorGpsStatus](../msg_docs/EstimatorGpsStatus.md) +- [ButtonEvent](../msg_docs/ButtonEvent.md) +- [DebugArray](../msg_docs/DebugArray.md) +- [Ekf2Timestamps](../msg_docs/Ekf2Timestamps.md) +- [GimbalManagerSetManualControl](../msg_docs/GimbalManagerSetManualControl.md) +- [IridiumsbdStatus](../msg_docs/IridiumsbdStatus.md) +- [OpenDroneIdSystem](../msg_docs/OpenDroneIdSystem.md) +- [VehicleImu](../msg_docs/VehicleImu.md) +- [GpsDump](../msg_docs/GpsDump.md) +- [WheelEncoders](../msg_docs/WheelEncoders.md) +- [EstimatorEventFlags](../msg_docs/EstimatorEventFlags.md) +- [DebugValue](../msg_docs/DebugValue.md) +- [LandingTargetPose](../msg_docs/LandingTargetPose.md) +- [OpenDroneIdOperatorId](../msg_docs/OpenDroneIdOperatorId.md) +- [VehicleOpticalFlowVel](../msg_docs/VehicleOpticalFlowVel.md) +- [RtlStatus](../msg_docs/RtlStatus.md) +- [VehicleAcceleration](../msg_docs/VehicleAcceleration.md) +- [GimbalControls](../msg_docs/GimbalControls.md) +- [ActuatorServosTrim](../msg_docs/ActuatorServosTrim.md) +- [FixedWingLateralStatus](../msg_docs/FixedWingLateralStatus.md) +- [HeaterStatus](../msg_docs/HeaterStatus.md) +- [YawEstimatorStatus](../msg_docs/YawEstimatorStatus.md) +- [RcChannels](../msg_docs/RcChannels.md) +- [TecsStatus](../msg_docs/TecsStatus.md) +- [EstimatorAidSource1d](../msg_docs/EstimatorAidSource1d.md) +- [InputRc](../msg_docs/InputRc.md) +- [SensorGyroFifo](../msg_docs/SensorGyroFifo.md) +- [GeofenceResult](../msg_docs/GeofenceResult.md) +- [OpenDroneIdSelfId](../msg_docs/OpenDroneIdSelfId.md) +- [UavcanParameterRequest](../msg_docs/UavcanParameterRequest.md) +- [ManualControlSwitches](../msg_docs/ManualControlSwitches.md) +- [NavigatorStatus](../msg_docs/NavigatorStatus.md) +- [CameraTrigger](../msg_docs/CameraTrigger.md) +- [EscReport](../msg_docs/EscReport.md) +- [EstimatorBias3d](../msg_docs/EstimatorBias3d.md) +- [GeofenceStatus](../msg_docs/GeofenceStatus.md) +- [GimbalManagerInformation](../msg_docs/GimbalManagerInformation.md) +- [ActuatorOutputs](../msg_docs/ActuatorOutputs.md) +- [EventV0](../msg_docs/EventV0.md) +- [ArmingCheckRequestV0](../msg_docs/ArmingCheckRequestV0.md) +- [VehicleConstraints](../msg_docs/VehicleConstraints.md) +- [IrlockReport](../msg_docs/IrlockReport.md) + ::: diff --git a/docs/en/middleware/uxrce_dds.md b/docs/en/middleware/uxrce_dds.md index 8f8da255d3..e50b3131e6 100644 --- a/docs/en/middleware/uxrce_dds.md +++ b/docs/en/middleware/uxrce_dds.md @@ -441,6 +441,7 @@ uxrce_dds_client start -n fancy_uav ``` This can be included in `etc/extras.txt` as part of a custom [System Startup](../concept/system_startup.md). +::: ## PX4 ROS 2 QoS Settings @@ -502,6 +503,11 @@ publications: - topic: /fmu/out/vehicle_trajectory_waypoint_desired type: px4_msgs::msg::VehicleTrajectoryWaypoint + - topic: /fmu/out/vehicle_imu + type: px4_msgs::msg::VehicleImu + rate_limit: 50. + instance: 1 # OPTIONAL + subscriptions: - topic: /fmu/in/offboard_control_mode @@ -534,6 +540,9 @@ Each (`topic`,`type`) pairs defines: 4. The message type (`VehicleOdometry`, `VehicleStatus`, `OffboardControlMode`, etc.) and the ROS 2 package (`px4_msgs`) that is expected to provide the message definition. 5. **(Optional)**: An additional `rate_limit` field (only for publication entries), which specifies the maximum rate (Hz) at which messages will be published on this topic by PX4 to ROS 2. If left unspecified, the maximum publication rate limit is set to 100 Hz. +6. **(Optional)**: An additional `instance` field (only for publication entries), which lets you select which instance of a [multi-instance topic](./uorb.md#multi-instance) you want to be published to ROS 2. + If provided, this option changes the ROS 2 topic name of the advertised uORB topic appending the instance number: `fmu/out/[uorb topic name][instance]` (plus eventual namespace and message version). + In the example above the final topic name would be `/fmu/out/vehicle_imu1`. `subscriptions` and `subscriptions_multi` allow us to choose the uORB topic instance that ROS 2 topics are routed to: either a shared instance that may also be getting updates from internal PX4 uORB publishers, or a separate instance that is reserved for ROS2 publications, respectively. Without this mechanism all ROS 2 messages would be routed to the _same_ uORB topic instance (because ROS 2 does not have the concept of [multiple topic instances](../middleware/uorb.md#multi-instance)), and it would not be possible for PX4 subscribers to differentiate between streams from ROS 2 or PX4 publishers. diff --git a/docs/en/modules/hello_sky.md b/docs/en/modules/hello_sky.md index ad1d9e5bc9..fd43f9cd97 100644 --- a/docs/en/modules/hello_sky.md +++ b/docs/en/modules/hello_sky.md @@ -434,6 +434,7 @@ The [complete example code](https://github.com/PX4/PX4-Autopilot/blob/main/src/e */ #include +#include #include #include #include diff --git a/docs/en/modules/modules_driver.md b/docs/en/modules/modules_driver.md index 7801da4db3..2b0b2a6b7e 100644 --- a/docs/en/modules/modules_driver.md +++ b/docs/en/modules/modules_driver.md @@ -2,6 +2,7 @@ Subcategories: +- [Adc](modules_driver_adc.md) - [Airspeed Sensor](modules_driver_airspeed_sensor.md) - [Baro](modules_driver_baro.md) - [Camera](modules_driver_camera.md) @@ -46,66 +47,6 @@ MCP23009 [arguments...] status print status info ``` -## adc - -Source: [drivers/adc/board_adc](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/adc/board_adc) - -### Description - -ADC driver. - -### Usage {#adc_usage} - -``` -adc [arguments...] - Commands: - start - - test - [-n] Do not publish ADC report, only system power - - stop - - status print status info -``` - -## ads1115 - -Source: [drivers/adc/ads1115](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/adc/ads1115) - -### Description - -Driver to enable an external [ADS1115](https://www.adafruit.com/product/1085) ADC connected via I2C. - -The driver is included by default in firmware for boards that do not have an internal analog to digital converter, -such as [PilotPi](../flight_controller/raspberry_pi_pilotpi.md) or [CUAV Nora](../flight_controller/cuav_nora.md) -(search for `CONFIG_DRIVERS_ADC_ADS1115` in board configuration files). - -It is enabled/disabled using the -[ADC_ADS1115_EN](../advanced_config/parameter_reference.md#ADC_ADS1115_EN) -parameter, and is disabled by default. -If enabled, internal ADCs are not used. - -### Usage {#ads1115_usage} - -``` -ads1115 [arguments...] - Commands: - start - [-I] Internal I2C bus(es) - [-X] External I2C bus(es) - [-b ] board-specific bus (default=all) (external SPI: n-th bus - (default=1)) - [-f ] bus frequency in kHz - [-q] quiet startup (no message if no device found) - [-a ] I2C address - default: 72 - - stop - - status print status info -``` - ## atxxxx Source: [drivers/osd/atxxxx](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/osd/atxxxx) @@ -808,6 +749,30 @@ lsm303agr [arguments...] status print status info ``` +## mcp9808 + +Source: [drivers/temperature_sensor/mcp9808](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/temperature_sensor/mcp9808) + +### Usage {#mcp9808_usage} + +``` +mcp9808 [arguments...] + Commands: + start + [-I] Internal I2C bus(es) + [-X] External I2C bus(es) + [-b ] board-specific bus (default=all) (external SPI: n-th bus + (default=1)) + [-f ] bus frequency in kHz + [-q] quiet startup (no message if no device found) + [-a ] I2C address + default: 24 + + stop + + status print status info +``` + ## msp_osd Source: [drivers/osd/msp_osd](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/osd/msp_osd) diff --git a/docs/en/modules/modules_driver_adc.md b/docs/en/modules/modules_driver_adc.md new file mode 100644 index 0000000000..cecdbff037 --- /dev/null +++ b/docs/en/modules/modules_driver_adc.md @@ -0,0 +1,107 @@ +# Modules Reference: Adc (Driver) + +## TLA2528 + +Source: [drivers/adc/tla2528](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/adc/tla2528) + +### Usage {#TLA2528_usage} + +``` +TLA2528 [arguments...] + Commands: + start + [-I] Internal I2C bus(es) + [-X] External I2C bus(es) + [-b ] board-specific bus (default=all) (external SPI: n-th bus + (default=1)) + [-f ] bus frequency in kHz + [-q] quiet startup (no message if no device found) + + stop + + status print status info +``` + +## adc + +Source: [drivers/adc/board_adc](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/adc/board_adc) + +### Description + +ADC driver. + +### Usage {#adc_usage} + +``` +adc [arguments...] + Commands: + start + + test + [-n] Do not publish ADC report, only system power + + stop + + status print status info +``` + +## ads1115 + +Source: [drivers/adc/ads1115](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/adc/ads1115) + +### Description + +Driver to enable an external [ADS1115](https://www.adafruit.com/product/1085) ADC connected via I2C. + +The driver is included by default in firmware for boards that do not have an internal analog to digital converter, +such as [PilotPi](../flight_controller/raspberry_pi_pilotpi.md) or [CUAV Nora](../flight_controller/cuav_nora.md) +(search for `CONFIG_DRIVERS_ADC_ADS1115` in board configuration files). + +It is enabled/disabled using the +[ADC_ADS1115_EN](../advanced_config/parameter_reference.md#ADC_ADS1115_EN) +parameter, and is disabled by default. +If enabled, internal ADCs are not used. + +### Usage {#ads1115_usage} + +``` +ads1115 [arguments...] + Commands: + start + [-I] Internal I2C bus(es) + [-X] External I2C bus(es) + [-b ] board-specific bus (default=all) (external SPI: n-th bus + (default=1)) + [-f ] bus frequency in kHz + [-q] quiet startup (no message if no device found) + [-a ] I2C address + default: 72 + + stop + + status print status info +``` + +## ads7953 + +Source: [drivers/adc/ads7953](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/adc/ads7953) + +### Usage {#ads7953_usage} + +``` +ads7953 [arguments...] + Commands: + start + [-s] Internal SPI bus(es) + [-S] External SPI bus(es) + [-b ] board-specific bus (default=all) (external SPI: n-th bus + (default=1)) + [-c ] chip-select pin (for internal SPI) or index (for external SPI) + [-m ] SPI mode + [-f ] bus frequency in kHz + [-q] quiet startup (no message if no device found) + + stop + + status print status info +``` diff --git a/docs/en/modules/modules_driver_radio_control.md b/docs/en/modules/modules_driver_radio_control.md index 98489438e5..3cfb312593 100644 --- a/docs/en/modules/modules_driver_radio_control.md +++ b/docs/en/modules/modules_driver_radio_control.md @@ -4,10 +4,9 @@ Source: [drivers/rc/crsf_rc](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/rc/crsf_rc) - ### Description -This module parses the CRSF RC uplink protocol and generates CRSF downlink telemetry data +This module parses the CRSF RC uplink protocol and generates CRSF downlink telemetry data ### Usage {#crsf_rc_usage} @@ -17,6 +16,10 @@ crsf_rc [arguments...] start [-d ] RC device values: , default: /dev/ttyS3 + [-b ] RC baudrate + default: 420000 + + inject Inject frame data bytes (for testing) stop @@ -27,10 +30,9 @@ crsf_rc [arguments...] Source: [drivers/rc/dsm_rc](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/rc/dsm_rc) - ### Description -This module does Spektrum DSM RC input parsing. +This module does Spektrum DSM RC input parsing. ### Usage {#dsm_rc_usage} @@ -52,10 +54,9 @@ dsm_rc [arguments...] Source: [drivers/rc/ghst_rc](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/rc/ghst_rc) - ### Description -This module does Ghost (GHST) RC input parsing. +This module does Ghost (GHST) RC input parsing. ### Usage {#ghst_rc_usage} @@ -75,9 +76,10 @@ ghst_rc [arguments...] Source: [drivers/rc_input](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/rc_input) - ### Description + This module does the RC input parsing and auto-selecting the method. Supported methods are: + - PPM - SBUS - DSM @@ -85,7 +87,6 @@ This module does the RC input parsing and auto-selecting the method. Supported m - ST24 - TBS Crossfire (CRSF) - ### Usage {#rc_input_usage} ``` @@ -106,10 +107,9 @@ rc_input [arguments...] Source: [drivers/rc/sbus_rc](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/rc/sbus_rc) - ### Description -This module does SBUS RC input parsing. +This module does SBUS RC input parsing. ### Usage {#sbus_rc_usage} diff --git a/docs/en/msg_docs/AdcReport.md b/docs/en/msg_docs/AdcReport.md index 53ab9a2f07..50fde63ff5 100644 --- a/docs/en/msg_docs/AdcReport.md +++ b/docs/en/msg_docs/AdcReport.md @@ -1,15 +1,21 @@ # AdcReport (UORB message) +ADC raw data. +Communicates raw data from an analog-to-digital converter (ADC) to other modules, such as battery status. [source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/AdcReport.msg) ```c -uint64 timestamp # time since system start (microseconds) -uint32 device_id # unique device ID for the sensor that does not change between power cycles -int16[12] channel_id # ADC channel IDs, negative for non-existent, TODO: should be kept same as array index -int32[12] raw_data # ADC channel raw value, accept negative value, valid if channel ID is positive -uint32 resolution # ADC channel resolution -float32 v_ref # ADC channel voltage reference, use to calculate LSB voltage(lsb=scale/resolution) +# ADC raw data. +# +# Communicates raw data from an analog-to-digital converter (ADC) to other modules, such as battery status. + +uint64 timestamp # [us] Time since system start +uint32 device_id # [-] unique device ID for the sensor that does not change between power cycles +int16[16] channel_id # [-] ADC channel IDs, negative for non-existent, TODO: should be kept same as array index +int32[16] raw_data # [-] ADC channel raw value, accept negative value, valid if channel ID is positive +uint32 resolution # [-] ADC channel resolution +float32 v_ref # [V] ADC channel voltage reference, use to calculate LSB voltage(lsb=scale/resolution) ``` diff --git a/docs/en/msg_docs/EscReport.md b/docs/en/msg_docs/EscReport.md index 4a75bee418..277402ae69 100644 --- a/docs/en/msg_docs/EscReport.md +++ b/docs/en/msg_docs/EscReport.md @@ -1,7 +1,5 @@ # EscReport (UORB message) - - [source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/EscReport.msg) ```c @@ -18,6 +16,19 @@ uint8 esc_state # State of ESC - depend on Vendor uint8 actuator_function # actuator output function (one of Motor1...MotorN) +uint8 ACTUATOR_FUNCTION_MOTOR1 = 101 +uint8 ACTUATOR_FUNCTION_MOTOR2 = 102 +uint8 ACTUATOR_FUNCTION_MOTOR3 = 103 +uint8 ACTUATOR_FUNCTION_MOTOR4 = 104 +uint8 ACTUATOR_FUNCTION_MOTOR5 = 105 +uint8 ACTUATOR_FUNCTION_MOTOR6 = 106 +uint8 ACTUATOR_FUNCTION_MOTOR7 = 107 +uint8 ACTUATOR_FUNCTION_MOTOR8 = 108 +uint8 ACTUATOR_FUNCTION_MOTOR9 = 109 +uint8 ACTUATOR_FUNCTION_MOTOR10 = 110 +uint8 ACTUATOR_FUNCTION_MOTOR11 = 111 +uint8 ACTUATOR_FUNCTION_MOTOR12 = 112 + uint16 failures # Bitmask to indicate the internal ESC faults int8 esc_power # Applied power 0-100 in % (negative values reserved) diff --git a/docs/en/msg_docs/InputRc.md b/docs/en/msg_docs/InputRc.md index 3f8bdb3da3..fbae6e0254 100644 --- a/docs/en/msg_docs/InputRc.md +++ b/docs/en/msg_docs/InputRc.md @@ -1,7 +1,5 @@ # InputRc (UORB message) - - [source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/InputRc.msg) ```c @@ -39,11 +37,13 @@ bool rc_lost # RC receiver connection status: True,if no frame has arrived in uint16 rc_lost_frame_count # Number of lost RC frames. Note: intended purpose: observe the radio link quality if RSSI is not available. This value must not be used to trigger any failsafe-alike functionality. uint16 rc_total_frame_count # Number of total RC frames. Note: intended purpose: observe the radio link quality if RSSI is not available. This value must not be used to trigger any failsafe-alike functionality. uint16 rc_ppm_frame_length # Length of a single PPM frame. Zero for non-PPM systems +uint16 rc_frame_rate # RC frame rate in msg/second. 0 = invalid uint8 input_source # Input source uint16[18] values # measured pulse widths for each of the supported channels int8 link_quality # link quality. Percentage 0-100%. -1 = invalid float32 rssi_dbm # Actual rssi in units of dBm. NaN = invalid +int8 link_snr # link signal to noise ratio in units of dB. -1 = invalid ``` diff --git a/docs/en/msg_docs/RoverVelocitySetpoint.md b/docs/en/msg_docs/RoverVelocitySetpoint.md deleted file mode 100644 index 65103082b8..0000000000 --- a/docs/en/msg_docs/RoverVelocitySetpoint.md +++ /dev/null @@ -1,15 +0,0 @@ -# RoverVelocitySetpoint (UORB message) - -Rover Velocity Setpoint - -[source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/RoverVelocitySetpoint.msg) - -```c -# Rover Velocity Setpoint - -uint64 timestamp # [us] Time since system start -float32 speed # [m/s] [@range -inf (Backwards), inf (Forwards)] Speed setpoint -float32 bearing # [rad] [@range -pi,pi] [@frame NED] [@invalid: NaN, speed is defined in body x direction] Bearing setpoint -float32 yaw # [rad] [@range -pi, pi] [@frame NED] [@invalid NaN, Defaults to vehicle yaw] Mecanum only: Yaw setpoint - -``` diff --git a/docs/en/msg_docs/RoverVelocityStatus.md b/docs/en/msg_docs/RoverVelocityStatus.md deleted file mode 100644 index dfd7756afa..0000000000 --- a/docs/en/msg_docs/RoverVelocityStatus.md +++ /dev/null @@ -1,18 +0,0 @@ -# RoverVelocityStatus (UORB message) - -Rover Velocity Status - -[source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/RoverVelocityStatus.msg) - -```c -# Rover Velocity Status - -uint64 timestamp # [us] Time since system start -float32 measured_speed_body_x # [m/s] [@range -inf (Backwards), inf (Forwards)] [@frame Body] Measured speed in body x direction -float32 adjusted_speed_body_x_setpoint # [m/s] [@range -inf (Backwards), inf (Forwards)] [@frame Body] Speed setpoint in body x direction that is being tracked (Applied slew rates) -float32 pid_throttle_body_x_integral # [] [@range -1, 1] Integral of the PID for the closed loop controller of the speed in body x direction -float32 measured_speed_body_y # [m/s] [@range -inf (Left), inf (Right)] [@frame Body] [@invalid NaN If not mecanum] Mecanum only: Measured speed in body y direction -float32 adjusted_speed_body_y_setpoint # [m/s] [@range -inf (Left), inf (Right)] [@frame Body] [@invalid NaN If not mecanum] Mecanum only: Speed setpoint in body y direction that is being tracked (Applied slew rates) -float32 pid_throttle_body_y_integral # [] [@range -1, 1] [@invalid NaN If not mecanum] Mecanum only: Integral of the PID for the closed loop controller of the speed in body y direction - -``` diff --git a/docs/en/msg_docs/SensorTemp.md b/docs/en/msg_docs/SensorTemp.md new file mode 100644 index 0000000000..5ed50541fe --- /dev/null +++ b/docs/en/msg_docs/SensorTemp.md @@ -0,0 +1,11 @@ +# SensorTemp (UORB message) + +[source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/SensorTemp.msg) + +```c +uint64 timestamp # time since system start (microseconds) + +uint32 device_id # unique device ID for the sensor that does not change between power cycles +float32 temperature # Temperature provided by sensor (Celsius) + +``` diff --git a/docs/en/msg_docs/VehicleCommand.md b/docs/en/msg_docs/VehicleCommand.md index 6c5e87ff5b..7f91701614 100644 --- a/docs/en/msg_docs/VehicleCommand.md +++ b/docs/en/msg_docs/VehicleCommand.md @@ -28,7 +28,7 @@ uint16 VEHICLE_CMD_DO_ORBIT = 34 # Start orbiting on the circumference of a circ uint16 VEHICLE_CMD_DO_FIGUREEIGHT = 35 # Start flying on the outline of a figure eight defined by the parameters. |[m] Major radius|[m] Minor radius|[m/s] Velocity|Orientation|Latitude/X|Longitude/Y|Altitude/Z| uint16 VEHICLE_CMD_NAV_ROI = 80 # Sets the region of interest (ROI) for a sensor set or the vehicle itself. This can then be used by the vehicles control system to control the vehicle attitude and the attitude of various sensors such as cameras. |[@enum VEHICLE_ROI] Region of interest mode.|MISSION index/ target ID.|ROI index (allows a vehicle to manage multiple ROI's)|Unused|x the location of the fixed ROI (see MAV_FRAME)|y|z| uint16 VEHICLE_CMD_NAV_PATHPLANNING = 81 # Control autonomous path planning on the MAV. |0: Disable local obstacle avoidance / local path planning (without resetting map), 1: Enable local path planning, 2: Enable and reset local path planning|0: Disable full path planning (without resetting map), 1: Enable, 2: Enable and reset map/occupancy grid, 3: Enable and reset planned route, but not occupancy grid|Unused|[deg] [@range 0, 360] Yaw angle at goal, in compass degrees|Latitude/X of goal|Longitude/Y of goal|Altitude/Z of goal| -uint16 VEHICLE_CMD_NAV_VTOL_TAKEOFF = 84 # Takeoff from ground / hand and transition to fixed wing. |Minimum pitch (if airspeed sensor present), desired pitch without sensor|Unused|Unused|Yaw angle (if magnetometer present), ignored without magnetometer|Latitude|Longitude|Altitude| +uint16 VEHICLE_CMD_NAV_VTOL_TAKEOFF = 84 # Takeoff from ground / hand and transition to fixed wing. |Minimum pitch (if airspeed sensor present), desired pitch without sensor|Transition heading, 0: Default, 3: Use specified transition heading|Unused|Yaw angle (if magnetometer present), ignored without magnetometer|Latitude|Longitude|Altitude| uint16 VEHICLE_CMD_NAV_VTOL_LAND = 85 # Transition to MC and land at location. |Unused|Unused|Unused|Desired yaw angle.|Latitude|Longitude|Altitude| uint16 VEHICLE_CMD_NAV_GUIDED_LIMITS = 90 # Set limits for external control. |[s] Timeout - maximum time that external controller will be allowed to control vehicle. 0 means no timeout|[m] Absolute altitude min AMSL - if vehicle moves below this alt, the command will be aborted and the mission will continue. 0 means no lower altitude limit|[m] Absolute altitude max - if vehicle moves above this alt, the command will be aborted and the mission will continue. 0 means no upper altitude limit|[m] Horizontal move limit (AMSL) - if vehicle moves more than this distance from it's location at the moment the command was executed, the command will be aborted and the mission will continue. 0 means no horizontal altitude limit|Unused|Unused|Unused| uint16 VEHICLE_CMD_NAV_GUIDED_MASTER = 91 # Set id of master controller. |System ID|Component ID|Unused|Unused|Unused|Unused|Unused| diff --git a/docs/en/msg_docs/index.md b/docs/en/msg_docs/index.md index a70fa245f5..1df0fa98f1 100644 --- a/docs/en/msg_docs/index.md +++ b/docs/en/msg_docs/index.md @@ -84,7 +84,7 @@ Graphs showing how these are used [can be found here](../middleware/uorb_graph.m - [ActuatorOutputs](ActuatorOutputs.md) - [ActuatorServosTrim](ActuatorServosTrim.md) — Servo trims, added as offset to servo outputs - [ActuatorTest](ActuatorTest.md) -- [AdcReport](AdcReport.md) +- [AdcReport](AdcReport.md) — ADC raw data. - [Airspeed](Airspeed.md) — Airspeed data from sensors - [AirspeedWind](AirspeedWind.md) — Wind estimate (from airspeed_selector) - [AutotuneAttitudeControlStatus](AutotuneAttitudeControlStatus.md) — Autotune attitude control status @@ -259,6 +259,7 @@ Graphs showing how these are used [can be found here](../middleware/uorb_graph.m The topic will not be updated when the vehicle is armed - [SensorSelection](SensorSelection.md) — Sensor ID's for the voted sensors output on the sensor_combined topic. Will be updated on startup of the sensor module and when sensor selection changes +- [SensorTemp](SensorTemp.md) - [SensorUwb](SensorUwb.md) — UWB distance contains the distance information measured by an ultra-wideband positioning system, such as Pozyx or NXP Rddrone. - [SensorsStatus](SensorsStatus.md) — Sensor check metrics. This will be zero for a sensor that's primary or unpopulated. diff --git a/docs/en/power_module/ark_12s_payload_power_module.md b/docs/en/power_module/ark_12s_payload_power_module.md new file mode 100644 index 0000000000..4693bf1976 --- /dev/null +++ b/docs/en/power_module/ark_12s_payload_power_module.md @@ -0,0 +1,56 @@ +# ARK 12S Payload Power Module + +The [ARK 12S Payload Power Module](https://arkelectron.com/product/ark-12s-payload-power-module/) is a dual 5V 6A and 12V 6A power supply and digital power monitor designed for the Pixhawk Autopilot Bus Carrier boards. + +This is similar to the [ARK 12S PAB Power Module](../power_module/ark_12s_pab_power_module.md) except that the additional 12V 6A supply allows easier powering of a payload. + +![ARK 12S Payload Power Module](../../assets/hardware/power_module/ark_power_modules//ark_12s_payload_power.jpg) + +## Where to Buy + +Order this module from: + +- [ARK Electronics](https://arkelectron.com/product/ark-12s-payload-power-module/) (US) + +## Hardware Specifications + +- **TI INA238 Digital Power Monitor** + - 0.0001 Ohm Shunt + - I2C Interface + +- **5.2V 6A Step-Down Regulator** + - 10V Minimum Input Voltage at 6A Out + - Output Over-Current Protection + +- **12.0V 6A Step-Down Regulator** + - 15V Minimum Input Voltage at 6A Out + - Output Over-Current Protection + +- **75V Maximum Input Voltage** + +- **Connections** + - Solder Pads Battery Input + - Solder Pads Battery Output + - 6 Pin Molex CLIK-Mate Output + - [Matches ARK PAB Carrier Power Pinout](https://arkelectron.gitbook.io/ark-documentation/flight-controllers/ark-pixhawk-autopilot-bus-carrier/pinout) + - 4 Pin Molex CLIK-Mate 12V Output + +- **Other** + - USA Built + - Includes 6 Pin Molex CLIK-Mate Cable + +- **Additional Information** + - Weight: 20.5 g + - Dimensions: 3.7 cm x 3.5 cm x 1.3 cm + +## PX4 Setup + +- Disable the `SENS_EN_INA226` parameter if it is enabled. +- Enable the `SENS_EN_INA238` parameter. +- Reboot the flight controller. +- Set the `INA238_SHUNT` parameter to 0.0001. +- Reboot the flight controller. + +## See Also + +- [ARK 12S Payload Power Module Documentation](https://docs.arkelectron.com/power/ark-12s-payload-power-module) (ARK Docs) diff --git a/docs/en/power_module/ark_pab_power_module.md b/docs/en/power_module/ark_pab_power_module.md index 7ee5f0d024..20eddbeeb8 100644 --- a/docs/en/power_module/ark_pab_power_module.md +++ b/docs/en/power_module/ark_pab_power_module.md @@ -6,35 +6,36 @@ Note that at 60A and 20°C without cooling, the 5V regulator is de-rated to a 3A ![ARK PAB Power Module](../../assets/hardware/power_module/ark_power_modules//ark_pab_power_module.jpg) +This power module is also available without connectors: + +![ARK PAB Power Module No Connector](../../assets/hardware/power_module/ark_power_modules//ark_pab_power_no_connector.jpg) + ## Where to Buy Order this module from: -- [ARK Electronics](https://arkelectron.com/product/ark-pab-power-module/) (US) +- [ARK Electronics - ARK PAB Power Module](https://arkelectron.com/product/ark-pab-power-module/) (US) +- [ARK Electronics - ARK PAB Power Module No Connector](https://arkelectron.com/product/ark-pab-power-module-no-connector/) (US) ## Hardware Specifications - **TI INA226 Digital Power Monitor** - - 0.0005 Ohm Shunt - I2C Interface - **5.2V 6A Step-Down Regulator** - - 33V Maximum Input Voltage - 5.8V Minimum Input Voltage at 6A Out - Output Over-Voltage Protection - Output Over-Current Protection - **Connections** - - - XT60 Battery Input - - XT60 Battery Output + - XT60 Battery Input / Solder Pad Battery Input (No Connector version) + - XT60 Battery Output / Solder Pad Battery Output (No Connector version) - 6 Pin Molex CLIK-Mate Output - [Matches ARK PAB Carrier Power Pinout](https://arkelectron.gitbook.io/ark-documentation/flight-controllers/ark-pixhawk-autopilot-bus-carrier/pinout) - **Other** - - USA Built - FCC Compliant - Includes 6 Pin Molex CLIK-Mate Cable diff --git a/docs/en/power_module/index.md b/docs/en/power_module/index.md index 05eb28f553..fe78d1c223 100644 --- a/docs/en/power_module/index.md +++ b/docs/en/power_module/index.md @@ -27,6 +27,7 @@ This section provides information about a number of power modules and power dist - Digital (I2C) voltage and current power modules (for Pixhawk FMUv6X and FMUv5X derived controllers): - [ARK PAB Power Module](../power_module/ark_pab_power_module.md) - [ARK 12S PAB Power Module](../power_module/ark_12s_pab_power_module.md) + - [ARK 12S Payload Power Module](../power_module/ark_12s_payload_power_module.md) - [Holybro PM02D](../power_module/holybro_pm02d.md) - [Holybro PM03D](../power_module/holybro_pm03d.md) - [DroneCAN](../dronecan/index.md) power modules diff --git a/docs/en/releases/main.md b/docs/en/releases/main.md index 3931d565b4..70f5a2860f 100644 --- a/docs/en/releases/main.md +++ b/docs/en/releases/main.md @@ -76,6 +76,10 @@ Please continue reading for [upgrade instructions](#upgrade-guide). - TBD +### RC + +- Parse ELRS Status and Link Statistics TX messages in the CRSF parser. + ### Multi-Rotor - Removed parameters `MPC_{XY/Z/YAW}_MAN_EXPO` and use default value instead, as they were not deemed necessary anymore. ([PX4-Autopilot#25435: Add new flight mode: Altitude Cruise](https://github.com/PX4/PX4-Autopilot/pull/25435)). @@ -89,6 +93,7 @@ Please continue reading for [upgrade instructions](#upgrade-guide). - [Fixed Wing Takeoff mode](../flight_modes_fw/takeoff.md) will now keep climbing with level wings on position loss. A target takeoff waypoint can be set to control takeoff course and loiter altitude. ([PX4-Autopilot#25083](https://github.com/PX4/PX4-Autopilot/pull/25083)). +- Automatically suppress angular rate oscillations using [Gain compression](../features_fw/gain_compression.md). ([PX4-Autopilot#25840: FW rate control: add gain compression algorithm](https://github.com/PX4/PX4-Autopilot/pull/25840)) ### Rover diff --git a/docs/en/sensor/barometer.md b/docs/en/sensor/barometer.md index 46f77a8d8b..598bdc3d11 100644 --- a/docs/en/sensor/barometer.md +++ b/docs/en/sensor/barometer.md @@ -30,17 +30,51 @@ If needed, you can: - Change the selection order of barometers using the [CAL_BAROx_PRIO](../advanced_config/parameter_reference.md#CAL_BARO0_PRIO) parameters for each barometer. - Disable a barometer by setting its [CAL_BAROx_PRIO](../advanced_config/parameter_reference.md#CAL_BARO0_PRIO) value to `0`. -## Calibration +## Baro Auto-Calibration (Developers) -Barometers don't require calibration. +::: tip +This section documents the automated calibration mechanisms that ensure accurate altitude measurements throughout flight operations. +It is intended primarily for a developer audience who want to understand the underlying mechanisms. +::: - +The system implements two complementary calibration approaches that work together to maintain altitude measurement precision. +Both calibrations are initiated at the beginning after a system boot. +Relative calibration is performed first, followed by GNSS-barometric calibration. -## Developer Information +### Relative Calibration + +Relative baro calibration is **always enabled** and operates automatically during system initialization. +This calibration establishes offset corrections for all secondary baro sensors relative to the primary (selected) sensor. + +This calibration: + +- Eliminates altitude jumps when switching between baro sensors during flight. +- Ensures consistent altitude readings across all available baro sensors. +- Maintains seamless sensor redundancy and failover capability. + +### GNSS-Baro Calibration + +::: info +GNSS-baro calibration requires an operational GNSS receiver with vertical accuracy (EPV) ≤ 8 meters. +Relative calibration must already have completed. +::: + +GNSS-baro calibration adjusts baro sensor offsets to align with absolute altitude measurements from the GNSS receiver. +This calibration is controlled by the [SENS_BAR_AUTOCAL](../advanced_config/parameter_reference.md#SENS_BAR_AUTOCAL) parameter (enabled by default). + +The algorithm monitors GNSS quality, collects altitude differences over a 2-second filtered window, and verifies stability within 4m tolerance. +Once stable, it uses binary search to calculate pressure offsets that align baro altitude with GNSS altitude (0.1m precision), then applies the offset to all sensors and saves the parameters. + +Notes: + +- **EKF Independence**: GNSS-baro calibration operates independently of EKF2 altitude fusion settings. +- **Execution Timing**: Calibration runs even when [EKF2_GPS_CTRL](../advanced_config/parameter_reference.md#EKF2_GPS_CTRL) altitude fusion is disabled. +- **One-Time Process**: Each calibration session completes once per system startup. +- **Persistence**: Calibration offsets are saved to parameters and persist across reboots. +- **Faulty GNSS Vulnerability**: If GNSS data is faulty during boot, the calibration will use incorrect altitude reference. + See [Faulty GNSS Data During Boot](../advanced_config/tuning_the_ecl_ekf.md#faulty-gnss-data-during-boot) for mitigation strategies. + +## See Also - [Baro driver source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/barometer) - [Modules Reference: Baro (Driver)](../modules/modules_driver_baro.md) documentation. diff --git a/docs/en/sensor/rangefinders.md b/docs/en/sensor/rangefinders.md index 69deebdc35..425b129241 100644 --- a/docs/en/sensor/rangefinders.md +++ b/docs/en/sensor/rangefinders.md @@ -15,11 +15,69 @@ This is a subset of the rangefinders that can be used with PX4. There may also be other DroneCAN rangefinders than those listed here. ::: -### ARK Flow & AKR Flow MR +| Rangefinder | Technology | Range (min – max) | Connections | NDAA | Notes | +| ------------------------------------------- | --------------- | ------------------------ | ---------------------- | ---- | ----------------------------------- | +| [Ainstein US-D1 Standard Radar Altimeter] | Microwave radar | ~50 m | UART | ✔️ | | +| [ARK DIST SR] | ToF (850 nm IR) | 8 cm to ~30 m | DroneCAN, UART | ✔️ | | +| [ARK DIST MR] | ToF (IR) | 8 cm to ~50 m | DroneCAN, UART | ✔️ | | +| [Benewake TFmini] | ToF (IR laser) | ~12 m | UART | ~ | | +| [Holybro ST VL53L1X Lidar] | ToF (IR) | up to ~4 m | I2C | ~ | | +| [LeddarOne] | ToF (IR) | 1 cm – 40 m | UART | ~ | | +| [Lidar-Lite] | ToF (IR laser) | 5 cm – 40 m | I2C, PWM | ~ | | +| [LightWare SF11/C] | ToF (IR laser) | up to ~120 m | UART, I2C | ~ | | +| [LightWare LW20/C] | ToF (IR laser) | up to ~100 m | I2C | ~ | Waterproof (IP67) + servo | +| [LightWare SF45/B] | ToF (IR laser) | ~50 m | UART | ~ | Rotary lidar (collision prevention) | +| [MaxBotix I2CXL-MaxSonar-EZ] | Ultrasonic | | I2C | ~ | | +| [RaccoonLab Cyphal & DroneCAN µRANGEFINDER] | ToF (IR) | ~0.1 m – ~8 m | DroneCAN, Cyphal | ~ | | +| [TeraRanger Evo 60 m] | ToF (IR) | 0.5 m – 60 m | I2C | ~ | | +| [TeraRanger Evo 600Hz] | ToF (IR) | 0.75 m – 8 m | I2C | ~ | High update rate (600 Hz) | +| [LightWare SF02] _(disc.)_ | ToF (IR laser) | ~50 m | UART | ~ | Discontinued | +| [LightWare SF10/A] _(disc.)_ | ToF (IR laser) | ~25 m | UART, I2C | ~ | Discontinued | +| [LightWare SF10/B] _(disc.)_ | ToF (IR laser) | ~50 m | UART, I2C | ~ | Discontinued | +| [LightWare SF10/C] _(disc.)_ | ToF (IR laser) | ~100 m | UART, I2C | ~ | Discontinued | +| [Lanbao PSK-CM8JL65-CC5] _(disc.)_ | ToF (IR) | 0.17 m – 8 m | UART | ✖️ | Discontinued | +| [TeraRanger One] _(disc.)_ | ToF (IR) | ~0.2 m – ~14 m (typical) | I2C (adapter required) | ~ | Discontinued | -[ARK Flow](../dronecan/ark_flow.md) and [ARK Flow MR](../dronecan/ark_flow_mr.md) are open-source Time-of-Flight (ToF) and optical flow sensor modules, which are capable of measuring distances from 8cm to 30m and from 8cm to 50m, respectively. -It can be connected to the flight controller via its CAN1 port, allowing additional sensors to connect through its CAN2 port. -It supports [DroneCAN](../dronecan/index.md), runs [PX4 DroneCAN Firmware](../dronecan/px4_cannode_fw.md), and is packed into a tiny form factor. +[Ainstein US-D1 Standard Radar Altimeter]: ../sensor/ulanding_radar.md +[ARK DIST SR]: ../dronecan/ark_dist.md +[ARK DIST MR]: ../dronecan/ark_dist_mr.md +[Benewake TFmini]: ../sensor/tfmini.md +[Holybro ST VL53L1X Lidar]: #holybro-st-vl53l1x-lidar +[Lanbao PSK-CM8JL65-CC5]: ../sensor/cm8jl65_ir_distance_sensor.md +[LeddarOne]: ../sensor/leddar_one.md +[Lidar-Lite]: ../sensor/lidar_lite.md +[LightWare Lidar]: ../sensor/sfxx_lidar.md +[LightWare SF11/C]: ../sensor/sfxx_lidar.md +[LightWare LW20/C]: ../sensor/sfxx_lidar.md +[LightWare SF45/B]: ../sensor/sfxx_lidar.md +[LightWare SF02]: ../sensor/sfxx_lidar.md +[LightWare SF10/A]: ../sensor/sfxx_lidar.md +[LightWare SF10/B]: ../sensor/sfxx_lidar.md +[LightWare SF10/C]: ../sensor/sfxx_lidar.md +[MaxBotix I2CXL-MaxSonar-EZ]: #maxbotix-i2cxl-maxsonar-ez +[TeraRanger Evo 60 m]: ../sensor/teraranger.md +[TeraRanger Evo 600Hz]: ../sensor/teraranger.md +[TeraRanger One]: ../sensor/teraranger.md + +These adaptors allows you to connect a non-CAN rangefinder via the CAN interface. +Note that the range depends on the connected rangefinder + +| Adaptor | Connections | NDAA | +| ------------------------------------------------------- | ---------------- | ---- | +| **Avionics Anonymous UAVCAN Laser Altimeter Interface** | DroneCAN | ~ | +| [RaccoonLab Cyphal & DroneCAN Rangefinder Adapter] | DroneCAN, Cyphal | ~ | + +[RaccoonLab Cyphal & DroneCAN µRANGEFINDER]: #raccoonlab-cyphal-and-dronecan-μrangefinder +[RaccoonLab Cyphal & DroneCAN Rangefinder Adapter]: #raccoonlab-cyphal-and-dronecan-rangefinder-adapter + +Note that some [Optical Flow](../sensor/optical_flow.md) sensors also include a rangefinder, such as [ARK Flow](../dronecan/ark_flow.md) and [ARK Flow MR](../dronecan/ark_flow_mr.md). + +### ARK DIST SR & ARK DIST MR + +[ARK DIST SR](../dronecan/ark_dist.md) and [ARK DIST MR](../dronecan/ark_dist_mr.md) are open-source Time-of-Flight (ToF) rangefinder modules, which are capable of measuring distances from 8cm to 30m and from 8cm to 50m, respectively. + +The sensors support [DroneCAN](../dronecan/index.md), run [PX4 DroneCAN Firmware](../dronecan/px4_cannode_fw.md), and are packed into a tiny form factor. +They can be connected to a flight controller via its `CAN1` port, allowing additional sensors to connected through the `CAN2` port. ### Holybro ST VL53L1X Lidar diff --git a/docs/ko/SUMMARY.md b/docs/ko/SUMMARY.md index fc556f5949..d89ca451f9 100644 --- a/docs/ko/SUMMARY.md +++ b/docs/ko/SUMMARY.md @@ -182,6 +182,7 @@ - [Wiring Quickstart](assembly/quick_start_durandal.md) - [Holybro Pix32 v5](flight_controller/holybro_pix32_v5.md) - [Wiring Quickstart](assembly/quick_start_holybro_pix32_v5.md) + - [MicoAir H743 Lite](flight_controller/micoair743-lite.md) - [ModalAI VOXL 2](flight_controller/modalai_voxl_2.md) - [mRo Control Zero F7](flight_controller/mro_control_zero_f7.md) - [Radiolink PIX6](flight_controller/radiolink_pix6.md) @@ -504,6 +505,7 @@ - [UART/Serial 포트](uart/index.md) - [포트 설정 가능 시리얼 드라이버](uart/user_configurable_serial_driver.md) - [RTK GPS (통합)](advanced/rtk_gps.md) + - [PPS Time Synchronization](advanced/pps_time_sync.md) - [미들웨어](middleware/index.md) - [uORB 메시지 전송](middleware/uorb.md) - [uORB 그라프](middleware/uorb_graph.md) diff --git a/docs/ko/advanced/pps_time_sync.md b/docs/ko/advanced/pps_time_sync.md new file mode 100644 index 0000000000..f0a67858b9 --- /dev/null +++ b/docs/ko/advanced/pps_time_sync.md @@ -0,0 +1,135 @@ +# PPS Time Synchronization (PX4 Integration) + +[Pulse Per Second](https://en.wikipedia.org/wiki/Pulse-per-second_signal) (PPS) time synchronization provides high-precision timing for GNSS receivers. +This page explains how PPS is integrated into PX4 and how to configure it. + +## 개요 + +PPS (Pulse Per Second) is a timing signal provided by GNSS receivers that outputs an electrical pulse once per second, synchronized to UTC time. +The PPS signal provides a highly accurate timing reference that PX4 can use to: + +- Refine GNSS time measurements and compensate for clock drift +- Provide precise UTC timestamps for camera capture events (for photogrammetry and mapping applications) +- Enable offline position refinement through accurate time correlation + +## 지원 하드웨어 + +PPS time synchronization can be supported on flight controllers that have a hardware timer input pin that can be configured for PPS capture, by [enabling the PPS capture driver](#enable-pps-driver-in-board-configuration) in the board configuration. + +Supported boards include (at time of writing): + +- [Ark FMUv6x](../flight_controller/ark_v6x.md) +- Auterion FMUv6x +- Auterion FMUv6s + +## 설정 + +### Enable PPS Driver in Board Configuration + +The [PPS capture driver](../modules/modules_driver.md#pps-capture) must be enabled in the board configuration. +This is done by adding the following to your board's configuration: + +```ini +CONFIG_DRIVERS_PPS_CAPTURE=y +``` + +### Configure PPS Parameters + +The configuration varies depending on your flight controller hardware. + +#### FMUv6X + +For FMUv6X-based flight controllers, configure PWM AUX Timer 3 and Function 9: + +```sh +param set PWM_AUX_TIM3 -2 +param set PWM_AUX_FUNC9 2064 +param set PPS_CAP_ENABLE 1 +``` + +#### FMUv6S + +For FMUv6S-based flight controllers, configure PWM MAIN Timer 3 and Function 10: + +```sh +param set PWM_MAIN_TIM3 -2 +param set PWM_MAIN_FUNC10 2064 +param set PPS_CAP_ENABLE 1 +``` + +### 배선 + +The wiring configuration depends on your specific flight controller. + +#### Skynode X (FMUv6x) + +Connect the PPS signal from your GNSS module to the flight controller using the 11-pin or 6-pin GPS connector: + +For detailed pinout information, refer to: + +- [Skynode GPS Peripherals - Pinouts](https://docs.auterion.com/hardware-integration/skynode/peripherals/gps#pinouts) + +#### Skynode S (FMUv6S) + +For FMUv6S, you need to route the PPS signal separately: + +1. Connect your GNSS module using the standard 6-pin GPS connector: [Skynode S GPS Interface](https://docs.auterion.com/hardware-integration/skynode-s/interfaces#gps) +2. Connect the PPS signal from your GNSS module to the **PPM_IN** pin: [Skynode S Extras 1 Interface](https://docs.auterion.com/hardware-integration/skynode-s/interfaces#extras-1) + +#### ARK Jetson Carrier Board (FMUv6x) + +For ARK FMUv6X on the Jetson carrier board: + +1. Connect your GNSS module using either the 10-pin or 6-pin GPS connector: [ARK PAB GPS1 Interface](../flight_controller/ark_pab#gps1) +2. Connect the PPS signal to the **FMU_CAP** pin: [ARK PAB ADIO Interface](../flight_controller/ark_pab.md#adio) + +## 검증 + +After configuring PPS, you can verify that it is working correctly: + +1. Connect to the [PX4 System Console](../debug/system_console.md) (via MAVLink shell or serial console). + +2. Wait for GNSS fix. + +3. Check the PPS capture status to confirm it is up and running: + + ```sh + pps_capture status + ``` + +4. You can also check the [PpsCapture](../msg_docs/PpsCapture.md) uORB topic + + ```sh + listener pps_capture + ``` + + Where you should see: `timestamp`, `rtc_timestamp`, and `pps_rate_exceeded_counter`. + +### PPS Capture Driver + +The PPS capture driver is located in `src/drivers/pps_capture` and uses hardware timer input capture to precisely measure the arrival time of each PPS pulse. + +주요 기능: + +- Sub-microsecond pulse capture precision (hardware-dependent) +- Automatic drift calculation and compensation +- Integration with the GNSS driver for refined time stamping + +See also: + +- [PPS Capture Driver Documentation](../modules/modules_driver.md#pps-capture) +- [PpsCapture Message](../msg_docs/PpsCapture.md) + +### Time Synchronization Flow + +1. GNSS module sends position/time data at ~1-20 Hz. +2. GNSS module outputs PPS pulse at 1 Hz, precisely aligned to UTC second boundary. +3. PPS capture driver measures the exact time of the PPS pulse arrival using hardware timer. +4. Driver calculates the offset between GNSS time (from UART data) and autopilot clock (from PPS measurement). +5. This offset is used to correct GNSS timestamps and improve sensor fusion accuracy. + +The PPS signal provides much higher temporal precision than the transmitted time data, which has latency and jitter from serial communication. + +:::warning +If the PPS driver does not sending any data for 5 seconds (despite having `PPS_CAP_ENABLE` set to 1), the `EKF2_GPS_DELAY` will be used instead for estimating the latency. +::: diff --git a/docs/ko/advanced_config/bootloader_update_from_betaflight.md b/docs/ko/advanced_config/bootloader_update_from_betaflight.md index 4498e65fa6..e1c4203c71 100644 --- a/docs/ko/advanced_config/bootloader_update_from_betaflight.md +++ b/docs/ko/advanced_config/bootloader_update_from_betaflight.md @@ -89,7 +89,7 @@ Flight controllers that have bootloader PX4-Autopilot `make` targets, can build The list of controllers for which this applies can be obtained by running the following `make` command, and noting the `make` targets that end in `_bootloader` ``` -$make list_config_targets +$ make list_config_targets ... cuav_nora_bootloader diff --git a/docs/ko/flight_controller/autopilot_manufacturer_supported.md b/docs/ko/flight_controller/autopilot_manufacturer_supported.md index a1b565877e..177c99d284 100644 --- a/docs/ko/flight_controller/autopilot_manufacturer_supported.md +++ b/docs/ko/flight_controller/autopilot_manufacturer_supported.md @@ -30,6 +30,7 @@ This category includes boards that are not fully compliant with the pixhawk stan - [Holybro Kakute H7](../flight_controller/kakuteh7.md) - [Holybro Durandal](../flight_controller/durandal.md) - [Holybro Pix32 v5](../flight_controller/holybro_pix32_v5.md) +- [MicoAir H743 Lite](../flight_controller/micoair743-lite.md) - [ModalAI VOXL 2](../flight_controller/modalai_voxl_2.md) - [mRo Control Zero](../flight_controller/mro_control_zero_f7.md) - [Radiolink PIX6](../flight_controller/radiolink_pix6.md) diff --git a/docs/ko/flight_controller/micoair743-lite.md b/docs/ko/flight_controller/micoair743-lite.md new file mode 100644 index 0000000000..af6032f040 --- /dev/null +++ b/docs/ko/flight_controller/micoair743-lite.md @@ -0,0 +1,153 @@ +# MicoAir743-Lite + + + +:::warning +PX4 does not manufacture this (or any) autopilot. +Contact the [manufacturer](https://micoair.com/) for hardware support or compliance issues. +::: + +MicoAir743-Lite is an ultra-high performance H743 flight controller with an unbeatable price, featuring the ICM45686 IMU sensor and integrated Bluetooth telemetry. + +![MicoAir743-Lite Front View](../../assets/flight_controller/micoair743_lite/front_view.png) + +Equipped with a high-performance H7 processor, the MicoAir743-Lite features a compact form factor with SH1.0 connectors (which are more suitable than Pixhawk-standard GH1.25 for this board size). +When paired with with Bluetooth telemetry, the board can be debugged with a phone or PC. + +:::info +This flight controller is [manufacturer supported](../flight_controller/autopilot_manufacturer_supported.md). +::: + +## MicoAir743-Lite (v1.1) + +![MicoAir743-Lite Back View](../../assets/flight_controller/micoair743_lite/back_view.png) + +## 요약 + +### Processors & Sensors + +- FMU Processor: STM32H743 + - 32 Bit Arm® Cortex®-M7, 480MHz, 2MB flash memory, 1MB RAM +- 내장 센서 : + - Accel/Gyro: ICM-45686 (with BalancedGyro™ Technology) + - Barometer: SPA06 +- On-board Bluetooth Telemetry + - Connected to UART8 internally, baudrate 115200 + - Connecting to QGC (PC or Android phone) via Bluetooth +- 기타 특성: + - Operating & storage temperature: -20 ~ 85°c + +### 인터페이스 + +- 8 UART (TELEM / GPS / RC) +- 14 PWM outputs (10 supports DShot) +- Support multiple RC inputs (SBUS / CRSF / DSM) +- 1 GPS port +- 1 I2C port +- 2 ADC port2 (VBAT, Current) +- 1 DJI O3/O4 VTX connector +- 1 MicroSD Card Slot +- 1 USB Type-C + +### Electrical data + +- VBAT Input: + - 2\~6S (6\~27V) +- USB Power Input: + - 4.75\~5.25V +- BEC Output: + - 5V 2A (for controller, receiver, GPS, optical flow or other devices) + - 9V 2A (for video transmitter, camera) + +### Mechanical data + +- Mounting: 30.5 x 30.5mm, Φ4mm +- Dimensions: 36 x 36 x 8 mm +- Weight: 10g + +![MicoAir743-Lite Size](../../assets/flight_controller/micoair743_lite/size.png) + +## 구매처 + +Order from [MicoAir Tech Store](https://store.micoair.com/product/micoair743-lite/). + +## 핀배열 + +Pinouts definition can be found in the [MicoAir743-Lite_pinout.xlsx](https://raw.githubusercontent.com/PX4/PX4-Autopilot/refs/heads/main/docs/assets/flight_controller/micoair743_lite/micoair743_lite_pinout.xlsx) file. + +## 시리얼 포트 매핑 + +| UART | 장치 | 포트 | +| ------ | ---------- | ------ | +| USART1 | /dev/ttyS0 | TELEM1 | +| USART2 | /dev/ttyS1 | GPS2 | +| USART3 | /dev/ttyS2 | GPS1 | +| UART4 | /dev/ttyS3 | TELEM2 | +| UART5 | /dev/ttyS4 | TELEM3 | +| USART6 | /dev/ttyS5 | RC | +| UART7 | /dev/ttyS6 | URT6 | +| UART8 | /dev/ttyS7 | TELEM4 | + +## Interfaces Diagram + +:::note +All the connectors used on the board are SH1.0 +::: + +![MicoAir743-Lite Interface Diagram](../../assets/flight_controller/micoair743_lite/interfaces_diagram.png) + +## Sample Wiring Diagram + +![MicoAir743-Lite Wiring Diagram](../../assets/flight_controller/micoair743_lite/wiring_diagram.png) + +## 펌웨어 빌드 + +To [build PX4](../dev_setup/building_px4.md) for this target: + +```sh +make micoair_h743-lite_default +``` + +## 펌웨어 설치 + +펌웨어는 일반적인 방법으로 설치할 수 있습니다. + +- 소스 빌드 및 업로드 + + ```sh + make micoair_h743-lite_default upload + ``` + +- [Load the firmware](../config/firmware.md) using _QGroundControl_. + 미리 빌드된 펌웨어나 사용자 지정 펌웨어를 사용할 수 있습니다. + + ::: info + At time of writing the only pre-built software is `PX4 main` (see [Installing PX4 Main, Beta or Custom Firmware](../config/firmware.md#installing-px4-main-beta-or-custom-firmware)). + Release builds will be supported for PX4 v1.17 and later. + +::: + +## 무선 조종 + +A [Radio Control (RC) system](../getting_started/rc_transmitter_receiver.md) is required if you want to manually control your vehicle (PX4 does not require a radio system for autonomous flight modes). + +The RC port is connected to the FMU and you can attach a receiver that uses the protocols `DSM`, `SBUS`, `CSRF`, `GHST`, or other protocol listed in [Radio Control modules](../modules/modules_driver_radio_control.md). +You will need to enable the protocol by setting the corresponding parameter `RC_xxxx_PRT_CFG`, such as [RC_CRSF_PRT_CFG](../advanced_config/parameter_reference.md#RC_CRSF_PRT_CFG) for a [CRSF receiver](../telemetry/crsf_telemetry.md). + +## 지원 플랫폼 및 기체 + +일반 RC 서보 또는 Futaba S-Bus 서보로 제어 가능한 모든 멀티콥터/비행기/로버 또는 보트. +The complete set of supported configurations can be seen in the [Airframes Reference](../airframes/airframe_reference.md). + +## 주변 장치 + +- [MicoAir Telemetry Radio Modules](https://micoair.com/radio_telemetry/) +- [MicoAir Optical & Range Sensor](https://micoair.com/optical_range_sensor/) +- [MicoAir GPS](https://micoair.com/gps/) +- [MicoAir ESC Modules](https://micoair.com/esc/) + +## 추가 정보 + +- [MicoAir Tech.](https://micoair.com/) +- [Details about MicoAir743-Lite](https://micoair.com/flightcontroller_micoair743lite/) +- [QGroundControl Download and Install](https://docs.qgroundcontrol.com/Stable_V5.0/en/qgc-user-guide/getting_started/download_and_install.html) diff --git a/docs/ko/flight_controller/pixhawk_series.md b/docs/ko/flight_controller/pixhawk_series.md index 979404a53a..7bca3dc03a 100644 --- a/docs/ko/flight_controller/pixhawk_series.md +++ b/docs/ko/flight_controller/pixhawk_series.md @@ -100,6 +100,24 @@ PX4 _developers_ need to know the FMU version of their board, as this is require +### FMUv6 Comparison + +| 기능 | **FMUv6X-RT** | **FMUv6X** | **FMUv6C** | +| ------------------ | ------------------------------- | ------------- | ------------- | +| **FMU MCU** | NXP i.MX RT1176 | STM32H753 | STM32H743V | +| **RAM** | 2 MB | 1 MB | 1 MB | +| **Flash** | 64 MB Octal SPI | 2 MB internal | 2 MB internal | +| **IO MCU** | STM32F103 | STM32F103 | STM32F103 | +| **Secure Element** | NXP SE051 | NXP SE051 | Not supported | +| **PAB Standard** | Supported | Supported | Not supported | +| **Ethernet** | Supported | Supported | Not supported | +| **IMUs** | 3× | 3× | 2× | +| **Barometers** | 2× | 2× | 1× | +| **Magnetometer** | 1× | 1× | 1× | +| **FMU PWM** | 12× | 8× | 8× | +| **IO PWM** | 8× | 8× | 8× | +| **CAN Bus** | 3× | 2× | 2× | + ### 라이선스와 상표 Pixhawk project schematics and reference designs are licensed under [CC BY-SA 3](https://creativecommons.org/licenses/by-sa/3.0/legalcode). diff --git a/docs/ko/flight_modes_fw/return.md b/docs/ko/flight_modes_fw/return.md index 3643254996..92119f1ed5 100644 --- a/docs/ko/flight_modes_fw/return.md +++ b/docs/ko/flight_modes_fw/return.md @@ -25,11 +25,6 @@ The default type is recommended. ::: -:::warning -There is a known issue ([PX4-Autopilot#25436](https://github.com/PX4/PX4-Autopilot/issues/25436)) with fixed-wing approaches and landings while in RTL mode. -Please review the issue and verify in simulation that the behavior you get is safe in an RTL landing scenario (if not, consider using rally points). -::: - ## Technical Summary Fixed-wing vehicles use the _mission landing/rally point_ return type by default. diff --git a/docs/ko/gps_compass/index.md b/docs/ko/gps_compass/index.md index 13aa607cc1..e7150d8383 100644 --- a/docs/ko/gps_compass/index.md +++ b/docs/ko/gps_compass/index.md @@ -145,21 +145,21 @@ To ensure the port is set up correctly perform a [Serial Port Configuration](../ The following steps show how to configure a secondary GPS on the `GPS 2` port in _QGroundControl_: 1. [Find and set](../advanced_config/parameters.md) the parameter [GPS_2_CONFIG](../advanced_config/parameter_reference.md#GPS_2_CONFIG) to **GPS 2**. - - Open _QGroundControl_ and navigate to the **Vehicle Setup > Parameters** section. - - Select the **GPS** tab, then open the [GPS_2_CONFIG](../advanced_config/parameter_reference.md#GPS_2_CONFIG) parameter and select `GPS 2` from the dropdown list. + - Open _QGroundControl_ and navigate to the **Vehicle Setup > Parameters** section. + - Select the **GPS** tab, then open the [GPS_2_CONFIG](../advanced_config/parameter_reference.md#GPS_2_CONFIG) parameter and select `GPS 2` from the dropdown list. - ![QGC Serial Example](../../assets/peripherals/qgc_serial_config_example.png) + ![QGC Serial Example](../../assets/peripherals/qgc_serial_config_example.png) 2. 다른 매개변수를 표시하려면 기체를 재부팅하십시오. 3. Select the **Serial** tab, and open the [SER_GPS2_BAUD](../advanced_config/parameter_reference.md#SER_GPS2_BAUD) parameter (`GPS 2` port baud rate): set it to _Auto_ (or 115200 for the Trimble). - ![QGC Serial Baudrate Example](../../assets/peripherals/qgc_serial_baudrate_example.png) + ![QGC Serial Baudrate Example](../../assets/peripherals/qgc_serial_baudrate_example.png) 보조 GPS 포트를 설정 후 : 1. 두 GPS 시스템의 데이터를 혼합하도록 ECL/EKF2 추정기를 설정합니다. - For detailed instructions see: [Using the ECL EKF > Dual Receivers](../advanced_config/tuning_the_ecl_ekf.md#dual-receivers). + For detailed instructions see: [Using the ECL EKF > Dual Receivers](../advanced_config/tuning_the_ecl_ekf.md#dual-receivers). ### DroneCAN GNSS Configuration @@ -197,11 +197,21 @@ It is possible to have low DOP (good satellite geometry) but still have high EPH EPH/EPV values therefore provide a more immediate and practical estimate of the actual GPS accuracy you can expect under current conditions. +### GNSS Position Fusion + +GNSS position fusion will not begin until yaw alignment is established. +If a magnetometer is available, the EKF aligns yaw using the magnetic heading, allowing GPS position fusion to start soon after boot. +If no magnetometer is present, the system must rely on GPS yaw (from a dual-antenna setup) or movement-based yaw estimation. +Until one of these provides a valid heading, the EKF will not start GPS position fusion, and the vehicle will remain in a “no position” state even though attitude data is valid. +This behavior prevents large position errors that could occur when the yaw reference is uncertain. + ## 개발자 정보 - GPS/RTK-GPS - [RTK-GPS](../advanced/rtk_gps.md) + - [PPS Time Synchronization](../advanced/pps_time_sync.md) - [GPS driver](../modules/modules_driver.md#gps) + - [PPS driver](../modules/modules_driver.md#pps-capture) - [DroneCAN Example](../dronecan/index.md) - 나침반 - [Driver source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/magnetometer) (Compasses) diff --git a/docs/ko/gps_compass/magnetometer.md b/docs/ko/gps_compass/magnetometer.md index a6c238c478..5474b68bbd 100644 --- a/docs/ko/gps_compass/magnetometer.md +++ b/docs/ko/gps_compass/magnetometer.md @@ -40,6 +40,7 @@ This list contains stand-alone magnetometer modules (without GNSS). | 장치 | 나침반 | DroneCan | | :--------------------------------------------------------------------------------------------------------------- | :----: | :------: | +| [ARK MAG](https://arkelectron.com/product/ark-mag/) | RM3100 | ✓ | | [Avionics Anonymous UAVCAN Magnetometer](https://www.tindie.com/products/avionicsanonymous/uavcan-magnetometer/) | ? | | | [Holybro DroneCAN RM3100 Compass/Magnetometer](https://holybro.com/products/dronecan-rm3100-compass) | RM3100 | ✓ | | [RaccoonLab DroneCAN/Cyphal Magnetometer RM3100](https://holybro.com/products/dronecan-rm3100-compass) | RM3100 | ✓ | diff --git a/docs/ko/middleware/uxrce_dds.md b/docs/ko/middleware/uxrce_dds.md index 844574bbcb..ecbaa8a8b7 100644 --- a/docs/ko/middleware/uxrce_dds.md +++ b/docs/ko/middleware/uxrce_dds.md @@ -454,6 +454,7 @@ uxrce_dds_client start -n fancy_uav ``` This can be included in `etc/extras.txt` as part of a custom [System Startup](../concept/system_startup.md). +::: ## PX4 ROS 2 QoS Settings @@ -515,6 +516,11 @@ publications: - topic: /fmu/out/vehicle_trajectory_waypoint_desired type: px4_msgs::msg::VehicleTrajectoryWaypoint + - topic: /fmu/out/vehicle_imu + type: px4_msgs::msg::VehicleImu + rate_limit: 50. + instance: 1 # OPTIONAL + subscriptions: - topic: /fmu/in/offboard_control_mode @@ -547,6 +553,9 @@ Each (`topic`,`type`) pairs defines: 4. The message type (`VehicleOdometry`, `VehicleStatus`, `OffboardControlMode`, etc.) and the ROS 2 package (`px4_msgs`) that is expected to provide the message definition. 5. **(Optional)**: An additional `rate_limit` field (only for publication entries), which specifies the maximum rate (Hz) at which messages will be published on this topic by PX4 to ROS 2. If left unspecified, the maximum publication rate limit is set to 100 Hz. +6. **(Optional)**: An additional `instance` field (only for publication entries), which lets you select which instance of a [multi-instance topic](./uorb.md#multi-instance) you want to be published to ROS 2. + If provided, this option changes the ROS 2 topic name of the advertised uORB topic appending the instance number: `fmu/out/[uorb topic name][instance]` (plus eventual namespace and message version). + In the example above the final topic name would be `/fmu/out/vehicle_imu1`. `subscriptions` and `subscriptions_multi` allow us to choose the uORB topic instance that ROS 2 topics are routed to: either a shared instance that may also be getting updates from internal PX4 uORB publishers, or a separate instance that is reserved for ROS2 publications, respectively. Without this mechanism all ROS 2 messages would be routed to the _same_ uORB topic instance (because ROS 2 does not have the concept of [multiple topic instances](../middleware/uorb.md#multi-instance)), and it would not be possible for PX4 subscribers to differentiate between streams from ROS 2 or PX4 publishers. @@ -588,7 +597,7 @@ For a list of services, details and examples see the [service documentation](../ These guidelines explain how to migrate from using PX4 v1.13 [Fast-RTPS](../middleware/micrortps.md) middleware to PX4 v1.14 `uXRCE-DDS` middleware. These are useful if you have [ROS 2 applications written for PX4 v1.13](https://docs.px4.io/v1.13/en/ros/ros2_comm.html), or you have used Fast-RTPS to interface your applications to PX4 [directly](https://docs.px4.io/v1.13/en/middleware/micrortps.html#agent-in-an-offboard-fast-dds-interface-ros-independent). -::: info +:::info This section contains migration-specific information. You should also read the rest of this page to properly understand uXRCE-DDS. ::: diff --git a/docs/ko/modules/hello_sky.md b/docs/ko/modules/hello_sky.md index f32e85ec7b..1f35a8d629 100644 --- a/docs/ko/modules/hello_sky.md +++ b/docs/ko/modules/hello_sky.md @@ -28,151 +28,151 @@ This consists of a single _C_ file and a _cmake_ definition (which tells the too 1. Create a new directory **PX4-Autopilot/src/examples/px4_simple_app**. 2. Create a new C file in that directory named **px4_simple_app.c**: - - 기본 헤더를 페이지 상단에 복사합니다. - 이것은 기여한 모든 파일에 첨부하여야 합니다. + - 기본 헤더를 페이지 상단에 복사합니다. + 이것은 기여한 모든 파일에 첨부하여야 합니다. - ```c - /**************************************************************************** - * - * Copyright (c) 2012-2022 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. - * - ****************************************************************************/ - ``` + ```c + /**************************************************************************** + * + * Copyright (c) 2012-2022 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. + * + ****************************************************************************/ + ``` - - 기본 헤더 아래에 다음 코드를 복사합니다. - 이것은 기여한 모든 파일에 첨부하여야 합니다. + - 기본 헤더 아래에 다음 코드를 복사합니다. + 이것은 기여한 모든 파일에 첨부하여야 합니다. - ```c - /** - * @file px4_simple_app.c - * Minimal application example for PX4 autopilot - * - * @author Example User - */ + ```c + /** + * @file px4_simple_app.c + * Minimal application example for PX4 autopilot + * + * @author Example User + */ - #include + #include - __EXPORT int px4_simple_app_main(int argc, char *argv[]); + __EXPORT int px4_simple_app_main(int argc, char *argv[]); - int px4_simple_app_main(int argc, char *argv[]) - { - PX4_INFO("Hello Sky!"); - return OK; - } - ``` + int px4_simple_app_main(int argc, char *argv[]) + { + PX4_INFO("Hello Sky!"); + return OK; + } + ``` - :::tip - The main function must be named `_main` and exported from the module as shown. + :::tip + The main function must be named `_main` and exported from the module as shown. ::: - :::tip - `PX4_INFO` is the equivalent of `printf` for the PX4 shell (included from **px4_platform_common/log.h**). - There are different log levels: `PX4_INFO`, `PX4_WARN`, `PX4_ERR`, `PX4_DEBUG`. - Warnings and errors are additionally added to the [ULog](../dev_log/ulog_file_format.md) and shown on [Flight Review](https://logs.px4.io/). + :::tip + `PX4_INFO` is the equivalent of `printf` for the PX4 shell (included from **px4_platform_common/log.h**). + There are different log levels: `PX4_INFO`, `PX4_WARN`, `PX4_ERR`, `PX4_DEBUG`. + Warnings and errors are additionally added to the [ULog](../dev_log/ulog_file_format.md) and shown on [Flight Review](https://logs.px4.io/). ::: 3. Create and open a new _cmake_ definition file named **CMakeLists.txt**. - 아래 텍스트를 복사하십시오. + 아래 텍스트를 복사하십시오. - ```cmake - ############################################################################ - # - # Copyright (c) 2015 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 examples__px4_simple_app - MAIN px4_simple_app - STACK_MAIN 2000 - SRCS - px4_simple_app.c - DEPENDS - ) - ``` + ```cmake + ############################################################################ + # + # Copyright (c) 2015 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 examples__px4_simple_app + MAIN px4_simple_app + STACK_MAIN 2000 + SRCS + px4_simple_app.c + DEPENDS + ) + ``` - The `px4_add_module()` method builds a static library from a module description. + The `px4_add_module()` method builds a static library from a module description. - - The `MODULE` block is the Firmware-unique name of the module (by convention the module name is prefixed by parent directories back to `src`). - - The `MAIN` block lists the entry point of the module, which registers the command with NuttX so that it can be called from the PX4 shell or SITL console. + - The `MODULE` block is the Firmware-unique name of the module (by convention the module name is prefixed by parent directories back to `src`). + - The `MAIN` block lists the entry point of the module, which registers the command with NuttX so that it can be called from the PX4 shell or SITL console. - :::tip - The `px4_add_module()` format is documented in [PX4-Autopilot/cmake/px4_add_module.cmake](https://github.com/PX4/PX4-Autopilot/blob/main/cmake/px4_add_module.cmake). + :::tip + The `px4_add_module()` format is documented in [PX4-Autopilot/cmake/px4_add_module.cmake](https://github.com/PX4/PX4-Autopilot/blob/main/cmake/px4_add_module.cmake). ::: - ::: info - If you specify `DYNAMIC` as an option to `px4_add_module`, a _shared library_ is created instead of a static library on POSIX platforms (these can be loaded without having to recompile PX4, and shared to others as binaries rather than source code). - Your app will not become a builtin command, but ends up in a separate file called `examples__px4_simple_app.px4mod`. - You can then run your command by loading the file at runtime using the `dyn` command: `dyn ./examples__px4_simple_app.px4mod` + ::: info + If you specify `DYNAMIC` as an option to `px4_add_module`, a _shared library_ is created instead of a static library on POSIX platforms (these can be loaded without having to recompile PX4, and shared to others as binaries rather than source code). + Your app will not become a builtin command, but ends up in a separate file called `examples__px4_simple_app.px4mod`. + You can then run your command by loading the file at runtime using the `dyn` command: `dyn ./examples__px4_simple_app.px4mod` ::: 4. Create and open a new _Kconfig_ definition file named **Kconfig** and define your symbol for naming (see [Kconfig naming convention](../hardware/porting_guide_config.md#px4-kconfig-symbol-naming-convention)). - 아래 텍스트를 복사하십시오. + 아래 텍스트를 복사하십시오. - ``` - menuconfig EXAMPLES_PX4_SIMPLE_APP - bool "px4_simple_app" - default n - ---help--- - Enable support for px4_simple_app - ``` + ``` + menuconfig EXAMPLES_PX4_SIMPLE_APP + bool "px4_simple_app" + default n + ---help--- + Enable support for px4_simple_app + ``` ## 애플리케이션/펌웨어 빌드 @@ -440,6 +440,7 @@ The [complete example code](https://github.com/PX4/PX4-Autopilot/blob/main/src/e */ #include +#include #include #include #include diff --git a/docs/ko/msg_docs/DifferentialPressure.md b/docs/ko/msg_docs/DifferentialPressure.md index f5fd908df9..83adb2d03e 100644 --- a/docs/ko/msg_docs/DifferentialPressure.md +++ b/docs/ko/msg_docs/DifferentialPressure.md @@ -1,17 +1,24 @@ # DifferentialPressure (UORB message) +Differential-pressure (airspeed) sensor + +This is populated by airspeed sensor drivers and used by the sensor module to calculate airspeed. +The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `SensorBaro` instance). + [source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/DifferentialPressure.msg) ```c -uint64 timestamp # time since system start (microseconds) -uint64 timestamp_sample +# Differential-pressure (airspeed) sensor +# +# This is populated by airspeed sensor drivers and used by the sensor module to calculate airspeed. +# The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `SensorBaro` instance). -uint32 device_id # unique device ID for the sensor that does not change between power cycles +uint64 timestamp # [us] Time of publication (since system start) +uint64 timestamp_sample # [us] Time of raw data capture -float32 differential_pressure_pa # differential pressure reading in Pascals (may be negative) - -float32 temperature # Temperature provided by sensor in degrees Celsius, NAN if unknown - -uint32 error_count # Number of errors detected by driver +uint32 device_id # [-] Unique device ID for the sensor that does not change between power cycles +float32 differential_pressure_pa # [Pa] Differential pressure reading (may be negative) +float32 temperature # [degC] [@invalid NaN if unknown] Temperature +uint32 error_count # [-] Number of errors detected by driver ``` diff --git a/docs/ko/msg_docs/SensorBaro.md b/docs/ko/msg_docs/SensorBaro.md index cf834ccf36..ef4d7a8f28 100644 --- a/docs/ko/msg_docs/SensorBaro.md +++ b/docs/ko/msg_docs/SensorBaro.md @@ -1,18 +1,25 @@ # SensorBaro (UORB message) +Barometer sensor + +This is populated by barometer drivers and used by the EKF2 estimator. +The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `DifferentialPressure` instance). + [source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/SensorBaro.msg) ```c -uint64 timestamp # time since system start (microseconds) -uint64 timestamp_sample +# Barometer sensor +# +# This is populated by barometer drivers and used by the EKF2 estimator. +# The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `DifferentialPressure` instance). -uint32 device_id # unique device ID for the sensor that does not change between power cycles +uint64 timestamp # [us] Time of publication (since system start) +uint64 timestamp_sample # [us] Time of raw data capture -float32 pressure # static pressure measurement in Pascals - -float32 temperature # temperature in degrees Celsius - -uint32 error_count +uint32 device_id # [-] Unique device ID for the sensor that does not change between power cycles +float32 pressure # [Pa] Static pressure measurement +float32 temperature # [degC] Temperature. +uint32 error_count # [-] Number of errors detected by driver. uint8 ORB_QUEUE_LENGTH = 4 diff --git a/docs/ko/msg_docs/VehicleStatus.md b/docs/ko/msg_docs/VehicleStatus.md index 9d46e42cb3..05e3f98bbb 100644 --- a/docs/ko/msg_docs/VehicleStatus.md +++ b/docs/ko/msg_docs/VehicleStatus.md @@ -20,20 +20,16 @@ uint8 ARMING_STATE_ARMED = 2 uint8 latest_arming_reason uint8 latest_disarming_reason -uint8 ARM_DISARM_REASON_TRANSITION_TO_STANDBY = 0 uint8 ARM_DISARM_REASON_STICK_GESTURE = 1 uint8 ARM_DISARM_REASON_RC_SWITCH = 2 uint8 ARM_DISARM_REASON_COMMAND_INTERNAL = 3 uint8 ARM_DISARM_REASON_COMMAND_EXTERNAL = 4 uint8 ARM_DISARM_REASON_MISSION_START = 5 -uint8 ARM_DISARM_REASON_SAFETY_BUTTON = 6 -uint8 ARM_DISARM_REASON_AUTO_DISARM_LAND = 7 -uint8 ARM_DISARM_REASON_AUTO_DISARM_PREFLIGHT = 8 -uint8 ARM_DISARM_REASON_KILL_SWITCH = 9 -uint8 ARM_DISARM_REASON_LOCKDOWN = 10 -uint8 ARM_DISARM_REASON_FAILURE_DETECTOR = 11 -uint8 ARM_DISARM_REASON_SHUTDOWN = 12 -uint8 ARM_DISARM_REASON_UNIT_TEST = 13 +uint8 ARM_DISARM_REASON_LANDING = 6 +uint8 ARM_DISARM_REASON_PREFLIGHT_INACTION = 7 +uint8 ARM_DISARM_REASON_KILL_SWITCH = 8 +uint8 ARM_DISARM_REASON_RC_BUTTON = 13 +uint8 ARM_DISARM_REASON_FAILSAFE = 14 uint64 nav_state_timestamp # time when current nav_state activated diff --git a/docs/ko/msg_docs/index.md b/docs/ko/msg_docs/index.md index a94bc75e82..374a1c5e0c 100644 --- a/docs/ko/msg_docs/index.md +++ b/docs/ko/msg_docs/index.md @@ -105,7 +105,7 @@ Graphs showing how these are used [can be found here](../middleware/uorb_graph.m - [DebugKeyValue](DebugKeyValue.md) - [DebugValue](DebugValue.md) - [DebugVect](DebugVect.md) -- [DifferentialPressure](DifferentialPressure.md) +- [DifferentialPressure](DifferentialPressure.md) — Differential-pressure (airspeed) sensor - [DistanceSensor](DistanceSensor.md) — DISTANCE_SENSOR message data - [DistanceSensorModeChangeRequest](DistanceSensorModeChangeRequest.md) - [DronecanNodeStatus](DronecanNodeStatus.md) @@ -240,7 +240,7 @@ Graphs showing how these are used [can be found here](../middleware/uorb_graph.m - [SensorAccel](SensorAccel.md) - [SensorAccelFifo](SensorAccelFifo.md) - [SensorAirflow](SensorAirflow.md) -- [SensorBaro](SensorBaro.md) +- [SensorBaro](SensorBaro.md) — Barometer sensor - [SensorCombined](SensorCombined.md) — Sensor readings in SI-unit form. These fields are scaled and offset-compensated where possible and do not change with board revisions and sensor updates. diff --git a/docs/uk/SUMMARY.md b/docs/uk/SUMMARY.md index 4066b1dece..f8c37f188b 100644 --- a/docs/uk/SUMMARY.md +++ b/docs/uk/SUMMARY.md @@ -182,6 +182,7 @@ - [Wiring Quickstart](assembly/quick_start_durandal.md) - [Holybro Pix32 v5](flight_controller/holybro_pix32_v5.md) - [Wiring Quickstart](assembly/quick_start_holybro_pix32_v5.md) + - [MicoAir H743 Lite](flight_controller/micoair743-lite.md) - [ModalAI VOXL 2](flight_controller/modalai_voxl_2.md) - [mRo Control Zero F7](flight_controller/mro_control_zero_f7.md) - [Radiolink PIX6](flight_controller/radiolink_pix6.md) @@ -504,6 +505,7 @@ - [UART/Послідовний порт](uart/index.md) - [Драйвери послідовного порту і їх налаштування](uart/user_configurable_serial_driver.md) - [RTK GPS (Інтеграція)](advanced/rtk_gps.md) + - [PPS Time Synchronization](advanced/pps_time_sync.md) - [Проміжне програмне забезпечення](middleware/index.md) - [Повідомлення uORB](middleware/uorb.md) - [Граф uORB](middleware/uorb_graph.md) diff --git a/docs/uk/advanced/pps_time_sync.md b/docs/uk/advanced/pps_time_sync.md new file mode 100644 index 0000000000..67456cc75d --- /dev/null +++ b/docs/uk/advanced/pps_time_sync.md @@ -0,0 +1,135 @@ +# PPS Time Synchronization (PX4 Integration) + +[Pulse Per Second](https://en.wikipedia.org/wiki/Pulse-per-second_signal) (PPS) time synchronization provides high-precision timing for GNSS receivers. +This page explains how PPS is integrated into PX4 and how to configure it. + +## Загальний огляд + +PPS (Pulse Per Second) is a timing signal provided by GNSS receivers that outputs an electrical pulse once per second, synchronized to UTC time. +The PPS signal provides a highly accurate timing reference that PX4 can use to: + +- Refine GNSS time measurements and compensate for clock drift +- Provide precise UTC timestamps for camera capture events (for photogrammetry and mapping applications) +- Enable offline position refinement through accurate time correlation + +## Підтримуване обладнання + +PPS time synchronization can be supported on flight controllers that have a hardware timer input pin that can be configured for PPS capture, by [enabling the PPS capture driver](#enable-pps-driver-in-board-configuration) in the board configuration. + +Supported boards include (at time of writing): + +- [Ark FMUv6x](../flight_controller/ark_v6x.md) +- Auterion FMUv6x +- Auterion FMUv6s + +## Установка + +### Enable PPS Driver in Board Configuration + +The [PPS capture driver](../modules/modules_driver.md#pps-capture) must be enabled in the board configuration. +This is done by adding the following to your board's configuration: + +```ini +CONFIG_DRIVERS_PPS_CAPTURE=y +``` + +### Configure PPS Parameters + +The configuration varies depending on your flight controller hardware. + +#### FMUv6X + +For FMUv6X-based flight controllers, configure PWM AUX Timer 3 and Function 9: + +```sh +param set PWM_AUX_TIM3 -2 +param set PWM_AUX_FUNC9 2064 +param set PPS_CAP_ENABLE 1 +``` + +#### FMUv6S + +For FMUv6S-based flight controllers, configure PWM MAIN Timer 3 and Function 10: + +```sh +param set PWM_MAIN_TIM3 -2 +param set PWM_MAIN_FUNC10 2064 +param set PPS_CAP_ENABLE 1 +``` + +### Підключення + +The wiring configuration depends on your specific flight controller. + +#### Skynode X (FMUv6x) + +Connect the PPS signal from your GNSS module to the flight controller using the 11-pin or 6-pin GPS connector: + +For detailed pinout information, refer to: + +- [Skynode GPS Peripherals - Pinouts](https://docs.auterion.com/hardware-integration/skynode/peripherals/gps#pinouts) + +#### Skynode S (FMUv6S) + +For FMUv6S, you need to route the PPS signal separately: + +1. Connect your GNSS module using the standard 6-pin GPS connector: [Skynode S GPS Interface](https://docs.auterion.com/hardware-integration/skynode-s/interfaces#gps) +2. Connect the PPS signal from your GNSS module to the **PPM_IN** pin: [Skynode S Extras 1 Interface](https://docs.auterion.com/hardware-integration/skynode-s/interfaces#extras-1) + +#### ARK Jetson Carrier Board (FMUv6x) + +For ARK FMUv6X on the Jetson carrier board: + +1. Connect your GNSS module using either the 10-pin or 6-pin GPS connector: [ARK PAB GPS1 Interface](../flight_controller/ark_pab#gps1) +2. Connect the PPS signal to the **FMU_CAP** pin: [ARK PAB ADIO Interface](../flight_controller/ark_pab.md#adio) + +## Перевірка + +After configuring PPS, you can verify that it is working correctly: + +1. Connect to the [PX4 System Console](../debug/system_console.md) (via MAVLink shell or serial console). + +2. Wait for GNSS fix. + +3. Check the PPS capture status to confirm it is up and running: + + ```sh + pps_capture status + ``` + +4. You can also check the [PpsCapture](../msg_docs/PpsCapture.md) uORB topic + + ```sh + listener pps_capture + ``` + + Where you should see: `timestamp`, `rtc_timestamp`, and `pps_rate_exceeded_counter`. + +### PPS Capture Driver + +The PPS capture driver is located in `src/drivers/pps_capture` and uses hardware timer input capture to precisely measure the arrival time of each PPS pulse. + +Основні функції: + +- Sub-microsecond pulse capture precision (hardware-dependent) +- Automatic drift calculation and compensation +- Integration with the GNSS driver for refined time stamping + +See also: + +- [PPS Capture Driver Documentation](../modules/modules_driver.md#pps-capture) +- [PpsCapture Message](../msg_docs/PpsCapture.md) + +### Time Synchronization Flow + +1. GNSS module sends position/time data at ~1-20 Hz. +2. GNSS module outputs PPS pulse at 1 Hz, precisely aligned to UTC second boundary. +3. PPS capture driver measures the exact time of the PPS pulse arrival using hardware timer. +4. Driver calculates the offset between GNSS time (from UART data) and autopilot clock (from PPS measurement). +5. This offset is used to correct GNSS timestamps and improve sensor fusion accuracy. + +The PPS signal provides much higher temporal precision than the transmitted time data, which has latency and jitter from serial communication. + +:::warning +If the PPS driver does not sending any data for 5 seconds (despite having `PPS_CAP_ENABLE` set to 1), the `EKF2_GPS_DELAY` will be used instead for estimating the latency. +::: diff --git a/docs/uk/advanced_config/bootloader_update_from_betaflight.md b/docs/uk/advanced_config/bootloader_update_from_betaflight.md index 803e8511bc..236e06f4eb 100644 --- a/docs/uk/advanced_config/bootloader_update_from_betaflight.md +++ b/docs/uk/advanced_config/bootloader_update_from_betaflight.md @@ -89,7 +89,7 @@ dfu-util -a 0 --dfuse-address 0x08000000 -D build//.bin Список контролерів, яких це стосується, можна отримати, виконавши наступну команду `make` і зазначивши цілі `make`, які закінчуються на `_bootloader` ``` -$make list_config_targets +$ make list_config_targets ... cuav_nora_bootloader diff --git a/docs/uk/flight_controller/autopilot_manufacturer_supported.md b/docs/uk/flight_controller/autopilot_manufacturer_supported.md index 7945545734..30cd5d538f 100644 --- a/docs/uk/flight_controller/autopilot_manufacturer_supported.md +++ b/docs/uk/flight_controller/autopilot_manufacturer_supported.md @@ -30,6 +30,7 @@ This category includes boards that are not fully compliant with the pixhawk stan - [Holybro Kakute H7](../flight_controller/kakuteh7.md) - [Holybro Durandal](../flight_controller/durandal.md) - [Holybro Pix32 v5](../flight_controller/holybro_pix32_v5.md) +- [MicoAir H743 Lite](../flight_controller/micoair743-lite.md) - [ModalAI VOXL 2](../flight_controller/modalai_voxl_2.md) - [mRo Control Zero](../flight_controller/mro_control_zero_f7.md) - [Radiolink PIX6](../flight_controller/radiolink_pix6.md) diff --git a/docs/uk/flight_controller/micoair743-lite.md b/docs/uk/flight_controller/micoair743-lite.md new file mode 100644 index 0000000000..3d0f443d5f --- /dev/null +++ b/docs/uk/flight_controller/micoair743-lite.md @@ -0,0 +1,153 @@ +# MicoAir743-Lite + + + +:::warning +PX4 не розробляє цей (або будь-який інший) автопілот. +Contact the [manufacturer](https://micoair.com/) for hardware support or compliance issues. +::: + +MicoAir743-Lite is an ultra-high performance H743 flight controller with an unbeatable price, featuring the ICM45686 IMU sensor and integrated Bluetooth telemetry. + +![MicoAir743-Lite Front View](../../assets/flight_controller/micoair743_lite/front_view.png) + +Equipped with a high-performance H7 processor, the MicoAir743-Lite features a compact form factor with SH1.0 connectors (which are more suitable than Pixhawk-standard GH1.25 for this board size). +When paired with with Bluetooth telemetry, the board can be debugged with a phone or PC. + +:::info +This flight controller is [manufacturer supported](../flight_controller/autopilot_manufacturer_supported.md). +::: + +## MicoAir743-Lite (v1.1) + +![MicoAir743-Lite Back View](../../assets/flight_controller/micoair743_lite/back_view.png) + +## Короткий опис + +### Processors & Sensors + +- FMU Processor: STM32H743 + - 32 Bit Arm® Cortex®-M7, 480MHz, 2MB flash memory, 1MB RAM +- Сенсори на платі + - Accel/Gyro: ICM-45686 (with BalancedGyro™ Technology) + - Barometer: SPA06 +- On-board Bluetooth Telemetry + - Connected to UART8 internally, baudrate 115200 + - Connecting to QGC (PC or Android phone) via Bluetooth +- Інші характеристики: + - Operating & storage temperature: -20 ~ 85°c + +### Інтерфейси + +- 8 UART (TELEM / GPS / RC) +- 14 PWM outputs (10 supports DShot) +- Support multiple RC inputs (SBUS / CRSF / DSM) +- 1 GPS port +- 1 I2C порт +- 2 ADC port2 (VBAT, Current) +- 1 DJI O3/O4 VTX connector +- 1 MicroSD Card Slot +- 1 USB Type-C + +### Електричні дані + +- VBAT Input: + - 2\~6S (6\~27V) +- USB Power Input: + - 4.75\~5.25V +- BEC Output: + - 5V 2A (for controller, receiver, GPS, optical flow or other devices) + - 9V 2A (for video transmitter, camera) + +### Механічні характеристики + +- Mounting: 30.5 x 30.5mm, Φ4mm +- Dimensions: 36 x 36 x 8 mm +- Weight: 10g + +![MicoAir743-Lite Size](../../assets/flight_controller/micoair743_lite/size.png) + +## Де купити + +Order from [MicoAir Tech Store](https://store.micoair.com/product/micoair743-lite/). + +## Схема розташування виводів + +Pinouts definition can be found in the [MicoAir743-Lite_pinout.xlsx](https://raw.githubusercontent.com/PX4/PX4-Autopilot/refs/heads/main/docs/assets/flight_controller/micoair743_lite/micoair743_lite_pinout.xlsx) file. + +## Налаштування послідовного порту + +| UART | Пристрій | Порт | +| ------ | ---------- | ------ | +| USART1 | /dev/ttyS0 | TELEM1 | +| USART2 | /dev/ttyS1 | GPS2 | +| USART3 | /dev/ttyS2 | GPS1 | +| UART4 | /dev/ttyS3 | TELEM2 | +| UART5 | /dev/ttyS4 | TELEM3 | +| USART6 | /dev/ttyS5 | RC | +| UART7 | /dev/ttyS6 | URT6 | +| UART8 | /dev/ttyS7 | TELEM4 | + +## Interfaces Diagram + +:::note +All the connectors used on the board are SH1.0 +::: + +![MicoAir743-Lite Interface Diagram](../../assets/flight_controller/micoair743_lite/interfaces_diagram.png) + +## Зразок схеми з'єднань + +![MicoAir743-Lite Wiring Diagram](../../assets/flight_controller/micoair743_lite/wiring_diagram.png) + +## Збірка прошивки + +To [build PX4](../dev_setup/building_px4.md) for this target: + +```sh +make micoair_h743-lite_default +``` + +## Встановлення прошивки PX4 + +Прошивку можна встановити будь-якими звичайними способами: + +- Збудуйте та завантажте джерело + + ```sh + make micoair_h743-lite_default upload + ``` + +- [Load the firmware](../config/firmware.md) using _QGroundControl_. + Ви можете використовувати або готове вбудоване програмне забезпечення, або власне користувацьке програмне забезпечення. + + ::: info + At time of writing the only pre-built software is `PX4 main` (see [Installing PX4 Main, Beta or Custom Firmware](../config/firmware.md#installing-px4-main-beta-or-custom-firmware)). + Release builds will be supported for PX4 v1.17 and later. + +::: + +## Радіоуправління + +A [Radio Control (RC) system](../getting_started/rc_transmitter_receiver.md) is required if you want to manually control your vehicle (PX4 does not require a radio system for autonomous flight modes). + +The RC port is connected to the FMU and you can attach a receiver that uses the protocols `DSM`, `SBUS`, `CSRF`, `GHST`, or other protocol listed in [Radio Control modules](../modules/modules_driver_radio_control.md). +You will need to enable the protocol by setting the corresponding parameter `RC_xxxx_PRT_CFG`, such as [RC_CRSF_PRT_CFG](../advanced_config/parameter_reference.md#RC_CRSF_PRT_CFG) for a [CRSF receiver](../telemetry/crsf_telemetry.md). + +## Підтримувані платформи / Конструкції + +Будь-який мультикоптер / літак / наземна платформа / човен, який може керуватися звичайними RC сервоприводами або сервоприводами Futaba S-Bus. +The complete set of supported configurations can be seen in the [Airframes Reference](../airframes/airframe_reference.md). + +## Периферійні пристрої + +- [MicoAir Telemetry Radio Modules](https://micoair.com/radio_telemetry/) +- [MicoAir Optical & Range Sensor](https://micoair.com/optical_range_sensor/) +- [MicoAir GPS](https://micoair.com/gps/) +- [MicoAir ESC Modules](https://micoair.com/esc/) + +## Подальша інформація + +- [MicoAir Tech.](https://micoair.com/) +- [Details about MicoAir743-Lite](https://micoair.com/flightcontroller_micoair743lite/) +- [QGroundControl Download and Install](https://docs.qgroundcontrol.com/Stable_V5.0/en/qgc-user-guide/getting_started/download_and_install.html) diff --git a/docs/uk/flight_controller/pixhawk_series.md b/docs/uk/flight_controller/pixhawk_series.md index 0753bcb5f8..81cece0209 100644 --- a/docs/uk/flight_controller/pixhawk_series.md +++ b/docs/uk/flight_controller/pixhawk_series.md @@ -100,6 +100,24 @@ PX4 _developers_ need to know the FMU version of their board, as this is require +### FMUv6 Comparison + +| Характеристика | **FMUv6X-RT** | **FMUv6X** | **FMUv6C** | +| ------------------ | ------------------------------- | ------------- | ------------- | +| **FMU MCU** | NXP i.MX RT1176 | STM32H753 | STM32H743V | +| **RAM** | 2 MB | 1 MB | 1 MB | +| **Flash** | 64 MB Octal SPI | 2 MB internal | 2 MB internal | +| **IO MCU** | STM32F103 | STM32F103 | STM32F103 | +| **Secure Element** | NXP SE051 | NXP SE051 | Not supported | +| **PAB Standard** | Supported | Supported | Not supported | +| **Ethernet** | Supported | Supported | Not supported | +| **IMUs** | 3× | 3× | 2× | +| **Barometers** | 2× | 2× | 1× | +| **Magnetometer** | 1× | 1× | 1× | +| **FMU PWM** | 12× | 8× | 8× | +| **IO PWM** | 8× | 8× | 8× | +| **CAN Bus** | 3× | 2× | 2× | + ### Ліцензування та товарні знаки Pixhawk project schematics and reference designs are licensed under [CC BY-SA 3](https://creativecommons.org/licenses/by-sa/3.0/legalcode). diff --git a/docs/uk/flight_modes_fw/return.md b/docs/uk/flight_modes_fw/return.md index 6a7e62d0af..3296524af6 100644 --- a/docs/uk/flight_modes_fw/return.md +++ b/docs/uk/flight_modes_fw/return.md @@ -25,11 +25,6 @@ ::: -:::warning -There is a known issue ([PX4-Autopilot#25436](https://github.com/PX4/PX4-Autopilot/issues/25436)) with fixed-wing approaches and landings while in RTL mode. -Please review the issue and verify in simulation that the behavior you get is safe in an RTL landing scenario (if not, consider using rally points). -::: - ## Технічний підсумок Літальні апарати з фіксованим крилом за замовчуванням використовують тип повернення до призначення _місії посадки/точка збору_. diff --git a/docs/uk/gps_compass/index.md b/docs/uk/gps_compass/index.md index 96ab9ae8a4..4a85a0f233 100644 --- a/docs/uk/gps_compass/index.md +++ b/docs/uk/gps_compass/index.md @@ -197,11 +197,21 @@ It is possible to have low DOP (good satellite geometry) but still have high EPH EPH/EPV values therefore provide a more immediate and practical estimate of the actual GPS accuracy you can expect under current conditions. +### GNSS Position Fusion + +GNSS position fusion will not begin until yaw alignment is established. +If a magnetometer is available, the EKF aligns yaw using the magnetic heading, allowing GPS position fusion to start soon after boot. +If no magnetometer is present, the system must rely on GPS yaw (from a dual-antenna setup) or movement-based yaw estimation. +Until one of these provides a valid heading, the EKF will not start GPS position fusion, and the vehicle will remain in a “no position” state even though attitude data is valid. +This behavior prevents large position errors that could occur when the yaw reference is uncertain. + ## Інформація для розробників - GPS/RTK-GPS - [RTK-GPS](../advanced/rtk_gps.md) + - [PPS Time Synchronization](../advanced/pps_time_sync.md) - [GPS driver](../modules/modules_driver.md#gps) + - [PPS driver](../modules/modules_driver.md#pps-capture) - [DroneCAN Example](../dronecan/index.md) - Компас - [Driver source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/magnetometer) (Compasses) diff --git a/docs/uk/gps_compass/magnetometer.md b/docs/uk/gps_compass/magnetometer.md index f7f12e2026..42d0d72b4e 100644 --- a/docs/uk/gps_compass/magnetometer.md +++ b/docs/uk/gps_compass/magnetometer.md @@ -40,6 +40,7 @@ PX4 можна використовувати з багатьма деталям | Пристрій | Компас | DroneCan | | :-------------------------------------------------------------------------------------------------------------- | :----: | :------: | +| [ARK MAG](https://arkelectron.com/product/ark-mag/) | RM3100 | ✓ | | [Магнітометр UAVCAN Avionics Anonymous](https://www.tindie.com/products/avionicsanonymous/uavcan-magnetometer/) | ? | | | [Компас/Магнітометр Holybro DroneCAN RM3100](https://holybro.com/products/dronecan-rm3100-compass) | RM3100 | ✓ | | [RaccoonLab DroneCAN/Cyphal Magnetometer RM3100](https://holybro.com/products/dronecan-rm3100-compass) | RM3100 | ✓ | diff --git a/docs/uk/middleware/uxrce_dds.md b/docs/uk/middleware/uxrce_dds.md index 8d21539d78..2f7f16aeba 100644 --- a/docs/uk/middleware/uxrce_dds.md +++ b/docs/uk/middleware/uxrce_dds.md @@ -454,6 +454,7 @@ uxrce_dds_client start -n fancy_uav ``` This can be included in `etc/extras.txt` as part of a custom [System Startup](../concept/system_startup.md). +::: ## PX4 ROS 2 QoS Settings @@ -515,6 +516,11 @@ publications: - topic: /fmu/out/vehicle_trajectory_waypoint_desired type: px4_msgs::msg::VehicleTrajectoryWaypoint + - topic: /fmu/out/vehicle_imu + type: px4_msgs::msg::VehicleImu + rate_limit: 50. + instance: 1 # OPTIONAL + subscriptions: - topic: /fmu/in/offboard_control_mode @@ -547,6 +553,9 @@ Each (`topic`,`type`) pairs defines: 4. The message type (`VehicleOdometry`, `VehicleStatus`, `OffboardControlMode`, etc.) and the ROS 2 package (`px4_msgs`) that is expected to provide the message definition. 5. **(Optional)**: An additional `rate_limit` field (only for publication entries), which specifies the maximum rate (Hz) at which messages will be published on this topic by PX4 to ROS 2. If left unspecified, the maximum publication rate limit is set to 100 Hz. +6. **(Optional)**: An additional `instance` field (only for publication entries), which lets you select which instance of a [multi-instance topic](./uorb.md#multi-instance) you want to be published to ROS 2. + If provided, this option changes the ROS 2 topic name of the advertised uORB topic appending the instance number: `fmu/out/[uorb topic name][instance]` (plus eventual namespace and message version). + In the example above the final topic name would be `/fmu/out/vehicle_imu1`. `subscriptions` and `subscriptions_multi` allow us to choose the uORB topic instance that ROS 2 topics are routed to: either a shared instance that may also be getting updates from internal PX4 uORB publishers, or a separate instance that is reserved for ROS2 publications, respectively. Without this mechanism all ROS 2 messages would be routed to the _same_ uORB topic instance (because ROS 2 does not have the concept of [multiple topic instances](../middleware/uorb.md#multi-instance)), and it would not be possible for PX4 subscribers to differentiate between streams from ROS 2 or PX4 publishers. @@ -588,7 +597,7 @@ For a list of services, details and examples see the [service documentation](../ These guidelines explain how to migrate from using PX4 v1.13 [Fast-RTPS](../middleware/micrortps.md) middleware to PX4 v1.14 `uXRCE-DDS` middleware. These are useful if you have [ROS 2 applications written for PX4 v1.13](https://docs.px4.io/v1.13/en/ros/ros2_comm.html), or you have used Fast-RTPS to interface your applications to PX4 [directly](https://docs.px4.io/v1.13/en/middleware/micrortps.html#agent-in-an-offboard-fast-dds-interface-ros-independent). -::: info +:::info This section contains migration-specific information. You should also read the rest of this page to properly understand uXRCE-DDS. ::: diff --git a/docs/uk/modules/hello_sky.md b/docs/uk/modules/hello_sky.md index 80a2ad2685..90dfe6b40e 100644 --- a/docs/uk/modules/hello_sky.md +++ b/docs/uk/modules/hello_sky.md @@ -440,6 +440,7 @@ The [complete example code](https://github.com/PX4/PX4-Autopilot/blob/main/src/e */ #include +#include #include #include #include diff --git a/docs/uk/msg_docs/DifferentialPressure.md b/docs/uk/msg_docs/DifferentialPressure.md index 33e950a107..66963b01f5 100644 --- a/docs/uk/msg_docs/DifferentialPressure.md +++ b/docs/uk/msg_docs/DifferentialPressure.md @@ -1,17 +1,24 @@ # DifferentialPressure (повідомлення UORB) +Differential-pressure (airspeed) sensor + +This is populated by airspeed sensor drivers and used by the sensor module to calculate airspeed. +The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `SensorBaro` instance). + [source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/DifferentialPressure.msg) ```c -uint64 timestamp # time since system start (microseconds) -uint64 timestamp_sample +# Differential-pressure (airspeed) sensor +# +# This is populated by airspeed sensor drivers and used by the sensor module to calculate airspeed. +# The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `SensorBaro` instance). -uint32 device_id # unique device ID for the sensor that does not change between power cycles +uint64 timestamp # [us] Time of publication (since system start) +uint64 timestamp_sample # [us] Time of raw data capture -float32 differential_pressure_pa # differential pressure reading in Pascals (may be negative) - -float32 temperature # Temperature provided by sensor in degrees Celsius, NAN if unknown - -uint32 error_count # Number of errors detected by driver +uint32 device_id # [-] Unique device ID for the sensor that does not change between power cycles +float32 differential_pressure_pa # [Pa] Differential pressure reading (may be negative) +float32 temperature # [degC] [@invalid NaN if unknown] Temperature +uint32 error_count # [-] Number of errors detected by driver ``` diff --git a/docs/uk/msg_docs/SensorBaro.md b/docs/uk/msg_docs/SensorBaro.md index cf834ccf36..ef4d7a8f28 100644 --- a/docs/uk/msg_docs/SensorBaro.md +++ b/docs/uk/msg_docs/SensorBaro.md @@ -1,18 +1,25 @@ # SensorBaro (UORB message) +Barometer sensor + +This is populated by barometer drivers and used by the EKF2 estimator. +The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `DifferentialPressure` instance). + [source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/SensorBaro.msg) ```c -uint64 timestamp # time since system start (microseconds) -uint64 timestamp_sample +# Barometer sensor +# +# This is populated by barometer drivers and used by the EKF2 estimator. +# The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `DifferentialPressure` instance). -uint32 device_id # unique device ID for the sensor that does not change between power cycles +uint64 timestamp # [us] Time of publication (since system start) +uint64 timestamp_sample # [us] Time of raw data capture -float32 pressure # static pressure measurement in Pascals - -float32 temperature # temperature in degrees Celsius - -uint32 error_count +uint32 device_id # [-] Unique device ID for the sensor that does not change between power cycles +float32 pressure # [Pa] Static pressure measurement +float32 temperature # [degC] Temperature. +uint32 error_count # [-] Number of errors detected by driver. uint8 ORB_QUEUE_LENGTH = 4 diff --git a/docs/uk/msg_docs/VehicleStatus.md b/docs/uk/msg_docs/VehicleStatus.md index f598e1e5b2..63192fceb7 100644 --- a/docs/uk/msg_docs/VehicleStatus.md +++ b/docs/uk/msg_docs/VehicleStatus.md @@ -20,20 +20,16 @@ uint8 ARMING_STATE_ARMED = 2 uint8 latest_arming_reason uint8 latest_disarming_reason -uint8 ARM_DISARM_REASON_TRANSITION_TO_STANDBY = 0 uint8 ARM_DISARM_REASON_STICK_GESTURE = 1 uint8 ARM_DISARM_REASON_RC_SWITCH = 2 uint8 ARM_DISARM_REASON_COMMAND_INTERNAL = 3 uint8 ARM_DISARM_REASON_COMMAND_EXTERNAL = 4 uint8 ARM_DISARM_REASON_MISSION_START = 5 -uint8 ARM_DISARM_REASON_SAFETY_BUTTON = 6 -uint8 ARM_DISARM_REASON_AUTO_DISARM_LAND = 7 -uint8 ARM_DISARM_REASON_AUTO_DISARM_PREFLIGHT = 8 -uint8 ARM_DISARM_REASON_KILL_SWITCH = 9 -uint8 ARM_DISARM_REASON_LOCKDOWN = 10 -uint8 ARM_DISARM_REASON_FAILURE_DETECTOR = 11 -uint8 ARM_DISARM_REASON_SHUTDOWN = 12 -uint8 ARM_DISARM_REASON_UNIT_TEST = 13 +uint8 ARM_DISARM_REASON_LANDING = 6 +uint8 ARM_DISARM_REASON_PREFLIGHT_INACTION = 7 +uint8 ARM_DISARM_REASON_KILL_SWITCH = 8 +uint8 ARM_DISARM_REASON_RC_BUTTON = 13 +uint8 ARM_DISARM_REASON_FAILSAFE = 14 uint64 nav_state_timestamp # time when current nav_state activated diff --git a/docs/uk/msg_docs/index.md b/docs/uk/msg_docs/index.md index d383ce1452..a8fff51a29 100644 --- a/docs/uk/msg_docs/index.md +++ b/docs/uk/msg_docs/index.md @@ -105,7 +105,7 @@ Graphs showing how these are used [can be found here](../middleware/uorb_graph.m - [DebugKeyValue](DebugKeyValue.md) - [DebugValue](DebugValue.md) - [DebugVect](DebugVect.md) -- [DifferentialPressure](DifferentialPressure.md) +- [DifferentialPressure](DifferentialPressure.md) — Differential-pressure (airspeed) sensor - [DistanceSensor](DistanceSensor.md) — DISTANCE_SENSOR message data - [DistanceSensorModeChangeRequest](DistanceSensorModeChangeRequest.md) - [DronecanNodeStatus](DronecanNodeStatus.md) @@ -240,7 +240,7 @@ Graphs showing how these are used [can be found here](../middleware/uorb_graph.m - [SensorAccel](SensorAccel.md) - [SensorAccelFifo](SensorAccelFifo.md) - [SensorAirflow](SensorAirflow.md) -- [SensorBaro](SensorBaro.md) +- [SensorBaro](SensorBaro.md) — Barometer sensor - [SensorCombined](SensorCombined.md) — Sensor readings in SI-unit form. These fields are scaled and offset-compensated where possible and do not change with board revisions and sensor updates. diff --git a/docs/zh/SUMMARY.md b/docs/zh/SUMMARY.md index 570c6aa5db..deab8841c3 100644 --- a/docs/zh/SUMMARY.md +++ b/docs/zh/SUMMARY.md @@ -182,6 +182,7 @@ - [Wiring Quickstart](assembly/quick_start_durandal.md) - [Holybro Pix32 v5](flight_controller/holybro_pix32_v5.md) - [Wiring Quickstart](assembly/quick_start_holybro_pix32_v5.md) + - [MicoAir H743 Lite](flight_controller/micoair743-lite.md) - [ModalAI VOXL 2](flight_controller/modalai_voxl_2.md) - [mRo Control Zero F7](flight_controller/mro_control_zero_f7.md) - [Radiolink PIX6](flight_controller/radiolink_pix6.md) @@ -504,6 +505,7 @@ - [UART/串口](uart/index.md) - [可配置的串口驱动](uart/user_configurable_serial_driver.md) - [RTK GPS (集成)](advanced/rtk_gps.md) + - [PPS Time Synchronization](advanced/pps_time_sync.md) - [中间件](middleware/index.md) - [uORB 通讯](middleware/uorb.md) - [uORB 图](middleware/uorb_graph.md) diff --git a/docs/zh/actuators/index.md b/docs/zh/actuators/index.md index 71f11b5a05..60b3dac4d0 100644 --- a/docs/zh/actuators/index.md +++ b/docs/zh/actuators/index.md @@ -8,6 +8,6 @@ - [电调校准](../advanced_config/esc_calibration.md) — PWM 电调的校准 (DShot/CAN 电调/舵机不需要) 。 -## See Also +## 另见 - [外设](../peripherals/index.md) - 包括非核心执行器,如夹具, 降落伞等。 diff --git a/docs/zh/advanced/pps_time_sync.md b/docs/zh/advanced/pps_time_sync.md new file mode 100644 index 0000000000..6679279b60 --- /dev/null +++ b/docs/zh/advanced/pps_time_sync.md @@ -0,0 +1,135 @@ +# PPS Time Synchronization (PX4 Integration) + +[Pulse Per Second](https://en.wikipedia.org/wiki/Pulse-per-second_signal) (PPS) time synchronization provides high-precision timing for GNSS receivers. +This page explains how PPS is integrated into PX4 and how to configure it. + +## 综述 + +PPS (Pulse Per Second) is a timing signal provided by GNSS receivers that outputs an electrical pulse once per second, synchronized to UTC time. +The PPS signal provides a highly accurate timing reference that PX4 can use to: + +- Refine GNSS time measurements and compensate for clock drift +- Provide precise UTC timestamps for camera capture events (for photogrammetry and mapping applications) +- Enable offline position refinement through accurate time correlation + +## 支持的硬件 + +PPS time synchronization can be supported on flight controllers that have a hardware timer input pin that can be configured for PPS capture, by [enabling the PPS capture driver](#enable-pps-driver-in-board-configuration) in the board configuration. + +Supported boards include (at time of writing): + +- [Ark FMUv6x](../flight_controller/ark_v6x.md) +- Auterion FMUv6x +- Auterion FMUv6s + +## 设置 + +### Enable PPS Driver in Board Configuration + +The [PPS capture driver](../modules/modules_driver.md#pps-capture) must be enabled in the board configuration. +This is done by adding the following to your board's configuration: + +```ini +CONFIG_DRIVERS_PPS_CAPTURE=y +``` + +### Configure PPS Parameters + +The configuration varies depending on your flight controller hardware. + +#### FMUv6X + +For FMUv6X-based flight controllers, configure PWM AUX Timer 3 and Function 9: + +```sh +param set PWM_AUX_TIM3 -2 +param set PWM_AUX_FUNC9 2064 +param set PPS_CAP_ENABLE 1 +``` + +#### FMUv6S + +For FMUv6S-based flight controllers, configure PWM MAIN Timer 3 and Function 10: + +```sh +param set PWM_MAIN_TIM3 -2 +param set PWM_MAIN_FUNC10 2064 +param set PPS_CAP_ENABLE 1 +``` + +### 布线 + +The wiring configuration depends on your specific flight controller. + +#### Skynode X (FMUv6x) + +Connect the PPS signal from your GNSS module to the flight controller using the 11-pin or 6-pin GPS connector: + +For detailed pinout information, refer to: + +- [Skynode GPS Peripherals - Pinouts](https://docs.auterion.com/hardware-integration/skynode/peripherals/gps#pinouts) + +#### Skynode S (FMUv6S) + +For FMUv6S, you need to route the PPS signal separately: + +1. Connect your GNSS module using the standard 6-pin GPS connector: [Skynode S GPS Interface](https://docs.auterion.com/hardware-integration/skynode-s/interfaces#gps) +2. Connect the PPS signal from your GNSS module to the **PPM_IN** pin: [Skynode S Extras 1 Interface](https://docs.auterion.com/hardware-integration/skynode-s/interfaces#extras-1) + +#### ARK Jetson Carrier Board (FMUv6x) + +For ARK FMUv6X on the Jetson carrier board: + +1. Connect your GNSS module using either the 10-pin or 6-pin GPS connector: [ARK PAB GPS1 Interface](../flight_controller/ark_pab#gps1) +2. Connect the PPS signal to the **FMU_CAP** pin: [ARK PAB ADIO Interface](../flight_controller/ark_pab.md#adio) + +## 验证 + +After configuring PPS, you can verify that it is working correctly: + +1. Connect to the [PX4 System Console](../debug/system_console.md) (via MAVLink shell or serial console). + +2. Wait for GNSS fix. + +3. Check the PPS capture status to confirm it is up and running: + + ```sh + pps_capture status + ``` + +4. You can also check the [PpsCapture](../msg_docs/PpsCapture.md) uORB topic + + ```sh + listener pps_capture + ``` + + Where you should see: `timestamp`, `rtc_timestamp`, and `pps_rate_exceeded_counter`. + +### PPS Capture Driver + +The PPS capture driver is located in `src/drivers/pps_capture` and uses hardware timer input capture to precisely measure the arrival time of each PPS pulse. + +主要特性: + +- Sub-microsecond pulse capture precision (hardware-dependent) +- Automatic drift calculation and compensation +- Integration with the GNSS driver for refined time stamping + +See also: + +- [PPS Capture Driver Documentation](../modules/modules_driver.md#pps-capture) +- [PpsCapture Message](../msg_docs/PpsCapture.md) + +### Time Synchronization Flow + +1. GNSS module sends position/time data at ~1-20 Hz. +2. GNSS module outputs PPS pulse at 1 Hz, precisely aligned to UTC second boundary. +3. PPS capture driver measures the exact time of the PPS pulse arrival using hardware timer. +4. Driver calculates the offset between GNSS time (from UART data) and autopilot clock (from PPS measurement). +5. This offset is used to correct GNSS timestamps and improve sensor fusion accuracy. + +The PPS signal provides much higher temporal precision than the transmitted time data, which has latency and jitter from serial communication. + +:::warning +If the PPS driver does not sending any data for 5 seconds (despite having `PPS_CAP_ENABLE` set to 1), the `EKF2_GPS_DELAY` will be used instead for estimating the latency. +::: diff --git a/docs/zh/advanced_config/bootloader_update_from_betaflight.md b/docs/zh/advanced_config/bootloader_update_from_betaflight.md index 3094cc3830..4d37bdbfe0 100644 --- a/docs/zh/advanced_config/bootloader_update_from_betaflight.md +++ b/docs/zh/advanced_config/bootloader_update_from_betaflight.md @@ -89,7 +89,7 @@ Flight controllers that have bootloader PX4-Autopilot `make` targets, can build The list of controllers for which this applies can be obtained by running the following `make` command, and noting the `make` targets that end in `_bootloader` ``` -$make list_config_targets +$ make list_config_targets ... cuav_nora_bootloader diff --git a/docs/zh/advanced_config/ethernet_setup.md b/docs/zh/advanced_config/ethernet_setup.md index ac1fca8e67..b41967a31e 100644 --- a/docs/zh/advanced_config/ethernet_setup.md +++ b/docs/zh/advanced_config/ethernet_setup.md @@ -268,7 +268,7 @@ MAVSDK can connect to the PX4 on port `14550` if you don't modify the PX4 Ethern accelerometer_integral_dt: 4997 ``` -## See Also +## 另见 - [Get The Pixhawk Raspberry Pi CM4 Baseboard By Holybro Talking With PX4](https://px4.io/get-the-pixhawk-raspberry-pi-cm4-baseboard-by-holybro-talking-with-px4/) (px4.io blog): - 展示如何通过有线以太网连接 Pixhawk 6X + Raspberry Pi 到 CM4 主板。 diff --git a/docs/zh/advanced_config/index.md b/docs/zh/advanced_config/index.md index b41f62561a..bab4c3f593 100644 --- a/docs/zh/advanced_config/index.md +++ b/docs/zh/advanced_config/index.md @@ -33,7 +33,7 @@ - [Bootloader 更新](../advanced_config/bootloader_update.md) - [通过 USB 更新 FMUv6X-RT bootloader](../advanced_config/bootloader_update_v6xrt.md) -## See Also +## 另见 - [标准配置](../config/index.md) - 大多数 PX4 机体所需要的基本传感器/功能配置。 - [飞控外设](../peripherals/index.md) - 设置特定传感器、可选传感器、执行器等。 diff --git a/docs/zh/assembly/_assembly.md b/docs/zh/assembly/_assembly.md index 19062417ac..42804d30f4 100644 --- a/docs/zh/assembly/_assembly.md +++ b/docs/zh/assembly/_assembly.md @@ -421,7 +421,7 @@ They recommend sensors, power systems, and other components from the same manufa - [Pixracer Wiring Quickstart](../assembly/quick_start_pixracer.md) - [mRo (3DR) Pixhawk Wiring Quickstart](../assembly/quick_start_pixhawk.md) -## See Also +## 另见 - [Drone Components & Parts](../getting_started/px4_basic_concepts.md#drone-components-parts) (Basic Concepts) - [Payloads](../getting_started/px4_basic_concepts.md#payloads) (Basic Concepts) diff --git a/docs/zh/camera/camera_architecture.md b/docs/zh/camera/camera_architecture.md index fd81c41352..89b9ea5a54 100644 --- a/docs/zh/camera/camera_architecture.md +++ b/docs/zh/camera/camera_architecture.md @@ -107,7 +107,7 @@ The logged topic will depend on whether or not the camera capture pin is enabled Note that camera capture events are not logged when using the [MAVLink cameras that support Camera Protocol v2](../camera/mavlink_v2_camera.md), because the corresponding trigger events are not generated within PX4. -## See Also +## 另见 - Camera trigger driver: [source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_trigger) - Camera capture driver: [source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_capture) diff --git a/docs/zh/camera/fc_connected_camera.md b/docs/zh/camera/fc_connected_camera.md index ea9e1e0164..fdae04a272 100644 --- a/docs/zh/camera/fc_connected_camera.md +++ b/docs/zh/camera/fc_connected_camera.md @@ -310,7 +310,7 @@ Wire up your cameras to your AUX port by connecting the ground and signal pins t You will have to modify your driver to follow the sequence diagram above. Public reference implementations for [IDS Imaging UEye](https://github.com/ProjectArtemis/ueye_cam) cameras and for [IEEE1394 compliant](https://github.com/andre-nguyen/camera1394) cameras are available. -## See Also +## 另见 - Camera trigger driver: [source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_trigger) - Camera capture driver: [source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_capture) diff --git a/docs/zh/camera/index.md b/docs/zh/camera/index.md index 015d7fc9a5..6367fb82c0 100644 --- a/docs/zh/camera/index.md +++ b/docs/zh/camera/index.md @@ -14,7 +14,7 @@ PX4 integrates with three types of cameras: 推荐[MAVLink 摄像头](../camera/mavlink_v2_camera.md),因为它们使用简单一致的命令/消息集提供了最广泛的相机功能访问。 如果相机不支持该协议,则可以在一台机载计算机上运行[摄像机管理器](../camera/mavlink_v2_camera.md#camera-managers)以在 MAVLink 和相机的本机协议之间进行接口交互。 -## See Also +## 另见 - [云台(相机支架)](../advanced/gimbal_control.md) - [相机集成/架构](../camera/camera_architecture.md) ( PX4 开发者) diff --git a/docs/zh/companion_computer/ark_jetson_pab_carrier.md b/docs/zh/companion_computer/ark_jetson_pab_carrier.md index c34e2a96e4..bbfa91cc1e 100644 --- a/docs/zh/companion_computer/ark_jetson_pab_carrier.md +++ b/docs/zh/companion_computer/ark_jetson_pab_carrier.md @@ -89,6 +89,6 @@ To flash the kernel, connect the Jetson to your Host PC via Micro USB, and boot ![Jetson Carrier Flashing Guide](../../assets/companion_computer/ark_jetson_pab_carrier/ark_jetson_flashing_guide.png) -## See Also +## 另见 - [ARK Jetson PAB Documentation](https://arkelectron.gitbook.io/ark-documentation/flight-controllers/ark-jetson-pab-carrier) (ARK Docs) diff --git a/docs/zh/companion_computer/holybro_pixhawk_jetson_baseboard.md b/docs/zh/companion_computer/holybro_pixhawk_jetson_baseboard.md index 93dd15e4e2..e49a32a97a 100644 --- a/docs/zh/companion_computer/holybro_pixhawk_jetson_baseboard.md +++ b/docs/zh/companion_computer/holybro_pixhawk_jetson_baseboard.md @@ -1329,7 +1329,7 @@ You should see high frequency sensor messages as the output: [sensor_combined_listener-1] accelerometer_integral_dt: 4999 ``` -## See Also +## 另见 - [Jetson carrier board Holybro Docs](https://docs.holybro.com/autopilot/pixhawk-baseboards/pixhawk-jetson-baseboard) - [PX4 Middleware docs](../middleware/uxrce_dds.md#starting-the-client) diff --git a/docs/zh/companion_computer/holybro_pixhawk_rpi_cm4_baseboard.md b/docs/zh/companion_computer/holybro_pixhawk_rpi_cm4_baseboard.md index edece004af..91bceef69c 100644 --- a/docs/zh/companion_computer/holybro_pixhawk_rpi_cm4_baseboard.md +++ b/docs/zh/companion_computer/holybro_pixhawk_rpi_cm4_baseboard.md @@ -418,7 +418,7 @@ And such output is expected if everything is set up correctly: [1731210066.597046] info | ProxyClient.cpp | create_datareader | datareader created | client_key: 0x00000001, datareader_id: 0x804(6), subscriber_id: 0x804(4) ``` -## See Also +## 另见 - [Get The Pixhawk Raspberry Pi CM4 Baseboard By Holybro Talking With PX4](https://px4.io/get-the-pixhawk-raspberry-pi-cm4-baseboard-by-holybro-talking-with-px4/) (px4.io blog): - 展示如何通过有线以太网连接 Pixhawk 6X + Raspberry Pi 到 CM4 主板。 diff --git a/docs/zh/complete_vehicles_fw/index.md b/docs/zh/complete_vehicles_fw/index.md index 636dfd5ef6..23a08e6ada 100644 --- a/docs/zh/complete_vehicles_fw/index.md +++ b/docs/zh/complete_vehicles_fw/index.md @@ -35,7 +35,7 @@ This section lists vehicles that are sold fully assembled and ready to fly (RTF) This section lists vehicles where you can update the software to run PX4. --> -## See Also +## 另见 - [DIY Builds](../frames_plane/diy_builds.md) - [Complete Vehicles (VTOL)](../complete_vehicles_vtol/index.md) diff --git a/docs/zh/complete_vehicles_mc/index.md b/docs/zh/complete_vehicles_mc/index.md index b8a8f1d948..9080d8601f 100644 --- a/docs/zh/complete_vehicles_mc/index.md +++ b/docs/zh/complete_vehicles_mc/index.md @@ -40,7 +40,7 @@ These may or may not be updatable to run "vanilla" PX4. - [Yuneec H520](https://px4.io/project/yuneec-h520-hexacopter/) - [AeroSense Aerobo (AS-MC02-P)](https://px4.io/project/aerosense-aerobo/) -## See Also +## 另见 - [Kits (MC)](../frames_multicopter/kits.md) - [DIY Builds](../frames_multicopter/diy_builds.md) diff --git a/docs/zh/complete_vehicles_vtol/index.md b/docs/zh/complete_vehicles_vtol/index.md index 9f32760d55..d3dc22f104 100644 --- a/docs/zh/complete_vehicles_vtol/index.md +++ b/docs/zh/complete_vehicles_vtol/index.md @@ -30,7 +30,7 @@ These may or may not be updatable to run "vanilla" PX4. - [WingtraOne Tailsitter VTOL](https://px4.io/project/wingtraone-tailsitter-vtol/) - [Flightwave Edge](https://px4.io/project/flywave-edge/) -## See Also +## 另见 - [Complete Vehicles (Fixed-Wing)](../complete_vehicles_fw/index.md) - [Complete Vehicles (MC)](../complete_vehicles_mc/index.md) diff --git a/docs/zh/config/index.md b/docs/zh/config/index.md index 1f02d044e1..cfc1fb3515 100644 --- a/docs/zh/config/index.md +++ b/docs/zh/config/index.md @@ -72,7 +72,7 @@ The video below shows most of the calibration process (it uses an older version If you need help with the configuration you can ask for help on the [QGroundControl Support forum](https://discuss.px4.io/c/qgroundcontrol/qgroundcontrol-usage/18). -## See Also +## 另见 - [QGroundControl > Setup](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/setup_view/setup_view.html) - [飞控外设](../peripherals/index.md) - 设置特定传感器、可选传感器、执行器等。 diff --git a/docs/zh/config_mc/index.md b/docs/zh/config_mc/index.md index e74e71cec9..3cb84d34cf 100644 --- a/docs/zh/config_mc/index.md +++ b/docs/zh/config_mc/index.md @@ -161,7 +161,7 @@ My assumption is that the mixing system can cope with whatever geometry you thro Yes but it must be physically feasible. E.g. if you make a quadrotor where all motors turn the same way it will "deal" with it but that cannot work without very specific controllers. Same for a monocopter or a tricopter without swiveling one motor. --> -## See Also +## 另见 - [QGroundControl > Setup](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/setup_view/setup_view.html) - [飞控外设](../peripherals/index.md) - 设置特定传感器、可选传感器、执行器等。 diff --git a/docs/zh/data_links/index.md b/docs/zh/data_links/index.md index 8e2ee7e2df..03154f03ce 100644 --- a/docs/zh/data_links/index.md +++ b/docs/zh/data_links/index.md @@ -12,6 +12,6 @@ PX4 使用 [MAVLink](https://mavlink.io/en/) 协议在无线电频道上传送 - [TBS Crossfire (CRSF) Telemetry](../telemetry/crsf_telemetry.md) — TBS Crossfire 接收机上的遥测 - [Satellite Comms (Iridium/RockBlock)](../advanced_features/satcom_roadblock.md) — 高延迟卫星通信 -## See Also +## 另见 - [安全配置 > 数据连接丢失的失效保护](../config/safety.md#data-link-loss-failsafe) diff --git a/docs/zh/dev_log/logging.md b/docs/zh/dev_log/logging.md index 05ed21e709..36bb608f46 100644 --- a/docs/zh/dev_log/logging.md +++ b/docs/zh/dev_log/logging.md @@ -186,6 +186,6 @@ There are different clients that support ulog streaming: Also make sure `txerr` stays at 0. Also make sure txerr stays at 0. If this goes up, either the NuttX sending buffer is too small, the physical link is saturated or the hardware is too slow to handle the data. -## See Also +## 另见 - [Encrypted logging](../dev_log/log_encryption.md) diff --git a/docs/zh/dronecan/ark_cannode.md b/docs/zh/dronecan/ark_cannode.md index 994405ef9b..d7b0724f8e 100644 --- a/docs/zh/dronecan/ark_cannode.md +++ b/docs/zh/dronecan/ark_cannode.md @@ -99,6 +99,6 @@ If you see a solid red LED there is an error and you should check the following: - Make sure the ARK CANnode has `ark_cannode_canbootloader` installed prior to flashing `ark_cannode_default`. - Remove binaries from the root and ufw directories of the SD card and try to build and flash again. -## See Also +## 另见 - [ARK CANnode Documentation](https://arkelectron.gitbook.io/ark-documentation/sensors/ark-cannode) (ARK Docs) diff --git a/docs/zh/dronecan/ark_flow.md b/docs/zh/dronecan/ark_flow.md index 50af8e5c9f..9507785cc7 100644 --- a/docs/zh/dronecan/ark_flow.md +++ b/docs/zh/dronecan/ark_flow.md @@ -133,6 +133,6 @@ If you see a solid red LED there is an error and you should check the following: _PX4 holding position using the ARK Flow sensor for velocity estimation (in [Position Mode](../flight_modes_mc/position.md))._ -## See Also +## 另见 - [ARK Flow](https://arkelectron.gitbook.io/ark-documentation/sensors/ark-flow) (ARK Docs) diff --git a/docs/zh/dronecan/ark_flow_mr.md b/docs/zh/dronecan/ark_flow_mr.md index 6ad95d9e73..eebbbc142c 100644 --- a/docs/zh/dronecan/ark_flow_mr.md +++ b/docs/zh/dronecan/ark_flow_mr.md @@ -128,6 +128,6 @@ If you see a solid red LED there is an error and you should check the following: _PX4 holding position using the ARK Flow MR sensor for velocity estimation (in [Position Mode](../flight_modes_mc/position.md))._ -## See Also +## 另见 - [ARK Flow MR](https://arkelectron.gitbook.io/ark-documentation/sensors/ark-flow-mr) (ARK Docs) diff --git a/docs/zh/dronecan/ark_gps.md b/docs/zh/dronecan/ark_gps.md index 5ffa097d86..f7284e0bae 100644 --- a/docs/zh/dronecan/ark_gps.md +++ b/docs/zh/dronecan/ark_gps.md @@ -112,6 +112,6 @@ If you see a red LED there is an error and you should check the following: - Make sure the ARK GPS has `ark_can-gps_canbootloader` installed prior to flashing `ark_can-gps_default`. - Remove binaries from the root and ufw directories of the SD card and try to build and flash again. -## See Also +## 另见 - [ARK GPS](https://arkelectron.gitbook.io/ark-documentation/sensors/ark-gps) (ARK Docs) diff --git a/docs/zh/dronecan/ark_mosaic__rtk_gps.md b/docs/zh/dronecan/ark_mosaic__rtk_gps.md index 24193f8de8..fb3851bd85 100644 --- a/docs/zh/dronecan/ark_mosaic__rtk_gps.md +++ b/docs/zh/dronecan/ark_mosaic__rtk_gps.md @@ -44,6 +44,6 @@ Order this module from: - USA Built - Supports DroneCAN Firmware Updating -## See Also +## 另见 - [ARK MOSAIC-X5 RTK GPS Documentation](https://arkelectron.gitbook.io/ark-documentation/sensors/ark-mosaic-x5-rtk-gps) (ARK Docs) diff --git a/docs/zh/dronecan/ark_rtk_gps.md b/docs/zh/dronecan/ark_rtk_gps.md index a30768e7dd..eb4d580f7e 100644 --- a/docs/zh/dronecan/ark_rtk_gps.md +++ b/docs/zh/dronecan/ark_rtk_gps.md @@ -200,6 +200,6 @@ ARK RTK GPS comes with the Ublox F9P module up to date with version 1.13 or newe - "Firmware Update SUCCESS" should be displayed if it updated successfully ![Firmware Update](../../assets/hardware/gps/ark/ark_rtk_gps_ublox_f9p_firmware_update.png) -## See Also +## 另见 - [ARK RTK GPS Documentation](https://arkelectron.gitbook.io/ark-documentation/sensors/ark-rtk-gps) (ARK Docs) diff --git a/docs/zh/dronecan/ark_teseo_gps.md b/docs/zh/dronecan/ark_teseo_gps.md index d5a3285f01..04313dc583 100644 --- a/docs/zh/dronecan/ark_teseo_gps.md +++ b/docs/zh/dronecan/ark_teseo_gps.md @@ -69,6 +69,6 @@ Order this module from: | 5 | FMU_SWCLK | 3.3V | | 6 | GND | GND | -## See Also +## 另见 - [ARK TESEO GPS Documentation](https://arkelectron.gitbook.io/ark-documentation/sensors/ark-teseo-gps) (ARK Docs) diff --git a/docs/zh/flight_controller/accton-godwit_ga1.md b/docs/zh/flight_controller/accton-godwit_ga1.md index 20e78c102b..1c3f0a39ff 100644 --- a/docs/zh/flight_controller/accton-godwit_ga1.md +++ b/docs/zh/flight_controller/accton-godwit_ga1.md @@ -80,7 +80,7 @@ This flight controller is [manufacturer supported](../flight_controller/autopilo | ------- | --------- | ------ | ---------- | | SERIAL1 | Telem1 | UART7 | /dev/ttyS6 | | SERIAL2 | Telem2 | UART5 | /dev/ttyS4 | -| SERIAL3 | GPS1 | USART1 | /dev/ttyS0 | +| SERIAL3 | GPS1 | USART1 | UART | | SERIAL4 | GPS2 | UART8 | /dev/ttyS7 | | SERIAL5 | Telem3 | USART2 | /dev/ttyS1 | | SERIAL6 | UART4 | UART4 | /dev/ttyS3 | diff --git a/docs/zh/flight_controller/ark_pab.md b/docs/zh/flight_controller/ark_pab.md index bbdf2081e1..da170835ec 100644 --- a/docs/zh/flight_controller/ark_pab.md +++ b/docs/zh/flight_controller/ark_pab.md @@ -320,6 +320,6 @@ For information about using this port see: ![ARKPAB Bottom Photo](../../assets/flight_controller/arkpab/ark_pab_back.jpg) -## See Also +## 另见 - [ARK Pixhawk Autopilot Bus Carrier](https://arkelectron.gitbook.io/ark-documentation/flight-controllers/ark-pixhawk-autopilot-bus-carrier) (ARK Docs) diff --git a/docs/zh/flight_controller/ark_pi6x.md b/docs/zh/flight_controller/ark_pi6x.md index 053e282c98..a8073e2658 100644 --- a/docs/zh/flight_controller/ark_pi6x.md +++ b/docs/zh/flight_controller/ark_pi6x.md @@ -297,6 +297,6 @@ Order this module from: | 21 | SDA0 | 3.3V | | 22 | 3.3V_RPI | 3.3V | -## See Also +## 另见 - [ARK Pi6X Flow Documentation](https://arkelectron.gitbook.io/ark-documentation/flight-controllers/ark-pi6x-flow) (ARK Docs) diff --git a/docs/zh/flight_controller/ark_v6x.md b/docs/zh/flight_controller/ark_v6x.md index d03215834f..75c7cb6d8a 100644 --- a/docs/zh/flight_controller/ark_v6x.md +++ b/docs/zh/flight_controller/ark_v6x.md @@ -63,9 +63,9 @@ For pinout of the ARKV6X see the [DS-10 Pixhawk Autopilot Bus Standard](https:// | UART | 设备 | Port | | ------ | ---------- | ------------------------------- | -| USART1 | /dev/ttyS0 | GPS | +| USART1 | UART | GPS | | USART2 | /dev/ttyS1 | TELEM3 | -| USART3 | /dev/ttyS2 | Debug Console | +| USART3 | /dev/ttyS2 | 调试控制台 | | UART4 | /dev/ttyS3 | UART4 & I2C | | UART5 | /dev/ttyS4 | TELEM2 | | USART6 | /dev/ttyS5 | PX4IO/RC | @@ -78,6 +78,6 @@ For pinout of the ARKV6X see the [DS-10 Pixhawk Autopilot Bus Standard](https:// make ark_fmu-v6x_default ``` -## See Also +## 另见 - [ARK Electronics ARKV6X](https://arkelectron.gitbook.io/ark-documentation/flight-controllers/arkv6x) (ARK Docs) diff --git a/docs/zh/flight_controller/auav_x2.md b/docs/zh/flight_controller/auav_x2.md index 04db108057..803d492ce6 100644 --- a/docs/zh/flight_controller/auav_x2.md +++ b/docs/zh/flight_controller/auav_x2.md @@ -82,11 +82,11 @@ As a CC-BY-SA 3.0 licensed Open Hardware design, all schematics and design files ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| UART1 | /dev/ttyS0 | IO debug | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | | | -| UART7 | CONSOLE | | -| UART8 | SERIAL4 | | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| UART | UART | IO debug | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | | | +| UART7 | CONSOLE | | +| UART8 | SERIAL4 | | diff --git a/docs/zh/flight_controller/autopilot_manufacturer_supported.md b/docs/zh/flight_controller/autopilot_manufacturer_supported.md index d6f07a44fb..e72970e0d0 100644 --- a/docs/zh/flight_controller/autopilot_manufacturer_supported.md +++ b/docs/zh/flight_controller/autopilot_manufacturer_supported.md @@ -30,6 +30,7 @@ The boards in this category are: - [Holybro Kakute H7](../flight_controller/kakuteh7.md) - [Holybro Durandal](../flight_controller/durandal.md) - [Holybro Pix32 v5](../flight_controller/holybro_pix32_v5.md) +- [MicoAir H743 Lite](../flight_controller/micoair743-lite.md) - [ModalAI VOXL 2](../flight_controller/modalai_voxl_2.md) - [mRo Control Zero](../flight_controller/mro_control_zero_f7.md) - [Radiolink PIX6](../flight_controller/radiolink_pix6.md) diff --git a/docs/zh/flight_controller/cuav_pixhawk_v6x.md b/docs/zh/flight_controller/cuav_pixhawk_v6x.md index 867935b932..814c52b10a 100644 --- a/docs/zh/flight_controller/cuav_pixhawk_v6x.md +++ b/docs/zh/flight_controller/cuav_pixhawk_v6x.md @@ -122,16 +122,16 @@ The [Pixhawk V6X Wiring Quick Start](../assembly/quick_start_cuav_pixhawk_v6x.md ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ------------- | -| USART1 | /dev/ttyS0 | GPS | -| USART2 | /dev/ttyS1 | TELEM3 | -| USART3 | /dev/ttyS2 | Debug Console | -| UART4 | /dev/ttyS3 | UART4 | -| UART5 | /dev/ttyS4 | TELEM2 | -| USART6 | /dev/ttyS5 | PX4IO/RC | -| UART7 | /dev/ttyS6 | TELEM1 | -| UART8 | /dev/ttyS7 | GPS2 | +| UART | 设备 | Port | +| ------ | ---------- | -------- | +| USART1 | UART | GPS | +| USART2 | /dev/ttyS1 | TELEM3 | +| USART3 | /dev/ttyS2 | 调试控制台 | +| UART4 | /dev/ttyS3 | UART4 | +| UART5 | /dev/ttyS4 | TELEM2 | +| USART6 | /dev/ttyS5 | PX4IO/RC | +| UART7 | /dev/ttyS6 | TELEM1 | +| UART8 | /dev/ttyS7 | GPS2 | ## 额定电压 diff --git a/docs/zh/flight_controller/cuav_v5.md b/docs/zh/flight_controller/cuav_v5.md index 5136fa5116..b73968cf07 100644 --- a/docs/zh/flight_controller/cuav_v5.md +++ b/docs/zh/flight_controller/cuav_v5.md @@ -122,12 +122,12 @@ The pinout is as shown. | UART | 设备 | Port | | ------ | ---------- | ---------------------------------------------------------- | -| UART1 | /dev/ttyS0 | GPS | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | +| UART | UART | GPS | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | | UART4 | /dev/ttyS3 | TELEM4 | | USART6 | /dev/ttyS4 | TX is RC input from SBUS_RC connector | -| UART7 | /dev/ttyS5 | Debug Console | +| UART7 | /dev/ttyS5 | 调试控制台 | | UART8 | /dev/ttyS6 | PX4IO | diff --git a/docs/zh/flight_controller/cuav_v5_nano.md b/docs/zh/flight_controller/cuav_v5_nano.md index 70e48783aa..c8f1c37c32 100644 --- a/docs/zh/flight_controller/cuav_v5_nano.md +++ b/docs/zh/flight_controller/cuav_v5_nano.md @@ -134,12 +134,12 @@ For more information see [Using JTAG for hardware debugging](#using-jtag-for-har | UART | 设备 | Port | | ------ | ---------- | ---------------------------------------------------------- | -| UART1 | /dev/ttyS0 | GPS | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | +| UART | UART | GPS | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | | UART4 | /dev/ttyS3 | TELEM4 | | USART6 | /dev/ttyS4 | TX is RC input from SBUS_RC connector | -| UART7 | /dev/ttyS5 | Debug Console | +| UART7 | /dev/ttyS5 | 调试控制台 | | UART8 | /dev/ttyS6 | Not connected (no PX4IO) | diff --git a/docs/zh/flight_controller/cuav_v5_plus.md b/docs/zh/flight_controller/cuav_v5_plus.md index 29f628ead0..49b6aa6d2d 100644 --- a/docs/zh/flight_controller/cuav_v5_plus.md +++ b/docs/zh/flight_controller/cuav_v5_plus.md @@ -160,12 +160,12 @@ For more information see [Using JTAG for hardware debugging](#using-jtag-for-har | UART | 设备 | Port | | ------ | ---------- | ---------------------------------------------------------- | -| UART1 | /dev/ttyS0 | GPS | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | +| UART | UART | GPS | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | | UART4 | /dev/ttyS3 | TELEM4 | | USART6 | /dev/ttyS4 | TX is RC input from SBUS_RC connector | -| UART7 | /dev/ttyS5 | Debug Console | +| UART7 | /dev/ttyS5 | 调试控制台 | | UART8 | /dev/ttyS6 | PX4IO | diff --git a/docs/zh/flight_controller/cuav_x25-evo.md b/docs/zh/flight_controller/cuav_x25-evo.md index baa18091b4..ec68641440 100644 --- a/docs/zh/flight_controller/cuav_x25-evo.md +++ b/docs/zh/flight_controller/cuav_x25-evo.md @@ -99,15 +99,15 @@ Order from [CUAV](https://store.cuav.net/). ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ------------- | -| USART1 | /dev/ttyS0 | GPS1 | -| USART2 | /dev/ttyS1 | GPS2 | -| USART3 | /dev/ttyS2 | Debug Console | -| UART4 | /dev/ttyS3 | UART4 | -| UART5 | /dev/ttyS4 | TELEM2 | -| USART6 | /dev/ttyS5 | RC | -| UART7 | /dev/ttyS6 | TELEM1 | +| UART | 设备 | Port | +| ------ | ---------- | ------ | +| USART1 | UART | GPS1 | +| USART2 | /dev/ttyS1 | GPS2 | +| USART3 | /dev/ttyS2 | 调试控制台 | +| UART4 | /dev/ttyS3 | UART4 | +| UART5 | /dev/ttyS4 | TELEM2 | +| USART6 | /dev/ttyS5 | RC | +| UART7 | /dev/ttyS6 | TELEM1 | ## 额定电压 diff --git a/docs/zh/flight_controller/cubepilot_cube_orange.md b/docs/zh/flight_controller/cubepilot_cube_orange.md index 5af04e96a0..1ab22c5bdb 100644 --- a/docs/zh/flight_controller/cubepilot_cube_orange.md +++ b/docs/zh/flight_controller/cubepilot_cube_orange.md @@ -204,14 +204,14 @@ The manufacturer [Cube User Guide](https://docs.cubepilot.org/user-guides/autopi ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| USART2 | /dev/ttyS0 | TELEM1 (flow control) | -| USART3 | /dev/ttyS1 | TELEM2 (flow control) | -| UART4 | /dev/ttyS2 | GPS1 | -| USART6 | /dev/ttyS3 | PX4IO | -| UART7 | /dev/ttyS4 | CONSOLE/ADSB-IN | -| UART8 | /dev/ttyS5 | GPS2 | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| USART2 | UART | TELEM1 (流控) | +| USART3 | /dev/ttyS1 | TELEM2 (流控) | +| UART4 | /dev/ttyS2 | GPS1 | +| USART6 | /dev/ttyS3 | PX4IO | +| UART7 | /dev/ttyS4 | CONSOLE/ADSB-IN | +| UART8 | /dev/ttyS5 | GPS2 | diff --git a/docs/zh/flight_controller/cubepilot_cube_orangeplus.md b/docs/zh/flight_controller/cubepilot_cube_orangeplus.md index c117bea8aa..b45014c233 100644 --- a/docs/zh/flight_controller/cubepilot_cube_orangeplus.md +++ b/docs/zh/flight_controller/cubepilot_cube_orangeplus.md @@ -205,14 +205,14 @@ The manufacturer [Cube User Guide](https://docs.cubepilot.org/user-guides/autopi ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| USART2 | /dev/ttyS0 | TELEM1 (flow control) | -| USART3 | /dev/ttyS1 | TELEM2 (flow control) | -| UART4 | /dev/ttyS2 | GPS1 | -| USART6 | /dev/ttyS3 | PX4IO | -| UART7 | /dev/ttyS4 | CONSOLE/ADSB-IN | -| UART8 | /dev/ttyS5 | GPS2 | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| USART2 | UART | TELEM1 (流控) | +| USART3 | /dev/ttyS1 | TELEM2 (流控) | +| UART4 | /dev/ttyS2 | GPS1 | +| USART6 | /dev/ttyS3 | PX4IO | +| UART7 | /dev/ttyS4 | CONSOLE/ADSB-IN | +| UART8 | /dev/ttyS5 | GPS2 | diff --git a/docs/zh/flight_controller/cubepilot_cube_yellow.md b/docs/zh/flight_controller/cubepilot_cube_yellow.md index cbdc917433..fab8867d0c 100644 --- a/docs/zh/flight_controller/cubepilot_cube_yellow.md +++ b/docs/zh/flight_controller/cubepilot_cube_yellow.md @@ -98,14 +98,14 @@ Board schematics and other documentation can be found here: [The Cube Project](h ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| USART2 | /dev/ttyS0 | TELEM1 (flow control) | -| USART3 | /dev/ttyS1 | TELEM2 (flow control) | -| UART4 | /dev/ttyS2 | GPS1 | -| USART6 | /dev/ttyS3 | PX4IO | -| UART7 | /dev/ttyS4 | CONSOLE/ADSB-IN | -| UART8 | /dev/ttyS5 | GPS2 | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| USART2 | UART | TELEM1 (流控) | +| USART3 | /dev/ttyS1 | TELEM2 (流控) | +| UART4 | /dev/ttyS2 | GPS1 | +| USART6 | /dev/ttyS3 | PX4IO | +| UART7 | /dev/ttyS4 | CONSOLE/ADSB-IN | +| UART8 | /dev/ttyS5 | GPS2 | diff --git a/docs/zh/flight_controller/durandal.md b/docs/zh/flight_controller/durandal.md index 6c552d2f62..b4acc8bb09 100644 --- a/docs/zh/flight_controller/durandal.md +++ b/docs/zh/flight_controller/durandal.md @@ -168,15 +168,15 @@ make holybro_durandal-v1_default ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ------------- | -| USART1 | /dev/ttyS0 | GPS1 | -| USART2 | /dev/ttyS1 | TELEM1 | -| USART3 | /dev/ttyS2 | TELEM2 | -| UART4 | /dev/ttyS3 | TELEM4/GPS2 | -| USART6 | /dev/ttyS4 | TELEM3 | -| UART7 | /dev/ttyS5 | Debug Console | -| UART8 | /dev/ttyS6 | PX4IO | +| UART | 设备 | Port | +| ------ | ---------- | ----------- | +| USART1 | UART | GPS1 | +| USART2 | /dev/ttyS1 | TELEM1 | +| USART3 | /dev/ttyS2 | TELEM2 | +| UART4 | /dev/ttyS3 | TELEM4/GPS2 | +| USART6 | /dev/ttyS4 | TELEM3 | +| UART7 | /dev/ttyS5 | 调试控制台 | +| UART8 | /dev/ttyS6 | PX4IO | diff --git a/docs/zh/flight_controller/holybro_pix32.md b/docs/zh/flight_controller/holybro_pix32.md index 1f35c44ca1..14c9b08e42 100644 --- a/docs/zh/flight_controller/holybro_pix32.md +++ b/docs/zh/flight_controller/holybro_pix32.md @@ -94,13 +94,13 @@ As a CC-BY-SA 3.0 licensed Open Hardware design, all schematics and design files ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| UART1 | /dev/ttyS0 | IO debug | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | | | -| UART7 | CONSOLE | | -| UART8 | SERIAL4 | | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| UART | UART | IO debug | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | | | +| UART7 | CONSOLE | | +| UART8 | SERIAL4 | | diff --git a/docs/zh/flight_controller/holybro_pix32_v6.md b/docs/zh/flight_controller/holybro_pix32_v6.md index 383938b43c..a91aa132ca 100644 --- a/docs/zh/flight_controller/holybro_pix32_v6.md +++ b/docs/zh/flight_controller/holybro_pix32_v6.md @@ -104,15 +104,15 @@ Order from [Holybro](https://holybro.com/products/pix32-v6). ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ------------- | -| USART1 | /dev/ttyS0 | GPS1 | -| USART2 | /dev/ttyS1 | TELEM3 | -| USART3 | /dev/ttyS2 | Debug Console | -| UART5 | /dev/ttyS3 | TELEM2 | -| USART6 | /dev/ttyS4 | PX4IO | -| UART7 | /dev/ttyS5 | TELEM1 | -| UART8 | /dev/ttyS6 | GPS2 | +| UART | 设备 | Port | +| ------ | ---------- | ------ | +| USART1 | UART | GPS1 | +| USART2 | /dev/ttyS1 | TELEM3 | +| USART3 | /dev/ttyS2 | 调试控制台 | +| UART5 | /dev/ttyS3 | TELEM2 | +| USART6 | /dev/ttyS4 | PX4IO | +| UART7 | /dev/ttyS5 | TELEM1 | +| UART8 | /dev/ttyS6 | GPS2 | ## 尺寸 diff --git a/docs/zh/flight_controller/kakutef7.md b/docs/zh/flight_controller/kakutef7.md index 9f928b43b3..3508db0e5c 100644 --- a/docs/zh/flight_controller/kakutef7.md +++ b/docs/zh/flight_controller/kakutef7.md @@ -113,9 +113,9 @@ In addition to the [basic configuration](../config/index.md), the following para | UART | 设备 | Port | | ------ | ---------- | ---------------------------------------- | -| USART1 | /dev/ttyS0 | TELEM1 | +| USART1 | UART | TELEM1 | | USART2 | /dev/ttyS1 | TELEM2 | -| USART3 | /dev/ttyS2 | Debug Console | +| USART3 | /dev/ttyS2 | 调试控制台 | | UART4 | /dev/ttyS3 | GPS1 | | USART6 | /dev/ttyS4 | RC SBUS | | UART7 | /dev/ttyS5 | ESC telemetry (DShot) | diff --git a/docs/zh/flight_controller/kakuteh7-wing.md b/docs/zh/flight_controller/kakuteh7-wing.md index e426a8aabe..59031d431b 100644 --- a/docs/zh/flight_controller/kakuteh7-wing.md +++ b/docs/zh/flight_controller/kakuteh7-wing.md @@ -69,7 +69,7 @@ Firmware can be manually installed in any of the normal ways: | UART | 设备 | Port | Default function | | ------ | ---------- | --------------------------- | ---------------- | -| USART1 | /dev/ttyS0 | GPS 1 | GPS1 | +| USART1 | UART | GPS 1 | GPS1 | | USART2 | /dev/ttyS1 | R2, T2 | GPS2 | | USART3 | /dev/ttyS2 | R3, T3 | TELEM1 | | UART5 | /dev/ttyS3 | R5, T5 | TELEM2 | diff --git a/docs/zh/flight_controller/kakuteh7.md b/docs/zh/flight_controller/kakuteh7.md index a48a394490..27c60acfde 100644 --- a/docs/zh/flight_controller/kakuteh7.md +++ b/docs/zh/flight_controller/kakuteh7.md @@ -117,9 +117,9 @@ In addition to the [basic configuration](../config/index.md), the following para | UART | 设备 | Port | | ------ | ---------- | ---------------------------------------- | -| USART1 | /dev/ttyS0 | TELEM1 | +| USART1 | UART | TELEM1 | | USART2 | /dev/ttyS1 | TELEM2 | -| USART3 | /dev/ttyS2 | Debug Console | +| USART3 | /dev/ttyS2 | 调试控制台 | | UART4 | /dev/ttyS3 | GPS1 | | USART6 | /dev/ttyS4 | RC SBUS | | UART7 | /dev/ttyS5 | ESC telemetry (DShot) | diff --git a/docs/zh/flight_controller/kakuteh7mini.md b/docs/zh/flight_controller/kakuteh7mini.md index d23416130f..23198d0064 100644 --- a/docs/zh/flight_controller/kakuteh7mini.md +++ b/docs/zh/flight_controller/kakuteh7mini.md @@ -124,9 +124,9 @@ In addition to the [basic configuration](../config/index.md), the following para | UART | 设备 | Port | | ------ | ---------- | ---------------------------------------- | -| USART1 | /dev/ttyS0 | TELEM1 | +| USART1 | UART | TELEM1 | | UART2 | /dev/ttyS1 | TELEM2 | -| USART3 | /dev/ttyS2 | Debug Console | +| USART3 | /dev/ttyS2 | 调试控制台 | | UART4 | /dev/ttyS3 | GPS1 | | USART6 | /dev/ttyS4 | RC SBUS | | UART7 | /dev/ttyS5 | ESC telemetry (DShot) | diff --git a/docs/zh/flight_controller/kakuteh7v2.md b/docs/zh/flight_controller/kakuteh7v2.md index cdd2f07aa7..d5b1f8faec 100644 --- a/docs/zh/flight_controller/kakuteh7v2.md +++ b/docs/zh/flight_controller/kakuteh7v2.md @@ -121,8 +121,8 @@ In addition to the [basic configuration](../config/index.md), the following para | UART | 设备 | Port | | ------ | ---------- | ---------------------------------------- | -| USART1 | /dev/ttyS0 | TELEM1 | -| USART3 | /dev/ttyS2 | Debug Console | +| USART1 | UART | TELEM1 | +| USART3 | /dev/ttyS2 | 调试控制台 | | UART4 | /dev/ttyS3 | GPS1 | | USART6 | /dev/ttyS4 | RC SBUS | | UART7 | /dev/ttyS5 | ESC telemetry (DShot) | diff --git a/docs/zh/flight_controller/micoair743-lite.md b/docs/zh/flight_controller/micoair743-lite.md new file mode 100644 index 0000000000..bf8c114b90 --- /dev/null +++ b/docs/zh/flight_controller/micoair743-lite.md @@ -0,0 +1,153 @@ +# MicoAir743-Lite + + + +:::warning +PX4 does not manufacture this (or any) autopilot. +Contact the [manufacturer](https://micoair.com/) for hardware support or compliance issues. +::: + +MicoAir743-Lite is an ultra-high performance H743 flight controller with an unbeatable price, featuring the ICM45686 IMU sensor and integrated Bluetooth telemetry. + +![MicoAir743-Lite Front View](../../assets/flight_controller/micoair743_lite/front_view.png) + +Equipped with a high-performance H7 processor, the MicoAir743-Lite features a compact form factor with SH1.0 connectors (which are more suitable than Pixhawk-standard GH1.25 for this board size). +When paired with with Bluetooth telemetry, the board can be debugged with a phone or PC. + +:::info +This flight controller is [manufacturer supported](../flight_controller/autopilot_manufacturer_supported.md). +::: + +## MicoAir743-Lite (v1.1) + +![MicoAir743-Lite Back View](../../assets/flight_controller/micoair743_lite/back_view.png) + +## 总览 + +### Processors & Sensors + +- FMU Processor: STM32H743 + - 32 Bit Arm® Cortex®-M7, 480MHz, 2MB flash memory, 1MB RAM +- On-board sensors + - Accel/Gyro: ICM-45686 (with BalancedGyro™ Technology) + - Barometer: SPA06 +- On-board Bluetooth Telemetry + - Connected to UART8 internally, baudrate 115200 + - Connecting to QGC (PC or Android phone) via Bluetooth +- 其它特性: + - Operating & storage temperature: -20 ~ 85°c + +### 接口 + +- 8 UART (TELEM / GPS / RC) +- 14 PWM outputs (10 supports DShot) +- Support multiple RC inputs (SBUS / CRSF / DSM) +- 1 GPS port +- 1 I2C port +- 2 ADC port2 (VBAT, Current) +- 1 DJI O3/O4 VTX connector +- 1 MicroSD Card Slot +- 1 USB Type-C + +### Electrical data + +- VBAT Input: + - 2\~6S (6\~27V) +- USB Power Input: + - 4.75\~5.25V +- BEC Output: + - 5V 2A (for controller, receiver, GPS, optical flow or other devices) + - 9V 2A (for video transmitter, camera) + +### Mechanical data + +- Mounting: 30.5 x 30.5mm, Φ4mm +- Dimensions: 36 x 36 x 8 mm +- Weight: 10g + +![MicoAir743-Lite Size](../../assets/flight_controller/micoair743_lite/size.png) + +## 购买渠道 + +Order from [MicoAir Tech Store](https://store.micoair.com/product/micoair743-lite/). + +## 针脚定义 + +Pinouts definition can be found in the [MicoAir743-Lite_pinout.xlsx](https://raw.githubusercontent.com/PX4/PX4-Autopilot/refs/heads/main/docs/assets/flight_controller/micoair743_lite/micoair743_lite_pinout.xlsx) file. + +## 串口映射 + +| UART | 设备 | Port | +| ------ | ---------- | ------ | +| USART1 | UART | TELEM1 | +| USART2 | /dev/ttyS1 | GPS2 | +| USART3 | /dev/ttyS2 | GPS1 | +| UART4 | /dev/ttyS3 | TELEM2 | +| UART5 | /dev/ttyS4 | TELEM3 | +| USART6 | /dev/ttyS5 | RC | +| UART7 | /dev/ttyS6 | URT6 | +| UART8 | /dev/ttyS7 | TELEM4 | + +## Interfaces Diagram + +:::note +All the connectors used on the board are SH1.0 +::: + +![MicoAir743-Lite Interface Diagram](../../assets/flight_controller/micoair743_lite/interfaces_diagram.png) + +## Sample Wiring Diagram + +![MicoAir743-Lite Wiring Diagram](../../assets/flight_controller/micoair743_lite/wiring_diagram.png) + +## 编译固件 + +To [build PX4](../dev_setup/building_px4.md) for this target: + +```sh +make micoair_h743-lite_default +``` + +## Installing PX4 Firmware + +The firmware can be installed in any of the normal ways: + +- Build and upload the source + + ```sh + make micoair_h743-lite_default upload + ``` + +- [Load the firmware](../config/firmware.md) using _QGroundControl_. + You can use either pre-built firmware or your own custom firmware. + + ::: info + At time of writing the only pre-built software is `PX4 main` (see [Installing PX4 Main, Beta or Custom Firmware](../config/firmware.md#installing-px4-main-beta-or-custom-firmware)). + Release builds will be supported for PX4 v1.17 and later. + +::: + +## 遥控器 + +A [Radio Control (RC) system](../getting_started/rc_transmitter_receiver.md) is required if you want to manually control your vehicle (PX4 does not require a radio system for autonomous flight modes). + +The RC port is connected to the FMU and you can attach a receiver that uses the protocols `DSM`, `SBUS`, `CSRF`, `GHST`, or other protocol listed in [Radio Control modules](../modules/modules_driver_radio_control.md). +You will need to enable the protocol by setting the corresponding parameter `RC_xxxx_PRT_CFG`, such as [RC_CRSF_PRT_CFG](../advanced_config/parameter_reference.md#RC_CRSF_PRT_CFG) for a [CRSF receiver](../telemetry/crsf_telemetry.md). + +## 支持的平台/机身 + +Any multicopter / airplane / rover or boat that can be controlled with normal RC servos or Futaba S-Bus servos. +The complete set of supported configurations can be seen in the [Airframes Reference](../airframes/airframe_reference.md). + +## 外部设备 + +- [MicoAir Telemetry Radio Modules](https://micoair.com/radio_telemetry/) +- [MicoAir Optical & Range Sensor](https://micoair.com/optical_range_sensor/) +- [MicoAir GPS](https://micoair.com/gps/) +- [MicoAir ESC Modules](https://micoair.com/esc/) + +## 更多信息 + +- [MicoAir Tech.](https://micoair.com/) +- [Details about MicoAir743-Lite](https://micoair.com/flightcontroller_micoair743lite/) +- [QGroundControl Download and Install](https://docs.qgroundcontrol.com/Stable_V5.0/en/qgc-user-guide/getting_started/download_and_install.html) diff --git a/docs/zh/flight_controller/mindpx.md b/docs/zh/flight_controller/mindpx.md index d69ba6d89b..7b3145c1bd 100644 --- a/docs/zh/flight_controller/mindpx.md +++ b/docs/zh/flight_controller/mindpx.md @@ -111,15 +111,15 @@ You can also find MindRacer at Amazon® or eBay®. ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ------------- | -| USART1 | /dev/ttyS0 | RC | -| USART2 | /dev/ttyS1 | TELEM1 | -| USART3 | /dev/ttyS2 | TELEM2 | -| UART4 | /dev/ttyS3 | GPS1 | -| USART6 | /dev/ttyS4 | ? | -| UART7 | /dev/ttyS5 | Debug Console | -| UART8 | /dev/ttyS6 | ? | +| UART | 设备 | Port | +| ------ | ---------- | ------ | +| USART1 | UART | RC | +| USART2 | /dev/ttyS1 | TELEM1 | +| USART3 | /dev/ttyS2 | TELEM2 | +| UART4 | /dev/ttyS3 | GPS1 | +| USART6 | /dev/ttyS4 | ? | +| UART7 | /dev/ttyS5 | 调试控制台 | +| UART8 | /dev/ttyS6 | ? | diff --git a/docs/zh/flight_controller/modalai_fc_v1.md b/docs/zh/flight_controller/modalai_fc_v1.md index 1e9562b83d..53ce071462 100644 --- a/docs/zh/flight_controller/modalai_fc_v1.md +++ b/docs/zh/flight_controller/modalai_fc_v1.md @@ -130,7 +130,7 @@ make modalai_fc-v1 | UART | 设备 | Port | | ------ | ---------- | ----------------------------------------------------------- | -| USART1 | /dev/ttyS0 | GPS1 (J10) | +| USART1 | UART | GPS1 (J10) | | USART2 | /dev/ttyS1 | TELEM3 (J4) | | USART3 | /dev/ttyS2 | Debug Console (J2) | | UART4 | /dev/ttyS3 | Expansion UART (J6) | diff --git a/docs/zh/flight_controller/modalai_voxl_flight.md b/docs/zh/flight_controller/modalai_voxl_flight.md index 352fd22892..806ea037ad 100644 --- a/docs/zh/flight_controller/modalai_voxl_flight.md +++ b/docs/zh/flight_controller/modalai_voxl_flight.md @@ -186,7 +186,7 @@ _Note: mappings shown are for the PX4 controlled interfaces only_ | UART | 设备 | Port | | ------ | ---------- | ---------------------------------------- | -| USART1 | /dev/ttyS0 | GPS1 (J1012) | +| USART1 | UART | GPS1 (J1012) | | USART2 | /dev/ttyS1 | TELEM3 (J1002) | | USART3 | /dev/ttyS2 | Debug Console (J1001) | | UART4 | /dev/ttyS3 | Expansion UART (J6) | diff --git a/docs/zh/flight_controller/mro_control_zero_f7.md b/docs/zh/flight_controller/mro_control_zero_f7.md index f17ce6a8f4..564cc9d13c 100644 --- a/docs/zh/flight_controller/mro_control_zero_f7.md +++ b/docs/zh/flight_controller/mro_control_zero_f7.md @@ -106,8 +106,8 @@ There is also an [ARM20-CTX 20-Pin to TC2030-IDC adapter](https://www.tag-connec | UART | 设备 | Port | | ------ | ---------- | -------------------------------------------------------------------------------------------------- | -| USART2 | /dev/ttyS0 | TELEM1 (flow control) | -| USART3 | /dev/ttyS1 | TELEM2 (flow control) | +| USART2 | UART | TELEM1 (流控) | +| USART3 | /dev/ttyS1 | TELEM2 (流控) | | UART4 | /dev/ttyS2 | GPS1 | | USART6 | /dev/ttyS3 | Flex port (can be configured as SPI or UART with Flow Control). | | UART7 | /dev/ttyS4 | CONSOLE | diff --git a/docs/zh/flight_controller/mro_pixhawk.md b/docs/zh/flight_controller/mro_pixhawk.md index 7ff5c5cd9c..afd00c790e 100644 --- a/docs/zh/flight_controller/mro_pixhawk.md +++ b/docs/zh/flight_controller/mro_pixhawk.md @@ -86,14 +86,14 @@ See [3DR Pixhawk 1 > Pinouts](../flight_controller/pixhawk.md#pinouts) ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| UART1 | /dev/ttyS0 | IO debug | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | | | -| UART7 | CONSOLE | | -| UART8 | SERIAL4 | | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| UART | UART | IO debug | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | | | +| UART7 | CONSOLE | | +| UART8 | SERIAL4 | | diff --git a/docs/zh/flight_controller/mro_x2.1.md b/docs/zh/flight_controller/mro_x2.1.md index d54c36cd5e..f22b80daa1 100644 --- a/docs/zh/flight_controller/mro_x2.1.md +++ b/docs/zh/flight_controller/mro_x2.1.md @@ -111,7 +111,7 @@ The board is documented on the mRo hardware repo: [x21_V2_schematic.pdf](https:/ | UART | 设备 | Port | | ------ | ---------- | --------------- | -| USART1 | /dev/ttyS0 | IO debug | +| USART1 | UART | IO debug | | USART2 | /dev/ttyS1 | SERIAL1 | | USART3 | /dev/ttyS2 | TELEM2 | | UART4 | /dev/ttyS3 | GPS/I2C | diff --git a/docs/zh/flight_controller/nxp_mr_vmu_rt1176.md b/docs/zh/flight_controller/nxp_mr_vmu_rt1176.md index 06436027d7..6f3ca1b0b8 100644 --- a/docs/zh/flight_controller/nxp_mr_vmu_rt1176.md +++ b/docs/zh/flight_controller/nxp_mr_vmu_rt1176.md @@ -182,7 +182,7 @@ _MR-VMU-RT1176_ connectors (following [Pixhawk Connector Standard](https://githu | UART | 设备 | Port | | ------ | ---------- | -------- | -| UART1 | /dev/ttyS0 | Debug | +| UART | UART | Debug | | UART3 | /dev/ttyS1 | GPS | | UART4 | /dev/ttyS2 | TELEM1 | | UART5 | /dev/ttyS3 | GPS2 | diff --git a/docs/zh/flight_controller/omnibus_f4_sd.md b/docs/zh/flight_controller/omnibus_f4_sd.md index ca2f22a264..c1783c71d1 100644 --- a/docs/zh/flight_controller/omnibus_f4_sd.md +++ b/docs/zh/flight_controller/omnibus_f4_sd.md @@ -107,7 +107,7 @@ Below are silkscreens for the Hobbywing XRotor Flight Controller F4. RC is connected to one of the following ports: -- UART1 +- UART - SBUS/PPM port (via inverter, internally goes to UART1) :::info @@ -164,7 +164,7 @@ Here is an example implementation. I used a Spektrum plug to get 3.3v from the D | UART | 设备 | Port | | ------ | ---------- | -------- | -| USART1 | /dev/ttyS0 | SerialRX | +| USART1 | UART | SerialRX | | USART4 | /dev/ttyS1 | TELEM1 | | USART6 | /dev/ttyS2 | GPS | diff --git a/docs/zh/flight_controller/pixfalcon.md b/docs/zh/flight_controller/pixfalcon.md index df1b22c5d8..0a53eb2800 100644 --- a/docs/zh/flight_controller/pixfalcon.md +++ b/docs/zh/flight_controller/pixfalcon.md @@ -68,7 +68,7 @@ Developers will need to solder wires to the board test pads for SWD, and to the | UART | 设备 | Port | | ------ | ---------- | ------------------------------------------- | -| UART1 | /dev/ttyS0 | IO Debug | +| UART | UART | IO Debug | | USART2 | /dev/ttyS1 | TELEM1 (No flow control) | | UART4 | /dev/ttyS2 | GPS | diff --git a/docs/zh/flight_controller/pixhack_v3.md b/docs/zh/flight_controller/pixhack_v3.md index e9f48ca3c5..f8e7b063e9 100644 --- a/docs/zh/flight_controller/pixhack_v3.md +++ b/docs/zh/flight_controller/pixhack_v3.md @@ -78,11 +78,11 @@ make px4_fmu-v3_default ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| UART1 | /dev/ttyS0 | IO debug | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | | | -| UART7 | | CONSOLE | -| UART8 | | SERIAL4 | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| UART | UART | IO debug | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | | | +| UART7 | | CONSOLE | +| UART8 | | SERIAL4 | diff --git a/docs/zh/flight_controller/pixhawk-2.md b/docs/zh/flight_controller/pixhawk-2.md index c92f721c6b..94272adce4 100644 --- a/docs/zh/flight_controller/pixhawk-2.md +++ b/docs/zh/flight_controller/pixhawk-2.md @@ -124,15 +124,15 @@ Board schematics and other documentation can be found here: [The Cube Project](h ### 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| USART1 | /dev/ttyS0 | | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | /dev/ttyS3 | GPS1 | -| USART6 | /dev/ttyS4 | PX4IO | -| UART7 | /dev/ttyS5 | CONSOLE | -| UART8 | /dev/ttyS6 | | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| USART1 | UART | | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | /dev/ttyS3 | GPS1 | +| USART6 | /dev/ttyS4 | PX4IO | +| UART7 | /dev/ttyS5 | CONSOLE | +| UART8 | /dev/ttyS6 | | diff --git a/docs/zh/flight_controller/pixhawk.md b/docs/zh/flight_controller/pixhawk.md index cbe395c9b0..6a2d7346ae 100644 --- a/docs/zh/flight_controller/pixhawk.md +++ b/docs/zh/flight_controller/pixhawk.md @@ -245,14 +245,14 @@ Due to space constraints two ports are on one connector. ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| UART1 | /dev/ttyS0 | IO debug | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | | | -| UART7 | CONSOLE | | -| UART8 | SERIAL4 | | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| UART | UART | IO debug | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | | | +| UART7 | CONSOLE | | +| UART8 | SERIAL4 | | diff --git a/docs/zh/flight_controller/pixhawk3_pro.md b/docs/zh/flight_controller/pixhawk3_pro.md index 38a10f1cd3..a0aebc8e8e 100644 --- a/docs/zh/flight_controller/pixhawk3_pro.md +++ b/docs/zh/flight_controller/pixhawk3_pro.md @@ -75,13 +75,13 @@ For information about wiring and using this port see: ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| UART1 | /dev/ttyS0 | WiFi | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | | | -| UART7 | CONSOLE | | -| UART8 | SERIAL4 | | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| UART | UART | WiFi | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | | | +| UART7 | CONSOLE | | +| UART8 | SERIAL4 | | diff --git a/docs/zh/flight_controller/pixhawk4.md b/docs/zh/flight_controller/pixhawk4.md index 5930e4db48..9ae81b06e0 100644 --- a/docs/zh/flight_controller/pixhawk4.md +++ b/docs/zh/flight_controller/pixhawk4.md @@ -75,15 +75,15 @@ The exception is the [debug port(s)](#debug_port) (pin 1 is the right-most, as s ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| UART1 | /dev/ttyS0 | GPS | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | /dev/ttyS3 | TELEM4 | -| USART6 | /dev/ttyS4 | RC SBUS | -| UART7 | /dev/ttyS5 | Debug Console | -| UART8 | /dev/ttyS6 | PX4IO | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| UART | UART | GPS | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | /dev/ttyS3 | TELEM4 | +| USART6 | /dev/ttyS4 | RC SBUS | +| UART7 | /dev/ttyS5 | 调试控制台 | +| UART8 | /dev/ttyS6 | PX4IO | ## 尺寸 diff --git a/docs/zh/flight_controller/pixhawk4_mini.md b/docs/zh/flight_controller/pixhawk4_mini.md index 1a73ddc3c2..e3921cbf63 100644 --- a/docs/zh/flight_controller/pixhawk4_mini.md +++ b/docs/zh/flight_controller/pixhawk4_mini.md @@ -129,7 +129,7 @@ The pinout uses the standard [Pixhawk debug connector](https://github.com/pixhaw | UART | 设备 | QGC Parameter Description | Port Label on FC | | :----: | :--------: | :-----------------------: | :-----------------------------------------: | -| UART1 | /dev/ttyS0 | GPS1 | GPS Module | +| UART | UART | GPS1 | GPS Module | | USART2 | /dev/ttyS1 | TELEM1 | TELEM1 | | USART3 | /dev/ttyS2 | TELEM2 | N/A | | UART4 | /dev/ttyS3 | TELEM/SERIAL4 | UART/l2C B | diff --git a/docs/zh/flight_controller/pixhawk5x.md b/docs/zh/flight_controller/pixhawk5x.md index 456b61315f..e0d6177760 100644 --- a/docs/zh/flight_controller/pixhawk5x.md +++ b/docs/zh/flight_controller/pixhawk5x.md @@ -140,9 +140,9 @@ Connector pin assignments are left to right (i.e. Pin 1 is the left-most pin). | UART | 设备 | Port | | ------ | ---------- | ------------------------------- | -| USART1 | /dev/ttyS0 | GPS | +| USART1 | UART | GPS | | USART2 | /dev/ttyS1 | TELEM3 | -| USART3 | /dev/ttyS2 | Debug Console | +| USART3 | /dev/ttyS2 | 调试控制台 | | UART4 | /dev/ttyS3 | UART4 & I2C | | UART5 | /dev/ttyS4 | TELEM2 | | USART6 | /dev/ttyS5 | PX4IO/RC | diff --git a/docs/zh/flight_controller/pixhawk6c.md b/docs/zh/flight_controller/pixhawk6c.md index d344238d42..b950285f81 100644 --- a/docs/zh/flight_controller/pixhawk6c.md +++ b/docs/zh/flight_controller/pixhawk6c.md @@ -110,15 +110,15 @@ The [Pixhawk 6C Wiring Quick Start](../assembly/quick_start_pixhawk6c.md) provid ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ------------- | -| USART1 | /dev/ttyS0 | GPS1 | -| USART2 | /dev/ttyS1 | TELEM3 | -| USART3 | /dev/ttyS2 | Debug Console | -| UART5 | /dev/ttyS3 | TELEM2 | -| USART6 | /dev/ttyS4 | PX4IO | -| UART7 | /dev/ttyS5 | TELEM1 | -| UART8 | /dev/ttyS6 | GPS2 | +| UART | 设备 | Port | +| ------ | ---------- | ------ | +| USART1 | UART | GPS1 | +| USART2 | /dev/ttyS1 | TELEM3 | +| USART3 | /dev/ttyS2 | 调试控制台 | +| UART5 | /dev/ttyS3 | TELEM2 | +| USART6 | /dev/ttyS4 | PX4IO | +| UART7 | /dev/ttyS5 | TELEM1 | +| UART8 | /dev/ttyS6 | GPS2 | ## 尺寸 diff --git a/docs/zh/flight_controller/pixhawk6c_mini.md b/docs/zh/flight_controller/pixhawk6c_mini.md index 1973aa00b6..a5e6079313 100644 --- a/docs/zh/flight_controller/pixhawk6c_mini.md +++ b/docs/zh/flight_controller/pixhawk6c_mini.md @@ -111,7 +111,7 @@ Please refer to the [Pixhawk 4 Mini Wiring Quick Start](../assembly/quick_start_ | UART | 设备 | QGC Parameter Description | Port Label on FC | | ------ | ---------- | ------------------------- | ---------------- | -| USART1 | /dev/ttyS0 | GPS1 | GPS1 | +| USART1 | UART | GPS1 | GPS1 | | USART2 | /dev/ttyS1 | TELEM3 | N/A | | USART3 | /dev/ttyS2 | N/A | FMU Debug | | UART5 | /dev/ttyS3 | TELEM2 | TELEM2 | @@ -205,7 +205,7 @@ For information about using this port see: Any multicopter / airplane / rover or boat that can be controlled with normal RC servos or Futaba S-Bus servos. The complete set of supported configurations can be seen in the [Airframes Reference](../airframes/airframe_reference.md). -## See Also +## 另见 - [Holybro Docs](https://docs.holybro.com/) (Holybro) - [Pixhawk 4 Mini Wiring Quick Start](../assembly/quick_start_pixhawk4_mini.md) (and [Pixhawk 6C Wiring QuickStart](../assembly/quick_start_pixhawk6c.md)) diff --git a/docs/zh/flight_controller/pixhawk6x-rt.md b/docs/zh/flight_controller/pixhawk6x-rt.md index cddcc6d4c6..bb3b3fa805 100644 --- a/docs/zh/flight_controller/pixhawk6x-rt.md +++ b/docs/zh/flight_controller/pixhawk6x-rt.md @@ -157,7 +157,7 @@ Sample Wiring Diagram | UART | 设备 | Port | | ------ | ---------- | -------- | -| UART1 | /dev/ttyS0 | Debug | +| UART | UART | Debug | | UART3 | /dev/ttyS1 | GPS | | UART4 | /dev/ttyS2 | TELEM1 | | UART5 | /dev/ttyS3 | GPS2 | diff --git a/docs/zh/flight_controller/pixhawk6x.md b/docs/zh/flight_controller/pixhawk6x.md index 8212476581..aec1d331f4 100644 --- a/docs/zh/flight_controller/pixhawk6x.md +++ b/docs/zh/flight_controller/pixhawk6x.md @@ -188,9 +188,9 @@ Sample Wiring Diagram | UART | 设备 | Port | | ------ | ---------- | ------------------------------- | -| USART1 | /dev/ttyS0 | GPS | +| USART1 | UART | GPS | | USART2 | /dev/ttyS1 | TELEM3 | -| USART3 | /dev/ttyS2 | Debug Console | +| USART3 | /dev/ttyS2 | 调试控制台 | | UART4 | /dev/ttyS3 | UART4 & I2C | | UART5 | /dev/ttyS4 | TELEM2 | | USART6 | /dev/ttyS5 | PX4IO/RC | diff --git a/docs/zh/flight_controller/pixhawk6x_pro.md b/docs/zh/flight_controller/pixhawk6x_pro.md index 02b3d67618..d93f74cf9a 100644 --- a/docs/zh/flight_controller/pixhawk6x_pro.md +++ b/docs/zh/flight_controller/pixhawk6x_pro.md @@ -148,9 +148,9 @@ The [Pixhawk 6X Wiring Quick Start](../assembly/quick_start_pixhawk6x.md) provid | UART | 设备 | Port | | ------ | ---------- | ------------------------------- | -| USART1 | /dev/ttyS0 | GPS | +| USART1 | UART | GPS | | USART2 | /dev/ttyS1 | TELEM3 | -| USART3 | /dev/ttyS2 | Debug Console | +| USART3 | /dev/ttyS2 | 调试控制台 | | UART4 | /dev/ttyS3 | UART4 & I2C | | UART5 | /dev/ttyS4 | TELEM2 | | USART6 | /dev/ttyS5 | PX4IO/RC | @@ -244,7 +244,7 @@ The complete set of supported configurations can be seen in the [Airframes Refer Download [here](https://docs.holybro.com/autopilot/pixhawk-6x-pro/download). -## See Also +## 另见 - [Holybro Docs](https://docs.holybro.com/autopilot/pixhawk-6x-pro) (Holybro) - [Pixhawk 6X Wiring QuickStart](../assembly/quick_start_pixhawk6x.md) diff --git a/docs/zh/flight_controller/pixhawk_series.md b/docs/zh/flight_controller/pixhawk_series.md index 6e98320632..20b01255b5 100644 --- a/docs/zh/flight_controller/pixhawk_series.md +++ b/docs/zh/flight_controller/pixhawk_series.md @@ -100,6 +100,24 @@ At very high level, the main differences are: +### FMUv6 Comparison + +| 特性 | **FMUv6X-RT** | **FMUv6X** | **FMUv6C** | +| ------------------ | ------------------------------- | ------------- | ------------- | +| **FMU MCU** | NXP i.MX RT1176 | STM32H753 | STM32H743V | +| **RAM** | 2 MB | 1 MB | 1 MB | +| **Flash** | 64 MB Octal SPI | 2 MB internal | 2 MB internal | +| **IO MCU** | STM32F103 | STM32F103 | STM32F103 | +| **Secure Element** | NXP SE051 | NXP SE051 | Not supported | +| **PAB Standard** | Supported | Supported | Not supported | +| **Ethernet** | Supported | Supported | Not supported | +| **IMUs** | 3× | 3× | 2× | +| **Barometers** | 2× | 2× | 1× | +| **Magnetometer** | 1× | 1× | 1× | +| **FMU PWM** | 12× | 8× | 8× | +| **IO PWM** | 8× | 8× | 8× | +| **CAN Bus** | 3× | 2× | 2× | + ### Licensing and Trademarks Pixhawk project schematics and reference designs are licensed under [CC BY-SA 3](https://creativecommons.org/licenses/by-sa/3.0/legalcode). diff --git a/docs/zh/flight_controller/pixracer.md b/docs/zh/flight_controller/pixracer.md index 2af7add617..2510ed17b1 100644 --- a/docs/zh/flight_controller/pixracer.md +++ b/docs/zh/flight_controller/pixracer.md @@ -188,14 +188,14 @@ For information about using this port see: ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| UART1 | /dev/ttyS0 | WiFi (ESP8266) | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | | | -| UART7 | CONSOLE | | -| UART8 | SERIAL4 | | +| UART | 设备 | Port | +| ------ | ---------- | --------------------------------- | +| UART | UART | WiFi (ESP8266) | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | | | +| UART7 | CONSOLE | | +| UART8 | SERIAL4 | | diff --git a/docs/zh/flight_controller/raccoonlab_fmu6x.md b/docs/zh/flight_controller/raccoonlab_fmu6x.md index 844a685878..ab1f90407d 100644 --- a/docs/zh/flight_controller/raccoonlab_fmu6x.md +++ b/docs/zh/flight_controller/raccoonlab_fmu6x.md @@ -103,9 +103,9 @@ This autopilot is [supported](../flight_controller/autopilot_pixhawk_standard.md | UART | 设备 | Port | | ------ | ---------- | ------------------------------- | -| USART1 | /dev/ttyS0 | GPS | +| USART1 | UART | GPS | | USART2 | /dev/ttyS1 | TELEM3 | -| USART3 | /dev/ttyS2 | Debug Console | +| USART3 | /dev/ttyS2 | 调试控制台 | | UART4 | /dev/ttyS3 | UART4 & I2C | | UART5 | /dev/ttyS4 | TELEM2 | | USART6 | /dev/ttyS5 | PX4IO/RC | diff --git a/docs/zh/flight_controller/radiolink_pix6.md b/docs/zh/flight_controller/radiolink_pix6.md index c5edb6ee19..61be8aeacb 100644 --- a/docs/zh/flight_controller/radiolink_pix6.md +++ b/docs/zh/flight_controller/radiolink_pix6.md @@ -302,14 +302,14 @@ Recommended modules include: ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| UART1 | /dev/ttyS0 | GPS1 | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | /dev/ttyS3 | GPS2 | -| UART7 | /dev/ttyS4 | Debug Console | -| UART8 | /dev/ttyS5 | PX4IO | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| UART | UART | GPS1 | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | /dev/ttyS3 | GPS2 | +| UART7 | /dev/ttyS4 | 调试控制台 | +| UART8 | /dev/ttyS5 | PX4IO | ## Analog inputs diff --git a/docs/zh/flight_controller/svehicle_e2.md b/docs/zh/flight_controller/svehicle_e2.md index d34e22e553..6bbcb05a8d 100644 --- a/docs/zh/flight_controller/svehicle_e2.md +++ b/docs/zh/flight_controller/svehicle_e2.md @@ -74,16 +74,16 @@ CRSF receiver must be wired to a spare port (UART) on the Flight Controller. The ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ------------- | -| USART1 | /dev/ttyS0 | GPS | -| USART2 | /dev/ttyS1 | TELEM3 | -| USART3 | /dev/ttyS2 | Debug Console | -| UART4 | /dev/ttyS3 | UART4 | -| UART5 | /dev/ttyS4 | TELEM2 | -| USART6 | /dev/ttyS5 | PX4IO/RC | -| UART7 | /dev/ttyS6 | TELEM1 | -| UART8 | /dev/ttyS7 | GPS2 | +| UART | 设备 | Port | +| ------ | ---------- | -------- | +| USART1 | UART | GPS | +| USART2 | /dev/ttyS1 | TELEM3 | +| USART3 | /dev/ttyS2 | 调试控制台 | +| UART4 | /dev/ttyS3 | UART4 | +| UART5 | /dev/ttyS4 | TELEM2 | +| USART6 | /dev/ttyS5 | PX4IO/RC | +| UART7 | /dev/ttyS6 | TELEM1 | +| UART8 | /dev/ttyS7 | GPS2 | ## PWM Output diff --git a/docs/zh/flight_controller/thepeach_k1.md b/docs/zh/flight_controller/thepeach_k1.md index 8f831afaba..3f69940c1a 100644 --- a/docs/zh/flight_controller/thepeach_k1.md +++ b/docs/zh/flight_controller/thepeach_k1.md @@ -50,15 +50,15 @@ It is based on the **Pixhawk-project FMUv3** open hardware design and runs **PX4 ## 串口映射 -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| USART1 | /dev/ttyS0 | IO Processor Debug | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | /dev/ttyS3 | GPS1 | -| USART6 | /dev/ttyS4 | PX4IO | -| UART7 | /dev/ttyS5 | Debug Console | -| UART8 | /dev/ttyS6 | TELEM4 | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| USART1 | UART | IO Processor Debug | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | /dev/ttyS3 | GPS1 | +| USART6 | /dev/ttyS4 | PX4IO | +| UART7 | /dev/ttyS5 | 调试控制台 | +| UART8 | /dev/ttyS6 | TELEM4 | ## 额定电压 diff --git a/docs/zh/flight_controller/thepeach_r1.md b/docs/zh/flight_controller/thepeach_r1.md index 1be40738ba..f4a4cb7281 100644 --- a/docs/zh/flight_controller/thepeach_r1.md +++ b/docs/zh/flight_controller/thepeach_r1.md @@ -56,8 +56,8 @@ It is based on the **Pixhawk-project FMUv3** open hardware design and runs **PX4 | UART | 设备 | Port | | ------ | ---------- | --------------------------------------------- | -| USART1 | /dev/ttyS0 | IO Processor Debug | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | +| USART1 | UART | IO Processor Debug | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | | USART3 | /dev/ttyS2 | TELEM2 (Raspberry pi cm3+) | | UART4 | /dev/ttyS3 | GPS1 | | USART6 | /dev/ttyS4 | PX4IO | diff --git a/docs/zh/flight_modes_fw/hold.md b/docs/zh/flight_modes_fw/hold.md index 437613fbb0..c626e198d9 100644 --- a/docs/zh/flight_modes_fw/hold.md +++ b/docs/zh/flight_modes_fw/hold.md @@ -40,7 +40,7 @@ Hold mode behaviour can be configured using the parameters below. | [NAV_LOITER_RAD](../advanced_config/parameter_reference.md#NAV_LOITER_RAD) | The radius of the loiter circle. | | [NAV_MIN_LTR_ALT](../advanced_config/parameter_reference.md#NAV_MIN_LTR_ALT) | Minimum height for loiter mode (vehicle will ascend to this altitude if mode is engaged at a lower altitude). | -## See Also +## 另见 [Hold Mode (MC)](../flight_modes_mc/hold.md) diff --git a/docs/zh/flight_modes_fw/land.md b/docs/zh/flight_modes_fw/land.md index 0a4220437d..2bb388a0a7 100644 --- a/docs/zh/flight_modes_fw/land.md +++ b/docs/zh/flight_modes_fw/land.md @@ -48,7 +48,7 @@ Land mode behaviour can be configured using the parameters below. | [FW_LND_AIRSPD](../advanced_config/parameter_reference.md#FW_LND_AIRSPD) | The airspeed setpoint. | | [FW_AIRSPD_FLP_SC](../advanced_config/parameter_reference.md#FW_AIRSPD_FLP_SC) | Factor applied to the minimum airspeed when flaps are fully deployed. Necessary if FW_LND_AIRSPD is below FW_AIRSPD_MIN. | -## See Also +## 另见 - [Land Mode (MC)](../flight_modes_mc/land.md) - [Land Mode (VTOL)](../flight_modes_vtol/land.md) diff --git a/docs/zh/flight_modes_fw/mission.md b/docs/zh/flight_modes_fw/mission.md index 63425174ba..e3d9dcb654 100644 --- a/docs/zh/flight_modes_fw/mission.md +++ b/docs/zh/flight_modes_fw/mission.md @@ -374,7 +374,7 @@ In landing mode, the distance sensor is used to determine proximity to the groun | [FW_WING_SPAN](../advanced_config/parameter_reference.md#FW_WING_SPAN) | Wing span of the airframe. | | [FW_WING_HEIGHT](../advanced_config/parameter_reference.md#FW_WING_HEIGHT) | Height of wing from bottom of gear (or belly if no gear). | -## See Also +## 另见 - [Missions](../flying/missions.md) - [包裹投递任务](../flying/package_delivery_mission.md) diff --git a/docs/zh/flight_modes_fw/return.md b/docs/zh/flight_modes_fw/return.md index c04e7619f1..db71badb10 100644 --- a/docs/zh/flight_modes_fw/return.md +++ b/docs/zh/flight_modes_fw/return.md @@ -25,11 +25,6 @@ The default type is recommended. ::: -:::warning -There is a known issue ([PX4-Autopilot#25436](https://github.com/PX4/PX4-Autopilot/issues/25436)) with fixed-wing approaches and landings while in RTL mode. -Please review the issue and verify in simulation that the behavior you get is safe in an RTL landing scenario (if not, consider using rally points). -::: - ## 技术总结 Fixed-wing vehicles use the _mission landing/rally point_ return type by default. @@ -66,7 +61,7 @@ The others are relevant if the destination is a rally point or the home location | [RTL_LOITER_RAD](../advanced_config/parameter_reference.md#RTL_LOITER_RAD) | [Fixed-wing Only] The radius of the loiter circle (at [RTL_LAND_DELAY](#RTL_LAND_DELAY)). | | [MIS_TKO_LAND_REQ](../advanced_config/parameter_reference.md#MIS_TKO_LAND_REQ) | Specify whether a mission landing or takeoff pattern is required. Fixed wings generally require this. | -## See Also +## 另见 - [Return Mode (Generic)](../flight_modes/return.md) - [Return Mode (Multicopter)](../flight_modes_mc/return.md) diff --git a/docs/zh/flight_modes_fw/takeoff.md b/docs/zh/flight_modes_fw/takeoff.md index 593c1f61e0..4561d8c8e4 100644 --- a/docs/zh/flight_modes_fw/takeoff.md +++ b/docs/zh/flight_modes_fw/takeoff.md @@ -142,7 +142,7 @@ Runway takeoff is affected by the following parameters: | [FW_WING_SPAN](../advanced_config/parameter_reference.md#FW_WING_SPAN) | The wingspan of the vehicle. Used to prevent wingstrikes. | | [FW_WING_HEIGHT](../advanced_config/parameter_reference.md#FW_WING_HEIGHT) | The height of the wings above ground (ground clearance). Used to prevent wingstrikes. | -## See Also +## 另见 - [Takeoff Mode (MC)](../flight_modes_mc/takeoff.md) - [Planning a mission takeoff](../flight_modes_fw/mission.md#mission-takeoff) diff --git a/docs/zh/flight_modes_mc/hold.md b/docs/zh/flight_modes_mc/hold.md index e65feb8774..605746c6f0 100644 --- a/docs/zh/flight_modes_mc/hold.md +++ b/docs/zh/flight_modes_mc/hold.md @@ -43,6 +43,6 @@ Hold mode behaviour can be configured using the parameters below. -## See Also +## 另见 [Hold Mode (FW)](../flight_modes_fw/hold.md) diff --git a/docs/zh/flight_modes_mc/land.md b/docs/zh/flight_modes_mc/land.md index f3cfe60a07..70f6c5d843 100644 --- a/docs/zh/flight_modes_mc/land.md +++ b/docs/zh/flight_modes_mc/land.md @@ -38,7 +38,7 @@ Land mode behaviour can be configured using the parameters below. | [COM_RC_OVERRIDE](../advanced_config/parameter_reference.md#COM_RC_OVERRIDE) | Controls whether stick movement on a multicopter (or VTOL in MC mode) causes a mode change to [Position mode](../flight_modes_mc/position.md). 可以分别为自动模式和 offboard 模式启用此功能,默认情况下在自动模式下启用此功能。 | | [COM_RC_STICK_OV](../advanced_config/parameter_reference.md#COM_RC_STICK_OV) | The amount of stick movement that causes a transition to [Position mode](../flight_modes_mc/position.md) (if [COM_RC_OVERRIDE](#COM_RC_OVERRIDE) is enabled). | -## See Also +## 另见 - [Land Mode (FW)](../flight_modes_fw/land.md) - [Land Mode (VTOL)](../flight_modes_vtol/land.md) diff --git a/docs/zh/flight_modes_mc/mission.md b/docs/zh/flight_modes_mc/mission.md index 77cd340405..7b8b03cb2d 100644 --- a/docs/zh/flight_modes_mc/mission.md +++ b/docs/zh/flight_modes_mc/mission.md @@ -228,7 +228,7 @@ If a mission with no takeoff mission item is started, the vehicle will ascend to If the vehicle is already flying when the mission is started, a takeoff mission item is treated as a normal waypoint. -## See Also +## 另见 - [Missions](../flying/missions.md) - [包裹投递任务](../flying/package_delivery_mission.md) diff --git a/docs/zh/flight_modes_mc/position.md b/docs/zh/flight_modes_mc/position.md index 023c8b95b8..f32b4f357b 100644 --- a/docs/zh/flight_modes_mc/position.md +++ b/docs/zh/flight_modes_mc/position.md @@ -81,6 +81,6 @@ All the parameters in the [Multicopter Position Control](../advanced_config/para If the estimate falls below acceptable levels, for example due to GPS loss, this may trigger a [Position (GPS) Loss Failsafe](../config/safety.md#position-gnss-loss-failsafe). 如果估计值低于可接受的水平,例如由于 GPS 丢失,这可能会触发位置 (GPS) 丢失故障保护 根据配置,是否有遥控器,以及是否有足够的高度估计,PX4 可能会切换到高度模式、手动模式、降落模式或终止。 -## See Also +## 另见 - [Position Slow Mode](../flight_modes_mc/position_slow.md) diff --git a/docs/zh/flight_modes_mc/position_slow.md b/docs/zh/flight_modes_mc/position_slow.md index d89bf42aff..24a81c5985 100644 --- a/docs/zh/flight_modes_mc/position_slow.md +++ b/docs/zh/flight_modes_mc/position_slow.md @@ -88,6 +88,6 @@ The value can be updated from a message at any time, and is latched until either Note that PX4 does not provide velocity limit telemetry (i.e. it does not support streaming the [VELOCITY_LIMITS](https://mavlink.io/en/messages/development.html#VELOCITY_LIMITS) message). -## See Also +## 另见 - [Position Slow Mode](../flight_modes_mc/position.md) diff --git a/docs/zh/flight_modes_mc/return.md b/docs/zh/flight_modes_mc/return.md index a933ab4567..f24fd32ddc 100644 --- a/docs/zh/flight_modes_mc/return.md +++ b/docs/zh/flight_modes_mc/return.md @@ -70,7 +70,7 @@ The parameters that are relevant to multicopter (assuming the [RTL_TYPE](../adva | [COM_RC_OVERRIDE](../advanced_config/parameter_reference.md#COM_RC_OVERRIDE) | Controls whether stick movement on a multicopter (or VTOL in MC mode) causes a mode change to [Position mode](../flight_modes_mc/position.md) (except when vehicle is handling a critical battery failsafe). 可以分别为自动模式和 offboard 模式启用此功能,默认情况下在自动模式下启用此功能。 | | [COM_RC_STICK_OV](../advanced_config/parameter_reference.md#COM_RC_STICK_OV) | The amount of stick movement that causes a transition to [Position mode](../flight_modes_mc/position.md) (if [COM_RC_OVERRIDE](#COM_RC_OVERRIDE) is enabled). | -## See Also +## 另见 - [Return Mode (Generic)](../flight_modes/return.md) - [Return Mode (Fixed-Wing)](../flight_modes_fw/return.md) diff --git a/docs/zh/flight_modes_mc/takeoff.md b/docs/zh/flight_modes_mc/takeoff.md index beed798c98..0cb1d3460f 100644 --- a/docs/zh/flight_modes_mc/takeoff.md +++ b/docs/zh/flight_modes_mc/takeoff.md @@ -36,7 +36,7 @@ Takeoff is affected by the following parameters: | [COM_RC_OVERRIDE](../advanced_config/parameter_reference.md#COM_RC_OVERRIDE) | Controls whether stick movement on a multicopter (or VTOL in MC mode) causes a mode change to [Position mode](../flight_modes_mc/position.md). 可以分别为自动模式和 offboard 模式启用此功能,默认情况下在自动模式下启用此功能。 | | [COM_RC_STICK_OV](../advanced_config/parameter_reference.md#COM_RC_STICK_OV) | The amount of stick movement that causes a transition to [Position mode](../flight_modes_mc/position.md) (if [COM_RC_OVERRIDE](#COM_RC_OVERRIDE) is enabled) | -## See Also +## 另见 - [Throw Launch (MC)](../flight_modes_mc/throw_launch.md) - [Takeoff Mode (FW)](../flight_modes_fw/takeoff.md) diff --git a/docs/zh/flight_modes_mc/throw_launch.md b/docs/zh/flight_modes_mc/throw_launch.md index 8bfa6c55f3..d421442b5f 100644 --- a/docs/zh/flight_modes_mc/throw_launch.md +++ b/docs/zh/flight_modes_mc/throw_launch.md @@ -95,7 +95,7 @@ The following parameters can be used to enable and configure throw launch: - [COM_THROW_SPEED](../advanced_config/parameter_reference.md#COM_THROW_SPEED) determines the minimum speed the aircraft should reach to detect the throw. If it is not reached, the engines will not turn on. -## See Also +## 另见 - [Takeoff Mode (Fixed-Wing) > Catapult/Hand Launch](../flight_modes_fw/takeoff.md#catapult-hand-launch). diff --git a/docs/zh/flight_modes_vtol/land.md b/docs/zh/flight_modes_vtol/land.md index 681bcf18fd..3da643d652 100644 --- a/docs/zh/flight_modes_vtol/land.md +++ b/docs/zh/flight_modes_vtol/land.md @@ -17,7 +17,7 @@ The VTOL-specific parameters are: | ---------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | | [NAV_FORCE_VT](../advanced_config/parameter_reference.md#NAV_FORCE_VT) | Force VTOL to takeoff and land as a multicopter (default: true) | -## See Also +## 另见 - [Land Mode (MC)](../flight_modes_mc/land.md) - [Land Mode (FW)](../flight_modes_fw/land.md) diff --git a/docs/zh/flight_modes_vtol/mission.md b/docs/zh/flight_modes_vtol/mission.md index ed4ffa878d..ca31540873 100644 --- a/docs/zh/flight_modes_vtol/mission.md +++ b/docs/zh/flight_modes_vtol/mission.md @@ -49,7 +49,7 @@ After transitioning the vehicle heads towards the 3D position defined in the mis A VTOL mission requires a `VTOL Takeoff` mission item (`MAV_CMD_NAV_VTOL_TAKEOFF`) to takeoff (or a `MAV_CMD_NAV_TAKEOFF` when the vehicle is in MC mode); if however the vehicle is already flying when the mission is started the takeoff item will be treated as a normal waypoint. -## See Also +## 另见 - [Mission Mode (MC)](../flight_modes_mc/mission.md) - [Mission Mode (FW)](../flight_modes_fw/mission.md) diff --git a/docs/zh/flight_modes_vtol/return.md b/docs/zh/flight_modes_vtol/return.md index 4905e2654e..34876f9f68 100644 --- a/docs/zh/flight_modes_vtol/return.md +++ b/docs/zh/flight_modes_vtol/return.md @@ -81,7 +81,7 @@ The others are relevant if the destination is a rally point or the home location | [RTL_LOITER_RAD](../advanced_config/parameter_reference.md#RTL_LOITER_RAD) | [Fixed-wing Only] The radius of the loiter circle (at [RTL_LAND_DELAY](#RTL_LAND_DELAY). | | [MIS_TKO_LAND_REQ](../advanced_config/parameter_reference.md#MIS_TKO_LAND_REQ) | Specify whether a mission landing or takeoff pattern is _required_. Generally fixed-wing vehicles set this to require a landing pattern but VTOL do not. | -## See Also +## 另见 - [Return Mode (Generic)](../flight_modes/return.md) - [Return Mode (Multicopter)](../flight_modes_mc/return.md) diff --git a/docs/zh/flying/basic_flying_mc.md b/docs/zh/flying/basic_flying_mc.md index 8bda6719e8..2f2cd8ac60 100644 --- a/docs/zh/flying/basic_flying_mc.md +++ b/docs/zh/flying/basic_flying_mc.md @@ -94,7 +94,7 @@ The following three modes are highly recommended for new users: You can also engage automatic modes on the _QGroundControl_ main flight screen. ::: -## See Also +## 另见 - [Terrain Follow/Hold & Range Assistance](../flying/terrain_following_holding.md) — How to enable terrain following - [Missions](../flying/missions.md) diff --git a/docs/zh/frames_multicopter/dji_f450_cuav_5nano.md b/docs/zh/frames_multicopter/dji_f450_cuav_5nano.md index d0310b1cb2..325680e123 100644 --- a/docs/zh/frames_multicopter/dji_f450_cuav_5nano.md +++ b/docs/zh/frames_multicopter/dji_f450_cuav_5nano.md @@ -43,8 +43,8 @@ This section lists all hardware for the frame. | DJI F450 Bottom plate | 1 | | DJI F450 Top plate | 1 | | DJI F450 legs with landing gear | 4 | -| M3\*8 screws | 18 | -| M2 5\*6 screws | 24 | +| M3\*8螺丝 | 18 | +| M2.5\*6 螺丝 | 24 | | Velcro Battery Strap | 1 | | DJI Phantom Built-in Nut Upgrade Propellers 9.4x5 | 1 | diff --git a/docs/zh/frames_multicopter/dji_f450_cuav_5plus.md b/docs/zh/frames_multicopter/dji_f450_cuav_5plus.md index 8fbd134973..60e86e05be 100644 --- a/docs/zh/frames_multicopter/dji_f450_cuav_5plus.md +++ b/docs/zh/frames_multicopter/dji_f450_cuav_5plus.md @@ -43,8 +43,8 @@ This section lists all hardware for the frame. | DJI F450 Bottom plate | 1 | | DJI F450 Top plate | 1 | | DJI F450 legs with landing gear | 4 | -| M3\*8 screws | 18 | -| M2 5\*6 screws | 24 | +| M3\*8螺丝 | 18 | +| M2.5\*6 螺丝 | 24 | | Velcro Battery Strap | 1 | | DJI Phantom Built-in Nut Upgrade Propellers 9.4x5 | 1 | diff --git a/docs/zh/frames_multicopter/holybro_s500_v2_pixhawk4.md b/docs/zh/frames_multicopter/holybro_s500_v2_pixhawk4.md index 57b595740f..5f1a97d4ff 100644 --- a/docs/zh/frames_multicopter/holybro_s500_v2_pixhawk4.md +++ b/docs/zh/frames_multicopter/holybro_s500_v2_pixhawk4.md @@ -3,88 +3,88 @@ This topic provides full instructions for building the kit and configuring PX4 using _QGroundControl_. :::info -Holybro initially supplied this kit with a [Holybro Pixhawk 4](../flight_controller/pixhawk4.md), but at time of writing this has been upgraded to a more recent Pixhawk (6C). -This build log is still relevant as the kit assembly is virtually the same, and likely to remain so as the flight controller is upgraded. +Holybro最初提供了和[Holybro Pixhawk 4](../flight_controller/pixhawk4.md)飞控一起提供这个套件, 但在撰写本文档时,这个系统已升级为较新的 Pixhawk (6C)。 +这个构建记录仍然具有相关性,因为套装组件几乎是一样的,而且随着飞行控制器升级,很可能仍然如此。 ::: ## Key information -- **Frame:** Holybro S500 -- **Flight controller:** [Pixhawk 4](../flight_controller/pixhawk4.md) -- **Assembly time (approx.):** 90 minutes (45 minutes for frame, 45 minutes for autopilot installation/configuration) +- **机架:** Holybro S500 +- **飞行控制器:** [Pixhawk 4](../flight_controller/pixhawk4.md) +- **大约组装时间:** 90 分钟 (机架组装45分钟,飞控安装和配置45分钟) -![Full S500 Kit](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_hero.png) +![完整的S500套件](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_hero.png) ## Bill of materials -The Holybro [S500 V2 Kit](https://holybro.com/collections/s500/products/s500-v2-development-kit) includes almost all the required components: +Holybro [S500 V2 套件](https://holybro.com/collections/s500/products/s500-v2-development-kit) 包含几乎所有需要的组件: -- A recent Pixhawk autopilot - - For this log it was Pixhawk 4 but far more recent versions are now included. -- Power Management PM02(Assembled) -- ARM adopts high strength plastics -- Motors - 2216 KV880( V2 Update) -- Propeller 1045( V2 Update) -- Pixhawk4 GPS +- 一个近期发布的 Pixhawk 飞控 + - 对于这个装机日志,它是 Pixhawk 4,但是现在的套件包含了更新的版本。 +- 电源管理模块 PM02(已组装) +- 采用高强度塑料的机臂 +- 马达 - 2216 KV880(V2 版本) +- 1045桨叶(V2 版本) +- Pixhawk4 GPS模组 - Fully assembled Power Management Board with ESCs -- 433 MHz / 915 MHz [Holybro Telemetry Radio](../telemetry/holybro_sik_radio.md) -- Power and Radio Cables -- Battery Straps -- Dimensions:383_385_240mm -- Wheelbase:480mm +- 433 MHz / 915 MHz [Holybro数传电台](../telemetry/holybro_sik_radio.md) +- 电源线和信号线 +- 电池绑带 +- 尺寸:383_385_240毫米 +- 轴距:480毫米 :::info -No LiPo battery is included. -In addition, we use a FrSky Taranis controller. +不包含锂电池。 +此外,我们使用一个FrSky Taranis遥控。 ::: ## 硬件 -| Item Description | Quantity | -| --------------------------------------------- | -------- | -| Wheelbase: 480mm | 1 | -| Arms | 4 | -| Set of Landing Gear | 2 | -| M3\*8 screws | 18 | -| M2 5\*6 screws | 24 | -| Battery Straps | 1 | -| Propeller 1045 (V2 Update) | 1 | +| 物品描述 | Quantity | +| -------------------------------- | -------- | +| 轴距:480毫米 | 1 | +| 机臂 | 4 | +| 起落架 | 2 | +| M3\*8螺丝 | 18 | +| M2.5\*6 螺丝 | 24 | +| 电池绑带 | 1 | +| 1045桨叶(V2 版本) | 1 | -![S500 Hardware](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_hardware.jpg) +![S500硬件](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_hardware.jpg) -## Package +## 包装 -| Items | Package | -| ---------------------------------------------------- | ------- | -| Pixhawk 4 | 1 | -| Pixhawk4 GPS MODULE | 1 | -| I2C splitter Board | 2 | -| 6 to 6 pin cable (power) | 3 | -| 4 to 4 pin cable (CAN) | 2 | -| 6 to 4 pin cable (Data) | 1 | -| 10 to 10 pin cable (PWM) | 2 | -| 8 to 8 pin cable(AUX) | 1 | -| 7 to 7 pin cable(SPI) | 1 | -| 6 to 6 pin cable(Debug) | 1 | -| PPM/SBUS out cable | 1 | -| XSR receiver cable | 1 | -| DSMX receiver cable | 1 | -| SBUS receiver cable | 1 | -| USB cable | 1 | -| 'X'type folding pedestal mount | 1 | -| 70mm & 140mm carbon rod standoff | 2 | -| 6\*3 2.54mm pitch Horizontal Pin | 1 | -| 8\*3 2.54mm pitch Horizontal Pin | 2 | -| Foam Set | 1 | -| Pixhawk4 Quick Start Guide | 1 | -| Pixhawk4 Pinouts | 1 | -| GPS Quick Start Guide | 1 | +| 物品 | 包装 | +| ---------------------------------------------------- | -- | +| Pixhawk 4 | 1 | +| Pixhawk4 GPS MODULE | 1 | +| I2C splitter Board | 2 | +| 6 to 6 pin cable (power) | 3 | +| 4 to 4 pin cable (CAN) | 2 | +| 6 to 4 pin cable (Data) | 1 | +| 10 to 10 pin cable (PWM) | 2 | +| 8 to 8 pin cable(AUX) | 1 | +| 7 to 7 pin cable(SPI) | 1 | +| 6 to 6 pin cable(Debug) | 1 | +| PPM/SBUS out cable | 1 | +| XSR receiver cable | 1 | +| DSMX receiver cable | 1 | +| SBUS receiver cable | 1 | +| USB cable | 1 | +| 'X'type folding pedestal mount | 1 | +| 70mm & 140mm carbon rod standoff | 2 | +| 6\*3 2.54mm pitch Horizontal Pin | 1 | +| 8\*3 2.54mm pitch Horizontal Pin | 2 | +| Foam Set | 1 | +| Pixhawk4 Quick Start Guide | 1 | +| Pixhawk4 Pinouts | 1 | +| GPS Quick Start Guide | 1 | ![S500 Package Contents](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_package.jpg) ### Electronics -| Item Description | Quantity | +| 物品描述 | Quantity | | ---------------------------------------------------------- | -------- | | Pixhawk 4 autopilot (PM06 not included) | 1 | | Power Management PM02 (Assembled) | 1 | @@ -112,9 +112,9 @@ The following tools are used in this assembly: ## 组装 -Estimate time to assemble is 90 minutes, about 45 minutes for frame assembly and 45 minutes installing and configuring the autopilot in QGroundControl. +估计的组装时间是90分钟,组装机架约45分钟,安装和在QGroundControl配置飞控约45分钟。 -1. Assembling the Landing Gear. +1. 安装起落架。 We are going to start by assembling the landing gear to the vertical pole. Unscrew the landing gear screws and insert the vertical pole as shown below. ![Figure 1](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_fig1.jpg) @@ -123,27 +123,27 @@ Estimate time to assemble is 90 minutes, about 45 minutes for frame assembly and 2. Assemble the Power Management Board to the landing gear. Screw the landing gear with a vertical pole to the Fully assembled Power Management Board. -The Board has 4 holes (see arrows below). +板子有4个洞(见下面的箭头)。 ![Figure 3](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_fig3.jpg) -Connect with the M3X8 screws, a total of 8 pieces, 4 on each side. +用 M3X8 螺丝连接,总共8个,每侧4个。 ![Figure 4](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_fig4.jpg) -1. Assemble the arms to the Power Management Board. - Attach the arm to the Power Management Board. +1. 把机臂装到电源管理板上。 + 把机臂装到电源管理板上。 ![Figure 6](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_fig7.jpg) ![Figure 7](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_fig8.jpg) - Use M2 5X6 screws a total of 2 in each arm. - Insert the screws from the bottom of the plate. + 在每个臂上使用2个M2.5X6螺丝。 + 从板块底部插入螺丝。 ![Figure 8](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_fig9.jpg) - Make sure the ESC cables run through the middle of the arm. + 确保电调的电线穿过机臂中间。 ![Figure 9](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_fig91.jpg) @@ -255,11 +255,11 @@ Connect with the M3X8 screws, a total of 8 pieces, 4 on each side. 9. Pixhawk 4 wiring. The Pixhawk 4, which has several different wires and connections with it. Included below is a picture of every wire needed with the Pixhawk and how it looks when connected. -10. Plugin Telemetry and GPS module to the flight controller as seen in Figure 37; plug in the RC receiver, all 4 ESCs to the flight controller as well as the power module. +10. 如图37所示,把数传模块和GPS模块接到飞行控制器上;连接遥控接收器、4 个电调以及电源模块到飞行控制器上。 ![Figure 37](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_fig37.png) -Fully assembled, the kit looks as shown below: +装好以后套件看起来像下面这样: ![Pixhawk Assembled](../../assets/airframes/multicopter/s500_holybro_pixhawk4/s500_pixhawk.jpg) @@ -274,16 +274,16 @@ _QGroundControl_ is used to install the PX4 autopilot and configure/tune it for Full instructions for installing and configuring PX4 can be found in [Basic Configuration](../config/index.md). ::: -First update the firmware and airframe: +首先更新固件和机架配置: - [Firmware](../config/firmware.md) - [Airframe](../config/airframe.md) - You will need to select the _Holybro S500_ airframe (**Quadrotor x > Holybro S500**). + 您需要选择 _Holybro S500_ 机架(**Quadrotor x > Holybro S500**)。 ![QGroundControl - Select HolyBro X500 airframe](../../assets/airframes/multicopter/s500_holybro_pixhawk4/qgc_airframe_holybro_s500.png) -Then set the actuator outputs: +然后设置执行器输出: - [Actuators](../config/actuators.md) - You should not need to update the vehicle geometry (as this is a preconfigured airframe). @@ -308,7 +308,7 @@ Ideally you should also do: ## 调试 Airframe selection sets _default_ autopilot parameters for the frame. -These are good enough to fly with, but it is a good idea to tune the parameters for a specific frame build. +这些足以让它起飞,但是为你的特定框架调整专有参数是一个好主意。 For instructions on how, start from [Autotune](../config/autotune_mc.md). diff --git a/docs/zh/frames_multicopter/holybro_x500V2_pixhawk5x.md b/docs/zh/frames_multicopter/holybro_x500V2_pixhawk5x.md index 723a3bb23b..a898733d96 100644 --- a/docs/zh/frames_multicopter/holybro_x500V2_pixhawk5x.md +++ b/docs/zh/frames_multicopter/holybro_x500V2_pixhawk5x.md @@ -2,7 +2,7 @@ :::info Holybro initially supplied this kit with a [Pixhawk 5X](../flight_controller/pixhawk5x.md), but at time of writing this has been upgraded to a [Holybro Pixhawk 6C](../flight_controller/pixhawk6c.md). -This build log is still relevant as the kit assembly is virtually the same, and likely to remain so as the flight controller is upgraded. +这个构建记录仍然具有相关性,因为套装组件几乎是一样的,而且随着飞行控制器升级,很可能仍然如此。 ::: This topic provides full instructions for building the [Holybro X500 V2 ARF Kit](https://holybro.com/collections/x500-kits) and configuring PX4 using _QGroundControl_. @@ -71,15 +71,15 @@ _Figure 1_: X500 V2 ARF Kit what's inside ### Electronics -| Item Description | Quantity | -| ------------------------------------------------------------------------------ | -------- | -| Pixhawk5x & Assorted Cables | 1 | -| M8N GPS Module | 1 | -| Power Module PM02D (with pre-soldered ESC power cables) | 1 | -| Motors 2216 KV880(V2 Update) | 4 | -| Holybro BLHeli S ESC 20A x4 | 1 | -| Holybro BLHeli S ESC 20A x4 | 1 | -| 433 MHz / 915 MHz [Holybro Telemetry Radio](../telemetry/holybro_sik_radio.md) | 1 | +| 物品描述 | Quantity | +| -------------------------------------------------------------------------- | -------- | +| Pixhawk5x & Assorted Cables | 1 | +| M8N GPS Module | 1 | +| Power Module PM02D (with pre-soldered ESC power cables) | 1 | +| Motors 2216 KV880(V2 Update) | 4 | +| Holybro BLHeli S ESC 20A x4 | 1 | +| Holybro BLHeli S ESC 20A x4 | 1 | +| 433 MHz / 915 MHz [Holybro数传电台](../telemetry/holybro_sik_radio.md) | 1 | ### Tools needed @@ -231,7 +231,7 @@ Ideally you should also do: ## 调试 Airframe selection sets _default_ autopilot parameters for the frame. -These are good enough to fly with, but it is a good idea to tune the parameters for a specific frame build. +这些足以让它起飞,但是为你的特定框架调整专有参数是一个好主意。 For instructions on how, start from [Autotune](../config/autotune_mc.md). diff --git a/docs/zh/frames_multicopter/holybro_x500_pixhawk4.md b/docs/zh/frames_multicopter/holybro_x500_pixhawk4.md index babc343497..e9c021c823 100644 --- a/docs/zh/frames_multicopter/holybro_x500_pixhawk4.md +++ b/docs/zh/frames_multicopter/holybro_x500_pixhawk4.md @@ -2,7 +2,7 @@ :::info Holybro initially supplied this kit with a [Holybro Pixhawk 4](../flight_controller/pixhawk4.md)), but at time of writing this has been upgraded to a [Holybro Pixhawk 6C](../flight_controller/pixhawk6c.md). -This build log is still relevant as the kit assembly is virtually the same, and likely to remain so as the flight controller is upgraded. +这个构建记录仍然具有相关性,因为套装组件几乎是一样的,而且随着飞行控制器升级,很可能仍然如此。 ::: This topic provides full instructions for building the kit and configuring PX4 using _QGroundControl_. @@ -10,7 +10,7 @@ This topic provides full instructions for building the kit and configuring PX4 u ## Key information - **Full Kit:** [Holybro X500 Kit](https://holybro.com/products/px4-development-kit-x500-v2) -- **Flight controller:** [Pixhawk 4](../flight_controller/pixhawk4.md) +- **飞行控制器:** [Pixhawk 4](../flight_controller/pixhawk4.md) - **Assembly time (approx.):** 3.75 hours (180 minutes for frame, 45 minutes for autopilot installation/configuration) ![Full X500 Kit](../../assets/airframes/multicopter/x500_holybro_pixhawk4/x500_hero.png) @@ -26,10 +26,10 @@ The Holybro [X500 Kit](https://holybro.com/products/px4-development-kit-x500-v2) - Holybro BLHeli S ESC 20A x4 (superseded - check [spare parts list](https://holybro.com/products/spare-parts-x500-v2-kit) for current version). - Propellers - 1045 x4 (superseded - check [spare parts list](https://holybro.com/products/spare-parts-x500-v2-kit) for current version). - Battery Strap -- Power and Radio Cables +- 电源线和信号线 - Wheelbase - 500 mm - Dimensions - 410x410x300 mm -- 433 MHz / 915 MHz [Holybro Telemetry Radio](../telemetry/holybro_sik_radio.md) +- 433 MHz / 915 MHz [Holybro数传电台](../telemetry/holybro_sik_radio.md) Additionally you will need a battery and receiver ([compatible radio system](../getting_started/rc_transmitter_receiver.md)) if you want to control the drone manually. @@ -55,14 +55,14 @@ This section lists all hardware for the frame and the autopilot installation. ### Electronics -| Item Description | Quantity | -| ------------------------------------------------------------------------------ | -------- | -| Pixhawk4 & Assorted Cables | 1 | -| Pixhawk4 GPS Module | 1 | -| Power Management PM07 (with pre-soldered ESC power cables) | 1 | -| Motors 2216 KV880(V2 Update) | 4 | -| Holybro BLHeli S ESC 20A x4 | 1 | -| 433 MHz / 915 MHz [Holybro Telemetry Radio](../telemetry/holybro_sik_radio.md) | 1 | +| 物品描述 | Quantity | +| ----------------------------------------------------------------------------- | -------- | +| Pixhawk4 & Assorted Cables | 1 | +| Pixhawk4 GPS Module | 1 | +| Power Management PM07 (with pre-soldered ESC power cables) | 1 | +| Motors 2216 KV880(V2 Update) | 4 | +| Holybro BLHeli S ESC 20A x4 | 1 | +| 433 MHz / 915 MHz [Holybro数传电台](../telemetry/holybro_sik_radio.md) | 1 | ### Tools needed @@ -223,7 +223,7 @@ First update the firmware, airframe, and actuator mappings: - [Airframe](../config/airframe.md) - You will need to select the _Holybro S500_ airframe (**Quadrotor x > Holybro S500**). + 您需要选择 _Holybro S500_ 机架(**Quadrotor x > Holybro S500**)。 ![QGroundControl - Select HolyBro X500 airframe](../../assets/airframes/multicopter/s500_holybro_pixhawk4/qgc_airframe_holybro_s500.png) @@ -250,7 +250,7 @@ Ideally you should also do: ## 调试 Airframe selection sets _default_ autopilot parameters for the frame. -These are good enough to fly with, but it is a good idea to tune the parameters for a specific frame build. +这些足以让它起飞,但是为你的特定框架调整专有参数是一个好主意。 For instructions on how, start from [Autotune](../config/autotune_mc.md). diff --git a/docs/zh/frames_multicopter/holybro_x500v2_pixhawk6c.md b/docs/zh/frames_multicopter/holybro_x500v2_pixhawk6c.md index a7a4bec9bb..4b45fdeeab 100644 --- a/docs/zh/frames_multicopter/holybro_x500v2_pixhawk6c.md +++ b/docs/zh/frames_multicopter/holybro_x500v2_pixhawk6c.md @@ -84,7 +84,7 @@ Note that the ESC connectors are color-coded and must be inserted in the PWM out ![esc_connector_pixhawk6c](../../assets/airframes/multicopter/x500_v2_holybro_pixhawk6c/esc_connector.jpg) -### Arms +### 机臂 **Screw-** Socket Cap Screw M3\*38 16pcs | Flange Locknut M3 16pcs @@ -207,7 +207,7 @@ Ideally you should also do: ## 调试 Airframe selection sets _default_ autopilot parameters for the frame. -These are good enough to fly with, but it is a good idea to tune the parameters for a specific frame build. +这些足以让它起飞,但是为你的特定框架调整专有参数是一个好主意。 For instructions on how, start from [Auto-tune](../config/autotune_mc.md). diff --git a/docs/zh/frames_multicopter/qav_r_5_kiss_esc_racer.md b/docs/zh/frames_multicopter/qav_r_5_kiss_esc_racer.md index 9fbeb29890..31a05cffaf 100644 --- a/docs/zh/frames_multicopter/qav_r_5_kiss_esc_racer.md +++ b/docs/zh/frames_multicopter/qav_r_5_kiss_esc_racer.md @@ -270,6 +270,6 @@ Ideally you should also do: ### 调试 Airframe selection sets _default_ autopilot parameters for the frame. -These are good enough to fly with, but it is a good idea to tune the parameters for a specific frame build. +这些足以让它起飞,但是为你的特定框架调整专有参数是一个好主意。 For instructions on how, start from [Autotune](../config/autotune_mc.md). diff --git a/docs/zh/frames_rover/index.md b/docs/zh/frames_rover/index.md index 76b1749d4f..7c6b4bffbc 100644 --- a/docs/zh/frames_rover/index.md +++ b/docs/zh/frames_rover/index.md @@ -55,7 +55,7 @@ Each wheel is driven by its own motor, and by controlling the speed and directio ![Mecanum rover](../../assets/airframes/rover/rover_mecanum.png) -## See Also +## 另见 - [Drive Modes](../flight_modes_rover/index.md) - [Configuration/Tuning](../config_rover/index.md) diff --git a/docs/zh/gps_compass/ark_sam_gps.md b/docs/zh/gps_compass/ark_sam_gps.md index 8354054a20..8c2301c671 100644 --- a/docs/zh/gps_compass/ark_sam_gps.md +++ b/docs/zh/gps_compass/ark_sam_gps.md @@ -56,6 +56,6 @@ The module should be plug-n-play when used with the `GPS2` port on most flight c | 5 | SDA | 3.3V | | 6 | GND | GND | -## See Also +## 另见 - [ARK SAM GPS Documentation](https://arkelectron.gitbook.io/ark-documentation/gps/ark-sam-gps) (ARK Docs) diff --git a/docs/zh/gps_compass/index.md b/docs/zh/gps_compass/index.md index 660cf102b3..3f846a2f4a 100644 --- a/docs/zh/gps_compass/index.md +++ b/docs/zh/gps_compass/index.md @@ -197,11 +197,21 @@ It is possible to have low DOP (good satellite geometry) but still have high EPH EPH/EPV values therefore provide a more immediate and practical estimate of the actual GPS accuracy you can expect under current conditions. +### GNSS Position Fusion + +GNSS position fusion will not begin until yaw alignment is established. +If a magnetometer is available, the EKF aligns yaw using the magnetic heading, allowing GPS position fusion to start soon after boot. +If no magnetometer is present, the system must rely on GPS yaw (from a dual-antenna setup) or movement-based yaw estimation. +Until one of these provides a valid heading, the EKF will not start GPS position fusion, and the vehicle will remain in a “no position” state even though attitude data is valid. +This behavior prevents large position errors that could occur when the yaw reference is uncertain. + ## 开发人员信息 - GPS/RTK-GPS - [RTK-GPS](../advanced/rtk_gps.md) + - [PPS Time Synchronization](../advanced/pps_time_sync.md) - [GPS driver](../modules/modules_driver.md#gps) + - [PPS driver](../modules/modules_driver.md#pps-capture) - [DroneCAN Example](../dronecan/index.md) - 罗盘 - [Driver source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/magnetometer) (Compasses) diff --git a/docs/zh/gps_compass/magnetometer.md b/docs/zh/gps_compass/magnetometer.md index 4fd06a5cc1..0435210bec 100644 --- a/docs/zh/gps_compass/magnetometer.md +++ b/docs/zh/gps_compass/magnetometer.md @@ -40,6 +40,7 @@ This list contains stand-alone magnetometer modules (without GNSS). | 设备 | 罗盘 | DroneCan | | :--------------------------------------------------------------------------------------------------------------- | :----: | :-------------------------: | +| [ARK MAG](https://arkelectron.com/product/ark-mag/) | RM3100 | ✓ | | [Avionics Anonymous UAVCAN Magnetometer](https://www.tindie.com/products/avionicsanonymous/uavcan-magnetometer/) | ? | | | [Holybro DroneCAN RM3100 Compass/Magnetometer](https://holybro.com/products/dronecan-rm3100-compass) | RM3100 | ✓ | | [RaccoonLab DroneCAN/Cyphal Magnetometer RM3100](https://holybro.com/products/dronecan-rm3100-compass) | RM3100 | ✓ | diff --git a/docs/zh/hardware/serial_port_mapping.md b/docs/zh/hardware/serial_port_mapping.md index 9799e398b4..3a3bdca5b9 100644 --- a/docs/zh/hardware/serial_port_mapping.md +++ b/docs/zh/hardware/serial_port_mapping.md @@ -1,27 +1,27 @@ # 串口映射 -This topic shows how to determine the mapping between USART/UART serial port device names (e.g. "ttyS0") and the associated ports on a flight controller, such as `TELEM1`, `TELEM2`, `GPS1`, `RC SBUS`, `Debug console`. +本主题说明如何确定USART/UART串行端口(下称串口)设备名称(例如“ttyS0”)与飞行控制器上对应端口(如`TELEM1`、`TELEM2`、`GPS1`、`RC SBUS`、`调试控制台(Debug console)`)之间的映射关系。 -The instructions are used to generate serial port mapping tables in flight controller documentation. -For example: [Pixhawk 4 > Serial Port Mapping](../flight_controller/pixhawk4.md#serial-port-mapping). +这份说明用于在飞行控制器文档中生成串行端口映射表。 +例如: [Pixhawk 4 > Serial Port Mapping](../flight_controller/pixhawk4.md#serial-port-mapping)。 :::info -The function assigned to each port does not _have to_ match the name (in most cases), and is set using a [Serial Port Configuration](../peripherals/serial_configuration.md). -Usually the port function is configured to match the name, which is why the port labelled `GPS1` will work with a GPS out of the box. +每个端口分配的功能不必与名称匹配(大多数情况下),并通过[串行端口配置](../peripherals/serial_configuration.md)。 +通常情况下端口功能是与名称相匹配的,因此标记为`GPS1`的端口可直接连接GPS设备。 ::: -## NuttX on STMxxyyy +## NuttX 在 STMxxyyy 上 -This section shows how to get the mappings for NuttX builds on STMxxyyy architectures by inspecting the board configuration files. -The instructions use FMUv5, but can similarly be extended for other FMU versions/NuttX boards. +本节将展示如何通过检查板载配置文件,获取在STMxxyyy架构上构建NuttX所需的映射信息。 +该说明使用FMUv5,但同样可扩展至其他FMU版本/NuttX开发板。 -### default.px4board +### -The **default.px4board** lists a number of serial port mappings (search for the text "SERIAL_PORTS"). +**default.px4board** 文件列出了若干串行端口映射(搜索文本“SERIAL_PORTS”)。 -From [/boards/px4/fmu-v5/default.px4board](https://github.com/PX4/PX4-Autopilot/blob/main/boards/px4/fmu-v5/default.px4board): +来自 [/boards/px4/fmu-v5/default.px4board](https://github.com/PX4/PX4-Autopilot/blob/main/boards/px4/fmu-v5/default.px4board): ``` CONFIG_BOARD_SERIAL_GPS1="/dev/ttyS0" @@ -30,7 +30,7 @@ CONFIG_BOARD_SERIAL_TEL2="/dev/ttyS2" CONFIG_BOARD_SERIAL_TEL4="/dev/ttyS3" ``` -Alternatively you can launch boardconfig using `make px4_fmu-v5 boardconfig` and access the serial port menu +或者,您可以通过执行 `make px4_fmu-v5 boardconfig` 启动板配置工具,并进入串口菜单。 ``` Serial ports ---> @@ -48,12 +48,12 @@ Alternatively you can launch boardconfig using `make px4_fmu-v5 boardconfig` and ### nsh/defconfig -The _nsh/defconfig_ allows you to determine which ports are defined, whether they are UART or USARTs, and the mapping between USART/UART and device. -You can also determine which port is used for the [serial/debug console](../debug/system_console.md). +_nsh/defconfig_ 允许您确定哪些端口被定义,它们是 UART 还是 USART,以及 USART/UART 与设备之间的映射关系。 +您还可以确定用于该功能的端口[serial/debug console](../debug/system_console.md)。 -Open the board's defconfig file, for example: [/boards/px4/fmu-v5/nuttx-config/nsh/defconfig](https://github.com/PX4/PX4-Autopilot/blob/main/boards/px4/fmu-v5/nuttx-config/nsh/defconfig#L215-L221) +打开板载的 defconfig 配置文件,例如:[/boards/px4/fmu-v5/nuttx-config/nsh/defconfig](https://github.com/PX4/PX4-Autopilot/blob/main/boards/px4/fmu-v5/nuttx-config/nsh/defconfig#L215-L221) -Search for the text "ART" until you find a section like with entries formatted like `CONFIG_STM32xx_USARTn=y` (where `xx` is a processor type and `n` is a port number). +搜索文本“ART”,直到找到类似以下格式的条目:`CONFIG_STM32xx_USARTn=y`(其中`xx`表示处理器类型,`n`表示端口号)。 例如: ``` @@ -66,10 +66,10 @@ CONFIG_STM32F7_USART3=y CONFIG_STM32F7_USART6=y ``` -The entries tell you which ports are defined, and whether they are UART or USART. +这些条目会告知您哪些端口已被定义,以及它们属于UART还是USART。 -Copy the section above and reorder numerically by "n". -Increment the device number _ttyS**n**_ alongside (zero based) to get the device-to-serial-port mapping. +复制上方段落,按“n”进行数字排序。 +同时递增设备编号ttySn(基于零的计数),以获取设备到串行端口的映射关系。 ``` ttyS0 CONFIG_STM32F7_USART1=y @@ -81,8 +81,8 @@ ttyS5 CONFIG_STM32F7_UART7=y ttyS6 CONFIG_STM32F7_UART8=y ``` -To get the DEBUG console mapping we search the [defconfig file](https://github.com/PX4/PX4-Autopilot/blob/main/boards/px4/fmu-v5/nuttx-config/nsh/defconfig#L212) for `SERIAL_CONSOLE`. -Below we see that the console is on UART7: +要获取调试控制台映射,我们需在[defconfig file](https://github.com/PX4/PX4-Autopilot/blob/main/boards/px4/fmu-v5/nuttx-config/nsh/defconfig#L212) 搜索 `SERIAL_CONSOLE`. +下面我们看到控制台位于UART7: ``` CONFIG_UART7_SERIAL_CONSOLE=y @@ -90,9 +90,9 @@ CONFIG_UART7_SERIAL_CONSOLE=y ### board_config.h -For flight controllers that have an IO board, determine the PX4IO connection from **board_config.h** by searching for `PX4IO_SERIAL_DEVICE`. +对于配备IO板的飞行控制器,请通过在**board_config.h**文件中搜索`PX4IO_SERIAL_DEVICE`来确定PX4IO连接。 -For example, [/boards/px4/fmu-v5/src/board_config.h](https://github.com/PX4/PX4-Autopilot/blob/main/boards/px4/fmu-v5/src/board_config.h#L59): +例如 [/boards/px4/fmu-v5/src/board_config.h](https://github.com/PX4/PX4-Autopilot/blob/main/boards/px4/fmu-v5/src/board_config.h#L59): ``` #define PX4IO_SERIAL_DEVICE "/dev/ttyS6" @@ -101,11 +101,11 @@ For example, [/boards/px4/fmu-v5/src/board_config.h](https://github.com/PX4/PX4- #define PX4IO_SERIAL_BASE STM32_UART8_BASE ``` -So the PX4IO is on `ttyS6` (we can also see that this maps to UART8, which we already knew from the preceding section). +PX4IO 位于 `ttyS6` 上(我们还可以看到它映射到 UART8,这一点我们从前一节已经知道)。 -### Putting it all together +### 整合所有内容 -The final mapping is: +最终映射表如下: ``` ttyS0 CONFIG_STM32F7_USART1=y GPS1 @@ -117,17 +117,17 @@ ttyS5 CONFIG_STM32F7_UART7=y DEBUG ttyS6 CONFIG_STM32F7_UART8=y PX4IO ``` -In the [flight controller docs](../flight_controller/pixhawk4.md#serial-port-mapping) the resulting table is: +在 [flight controller docs]../flight_controller/pixhawk4.md#serial-port-mapping最终生成的表格如下: -| UART | 设备 | Port | -| ------ | ---------- | ---------------------------------------- | -| UART1 | /dev/ttyS0 | GPS | -| USART2 | /dev/ttyS1 | TELEM1 (flow control) | -| USART3 | /dev/ttyS2 | TELEM2 (flow control) | -| UART4 | /dev/ttyS3 | TELEM4 | -| USART6 | /dev/ttyS4 | RC SBUS | -| UART7 | /dev/ttyS5 | Debug Console | -| UART8 | /dev/ttyS6 | PX4IO | +| UART | 设备 | Port | +| ------ | ---------- | ------------------------------ | +| UART | UART | GPS | +| USART2 | /dev/ttyS1 | TELEM1 (流控) | +| USART3 | /dev/ttyS2 | TELEM2 (流控) | +| UART4 | /dev/ttyS3 | TELEM4 | +| USART6 | /dev/ttyS4 | RC SBUS | +| UART7 | /dev/ttyS5 | 调试控制台 | +| UART8 | /dev/ttyS6 | PX4IO | ## Other Architectures @@ -135,7 +135,7 @@ In the [flight controller docs](../flight_controller/pixhawk4.md#serial-port-map Contributions welcome! ::: -## See Also +## 另见 - [Serial Port Configuration](../peripherals/serial_configuration.md) - [MAVLink Telemetry (OSD/GCS)](../peripherals/mavlink_peripherals.md) diff --git a/docs/zh/middleware/uorb.md b/docs/zh/middleware/uorb.md index 54af3bd7e9..2f190bb439 100644 --- a/docs/zh/middleware/uorb.md +++ b/docs/zh/middleware/uorb.md @@ -278,7 +278,7 @@ For more information see: [Plotting uORB Topic Data in Real Time using PlotJuggl -## See Also +## 另见 - _PX4 uORB Explained_ Blog series - [Part 1](https://px4.io/px4-uorb-explained-part-1/) diff --git a/docs/zh/middleware/uxrce_dds.md b/docs/zh/middleware/uxrce_dds.md index 65b014b0c1..93908a76ee 100644 --- a/docs/zh/middleware/uxrce_dds.md +++ b/docs/zh/middleware/uxrce_dds.md @@ -454,6 +454,7 @@ uxrce_dds_client start -n fancy_uav ``` This can be included in `etc/extras.txt` as part of a custom [System Startup](../concept/system_startup.md). +::: ## PX4 ROS 2 QoS Settings @@ -515,6 +516,11 @@ publications: - topic: /fmu/out/vehicle_trajectory_waypoint_desired type: px4_msgs::msg::VehicleTrajectoryWaypoint + - topic: /fmu/out/vehicle_imu + type: px4_msgs::msg::VehicleImu + rate_limit: 50. + instance: 1 # OPTIONAL + subscriptions: - topic: /fmu/in/offboard_control_mode @@ -547,6 +553,9 @@ Each (`topic`,`type`) pairs defines: 4. The message type (`VehicleOdometry`, `VehicleStatus`, `OffboardControlMode`, etc.) and the ROS 2 package (`px4_msgs`) that is expected to provide the message definition. 5. **(Optional)**: An additional `rate_limit` field (only for publication entries), which specifies the maximum rate (Hz) at which messages will be published on this topic by PX4 to ROS 2. If left unspecified, the maximum publication rate limit is set to 100 Hz. +6. **(Optional)**: An additional `instance` field (only for publication entries), which lets you select which instance of a [multi-instance topic](./uorb.md#multi-instance) you want to be published to ROS 2. + If provided, this option changes the ROS 2 topic name of the advertised uORB topic appending the instance number: `fmu/out/[uorb topic name][instance]` (plus eventual namespace and message version). + In the example above the final topic name would be `/fmu/out/vehicle_imu1`. `subscriptions` and `subscriptions_multi` allow us to choose the uORB topic instance that ROS 2 topics are routed to: either a shared instance that may also be getting updates from internal PX4 uORB publishers, or a separate instance that is reserved for ROS2 publications, respectively. Without this mechanism all ROS 2 messages would be routed to the _same_ uORB topic instance (because ROS 2 does not have the concept of [multiple topic instances](../middleware/uorb.md#multi-instance)), and it would not be possible for PX4 subscribers to differentiate between streams from ROS 2 or PX4 publishers. @@ -588,7 +597,7 @@ For a list of services, details and examples see the [service documentation](../ These guidelines explain how to migrate from using PX4 v1.13 [Fast-RTPS](../middleware/micrortps.md) middleware to PX4 v1.14 `uXRCE-DDS` middleware. These are useful if you have [ROS 2 applications written for PX4 v1.13](https://docs.px4.io/v1.13/en/ros/ros2_comm.html), or you have used Fast-RTPS to interface your applications to PX4 [directly](https://docs.px4.io/v1.13/en/middleware/micrortps.html#agent-in-an-offboard-fast-dds-interface-ros-independent). -::: info +:::info This section contains migration-specific information. You should also read the rest of this page to properly understand uXRCE-DDS. ::: diff --git a/docs/zh/modules/hello_sky.md b/docs/zh/modules/hello_sky.md index 02e2a97e82..e1c185d810 100644 --- a/docs/zh/modules/hello_sky.md +++ b/docs/zh/modules/hello_sky.md @@ -440,6 +440,7 @@ The [complete example code](https://github.com/PX4/PX4-Autopilot/blob/main/src/e */ #include +#include #include #include #include diff --git a/docs/zh/msg_docs/DifferentialPressure.md b/docs/zh/msg_docs/DifferentialPressure.md index f5fd908df9..83adb2d03e 100644 --- a/docs/zh/msg_docs/DifferentialPressure.md +++ b/docs/zh/msg_docs/DifferentialPressure.md @@ -1,17 +1,24 @@ # DifferentialPressure (UORB message) +Differential-pressure (airspeed) sensor + +This is populated by airspeed sensor drivers and used by the sensor module to calculate airspeed. +The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `SensorBaro` instance). + [source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/DifferentialPressure.msg) ```c -uint64 timestamp # time since system start (microseconds) -uint64 timestamp_sample +# Differential-pressure (airspeed) sensor +# +# This is populated by airspeed sensor drivers and used by the sensor module to calculate airspeed. +# The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `SensorBaro` instance). -uint32 device_id # unique device ID for the sensor that does not change between power cycles +uint64 timestamp # [us] Time of publication (since system start) +uint64 timestamp_sample # [us] Time of raw data capture -float32 differential_pressure_pa # differential pressure reading in Pascals (may be negative) - -float32 temperature # Temperature provided by sensor in degrees Celsius, NAN if unknown - -uint32 error_count # Number of errors detected by driver +uint32 device_id # [-] Unique device ID for the sensor that does not change between power cycles +float32 differential_pressure_pa # [Pa] Differential pressure reading (may be negative) +float32 temperature # [degC] [@invalid NaN if unknown] Temperature +uint32 error_count # [-] Number of errors detected by driver ``` diff --git a/docs/zh/msg_docs/SensorBaro.md b/docs/zh/msg_docs/SensorBaro.md index cf834ccf36..ef4d7a8f28 100644 --- a/docs/zh/msg_docs/SensorBaro.md +++ b/docs/zh/msg_docs/SensorBaro.md @@ -1,18 +1,25 @@ # SensorBaro (UORB message) +Barometer sensor + +This is populated by barometer drivers and used by the EKF2 estimator. +The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `DifferentialPressure` instance). + [source file](https://github.com/PX4/PX4-Autopilot/blob/main/msg/SensorBaro.msg) ```c -uint64 timestamp # time since system start (microseconds) -uint64 timestamp_sample +# Barometer sensor +# +# This is populated by barometer drivers and used by the EKF2 estimator. +# The information is published in the `SCALED_PRESSURE_n` MAVLink messages (along with information from a corresponding `DifferentialPressure` instance). -uint32 device_id # unique device ID for the sensor that does not change between power cycles +uint64 timestamp # [us] Time of publication (since system start) +uint64 timestamp_sample # [us] Time of raw data capture -float32 pressure # static pressure measurement in Pascals - -float32 temperature # temperature in degrees Celsius - -uint32 error_count +uint32 device_id # [-] Unique device ID for the sensor that does not change between power cycles +float32 pressure # [Pa] Static pressure measurement +float32 temperature # [degC] Temperature. +uint32 error_count # [-] Number of errors detected by driver. uint8 ORB_QUEUE_LENGTH = 4 diff --git a/docs/zh/msg_docs/VehicleStatus.md b/docs/zh/msg_docs/VehicleStatus.md index 9d46e42cb3..05e3f98bbb 100644 --- a/docs/zh/msg_docs/VehicleStatus.md +++ b/docs/zh/msg_docs/VehicleStatus.md @@ -20,20 +20,16 @@ uint8 ARMING_STATE_ARMED = 2 uint8 latest_arming_reason uint8 latest_disarming_reason -uint8 ARM_DISARM_REASON_TRANSITION_TO_STANDBY = 0 uint8 ARM_DISARM_REASON_STICK_GESTURE = 1 uint8 ARM_DISARM_REASON_RC_SWITCH = 2 uint8 ARM_DISARM_REASON_COMMAND_INTERNAL = 3 uint8 ARM_DISARM_REASON_COMMAND_EXTERNAL = 4 uint8 ARM_DISARM_REASON_MISSION_START = 5 -uint8 ARM_DISARM_REASON_SAFETY_BUTTON = 6 -uint8 ARM_DISARM_REASON_AUTO_DISARM_LAND = 7 -uint8 ARM_DISARM_REASON_AUTO_DISARM_PREFLIGHT = 8 -uint8 ARM_DISARM_REASON_KILL_SWITCH = 9 -uint8 ARM_DISARM_REASON_LOCKDOWN = 10 -uint8 ARM_DISARM_REASON_FAILURE_DETECTOR = 11 -uint8 ARM_DISARM_REASON_SHUTDOWN = 12 -uint8 ARM_DISARM_REASON_UNIT_TEST = 13 +uint8 ARM_DISARM_REASON_LANDING = 6 +uint8 ARM_DISARM_REASON_PREFLIGHT_INACTION = 7 +uint8 ARM_DISARM_REASON_KILL_SWITCH = 8 +uint8 ARM_DISARM_REASON_RC_BUTTON = 13 +uint8 ARM_DISARM_REASON_FAILSAFE = 14 uint64 nav_state_timestamp # time when current nav_state activated diff --git a/docs/zh/msg_docs/index.md b/docs/zh/msg_docs/index.md index dfed09c171..2512c7058d 100644 --- a/docs/zh/msg_docs/index.md +++ b/docs/zh/msg_docs/index.md @@ -105,7 +105,7 @@ Graphs showing how these are used [can be found here](../middleware/uorb_graph.m - [DebugKeyValue](DebugKeyValue.md) - [DebugValue](DebugValue.md) - [DebugVect](DebugVect.md) -- [DifferentialPressure](DifferentialPressure.md) +- [DifferentialPressure](DifferentialPressure.md) — Differential-pressure (airspeed) sensor - [DistanceSensor](DistanceSensor.md) — DISTANCE_SENSOR message data - [DistanceSensorModeChangeRequest](DistanceSensorModeChangeRequest.md) - [DronecanNodeStatus](DronecanNodeStatus.md) @@ -240,7 +240,7 @@ Graphs showing how these are used [can be found here](../middleware/uorb_graph.m - [SensorAccel](SensorAccel.md) - [SensorAccelFifo](SensorAccelFifo.md) - [SensorAirflow](SensorAirflow.md) -- [SensorBaro](SensorBaro.md) +- [SensorBaro](SensorBaro.md) — Barometer sensor - [SensorCombined](SensorCombined.md) — Sensor readings in SI-unit form. These fields are scaled and offset-compensated where possible and do not change with board revisions and sensor updates. diff --git a/docs/zh/peripherals/mavlink_peripherals.md b/docs/zh/peripherals/mavlink_peripherals.md index ed88794411..94f8cc82cf 100644 --- a/docs/zh/peripherals/mavlink_peripherals.md +++ b/docs/zh/peripherals/mavlink_peripherals.md @@ -119,7 +119,7 @@ Links to setup instructions for specific MAVLink components: - [MAVLink Cameras (Camera Protocol v2) > PX4 Configuration](../camera/mavlink_v2_camera.md#px4-configuration) - [Gimbal Configuration > MAVLink Gimbal (MNT_MODE_OUT=MAVLINK)](../advanced/gimbal_control.md#mavlink-gimbal-mnt-mode-out-mavlink) -## See Also +## 另见 - [Serial Port Configuration](../peripherals/serial_configuration.md) - [PX4 Ethernet Setup > PX4 MAVLink Serial Port Configuration](../advanced_config/ethernet_setup.md#px4-mavlink-serial-port-configuration) diff --git a/docs/zh/peripherals/remote_id.md b/docs/zh/peripherals/remote_id.md index b3188fb10c..3cfc7bcde4 100644 --- a/docs/zh/peripherals/remote_id.md +++ b/docs/zh/peripherals/remote_id.md @@ -257,6 +257,6 @@ If the Remote ID CAN node is present and the messages are not being received, th Once configured, check the MAVLink Inspector again and check that the `OPEN_DRONE_ID_BASIC_ID` and `OPEN_DRONE_ID_LOCATION` messages are now present. -## See Also +## 另见 - [Remote Identification of Drones](https://www.faa.gov/uas/getting_started/remote_id) (FAA) diff --git a/docs/zh/power_module/ark_12s_pab_power_module.md b/docs/zh/power_module/ark_12s_pab_power_module.md index 21c3e5ca77..4f262920bd 100644 --- a/docs/zh/power_module/ark_12s_pab_power_module.md +++ b/docs/zh/power_module/ark_12s_pab_power_module.md @@ -47,6 +47,6 @@ Order this module from: - Set the `INA238_SHUNT` parameter to 0.0001. - Reboot the flight controller. -## See Also +## 另见 - [ARK 12S PAB Power Module Documentation](https://arkelectron.gitbook.io/ark-documentation/power/ark-12s-pab-power-module) (ARK Docs) diff --git a/docs/zh/power_module/ark_pab_power_module.md b/docs/zh/power_module/ark_pab_power_module.md index 24bd243862..a2d3977bd7 100644 --- a/docs/zh/power_module/ark_pab_power_module.md +++ b/docs/zh/power_module/ark_pab_power_module.md @@ -48,6 +48,6 @@ Order this module from: - Enable the SENS_EN_INA226 parameter if it not enabled. - Reboot the flight controller. -## See Also +## 另见 - [ARK PAB Power Module Documentation](https://arkelectron.gitbook.io/ark-documentation/power/ark-pab-power-module) (ARK Docs) diff --git a/docs/zh/power_module/holybro_pm02d.md b/docs/zh/power_module/holybro_pm02d.md index 1de3c25724..5660abda66 100644 --- a/docs/zh/power_module/holybro_pm02d.md +++ b/docs/zh/power_module/holybro_pm02d.md @@ -49,6 +49,6 @@ For this module you must instead enable parameter [SENS_EN_INA226](../advanced_c Note that the current divider and voltage divider should not be set in the [Battery Configuration](../config/battery.md) (the default values are accurate within 5%). -## See Also +## 另见 - [Digital Power Module (PM) Setup](https://docs.holybro.com/power-module-and-pdb/power-module/digital-power-module-pm-setup#px4-setup) (Manufacturer guide) diff --git a/docs/zh/ros/mavros_installation.md b/docs/zh/ros/mavros_installation.md index 91c41c9fc5..6568e755d3 100644 --- a/docs/zh/ros/mavros_installation.md +++ b/docs/zh/ros/mavros_installation.md @@ -201,7 +201,7 @@ The [MAVROS Offboard Example (C++)](../ros/mavros_offboard_cpp.md), will show yo If you have an example app using the PX4 Autopilot and MAVROS, we can help you get it on our docs. ::: -## See Also +## 另见 - [mavros ROS Package Summary](https://wiki.ros.org/mavros#mavros.2BAC8-Plugins.sys_status) - [mavros source](https://github.com/mavlink/mavros/) diff --git a/docs/zh/ros2/offboard_control.md b/docs/zh/ros2/offboard_control.md index 5ae2e2973d..07945ac9ea 100644 --- a/docs/zh/ros2/offboard_control.md +++ b/docs/zh/ros2/offboard_control.md @@ -217,6 +217,6 @@ void OffboardControl::publish_vehicle_command(uint16_t command, float param1, fl 参数字段和 指令字段对应于 [MAVLink commands](https://mavlink.io/en/messages/common.html#mav_commands)以及他们的参数值 ::: -## See Also +## 另见 - [Python ROS2 offboard examples with PX4](https://github.com/Jaeyoung-Lim/px4-offboard) (Jaeyoung-Lim/px4-offboard). diff --git a/docs/zh/sensor/airspeed.md b/docs/zh/sensor/airspeed.md index 6e5a796164..0442aae34f 100644 --- a/docs/zh/sensor/airspeed.md +++ b/docs/zh/sensor/airspeed.md @@ -73,7 +73,7 @@ Airspeed sensors should be calibrated by following the instructions: [Basic Conf For more advanced validation, configuration and debugging see [Airspeed Validation](../advanced_config/airspeed_validation.md). -## See Also +## 另见 - [Using PX4's Navigation Filter (EKF2) > Airspeed](../advanced_config/tuning_the_ecl_ekf.md#airspeed) - [Airspeed drivers](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/differential_pressure) (source code) diff --git a/docs/zh/telemetry/crsf_telemetry.md b/docs/zh/telemetry/crsf_telemetry.md index b265e83580..cbb8abf219 100644 --- a/docs/zh/telemetry/crsf_telemetry.md +++ b/docs/zh/telemetry/crsf_telemetry.md @@ -213,7 +213,7 @@ The supported telemetry messages and their source are listed below (this table i | FM | Flight mode | FC | | VSPD | Barometer | FC | -## See Also +## 另见 - [TBS Crossfire Manual](https://www.team-blacksheep.com/media/files/tbs-crossfire-manual.pdf) - [ExpressLRS Documentation](https://www.expresslrs.org/quick-start/getting-started/) diff --git a/msg/AdcReport.msg b/msg/AdcReport.msg index 1ae72b6d6c..4a56bc2875 100644 --- a/msg/AdcReport.msg +++ b/msg/AdcReport.msg @@ -1,6 +1,10 @@ -uint64 timestamp # time since system start (microseconds) -uint32 device_id # unique device ID for the sensor that does not change between power cycles -int16[12] channel_id # ADC channel IDs, negative for non-existent, TODO: should be kept same as array index -int32[12] raw_data # ADC channel raw value, accept negative value, valid if channel ID is positive -uint32 resolution # ADC channel resolution -float32 v_ref # ADC channel voltage reference, use to calculate LSB voltage(lsb=scale/resolution) +# ADC raw data. +# +# Communicates raw data from an analog-to-digital converter (ADC) to other modules, such as battery status. + +uint64 timestamp # [us] Time since system start +uint32 device_id # [-] unique device ID for the sensor that does not change between power cycles +int16[16] channel_id # [-] ADC channel IDs, negative for non-existent, TODO: should be kept same as array index +int32[16] raw_data # [-] ADC channel raw value, accept negative value, valid if channel ID is positive +uint32 resolution # [-] ADC channel resolution +float32 v_ref # [V] ADC channel voltage reference, use to calculate LSB voltage(lsb=scale/resolution) diff --git a/msg/CMakeLists.txt b/msg/CMakeLists.txt index 7eda1cc316..253024588d 100644 --- a/msg/CMakeLists.txt +++ b/msg/CMakeLists.txt @@ -98,6 +98,7 @@ set(msg_files GeneratorStatus.msg GeofenceResult.msg GeofenceStatus.msg + GainCompression.msg GimbalControls.msg GimbalDeviceAttitudeStatus.msg GimbalDeviceInformation.msg @@ -207,6 +208,7 @@ set(msg_files SensorSelection.msg SensorsStatus.msg SensorsStatusImu.msg + SensorTemp.msg SensorUwb.msg SensorAirflow.msg SystemPower.msg diff --git a/msg/EscReport.msg b/msg/EscReport.msg index 9a75c3d7cc..ca80753f14 100644 --- a/msg/EscReport.msg +++ b/msg/EscReport.msg @@ -11,6 +11,19 @@ uint8 esc_state # State of ESC - depend on Vendor uint8 actuator_function # actuator output function (one of Motor1...MotorN) +uint8 ACTUATOR_FUNCTION_MOTOR1 = 101 +uint8 ACTUATOR_FUNCTION_MOTOR2 = 102 +uint8 ACTUATOR_FUNCTION_MOTOR3 = 103 +uint8 ACTUATOR_FUNCTION_MOTOR4 = 104 +uint8 ACTUATOR_FUNCTION_MOTOR5 = 105 +uint8 ACTUATOR_FUNCTION_MOTOR6 = 106 +uint8 ACTUATOR_FUNCTION_MOTOR7 = 107 +uint8 ACTUATOR_FUNCTION_MOTOR8 = 108 +uint8 ACTUATOR_FUNCTION_MOTOR9 = 109 +uint8 ACTUATOR_FUNCTION_MOTOR10 = 110 +uint8 ACTUATOR_FUNCTION_MOTOR11 = 111 +uint8 ACTUATOR_FUNCTION_MOTOR12 = 112 + uint16 failures # Bitmask to indicate the internal ESC faults int8 esc_power # Applied power 0-100 in % (negative values reserved) diff --git a/msg/GainCompression.msg b/msg/GainCompression.msg new file mode 100644 index 0000000000..b7d6735007 --- /dev/null +++ b/msg/GainCompression.msg @@ -0,0 +1,5 @@ +uint64 timestamp # Time since system start (microseconds) + +float32[3] compression_gains # [-] [@frame FRD] [@range 0, 1] Multiplicative gain to modify the output of the controller per axis +float32[3] spectral_damper_hpf # [-] [@frame FRD] Squared output of spectral damper high-pass filter +float32[3] spectral_damper_out # [-] [@frame FRD] Spectral damper output squared diff --git a/msg/InputRc.msg b/msg/InputRc.msg index 782477407e..2f72125ab8 100644 --- a/msg/InputRc.msg +++ b/msg/InputRc.msg @@ -32,9 +32,11 @@ bool rc_lost # RC receiver connection status: True,if no frame has arrived in uint16 rc_lost_frame_count # Number of lost RC frames. Note: intended purpose: observe the radio link quality if RSSI is not available. This value must not be used to trigger any failsafe-alike functionality. uint16 rc_total_frame_count # Number of total RC frames. Note: intended purpose: observe the radio link quality if RSSI is not available. This value must not be used to trigger any failsafe-alike functionality. uint16 rc_ppm_frame_length # Length of a single PPM frame. Zero for non-PPM systems +uint16 rc_frame_rate # RC frame rate in msg/second. 0 = invalid uint8 input_source # Input source uint16[18] values # measured pulse widths for each of the supported channels int8 link_quality # link quality. Percentage 0-100%. -1 = invalid float32 rssi_dbm # Actual rssi in units of dBm. NaN = invalid +int8 link_snr # link signal to noise ratio in units of dB. -1 = invalid diff --git a/msg/SensorTemp.msg b/msg/SensorTemp.msg new file mode 100644 index 0000000000..2837857ef1 --- /dev/null +++ b/msg/SensorTemp.msg @@ -0,0 +1,4 @@ +uint64 timestamp # time since system start (microseconds) + +uint32 device_id # unique device ID for the sensor that does not change between power cycles +float32 temperature # Temperature provided by sensor (Celsius) diff --git a/msg/px4_msgs_old/msg/ConfigOverridesV0.msg b/msg/px4_msgs_old/msg/ConfigOverridesV0.msg new file mode 100644 index 0000000000..b274adfbec --- /dev/null +++ b/msg/px4_msgs_old/msg/ConfigOverridesV0.msg @@ -0,0 +1,21 @@ +# Configurable overrides by (external) modes or mode executors + +uint32 MESSAGE_VERSION = 0 + +uint64 timestamp # time since system start (microseconds) + +bool disable_auto_disarm # Prevent the drone from automatically disarming after landing (if configured) + +bool defer_failsafes # Defer all failsafes that can be deferred (until the flag is cleared) +int16 defer_failsafes_timeout_s # Maximum time a failsafe can be deferred. 0 = system default, -1 = no timeout + + +int8 SOURCE_TYPE_MODE = 0 +int8 SOURCE_TYPE_MODE_EXECUTOR = 1 +int8 source_type + +uint8 source_id # ID depending on source_type + +uint8 ORB_QUEUE_LENGTH = 4 + +# TOPICS config_overrides config_overrides_request diff --git a/msg/px4_msgs_old/msg/RegisterExtComponentReplyV0.msg b/msg/px4_msgs_old/msg/RegisterExtComponentReplyV0.msg new file mode 100644 index 0000000000..4495bcdb90 --- /dev/null +++ b/msg/px4_msgs_old/msg/RegisterExtComponentReplyV0.msg @@ -0,0 +1,15 @@ +uint32 MESSAGE_VERSION = 0 + +uint64 timestamp # time since system start (microseconds) + +uint64 request_id # ID from the request +char[25] name # name from the request + +uint16 px4_ros2_api_version + +bool success +int8 arming_check_id # arming check registration ID (-1 if invalid) +int8 mode_id # assigned mode ID (-1 if invalid) +int8 mode_executor_id # assigned mode executor ID (-1 if invalid) + +uint8 ORB_QUEUE_LENGTH = 2 diff --git a/msg/px4_msgs_old/msg/RegisterExtComponentRequestV0.msg b/msg/px4_msgs_old/msg/RegisterExtComponentRequestV0.msg new file mode 100644 index 0000000000..b0798705ca --- /dev/null +++ b/msg/px4_msgs_old/msg/RegisterExtComponentRequestV0.msg @@ -0,0 +1,24 @@ +# Request to register an external component + +uint32 MESSAGE_VERSION = 0 + +uint64 timestamp # time since system start (microseconds) + +uint64 request_id # ID, set this to a random value +char[25] name # either the requested mode name, or component name + +uint16 LATEST_PX4_ROS2_API_VERSION = 1 # API version compatibility. Increase this on a breaking semantic change. Changes to any message field are detected separately and do not require an API version change. + +uint16 px4_ros2_api_version # Set to LATEST_PX4_ROS2_API_VERSION + +# Components to be registered +bool register_arming_check +bool register_mode # registering a mode also requires arming_check to be set +bool register_mode_executor # registering an executor also requires a mode to be registered (which is the owned mode by the executor) + +bool enable_replace_internal_mode # set to true if an internal mode should be replaced +uint8 replace_internal_mode # vehicle_status::NAVIGATION_STATE_* +bool activate_mode_immediately # switch to the registered mode (can only be set in combination with an executor) + + +uint8 ORB_QUEUE_LENGTH = 2 diff --git a/msg/translation_node/translations/all_translations.h b/msg/translation_node/translations/all_translations.h index 1322253715..12a8763ec6 100644 --- a/msg/translation_node/translations/all_translations.h +++ b/msg/translation_node/translations/all_translations.h @@ -10,8 +10,11 @@ #include "translation_arming_check_reply_v1.h" #include "translation_arming_check_request_v1.h" #include "translation_battery_status_v1.h" +#include "translation_config_overrides_v1.h" #include "translation_event_v1.h" #include "translation_home_position_v1.h" +#include "translation_register_ext_component_reply_v1.h" +#include "translation_register_ext_component_request_v1.h" #include "translation_vehicle_attitude_setpoint_v1.h" #include "translation_vehicle_status_v1.h" #include "translation_vehicle_local_position_v1.h" diff --git a/msg/translation_node/translations/translation_config_overrides_v1.h b/msg/translation_node/translations/translation_config_overrides_v1.h new file mode 100644 index 0000000000..1f7e813951 --- /dev/null +++ b/msg/translation_node/translations/translation_config_overrides_v1.h @@ -0,0 +1,41 @@ +/**************************************************************************** + * Copyright (c) 2025 PX4 Development Team. + * SPDX-License-Identifier: BSD-3-Clause + ****************************************************************************/ +#pragma once + +// Translate ConfigOverrides v0 <--> v1 +#include +#include + +class ConfigOverridesV1Translation { +public: + using MessageOlder = px4_msgs_old::msg::ConfigOverridesV0; + static_assert(MessageOlder::MESSAGE_VERSION == 0); + + using MessageNewer = px4_msgs::msg::ConfigOverrides; + static_assert(MessageNewer::MESSAGE_VERSION == 1); + + static constexpr const char* kTopic = "fmu/in/config_overrides_request"; + + static void fromOlder(const MessageOlder &msg_older, MessageNewer &msg_newer) { + msg_newer.timestamp = msg_older.timestamp; + msg_newer.disable_auto_disarm = msg_older.disable_auto_disarm; + msg_newer.defer_failsafes = msg_older.defer_failsafes; + msg_newer.defer_failsafes_timeout_s = msg_older.defer_failsafes_timeout_s; + msg_newer.disable_auto_set_home = false; + msg_newer.source_type = msg_older.source_type; + msg_newer.source_id = msg_older.source_id; + } + + static void toOlder(const MessageNewer &msg_newer, MessageOlder &msg_older) { + msg_older.timestamp = msg_newer.timestamp; + msg_older.disable_auto_disarm = msg_newer.disable_auto_disarm; + msg_older.defer_failsafes = msg_newer.defer_failsafes; + msg_older.defer_failsafes_timeout_s = msg_newer.defer_failsafes_timeout_s; + msg_older.source_type = msg_newer.source_type; + msg_older.source_id = msg_newer.source_id; + } +}; + +REGISTER_TOPIC_TRANSLATION_DIRECT(ConfigOverridesV1Translation); diff --git a/msg/translation_node/translations/translation_register_ext_component_reply_v1.h b/msg/translation_node/translations/translation_register_ext_component_reply_v1.h new file mode 100644 index 0000000000..7ff61d7d97 --- /dev/null +++ b/msg/translation_node/translations/translation_register_ext_component_reply_v1.h @@ -0,0 +1,45 @@ +/**************************************************************************** + * Copyright (c) 2025 PX4 Development Team. + * SPDX-License-Identifier: BSD-3-Clause + ****************************************************************************/ +#pragma once + +// Translate RegisterExtComponentReply v0 <--> v1 +#include +#include + +class RegisterExtComponentReplyV1Translation { +public: + using MessageOlder = px4_msgs_old::msg::RegisterExtComponentReplyV0; + static_assert(MessageOlder::MESSAGE_VERSION == 0); + + using MessageNewer = px4_msgs::msg::RegisterExtComponentReply; + static_assert(MessageNewer::MESSAGE_VERSION == 1); + + static constexpr const char* kTopic = "fmu/out/register_ext_component_reply"; + + static void fromOlder(const MessageOlder &msg_older, MessageNewer &msg_newer) { + msg_newer.timestamp = msg_older.timestamp; + msg_newer.request_id = msg_older.request_id; + msg_newer.name = msg_older.name; + msg_newer.px4_ros2_api_version = msg_older.px4_ros2_api_version; + msg_newer.success = msg_older.success; + msg_newer.arming_check_id = msg_older.arming_check_id; + msg_newer.mode_id = msg_older.mode_id; + msg_newer.mode_executor_id = msg_older.mode_executor_id; + msg_newer.not_user_selectable = false; + } + + static void toOlder(const MessageNewer &msg_newer, MessageOlder &msg_older) { + msg_older.timestamp = msg_newer.timestamp; + msg_older.request_id = msg_newer.request_id; + msg_older.name = msg_newer.name; + msg_older.px4_ros2_api_version = msg_newer.px4_ros2_api_version; + msg_older.success = msg_newer.success; + msg_older.arming_check_id = msg_newer.arming_check_id; + msg_older.mode_id = msg_newer.mode_id; + msg_older.mode_executor_id = msg_newer.mode_executor_id; + } +}; + +REGISTER_TOPIC_TRANSLATION_DIRECT(RegisterExtComponentReplyV1Translation); diff --git a/msg/translation_node/translations/translation_register_ext_component_request_v1.h b/msg/translation_node/translations/translation_register_ext_component_request_v1.h new file mode 100644 index 0000000000..9f90b90784 --- /dev/null +++ b/msg/translation_node/translations/translation_register_ext_component_request_v1.h @@ -0,0 +1,49 @@ +/**************************************************************************** + * Copyright (c) 2025 PX4 Development Team. + * SPDX-License-Identifier: BSD-3-Clause + ****************************************************************************/ +#pragma once + +// Translate RegisterExtComponentRequest v0 <--> v1 +#include +#include + +class RegisterExtComponentRequestV1Translation { +public: + using MessageOlder = px4_msgs_old::msg::RegisterExtComponentRequestV0; + static_assert(MessageOlder::MESSAGE_VERSION == 0); + + using MessageNewer = px4_msgs::msg::RegisterExtComponentRequest; + static_assert(MessageNewer::MESSAGE_VERSION == 1); + + static constexpr const char* kTopic = "fmu/in/register_ext_component_request"; + + static void fromOlder(const MessageOlder &msg_older, MessageNewer &msg_newer) { + msg_newer.timestamp = msg_older.timestamp; + msg_newer.request_id = msg_older.request_id; + msg_newer.name = msg_older.name; + msg_newer.px4_ros2_api_version = msg_older.px4_ros2_api_version; + msg_newer.register_arming_check = msg_older.register_arming_check; + msg_newer.register_mode = msg_older.register_mode; + msg_newer.register_mode_executor = msg_older.register_mode_executor; + msg_newer.enable_replace_internal_mode = msg_older.enable_replace_internal_mode; + msg_newer.replace_internal_mode = msg_older.replace_internal_mode; + msg_newer.activate_mode_immediately = msg_older.activate_mode_immediately; + msg_newer.not_user_selectable = false; + } + + static void toOlder(const MessageNewer &msg_newer, MessageOlder &msg_older) { + msg_older.timestamp = msg_newer.timestamp; + msg_older.request_id = msg_newer.request_id; + msg_older.name = msg_newer.name; + msg_older.px4_ros2_api_version = msg_newer.px4_ros2_api_version; + msg_older.register_arming_check = msg_newer.register_arming_check; + msg_older.register_mode = msg_newer.register_mode; + msg_older.register_mode_executor = msg_newer.register_mode_executor; + msg_older.enable_replace_internal_mode = msg_newer.enable_replace_internal_mode; + msg_older.replace_internal_mode = msg_newer.replace_internal_mode; + msg_older.activate_mode_immediately = msg_newer.activate_mode_immediately; + } +}; + +REGISTER_TOPIC_TRANSLATION_DIRECT(RegisterExtComponentRequestV1Translation); diff --git a/msg/versioned/ConfigOverrides.msg b/msg/versioned/ConfigOverrides.msg index b274adfbec..51fd86b037 100644 --- a/msg/versioned/ConfigOverrides.msg +++ b/msg/versioned/ConfigOverrides.msg @@ -1,6 +1,6 @@ # Configurable overrides by (external) modes or mode executors -uint32 MESSAGE_VERSION = 0 +uint32 MESSAGE_VERSION = 1 uint64 timestamp # time since system start (microseconds) @@ -8,7 +8,7 @@ bool disable_auto_disarm # Prevent the drone from automatically disarmin bool defer_failsafes # Defer all failsafes that can be deferred (until the flag is cleared) int16 defer_failsafes_timeout_s # Maximum time a failsafe can be deferred. 0 = system default, -1 = no timeout - +bool disable_auto_set_home # Prevent the drone from automatically setting the home position on arm or takeoff int8 SOURCE_TYPE_MODE = 0 int8 SOURCE_TYPE_MODE_EXECUTOR = 1 diff --git a/msg/versioned/RegisterExtComponentReply.msg b/msg/versioned/RegisterExtComponentReply.msg index 4495bcdb90..17ff6765c9 100644 --- a/msg/versioned/RegisterExtComponentReply.msg +++ b/msg/versioned/RegisterExtComponentReply.msg @@ -1,4 +1,4 @@ -uint32 MESSAGE_VERSION = 0 +uint32 MESSAGE_VERSION = 1 uint64 timestamp # time since system start (microseconds) @@ -12,4 +12,6 @@ int8 arming_check_id # arming check registration ID (-1 if invalid) int8 mode_id # assigned mode ID (-1 if invalid) int8 mode_executor_id # assigned mode executor ID (-1 if invalid) +bool not_user_selectable # mode cannot be selected by the user + uint8 ORB_QUEUE_LENGTH = 2 diff --git a/msg/versioned/RegisterExtComponentRequest.msg b/msg/versioned/RegisterExtComponentRequest.msg index b0798705ca..3b76aef15e 100644 --- a/msg/versioned/RegisterExtComponentRequest.msg +++ b/msg/versioned/RegisterExtComponentRequest.msg @@ -1,6 +1,6 @@ # Request to register an external component -uint32 MESSAGE_VERSION = 0 +uint32 MESSAGE_VERSION = 1 uint64 timestamp # time since system start (microseconds) @@ -19,6 +19,6 @@ bool register_mode_executor # registering an executor also requires a mod bool enable_replace_internal_mode # set to true if an internal mode should be replaced uint8 replace_internal_mode # vehicle_status::NAVIGATION_STATE_* bool activate_mode_immediately # switch to the registered mode (can only be set in combination with an executor) - +bool not_user_selectable # mode cannot be selected by the user uint8 ORB_QUEUE_LENGTH = 2 diff --git a/msg/versioned/VehicleCommand.msg b/msg/versioned/VehicleCommand.msg index 8f20ec2d85..b5d642b140 100644 --- a/msg/versioned/VehicleCommand.msg +++ b/msg/versioned/VehicleCommand.msg @@ -20,7 +20,7 @@ uint16 VEHICLE_CMD_DO_ORBIT = 34 # Start orbiting on the circumference of a circ uint16 VEHICLE_CMD_DO_FIGUREEIGHT = 35 # Start flying on the outline of a figure eight defined by the parameters. |[m] Major radius|[m] Minor radius|[m/s] Velocity|Orientation|Latitude/X|Longitude/Y|Altitude/Z| uint16 VEHICLE_CMD_NAV_ROI = 80 # Sets the region of interest (ROI) for a sensor set or the vehicle itself. This can then be used by the vehicles control system to control the vehicle attitude and the attitude of various sensors such as cameras. |[@enum VEHICLE_ROI] Region of interest mode.|MISSION index/ target ID.|ROI index (allows a vehicle to manage multiple ROI's)|Unused|x the location of the fixed ROI (see MAV_FRAME)|y|z| uint16 VEHICLE_CMD_NAV_PATHPLANNING = 81 # Control autonomous path planning on the MAV. |0: Disable local obstacle avoidance / local path planning (without resetting map), 1: Enable local path planning, 2: Enable and reset local path planning|0: Disable full path planning (without resetting map), 1: Enable, 2: Enable and reset map/occupancy grid, 3: Enable and reset planned route, but not occupancy grid|Unused|[deg] [@range 0, 360] Yaw angle at goal, in compass degrees|Latitude/X of goal|Longitude/Y of goal|Altitude/Z of goal| -uint16 VEHICLE_CMD_NAV_VTOL_TAKEOFF = 84 # Takeoff from ground / hand and transition to fixed wing. |Minimum pitch (if airspeed sensor present), desired pitch without sensor|Unused|Unused|Yaw angle (if magnetometer present), ignored without magnetometer|Latitude|Longitude|Altitude| +uint16 VEHICLE_CMD_NAV_VTOL_TAKEOFF = 84 # Takeoff from ground / hand and transition to fixed wing. |Minimum pitch (if airspeed sensor present), desired pitch without sensor|Transition heading, 0: Default, 3: Use specified transition heading|Unused|Yaw angle (if magnetometer present), ignored without magnetometer|Latitude|Longitude|Altitude| uint16 VEHICLE_CMD_NAV_VTOL_LAND = 85 # Transition to MC and land at location. |Unused|Unused|Unused|Desired yaw angle.|Latitude|Longitude|Altitude| uint16 VEHICLE_CMD_NAV_GUIDED_LIMITS = 90 # Set limits for external control. |[s] Timeout - maximum time that external controller will be allowed to control vehicle. 0 means no timeout|[m] Absolute altitude min AMSL - if vehicle moves below this alt, the command will be aborted and the mission will continue. 0 means no lower altitude limit|[m] Absolute altitude max - if vehicle moves above this alt, the command will be aborted and the mission will continue. 0 means no upper altitude limit|[m] Horizontal move limit (AMSL) - if vehicle moves more than this distance from it's location at the moment the command was executed, the command will be aborted and the mission will continue. 0 means no horizontal altitude limit|Unused|Unused|Unused| uint16 VEHICLE_CMD_NAV_GUIDED_MASTER = 91 # Set id of master controller. |System ID|Component ID|Unused|Unused|Unused|Unused|Unused| diff --git a/platforms/common/include/px4_platform_common/board_common.h b/platforms/common/include/px4_platform_common/board_common.h index 8905507cd0..1056d721b9 100644 --- a/platforms/common/include/px4_platform_common/board_common.h +++ b/platforms/common/include/px4_platform_common/board_common.h @@ -157,8 +157,13 @@ #if BOARD_NUMBER_BRICKS == 0 /* allow SITL to disable all bricks */ #elif BOARD_NUMBER_BRICKS == 1 -# define BOARD_BATT_V_LIST {ADC_BATTERY_VOLTAGE_CHANNEL} -# define BOARD_BATT_I_LIST {ADC_BATTERY_CURRENT_CHANNEL} +# if defined(BOARD_NUMBER_DIGITAL_BRICKS) +# define BOARD_BATT_V_LIST {-1} +# define BOARD_BATT_I_LIST {-1} +# else +# define BOARD_BATT_V_LIST {ADC_BATTERY_VOLTAGE_CHANNEL} +# define BOARD_BATT_I_LIST {ADC_BATTERY_CURRENT_CHANNEL} +# endif # define BOARD_BRICK_VALID_LIST {BOARD_ADC_BRICK_VALID} #elif BOARD_NUMBER_BRICKS == 2 # if defined(BOARD_NUMBER_DIGITAL_BRICKS) diff --git a/platforms/nuttx/CMakeLists.txt b/platforms/nuttx/CMakeLists.txt index 4bee8ed581..49e44b12ae 100644 --- a/platforms/nuttx/CMakeLists.txt +++ b/platforms/nuttx/CMakeLists.txt @@ -507,6 +507,9 @@ if(NOT NUTTX_DIR MATCHES "external") if(CONFIG_ARCH_CHIP_MIMXRT1062DVL6A) set(DEBUG_DEVICE "MIMXRT1062XXX6A") set(DEBUG_SVD_FILE "MIMXRT1062.xml") + elseif(CONFIG_ARCH_CHIP_MIMXRT1064DVL6A) + set(DEBUG_DEVICE "MIMXRT1064XXX6A") + set(DEBUG_SVD_FILE "MIMXRT1064.xml") elseif(CONFIG_ARCH_CHIP_MIMXRT1176DVMAA) set(DEBUG_DEVICE "MIMXRT1176DVMAA") set(DEBUG_SVD_FILE "MIMXRT1176_cm7.xml") diff --git a/platforms/nuttx/NuttX/nuttx b/platforms/nuttx/NuttX/nuttx index d50ffd3544..201d8b01f1 160000 --- a/platforms/nuttx/NuttX/nuttx +++ b/platforms/nuttx/NuttX/nuttx @@ -1 +1 @@ -Subproject commit d50ffd354495ce5d30814dba41d2eb70a32b8fa3 +Subproject commit 201d8b01f14269a9647ef6da499214ffd39ff8f0 diff --git a/platforms/nuttx/cmake/px4_impl_os.cmake b/platforms/nuttx/cmake/px4_impl_os.cmake index cefa37a6c2..98be37ff3f 100644 --- a/platforms/nuttx/cmake/px4_impl_os.cmake +++ b/platforms/nuttx/cmake/px4_impl_os.cmake @@ -158,6 +158,9 @@ function(px4_os_determine_build_chip) elseif(CONFIG_ARCH_CHIP_MIMXRT1062DVL6A) set(CHIP_MANUFACTURER "nxp") set(CHIP "rt106x") + elseif(CONFIG_ARCH_CHIP_MIMXRT1064DVL6A) + set(CHIP_MANUFACTURER "nxp") + set(CHIP "rt106x") elseif(CONFIG_ARCH_CHIP_MIMXRT1176DVMAA) set(CHIP_MANUFACTURER "nxp") set(CHIP "rt117x") diff --git a/platforms/nuttx/src/bootloader/nxp/imxrt_common/main.c b/platforms/nuttx/src/bootloader/nxp/imxrt_common/main.c index dcdc50a911..a137c8477b 100644 --- a/platforms/nuttx/src/bootloader/nxp/imxrt_common/main.c +++ b/platforms/nuttx/src/bootloader/nxp/imxrt_common/main.c @@ -9,9 +9,19 @@ #include "hw_config.h" #include #include -#include -#include -#include +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x +# include +# include +# include +#else +# include +# include +# include +# include +# include "hardware/imxrt_ccm.h" +# include "imxrt_periphclks.h" +# define SNVS_LPCR_GPR_Z_DIS (1 << 24) /* Bit 24: General Purpose Registers Zeroization Disable */ +#endif #include #include "imxrt_clockconfig.h" @@ -30,14 +40,31 @@ #define APP_SIZE_MAX (BOARD_FLASH_SIZE - (BOOTLOADER_RESERVATION_SIZE + APP_RESERVATION_SIZE)) +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x #define CHIP_TAG "i.MX RT11?0,r??" -#define CHIP_TAG_LEN sizeof(CHIP_TAG)-1 - #define SI_REV(n) ((n & 0x7000000) >> 24) #define DIFPROG_TYPE(n) ((n & 0xF000) >> 12) #define DIFPROG_REV_MAJOR(n) ((n & 0xF0) >> 4) #define DIFPROG_REV_MINOR(n) ((n & 0xF)) +#elif defined(CONFIG_ARCH_FAMILY_IMXRT106x) +#define CHIP_TAG "i.MX RT10?? r?.?" +#define DIGPROG_MINOR_SHIFT 0 +#define DIGPROG_MINOR_MASK (0xff << DIGPROG_MINOR_SHIFT) +#define DIGPROG_MINOR(info) (((info) & DIGPROG_MINOR_MASK) >> DIGPROG_MINOR_SHIFT) +#define DIGPROG_MAJOR_LOWER_SHIFT 8 +#define DIGPROG_MAJOR_LOWER_MASK (0xff << DIGPROG_MAJOR_LOWER_SHIFT) +#define DIGPROG_MAJOR_LOWER(info) (((info) & DIGPROG_MAJOR_LOWER_MASK) >> DIGPROG_MAJOR_LOWER_SHIFT) +#define DIGPROG_MAJOR_UPPER_SHIFT 16 +#define DIGPROG_MAJOR_UPPER_MASK (0xff << DIGPROG_MAJOR_UPPER_SHIFT) +#define DIGPROG_MAJOR_UPPER(info) (((info) & DIGPROG_MAJOR_UPPER_MASK) >> DIGPROG_MAJOR_UPPER_SHIFT) +#endif +#define CHIP_TAG_LEN sizeof(CHIP_TAG)-1 +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x +#define FLASH_BASE IMXRT_FLEXSPI1_CIPHER_BASE +#elif defined(CONFIG_ARCH_CHIP_MIMXRT1064DVL6A) +#define FLASH_BASE IMXRT_FLEX2CIPHER_BASE +#endif /* context passed to cinit */ #if INTERFACE_USART @@ -287,6 +314,27 @@ board_deinit(void) px4_arch_configgpio(MK_GPIO_INPUT(BOARD_PIN_LED_BOOTLOADER)); #endif +#ifdef CONFIG_ARCH_FAMILY_IMXRT106x + + // Restore CCM registers to ROM state + putreg32(0x00000001, IMXRT_CCM_CACRR); + putreg32(0x000A8200, IMXRT_CCM_CBCDR); + putreg32(0x06490B03, IMXRT_CCM_CSCDR1); + putreg32(0x75AE8104, IMXRT_CCM_CBCMR); + putreg32(0x67930001, IMXRT_CCM_CSCMR1); + + imxrt_clockoff_lpuart3(); + imxrt_clockoff_usboh3(); + imxrt_clockoff_timer3(); + imxrt_clockoff_xbar1(); + imxrt_clockoff_xbar3(); + + up_disable_icache(); + up_disable_dcache(); + +#endif + +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x const uint32_t dnfw[] = { CCM_CR_M7, CCM_CR_BUS, @@ -309,6 +357,8 @@ board_deinit(void) putreg32(CCM_CR_CTRL_OFF, IMXRT_CCM_CR_CTRL(i)); } } + +#endif } inline void arch_systic_init(void) @@ -365,7 +415,7 @@ ssize_t arch_flash_write(uintptr_t address, const void *buffer, size_t buflen) j++; } - uintptr_t offset = ((uintptr_t) address) - IMXRT_FLEXSPI1_CIPHER_BASE; + uintptr_t offset = ((uintptr_t) address) - FLASH_BASE; volatile uint32_t status = ROM_FLEXSPI_NorFlash_ProgramPage(1, pConfig, offset, (const uint32_t *)buffer); up_invalidate_dcache((uintptr_t)address, @@ -400,7 +450,7 @@ flash_func_sector_size(unsigned sector) ssize_t up_progmem_ispageerased(unsigned sector) { const uint32_t bytes_per_sector = flash_func_sector_size(sector); - uint32_t *address = (uint32_t *)(IMXRT_FLEXSPI1_CIPHER_BASE + (sector * bytes_per_sector)); + uint32_t *address = (uint32_t *)(FLASH_BASE + (sector * bytes_per_sector)); const uint32_t uint32_per_sector = bytes_per_sector / sizeof(*address); int blank = 0; /* Assume it is Bank */ @@ -437,9 +487,9 @@ flash_func_erase_sector(unsigned sector, bool force) struct flexspi_nor_config_s *pConfig = &g_bootConfig; const uint32_t bytes_per_sector = flash_func_sector_size(sector); - uint32_t *address = (uint32_t *)(IMXRT_FLEXSPI1_CIPHER_BASE + (sector * bytes_per_sector)); + uint32_t *address = (uint32_t *)(FLASH_BASE + (sector * bytes_per_sector)); - uintptr_t offset = ((uintptr_t) address) - IMXRT_FLEXSPI1_CIPHER_BASE; + uintptr_t offset = ((uintptr_t) address) - FLASH_BASE; irqstate_t flags; flags = enter_critical_section(); volatile uint32_t status = ROM_FLEXSPI_NorFlash_Erase(1, pConfig, (uintptr_t) offset, bytes_per_sector); @@ -473,6 +523,8 @@ flash_func_read_otp(uintptr_t address) return 0; } +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x + uint32_t get_mcu_id(void) { // ??? is DEBUGMCU get able @@ -499,6 +551,36 @@ int get_mcu_desc(int max, uint8_t *revstr) return strp - revstr; } +#elif defined(CONFIG_ARCH_FAMILY_IMXRT106x) + +uint32_t get_mcu_id(void) +{ + return getreg32(IMXRT_OCOTP_UNIQUE_ID_LSB); +} + +int get_mcu_desc(int max, uint8_t *revstr) +{ + uint32_t info = getreg32(IMXRT_USB_ANALOG_DIGPROG); + // CHIP_TAG "i.MX RT10?? r?.?" + static uint8_t chip[sizeof(CHIP_TAG) + 1] = CHIP_TAG; + chip[CHIP_TAG_LEN - 1] = '0' + DIGPROG_MINOR(info); + chip[CHIP_TAG_LEN - 3] = '1' + DIGPROG_MAJOR_LOWER(info); + chip[CHIP_TAG_LEN - 6] = getreg32(0x401F867C) == 0x10 ? '4' : '2'; + chip[CHIP_TAG_LEN - 7] = DIGPROG_MAJOR_UPPER(info) == 0x6a ? '5' : '6'; + + uint8_t *endp = &revstr[max - 1]; + uint8_t *strp = revstr; + uint8_t *des = chip; + + while (strp < endp && *des) { + *strp++ = *des++; + } + + return strp - revstr; +} + +#endif + int check_silicon(void) { @@ -717,6 +799,7 @@ bootloader_main(void) * Returns - 0 if connected. * ************************************************************************************/ +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x #undef IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT #define USB1_VBUS_DET_STAT_OFFSET 0xd0 #define IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT (IMXRT_USBPHY1_BASE + USB1_VBUS_DET_STAT_OFFSET) @@ -727,6 +810,17 @@ bootloader_main(void) try_boot = false; } +#elif defined(CONFIG_ARCH_FAMILY_IMXRT106x) +#undef IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT +#define IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT (IMXRT_ANATOP_BASE + IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT_OFFSET) + + if ((getreg32(IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT) & USB_ANALOG_USB_VBUS_DETECT_STAT_VBUS_VALID) != 0) { + usb_connected = true; + /* don't try booting before we set up the bootloader */ + try_boot = false; + } + +#endif #endif #if INTERFACE_USART diff --git a/platforms/nuttx/src/bootloader/nxp/rt106x/CMakeLists.txt b/platforms/nuttx/src/bootloader/nxp/rt106x/CMakeLists.txt new file mode 100644 index 0000000000..a1c9b593c9 --- /dev/null +++ b/platforms/nuttx/src/bootloader/nxp/rt106x/CMakeLists.txt @@ -0,0 +1,34 @@ +############################################################################ +# +# Copyright (c) 2023 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(../imxrt_common arch_bootloader) diff --git a/platforms/nuttx/src/px4/common/SerialImpl.cpp b/platforms/nuttx/src/px4/common/SerialImpl.cpp index 9bb84dd902..f8968e4881 100644 --- a/platforms/nuttx/src/px4/common/SerialImpl.cpp +++ b/platforms/nuttx/src/px4/common/SerialImpl.cpp @@ -180,8 +180,34 @@ bool SerialImpl::configure() // uart_config.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG); - /* no parity, one stop bit, disable flow control */ - uart_config.c_cflag &= ~(CSTOPB | PARENB | CRTSCTS); + // Control modes + uart_config.c_cflag = 0; + + switch (_bytesize) { + case ByteSize::FiveBits: uart_config.c_cflag |= CS5; break; + + case ByteSize::SixBits: uart_config.c_cflag |= CS6; break; + + case ByteSize::SevenBits: uart_config.c_cflag |= CS7; break; + + case ByteSize::EightBits: uart_config.c_cflag |= CS8; break; + } + + if (_flowcontrol == FlowControl::Enabled) { + uart_config.c_cflag |= CRTSCTS; + } + + if (_parity != Parity::None) { + uart_config.c_cflag |= PARENB; + } + + if (_parity == Parity::Odd) { + uart_config.c_cflag |= PARODD; + } + + if (_stopbits == StopBits::Two) { + uart_config.c_cflag |= CSTOPB; + } /* set baud rate */ if ((termios_state = cfsetispeed(&uart_config, speed)) < 0) { @@ -486,7 +512,19 @@ ByteSize SerialImpl::getBytesize() const bool SerialImpl::setBytesize(ByteSize bytesize) { - return bytesize == ByteSize::EightBits; + // check if already configured + if ((bytesize == _bytesize) && _open) { + return true; + } + + _bytesize = bytesize; + + // process bytesize change now if port is already open + if (_open) { + return configure(); + } + + return true; } Parity SerialImpl::getParity() const @@ -496,7 +534,19 @@ Parity SerialImpl::getParity() const bool SerialImpl::setParity(Parity parity) { - return parity == Parity::None; + // check if already configured + if ((parity == _parity) && _open) { + return true; + } + + _parity = parity; + + // process parity change now if port is already open + if (_open) { + return configure(); + } + + return true; } StopBits SerialImpl::getStopbits() const @@ -506,7 +556,19 @@ StopBits SerialImpl::getStopbits() const bool SerialImpl::setStopbits(StopBits stopbits) { - return stopbits == StopBits::One; + // check if already configured + if ((stopbits == _stopbits) && _open) { + return true; + } + + _stopbits = stopbits; + + // process stopbits change now if port is already open + if (_open) { + return configure(); + } + + return true; } FlowControl SerialImpl::getFlowcontrol() const @@ -516,7 +578,19 @@ FlowControl SerialImpl::getFlowcontrol() const bool SerialImpl::setFlowcontrol(FlowControl flowcontrol) { - return flowcontrol == FlowControl::Disabled; + // check if already configured + if ((flowcontrol == _flowcontrol) && _open) { + return true; + } + + _flowcontrol = flowcontrol; + + // process flowcontrol change now if port is already open + if (_open) { + return configure(); + } + + return true; } bool SerialImpl::getSingleWireMode() const diff --git a/platforms/nuttx/src/px4/nxp/imxrt/board_reset/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/imxrt/board_reset/CMakeLists.txt index deff20f14c..cba22cb320 100644 --- a/platforms/nuttx/src/px4/nxp/imxrt/board_reset/CMakeLists.txt +++ b/platforms/nuttx/src/px4/nxp/imxrt/board_reset/CMakeLists.txt @@ -35,9 +35,7 @@ px4_add_library(arch_board_reset board_reset.cpp ) -if (CONFIG_ARCH_FAMILY_IMXRT117x) target_link_libraries(arch_board_reset PRIVATE arch_board_romapi) -endif() # up_systemreset if (NOT DEFINED CONFIG_BUILD_FLAT) diff --git a/platforms/nuttx/src/px4/nxp/imxrt/board_reset/board_reset.cpp b/platforms/nuttx/src/px4/nxp/imxrt/board_reset/board_reset.cpp index 1d29a64dfb..632180f412 100644 --- a/platforms/nuttx/src/px4/nxp/imxrt/board_reset/board_reset.cpp +++ b/platforms/nuttx/src/px4/nxp/imxrt/board_reset/board_reset.cpp @@ -45,6 +45,12 @@ #ifdef CONFIG_ARCH_FAMILY_IMXRT117x #include +#elif defined CONFIG_ARCH_FAMILY_IMXRT106x +# include +# define SNVS_LPCR_GPR_Z_DIS (1 << 24) /* Bit 24: General Purpose Registers Zeroization Disable */ +#endif + +#ifdef BOARD_HAS_ISP_BOOTLOADER #include #include #endif @@ -59,12 +65,12 @@ static int board_reset_enter_bootloader() { -#ifdef CONFIG_ARCH_FAMILY_IMXRT117x +#ifdef BOARD_HAS_TEENSY_BOOTLOADER + asm("BKPT #251"); /* Enter Teensy MKL02 bootloader */ +#else uint32_t regvalue = BOOT_RTC_SIGNATURE; modifyreg32(IMXRT_SNVS_LPCR, 0, SNVS_LPCR_GPR_Z_DIS); putreg32(regvalue, PX4_IMXRT_RTC_REBOOT_REG_ADDRESS); -#elif defined(BOARD_HAS_TEENSY_BOOTLOADER) - asm("BKPT #251"); /* Enter Teensy MKL02 bootloader */ #endif return OK; } @@ -75,15 +81,14 @@ int board_reset(int status) board_reset_enter_bootloader(); } -#if defined(BOARD_HAS_ISP_BOOTLOADER) - else if (status == REBOOT_TO_ISP) { +#ifdef BOARD_HAS_ISP_BOOTLOADER uint32_t arg = 0xeb100000; ROM_API_Init(); ROM_RunBootloader(&arg); +#endif } -#endif #if defined(BOARD_HAS_ON_RESET) board_on_reset(status); diff --git a/platforms/nuttx/src/px4/nxp/imxrt/dshot/dshot.c b/platforms/nuttx/src/px4/nxp/imxrt/dshot/dshot.c index 233d4fc288..7bd2508ddf 100644 --- a/platforms/nuttx/src/px4/nxp/imxrt/dshot/dshot.c +++ b/platforms/nuttx/src/px4/nxp/imxrt/dshot/dshot.c @@ -74,26 +74,40 @@ typedef enum { BDSHOT_RECEIVE_COMPLETE, } dshot_state; -typedef struct dshot_handler_t { +typedef struct dshot_channel_t { bool init; uint32_t data_seg1; uint32_t irq_data; dshot_state state; - bool bdshot; uint32_t raw_response; uint16_t erpm; uint32_t crc_error_cnt; uint32_t frame_error_cnt; uint32_t no_response_cnt; uint32_t last_no_response_cnt; -} dshot_handler_t; + bool bdshot; + uint32_t bdshot_tcmp; + uint32_t bdshot_training_mask; + uint8_t bdshot_training_count; + uint8_t bdshot_training_success; + bool bdshot_training_done; + int8_t bdshot_tcmp_offset; +} dshot_channel_t; #define BDSHOT_OFFLINE_COUNT 400 // If there are no responses for 400 setpoints ESC is offline -static dshot_handler_t dshot_inst[DSHOT_TIMERS] = {}; +#define BDSHOT_TCMP_MIN_OFFSET -16 +#define BDSHOT_TCMP_MAX_OFFSET 15 +#define BDSHOT_TCMP_TO_MASK(x) ((x) - BDSHOT_TCMP_MIN_OFFSET) +#define BDSHOT_TRAINING_TRIES 200 +#define BDSHOT_TRAINING_SUCCESS 198 + +#define BDSHOT_ZERO_RESPONSE 0x52951 + +static dshot_channel_t dshot_inst[DSHOT_TIMERS] = {}; static uint32_t dshot_tcmp; -static uint32_t bdshot_tcmp; +static unsigned dshot_speed; static uint32_t dshot_mask; static uint32_t bdshot_recv_mask; static uint32_t bdshot_parsed_recv_mask; @@ -155,6 +169,12 @@ static inline void clear_timer_status_flags(uint32_t mask) flexio_putreg32(mask, IMXRT_FLEXIO_TIMSTAT_OFFSET); } +static inline void flexio_dshot_set_tcmp(uint32_t channel) +{ + dshot_inst[channel].bdshot_tcmp = 0x2900 | (((BOARD_FLEXIO_PREQ / (dshot_speed * 5 / 4) / 2) + + dshot_inst[channel].bdshot_tcmp_offset) & 0xFF); +} + static void flexio_dshot_output(uint32_t channel, uint32_t pin, uint32_t timcmp, bool inverted) { /* Disable Shifter */ @@ -278,7 +298,7 @@ static int flexio_irq_handler(int irq, void *context, void *arg) IMXRT_FLEXIO_TIMCFG0_OFFSET + channel * 0x4); /* Enable on pin transition, resychronize through reset on rising edge */ - flexio_putreg32(bdshot_tcmp, IMXRT_FLEXIO_TIMCMP0_OFFSET + channel * 0x4); + flexio_putreg32(dshot_inst[channel].bdshot_tcmp, IMXRT_FLEXIO_TIMCMP0_OFFSET + channel * 0x4); /* Trigger on FXIO pin transition, Baud mode */ flexio_putreg32(FLEXIO_TIMCTL_TRGSEL(2 * timer_io_channels[channel].dshot.flexio_pin) | @@ -305,7 +325,7 @@ int up_dshot_init(uint32_t channel_mask, unsigned dshot_pwm_freq, bool enable_bi { /* Calculate dshot timings based on dshot_pwm_freq */ dshot_tcmp = 0x2F00 | (((BOARD_FLEXIO_PREQ / (dshot_pwm_freq * 3) / 2) - 1) & 0xFF); - bdshot_tcmp = 0x2900 | (((BOARD_FLEXIO_PREQ / (dshot_pwm_freq * 5 / 4) / 2) - 3) & 0xFF); + dshot_speed = dshot_pwm_freq; /* Clock FlexIO peripheral */ imxrt_clockall_flexio1(); @@ -340,7 +360,16 @@ int up_dshot_init(uint32_t channel_mask, unsigned dshot_pwm_freq, bool enable_bi imxrt_config_gpio(timer_io_channels[channel].dshot.pinmux | IOMUX_PULL_UP); - dshot_inst[channel].bdshot = enable_bidirectional_dshot; + if (enable_bidirectional_dshot) { + dshot_inst[channel].bdshot = true; + dshot_inst[channel].bdshot_training_mask = 0; + dshot_inst[channel].bdshot_tcmp_offset = BDSHOT_TCMP_MIN_OFFSET; + dshot_inst[channel].bdshot_training_done = false; + flexio_dshot_set_tcmp(channel); + + } else { + dshot_inst[channel].bdshot = false; + } flexio_dshot_output(channel, timer_io_channels[channel].dshot.flexio_pin, dshot_tcmp, dshot_inst[channel].bdshot); @@ -357,6 +386,52 @@ int up_dshot_init(uint32_t channel_mask, unsigned dshot_pwm_freq, bool enable_bi return channel_mask; } +void up_bdshot_training(uint32_t channel, uint32_t value) +{ + dshot_channel_t *ch = &dshot_inst[channel]; + + if (value == BDSHOT_ZERO_RESPONSE) { + // Count successful responses + ch->bdshot_training_success++; + + } else if ((value & 0x1) == 0) { + // Invalidate frame error immediately + ch->bdshot_training_count = BDSHOT_TRAINING_TRIES - 1; + } + + // Keep count and check if a training round finished + ch->bdshot_training_count++; + + if (ch->bdshot_training_count == BDSHOT_TRAINING_TRIES) { + if (ch->bdshot_training_success >= BDSHOT_TRAINING_SUCCESS) { + ch->bdshot_training_mask |= + (1 << BDSHOT_TCMP_TO_MASK(ch->bdshot_tcmp_offset)); + } + + ch->bdshot_training_count = 0; + ch->bdshot_training_success = 0; + ch->bdshot_tcmp_offset++; + + if (ch->bdshot_tcmp_offset == BDSHOT_TCMP_MAX_OFFSET) { + + if (ch->bdshot_training_mask == 0) { + // No candidates retry + ch->bdshot_tcmp_offset = BDSHOT_TCMP_MIN_OFFSET; + + } else { + // Training done, use mask to find best offset + int low = __builtin_ctz(ch->bdshot_training_mask); + int high = 31 - __builtin_clz(ch->bdshot_training_mask); + ch->bdshot_tcmp_offset = ((low + high) / 2) + BDSHOT_TCMP_MIN_OFFSET; + ch->bdshot_training_done = true; + } + } + + // Update TCMP + flexio_dshot_set_tcmp(channel); + } +} + void up_bdshot_erpm(void) { uint32_t value; @@ -373,8 +448,12 @@ void up_bdshot_erpm(void) if (bdshot_recv_mask & (1 << channel)) { value = ~dshot_inst[channel].raw_response & 0xFFFFF; - /* if lowest significant isn't 1 we've got a framing error */ - if (value & 0x1) { + // BDSHOT ESC hardware varies and timings differ between units. + // Run training to estimate the correct baudrate to lock onto. + if (!dshot_inst[channel].bdshot_training_done) { + up_bdshot_training(channel, value); + + } else if (value & 0x1) { /* if lowest significant isn't 1 we've got a framing error */ /* Decode RLL */ value = (value ^ (value >> 1)); @@ -425,7 +504,7 @@ int up_bdshot_num_erpm_ready(void) for (unsigned i = 0; i < DSHOT_TIMERS; ++i) { // We only check that data has been received, rather than if it's valid. // This ensures data is published even if one channel has bit errors. - if (bdshot_recv_mask & (1 << i)) { + if (bdshot_parsed_recv_mask & (1 << i)) { ++num_ready; } } @@ -461,6 +540,8 @@ void up_bdshot_status(void) if (dshot_inst[channel].init) { PX4_INFO("Channel %i %s Last erpm %i value", channel, up_bdshot_channel_status(channel) ? "online" : "offline", dshot_inst[channel].erpm); + PX4_INFO("BDSHOT Training done: %s TCMP offset: %d", dshot_inst[channel].bdshot_training_done ? "YES" : "NO", + dshot_inst[channel].bdshot_tcmp_offset); PX4_INFO("CRC errors Frame error No response"); PX4_INFO("%10lu %11lu %11lu", dshot_inst[channel].crc_error_cnt, dshot_inst[channel].frame_error_cnt, dshot_inst[channel].no_response_cnt); diff --git a/platforms/nuttx/src/px4/nxp/imxrt/include/px4_arch/imxrt_flexspi_nor_flash.h b/platforms/nuttx/src/px4/nxp/imxrt/include/px4_arch/imxrt_flexspi_nor_flash.h index 727744b974..e58554aa5b 100644 --- a/platforms/nuttx/src/px4/nxp/imxrt/include/px4_arch/imxrt_flexspi_nor_flash.h +++ b/platforms/nuttx/src/px4/nxp/imxrt/include/px4_arch/imxrt_flexspi_nor_flash.h @@ -138,18 +138,33 @@ (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \ FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1)) +#ifdef CONFIG_ARCH_FAMILY_IMXRT106x +//!@brief Definitions for FlexSPI Serial Clock Frequency +typedef enum _FlexSpiSerialClockFreq { + kFlexSpiSerialClk_30MHz = 1, + kFlexSpiSerialClk_50MHz = 2, + kFlexSpiSerialClk_60MHz = 3, + kFlexSpiSerialClk_75MHz = 4, + kFlexSpiSerialClk_80MHz = 5, + kFlexSpiSerialClk_100MHz = 6, + kFlexSpiSerialClk_120MHz = 7, + kFlexSpiSerialClk_133MHz = 8, + kFlexSpiSerialClk_166MHz = 9, +} flexspi_serial_clk_freq_t; +#elif defined(CONFIG_ARCH_FAMILY_IMXRT117x) //!@brief Definitions for FlexSPI Serial Clock Frequency typedef enum _FlexSpiSerialClockFreq { kFlexSpiSerialClk_30MHz = 1, kFlexSpiSerialClk_50MHz = 2, kFlexSpiSerialClk_60MHz = 3, kFlexSpiSerialClk_80MHz = 4, - kFlexSpiSerialClk_100MHz = 5, + kFlexSpiSerialClk_100MHz = 5, kFlexSpiSerialClk_120MHz = 6, kFlexSpiSerialClk_133MHz = 7, kFlexSpiSerialClk_166MHz = 8, kFlexSpiSerialClk_200MHz = 9, } flexspi_serial_clk_freq_t; +#endif //!@brief FlexSPI clock configuration type enum { diff --git a/platforms/nuttx/src/px4/nxp/imxrt/include/px4_arch/imxrt_romapi.h b/platforms/nuttx/src/px4/nxp/imxrt/include/px4_arch/imxrt_romapi.h index f51775e2bd..fa944e0c1b 100644 --- a/platforms/nuttx/src/px4/nxp/imxrt/include/px4_arch/imxrt_romapi.h +++ b/platforms/nuttx/src/px4/nxp/imxrt/include/px4_arch/imxrt_romapi.h @@ -239,7 +239,9 @@ status_t ROM_FLEXSPI_NorFlash_Erase(uint32_t instance, flexspi_nor_config_t *con * @retval kStatus_ROM_FLEXSPI_SequenceExecutionTimeout Sequence Execution timeout. * @retval kStatus_ROM_FLEXSPI_DeviceTimeout the device timeout */ +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x status_t ROM_FLEXSPI_NorFlash_EraseSector(uint32_t instance, flexspi_nor_config_t *config, uint32_t start); +#endif /*! * @brief Erase one block specified by address @@ -259,7 +261,9 @@ status_t ROM_FLEXSPI_NorFlash_EraseSector(uint32_t instance, flexspi_nor_config_ * @retval kStatus_ROM_FLEXSPI_SequenceExecutionTimeout Sequence Execution timeout. * @retval kStatus_ROM_FLEXSPI_DeviceTimeout the device timeout */ +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x status_t ROM_FLEXSPI_NorFlash_EraseBlock(uint32_t instance, flexspi_nor_config_t *config, uint32_t start); +#endif /*! * @brief Erase all the Serial NOR devices connected on FLEXSPI. @@ -342,10 +346,12 @@ status_t ROM_FLEXSPI_NorFlash_UpdateLut(uint32_t instance, * @retval kStatus_ROM_FLEXSPI_InvalidSequence A invalid Sequence is provided. * @retval kStatus_ROM_FLEXSPI_DeviceTimeout Device timeout. */ +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x status_t ROM_FLEXSPI_NorFlash_WaitBusy(uint32_t instance, flexspi_nor_config_t *config, bool isParallelMode, uint32_t address); +#endif /*@}*/ /*! diff --git a/platforms/nuttx/src/px4/nxp/imxrt/romapi/imxrt_romapi.c b/platforms/nuttx/src/px4/nxp/imxrt/romapi/imxrt_romapi.c index 68443e3353..e6b657d326 100644 --- a/platforms/nuttx/src/px4/nxp/imxrt/romapi/imxrt_romapi.c +++ b/platforms/nuttx/src/px4/nxp/imxrt/romapi/imxrt_romapi.c @@ -52,8 +52,29 @@ typedef union _standard_version { #endif } standard_version_t; + +#ifdef CONFIG_ARCH_FAMILY_IMXRT106x + /*! - * @brief Interface for the ROM FLEXSPI NOR flash driver. + * @brief Interface for the IMXRT106X ROM FLEXSPI NOR flash driver. + */ +typedef struct { + uint32_t version; + status_t (*init)(uint32_t instance, flexspi_nor_config_t *config); + status_t (*page_program)(uint32_t instance, flexspi_nor_config_t *config, uint32_t dst_addr, const uint32_t *src); + status_t (*erase_all)(uint32_t instance, flexspi_nor_config_t *config); + status_t (*erase)(uint32_t instance, flexspi_nor_config_t *config, uint32_t start, uint32_t length); + status_t (*read)(uint32_t instance, flexspi_nor_config_t *config, uint32_t *dst, uint32_t start, uint32_t bytes); + void (*clear_cache)(uint32_t instance); + status_t (*xfer)(uint32_t instance, flexspi_xfer_t *xfer); + status_t (*update_lut)(uint32_t instance, uint32_t seqIndex, const uint32_t *lutBase, uint32_t numberOfSeq); + status_t (*get_config)(uint32_t instance, flexspi_nor_config_t *config, serial_nor_config_option_t *option); +} flexspi_nor_driver_interface_t; + +#elif defined(CONFIG_ARCH_FAMILY_IMXRT117x) + +/*! + * @brief Interface for the IMXRT117X ROM FLEXSPI NOR flash driver. */ typedef struct { uint32_t version; @@ -73,6 +94,33 @@ typedef struct { const uint32_t reserved1[2]; /*!< Reserved */ } flexspi_nor_driver_interface_t; +#endif + + +#ifdef CONFIG_ARCH_FAMILY_IMXRT106x + +/*! +* @brief Root of the bootloader api tree. +* +* An instance of this struct resides in read-only memory in the bootloader. It +* provides a user application access to APIs exported by the bootloader. +* +* @note The order of existing fields must not be changed. +*/ +typedef struct { + const uint32_t version; //!< Bootloader version number + const char *copyright; //!< Bootloader Copyright + void (*runBootloader)(void *arg); //!< Function to start the bootloader executing + const uint32_t *reserved0; //!< Reserved + const flexspi_nor_driver_interface_t *flexSpiNorDriver; //!< FlexSPI NOR Flash API + const uint32_t *reserved1; //!< Reserved + const uint32_t *unused_rtwdogDriver; + const uint32_t *unused_wdogDriver; + const uint32_t *reserved2; +} bootloader_api_entry_t; + +#elif defined(CONFIG_ARCH_FAMILY_IMXRT117x) + /*! * @brief Root of the bootloader api tree. * @@ -89,6 +137,8 @@ typedef struct { const uint32_t reserved[8]; /*!< Reserved */ } bootloader_api_entry_t; +#endif + /******************************************************************************* * Variables ******************************************************************************/ @@ -104,13 +154,18 @@ static bootloader_api_entry_t *g_bootloaderTree = NULL; locate_code(".ramfunc") void ROM_API_Init(void) { +#ifdef CONFIG_ARCH_FAMILY_IMXRT106x + g_bootloaderTree = ((bootloader_api_entry_t *) * (uint32_t *)0x0020001cU); +#else - if ((getreg32(IMXRT_ANADIG_MISC_MISC_DIFPROG) & ANADIG_MISC_MISC_DIFPROG_CHIPID(0x10U)) != 0U) { - g_bootloaderTree = ((bootloader_api_entry_t *) * (uint32_t *)0x0021001cU); + if (getreg32(IMXRT_ANADIG_MISC_MISC_DIFPROG) == 0x001170A0U) { + g_bootloaderTree = ((bootloader_api_entry_t *) * (uint32_t *)0x0020001cU); } else { - g_bootloaderTree = ((bootloader_api_entry_t *) * (uint32_t *)0x0020001cU); + g_bootloaderTree = ((bootloader_api_entry_t *) * (uint32_t *)0x0021001cU); } + +#endif } /*! @@ -193,6 +248,8 @@ status_t ROM_FLEXSPI_NorFlash_Erase(uint32_t instance, flexspi_nor_config_t *con return g_bootloaderTree->flexSpiNorDriver->erase(instance, config, start, length); } +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x + /*! * @brief Erase one sector specified by address. * @@ -219,6 +276,8 @@ status_t ROM_FLEXSPI_NorFlash_EraseBlock(uint32_t instance, flexspi_nor_config_t return g_bootloaderTree->flexSpiNorDriver->erase_block(instance, config, start); } +#endif + /*! @brief Erase all the Serial NOR devices connected on FLEXSPI. */ locate_code(".ramfunc") status_t ROM_FLEXSPI_NorFlash_EraseAll(uint32_t instance, flexspi_nor_config_t *config) @@ -242,23 +301,42 @@ status_t ROM_FLEXSPI_NorFlash_UpdateLut(uint32_t instance, return g_bootloaderTree->flexSpiNorDriver->update_lut(instance, seqIndex, lutBase, seqNumber); } + +#ifdef CONFIG_ARCH_FAMILY_IMXRT106x + +/*! @brief Software reset for the FLEXSPI logic. */ +locate_code(".ramfunc") +void ROM_FLEXSPI_NorFlash_ClearCache(uint32_t instance) +{ + g_bootloaderTree->flexSpiNorDriver->clear_cache(instance); +} + + +#elif defined(CONFIG_ARCH_FAMILY_IMXRT117x) + /*! @brief Software reset for the FLEXSPI logic. */ locate_code(".ramfunc") void ROM_FLEXSPI_NorFlash_ClearCache(uint32_t instance) { uint32_t clearCacheFunctionAddress; - if ((getreg32(IMXRT_ANADIG_MISC_MISC_DIFPROG) & ANADIG_MISC_MISC_DIFPROG_CHIPID(0x10U)) != 0U) { + if (getreg32(IMXRT_ANADIG_MISC_MISC_DIFPROG) == 0x001170a0U) { + clearCacheFunctionAddress = 0x0020426bU; + + } else if (getreg32(IMXRT_ANADIG_MISC_MISC_DIFPROG) == 0x001170b0U) { clearCacheFunctionAddress = 0x0021a3b7U; } else { - clearCacheFunctionAddress = 0x0020426bU; + clearCacheFunctionAddress = 0x0021a3bfU; } clearCacheCommand_t clearCacheCommand; MISRA_CAST(clearCacheCommand_t, clearCacheCommand, uint32_t, clearCacheFunctionAddress); (void)clearCacheCommand(instance); } +#endif + +#ifdef CONFIG_ARCH_FAMILY_IMXRT117x /*! @brief Wait until device is idle*/ locate_code(".ramfunc") @@ -269,3 +347,5 @@ status_t ROM_FLEXSPI_NorFlash_WaitBusy(uint32_t instance, { return g_bootloaderTree->flexSpiNorDriver->wait_busy(instance, config, isParallelMode, address); } + +#endif diff --git a/platforms/nuttx/src/px4/nxp/imxrt/version/board_mcu_version.c b/platforms/nuttx/src/px4/nxp/imxrt/version/board_mcu_version.c index ae8594bd4f..94c75844d8 100644 --- a/platforms/nuttx/src/px4/nxp/imxrt/version/board_mcu_version.c +++ b/platforms/nuttx/src/px4/nxp/imxrt/version/board_mcu_version.c @@ -90,7 +90,7 @@ int board_mcu_version(char *rev, const char **revstr, const char **errata) #define DIGPROG_MAJOR_UPPER_MASK (0xff << DIGPROG_MAJOR_UPPER_SHIFT) #define DIGPROG_MAJOR_UPPER(info) (((info) & DIGPROG_MAJOR_UPPER_MASK) >> DIGPROG_MAJOR_UPPER_SHIFT) // 876543210 -#define CHIP_TAG "i.MX RT10?2 r?.?" +#define CHIP_TAG "i.MX RT10?? r?.?" #define CHIP_TAG_LEN sizeof(CHIP_TAG)-1 int board_mcu_version(char *rev, const char **revstr, const char **errata) @@ -100,6 +100,7 @@ int board_mcu_version(char *rev, const char **revstr, const char **errata) chip[CHIP_TAG_LEN - 1] = '0' + DIGPROG_MINOR(info); chip[CHIP_TAG_LEN - 3] = '1' + DIGPROG_MAJOR_LOWER(info); + chip[CHIP_TAG_LEN - 6] = getreg32(0x401F867C) == 0x10 ? '4' : '2'; chip[CHIP_TAG_LEN - 7] = DIGPROG_MAJOR_UPPER(info) == 0x6a ? '5' : '6'; *revstr = chip; *rev = '0' + DIGPROG_MINOR(info); diff --git a/platforms/nuttx/src/px4/nxp/rt106x/CMakeLists.txt b/platforms/nuttx/src/px4/nxp/rt106x/CMakeLists.txt index f487b031c7..57bd94ee6e 100644 --- a/platforms/nuttx/src/px4/nxp/rt106x/CMakeLists.txt +++ b/platforms/nuttx/src/px4/nxp/rt106x/CMakeLists.txt @@ -36,11 +36,13 @@ add_subdirectory(../imxrt/adc adc) add_subdirectory(../imxrt/board_critmon board_critmon) add_subdirectory(../imxrt/board_hw_info board_hw_info) add_subdirectory(../imxrt/board_reset board_reset) +add_subdirectory(../imxrt/romapi romapi) add_subdirectory(../imxrt/dshot dshot) add_subdirectory(../imxrt/hrt hrt) add_subdirectory(../imxrt/led_pwm led_pwm) add_subdirectory(../imxrt/io_pins io_pins) add_subdirectory(../imxrt/tone_alarm tone_alarm) add_subdirectory(../imxrt/version version) +add_subdirectory(../imxrt/spi spi) add_subdirectory(px4io_serial) diff --git a/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/hw_description.h b/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/hw_description.h index d4aada2ffe..27da505127 100644 --- a/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/hw_description.h +++ b/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/hw_description.h @@ -41,8 +41,8 @@ #include #include -#ifndef CONFIG_ARCH_CHIP_MIMXRT1062DVL6A -# error "This code has only been validated with IMXRT1062. Make sure it is correct before using it on another board." +#if !defined(CONFIG_ARCH_CHIP_MIMXRT1062DVL6A) && !defined(CONFIG_ARCH_CHIP_MIMXRT1064DVL6A) +# error "This code has only been validated with IMXRT1062 and IMXRT1064. Make sure it is correct before using it on another board." #endif /* diff --git a/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/imxrt_flexspi_nor_flash.h b/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/imxrt_flexspi_nor_flash.h new file mode 100644 index 0000000000..3925012e86 --- /dev/null +++ b/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/imxrt_flexspi_nor_flash.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2024 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. + * + ****************************************************************************/ +#pragma once + + +#include "../../../imxrt/include/px4_arch/imxrt_flexspi_nor_flash.h" diff --git a/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/imxrt_romapi.h b/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/imxrt_romapi.h new file mode 100644 index 0000000000..aeab841162 --- /dev/null +++ b/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/imxrt_romapi.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * + * Copyright (c) 2024 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. + * + ****************************************************************************/ +#pragma once + + +#include "../../../imxrt/include/px4_arch/imxrt_romapi.h" diff --git a/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/io_timer_hw_description.h b/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/io_timer_hw_description.h index 5cbc33fdc3..a5ec76ea25 100644 --- a/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/io_timer_hw_description.h +++ b/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/io_timer_hw_description.h @@ -47,8 +47,8 @@ #include #include -#ifndef CONFIG_ARCH_CHIP_MIMXRT1062DVL6A -# error "This code has only been validated with IMXRT1062. Make sure it is correct before using it on another board." +#if !defined(CONFIG_ARCH_CHIP_MIMXRT1062DVL6A) && !defined(CONFIG_ARCH_CHIP_MIMXRT1064DVL6A) +# error "This code has only been validated with IMXRT1062 and IMXRT1064. Make sure it is correct before using it on another board." #endif diff --git a/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/spi_hw_description.h b/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/spi_hw_description.h index de0c30247d..0e1a46b8e3 100644 --- a/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/spi_hw_description.h +++ b/platforms/nuttx/src/px4/nxp/rt106x/include/px4_arch/spi_hw_description.h @@ -46,6 +46,58 @@ #define GENERAL_OUTPUT_IOMUX (IOMUX_CMOS_OUTPUT | IOMUX_PULL_KEEP | IOMUX_DRIVE_33OHM | IOMUX_SPEED_MEDIUM | IOMUX_SLEW_FAST) +constexpr bool validateSPIConfig(const px4_spi_bus_t spi_busses_conf[SPI_BUS_MAX_BUS_ITEMS]) +{ + const bool nuttx_enabled_spi_buses[] = { +#ifdef CONFIG_IMXRT_LPSPI1 + true, +#else + false, +#endif +#ifdef CONFIG_IMXRT_LPSPI2 + true, +#else + false, +#endif +#ifdef CONFIG_IMXRT_LPSPI3 + true, +#else + false, +#endif +#ifdef CONFIG_IMXRT_LPSPI4 + true, +#else + false, +#endif +#ifdef CONFIG_IMXRT_LPSPI5 + true, +#else + false, +#endif +#ifdef CONFIG_IMXRT_LPSPI6 + true, +#else + false, +#endif + }; + + for (unsigned i = 0; i < sizeof(nuttx_enabled_spi_buses) / sizeof(nuttx_enabled_spi_buses[0]); ++i) { + bool found_bus = false; + + for (int j = 0; j < SPI_BUS_MAX_BUS_ITEMS; ++j) { + if (spi_busses_conf[j].bus == (int)i + 1) { + found_bus = true; + } + } + + // Either the bus is enabled in NuttX and configured in spi_busses_conf, or disabled and not configured + constexpr_assert(found_bus == nuttx_enabled_spi_buses[i], "SPI bus config mismatch (CONFIG_STM32H7_SPIx)"); + } + + return false; +} + + static inline constexpr px4_spi_bus_device_t initSPIDevice(uint32_t devid, SPI::CS cs_gpio, SPI::DRDY drdy_gpio = {}) { px4_spi_bus_device_t ret{}; @@ -138,8 +190,57 @@ static inline constexpr SPI::bus_device_external_cfg_t initSPIConfigExternal(SPI return ret; } -constexpr bool validateSPIConfig(const px4_spi_bus_t spi_busses_conf[SPI_BUS_MAX_BUS_ITEMS]) + +struct px4_spi_bus_array_t { + px4_spi_bus_t item[SPI_BUS_MAX_BUS_ITEMS]; +}; +#if defined(BOARD_HAS_HW_SPLIT_VERSIONING) +static inline constexpr px4_spi_bus_all_hw_t initSPIFmumID(hw_fmun_id_t hw_fmun_id, + const px4_spi_bus_array_t &bus_items) { - return true; + px4_spi_bus_all_hw_t ret{}; + + for (int i = 0; i < SPI_BUS_MAX_BUS_ITEMS; ++i) { + ret.buses[i] = bus_items.item[i]; + } + + ret.board_hw_fmun_id = hw_fmun_id; + return ret; } +#else +static inline constexpr px4_spi_bus_all_hw_t initSPIHWVersion(int hw_version_revision, + const px4_spi_bus_array_t &bus_items) +{ + px4_spi_bus_all_hw_t ret{}; + + for (int i = 0; i < SPI_BUS_MAX_BUS_ITEMS; ++i) { + ret.buses[i] = bus_items.item[i]; + } + + ret.board_hw_version_revision = hw_version_revision; + return ret; +} +#endif +constexpr bool validateSPIConfig(const px4_spi_bus_t spi_buses_conf[SPI_BUS_MAX_BUS_ITEMS]); + +constexpr bool validateSPIConfig(const px4_spi_bus_all_hw_t spi_buses_conf[BOARD_NUM_SPI_CFG_HW_VERSIONS]) +{ + for (int ver = 0; ver < BOARD_NUM_SPI_CFG_HW_VERSIONS; ++ver) { + validateSPIConfig(spi_buses_conf[ver].buses); + } + + for (int ver = 1; ver < BOARD_NUM_SPI_CFG_HW_VERSIONS; ++ver) { + for (int i = 0; i < SPI_BUS_MAX_BUS_ITEMS; ++i) { + const bool equal_power_enable_gpio = spi_buses_conf[ver].buses[i].power_enable_gpio == spi_buses_conf[ver - + 1].buses[i].power_enable_gpio; + // currently board_control_spi_sensors_power_configgpio() depends on that - this restriction can be removed + // by ensuring board_control_spi_sensors_power_configgpio() is called after the hw version is determined + // and SPI config is initialized. + constexpr_assert(equal_power_enable_gpio, "All HW versions must define the same power enable GPIO"); + } + } + + return false; +} + #endif // CONFIG_SPI diff --git a/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c index 7e8a19726d..495cb3be03 100644 --- a/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c @@ -888,9 +888,12 @@ int io_timer_channel_init(unsigned channel, io_timer_channel_mode_t mode, #if !defined(BOARD_HAS_NO_CAPTURE) case IOTimerChanMode_Capture: + setbits = CCMR_C1_CAPTURE_INIT; + break; + case IOTimerChanMode_CaptureDMA: setbits = CCMR_C1_CAPTURE_INIT; - gpio = timer_io_channels[channel].gpio_in; + gpio = timer_io_channels[channel].gpio_in | GPIO_PULLUP; break; #endif @@ -980,7 +983,6 @@ int io_timer_channel_init(unsigned channel, io_timer_channel_mode_t mode, int io_timer_set_enable(bool state, io_timer_channel_mode_t mode, io_timer_channel_allocation_t masks) { - struct action_cache_t { uint32_t ccer_clearbits; uint32_t ccer_setbits; @@ -1065,7 +1067,6 @@ int io_timer_set_enable(bool state, io_timer_channel_mode_t mode, io_timer_chann irqstate_t flags = px4_enter_critical_section(); - for (unsigned actions = 0; actions < arraySize(action_cache); actions++) { if (action_cache[actions].base != 0) { uint32_t rvalue = _REG32(action_cache[actions].base, STM32_GTIM_CCER_OFFSET); diff --git a/platforms/posix/src/px4/common/SerialImpl.cpp b/platforms/posix/src/px4/common/SerialImpl.cpp index 0c23b050e0..cb12b6919d 100644 --- a/platforms/posix/src/px4/common/SerialImpl.cpp +++ b/platforms/posix/src/px4/common/SerialImpl.cpp @@ -169,8 +169,34 @@ bool SerialImpl::configure() // uart_config.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG); - /* no parity, one stop bit, disable flow control */ - uart_config.c_cflag &= ~(CSTOPB | PARENB | CRTSCTS); + // Control modes + uart_config.c_cflag = 0; + + switch (_bytesize) { + case ByteSize::FiveBits: uart_config.c_cflag |= CS5; break; + + case ByteSize::SixBits: uart_config.c_cflag |= CS6; break; + + case ByteSize::SevenBits: uart_config.c_cflag |= CS7; break; + + case ByteSize::EightBits: uart_config.c_cflag |= CS8; break; + } + + if (_flowcontrol == FlowControl::Enabled) { + uart_config.c_cflag |= CRTSCTS; + } + + if (_parity != Parity::None) { + uart_config.c_cflag |= PARENB; + } + + if (_parity == Parity::Odd) { + uart_config.c_cflag |= PARODD; + } + + if (_stopbits == StopBits::Two) { + uart_config.c_cflag |= CSTOPB; + } /* set baud rate */ if ((termios_state = cfsetispeed(&uart_config, speed)) < 0) { @@ -445,7 +471,6 @@ uint32_t SerialImpl::getBaudrate() const bool SerialImpl::setBaudrate(uint32_t baudrate) { - // check if already configured if ((baudrate == _baudrate) && _open) { return true; } @@ -467,7 +492,17 @@ ByteSize SerialImpl::getBytesize() const bool SerialImpl::setBytesize(ByteSize bytesize) { - return bytesize == ByteSize::EightBits; + if ((bytesize == _bytesize) && _open) { + return true; + } + + _bytesize = bytesize; + + if (_open) { + return configure(); + } + + return true; } Parity SerialImpl::getParity() const @@ -477,7 +512,17 @@ Parity SerialImpl::getParity() const bool SerialImpl::setParity(Parity parity) { - return parity == Parity::None; + if ((parity == _parity) && _open) { + return true; + } + + _parity = parity; + + if (_open) { + return configure(); + } + + return true; } StopBits SerialImpl::getStopbits() const @@ -487,7 +532,17 @@ StopBits SerialImpl::getStopbits() const bool SerialImpl::setStopbits(StopBits stopbits) { - return stopbits == StopBits::One; + if ((stopbits == _stopbits) && _open) { + return true; + } + + _stopbits = stopbits; + + if (_open) { + return configure(); + } + + return true; } FlowControl SerialImpl::getFlowcontrol() const @@ -497,7 +552,17 @@ FlowControl SerialImpl::getFlowcontrol() const bool SerialImpl::setFlowcontrol(FlowControl flowcontrol) { - return flowcontrol == FlowControl::Disabled; + if ((flowcontrol == _flowcontrol) && _open) { + return true; + } + + _flowcontrol = flowcontrol; + + if (_open) { + return configure(); + } + + return true; } bool SerialImpl::getSingleWireMode() const diff --git a/platforms/qurt/src/px4/SerialImpl.cpp b/platforms/qurt/src/px4/SerialImpl.cpp index 312c830041..5c31be9a5c 100644 --- a/platforms/qurt/src/px4/SerialImpl.cpp +++ b/platforms/qurt/src/px4/SerialImpl.cpp @@ -103,25 +103,14 @@ bool SerialImpl::open() return false; } - if (_bytesize != ByteSize::EightBits) { - PX4_ERR("Qurt platform only supports ByteSize::EightBits"); - return false; - } + // Check all non-supported configurations without duplicating the error strings + if (!setBytesize(_bytesize)) { return false; } - if (_parity != Parity::None) { - PX4_ERR("Qurt platform only supports Parity::None"); - return false; - } + if (!setParity(_parity)) { return false; } - if (_stopbits != StopBits::One) { - PX4_ERR("Qurt platform only supports StopBits::One"); - return false; - } + if (!setStopbits(_stopbits)) { return false; } - if (_flowcontrol != FlowControl::Disabled) { - PX4_ERR("Qurt platform only supports FlowControl::Disabled"); - return false; - } + if (!setFlowcontrol(_flowcontrol)) { return false; } if (!validatePort(_port)) { PX4_ERR("Invalid port %s", _port); @@ -348,7 +337,12 @@ ByteSize SerialImpl::getBytesize() const bool SerialImpl::setBytesize(ByteSize bytesize) { - return bytesize == ByteSize::EightBits; + if (bytesize != ByteSize::EightBits) { + PX4_ERR("Qurt platform only supports ByteSize::EightBits"); + return false; + } + + return true; } Parity SerialImpl::getParity() const @@ -358,7 +352,12 @@ Parity SerialImpl::getParity() const bool SerialImpl::setParity(Parity parity) { - return parity == Parity::None; + if (parity != Parity::None) { + PX4_ERR("Qurt platform only supports Parity::None"); + return false; + } + + return true; } StopBits SerialImpl::getStopbits() const @@ -368,7 +367,12 @@ StopBits SerialImpl::getStopbits() const bool SerialImpl::setStopbits(StopBits stopbits) { - return stopbits == StopBits::One; + if (stopbits != StopBits::One) { + PX4_ERR("Qurt platform only supports StopBits::One"); + return false; + } + + return true; } FlowControl SerialImpl::getFlowcontrol() const @@ -378,7 +382,12 @@ FlowControl SerialImpl::getFlowcontrol() const bool SerialImpl::setFlowcontrol(FlowControl flowcontrol) { - return flowcontrol == FlowControl::Disabled; + if (flowcontrol != FlowControl::Disabled) { + PX4_ERR("Qurt platform only supports FlowControl::Disabled"); + return false; + } + + return true; } bool SerialImpl::getSingleWireMode() const @@ -388,8 +397,12 @@ bool SerialImpl::getSingleWireMode() const bool SerialImpl::setSingleWireMode() { - // Qurt platform does not support single wire mode - return false; + if (enable) { + PX4_ERR("Qurt platform does not support single wire mode"); + return false; + } + + return true; } bool SerialImpl::getSwapRxTxMode() const @@ -399,14 +412,22 @@ bool SerialImpl::getSwapRxTxMode() const bool SerialImpl::setSwapRxTxMode() { - // Qurt platform does not support swap rx tx mode - return false; + if (enable) { + PX4_ERR("Qurt platform does not support swap rx tx mode"); + return false; + } + + return true; } bool SerialImpl::setInvertedMode(bool enable) { - // Qurt platform does not support inverted mode - return false == enable; + if (enable) { + PX4_ERR("Qurt platform does not support inverted mode"); + return false; + } + + return true; } bool SerialImpl::getInvertedMode() const { diff --git a/src/drivers/adc/ads1115/ads1115_main.cpp b/src/drivers/adc/ads1115/ads1115_main.cpp index 1967b58263..140b8dfd0e 100644 --- a/src/drivers/adc/ads1115/ads1115_main.cpp +++ b/src/drivers/adc/ads1115/ads1115_main.cpp @@ -154,6 +154,7 @@ If enabled, internal ADCs are not used. )DESCR_STR"); PRINT_MODULE_USAGE_NAME("ads1115", "driver"); + PRINT_MODULE_USAGE_SUBCATEGORY("adc"); PRINT_MODULE_USAGE_COMMAND("start"); PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false); PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(0x48); diff --git a/src/drivers/adc/ads7953/ADS7953.cpp b/src/drivers/adc/ads7953/ADS7953.cpp new file mode 100644 index 0000000000..8a25b56c5b --- /dev/null +++ b/src/drivers/adc/ads7953/ADS7953.cpp @@ -0,0 +1,135 @@ + +#include "ADS7953.h" +#include +#include +#include +#include + +ADS7953::ADS7953(const I2CSPIDriverConfig &config) : + SPI(config), + I2CSPIDriver(config), + ModuleParams(nullptr), + _cycle_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": single-sample")), + _comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors")) +{ + static_assert(arraySize(adc_report_s::channel_id) >= NUM_CHANNELS, "ADS7953 reports 16 channels"); +} + +ADS7953::~ADS7953() +{ + ScheduleClear(); + perf_free(_cycle_perf); + perf_free(_comms_errors); +} + +int ADS7953::init() +{ + int ret = SPI::init(); + + if (ret != PX4_OK) { + PX4_DEBUG("SPI::init failed (%i)", ret); + return ret; + } + + _adc_report.device_id = this->get_device_id(); + _adc_report.v_ref = _adc_ads7953_refv.get(); + _adc_report.resolution = 4096; + + for (unsigned i = 0; i < PX4_MAX_ADC_CHANNELS; ++i) { + _adc_report.channel_id[i] = -1; + } + + ScheduleOnInterval(SAMPLE_INTERVAL, SAMPLE_INTERVAL); + return PX4_OK; +} + +int ADS7953::probe() +{ + // The ADS7953 has no ID register which we can check, so we verify the device via the returned channel ID. + // We set the mode to "manual mode" and the channel to measure to 1. + // If the returned channel ID on the third message is 1, we assume the ADS7953 is connected. + uint8_t recv_data[2]; + + int ret = rw_msg(&recv_data[0], 1, true); + + if (ret != PX4_OK) { + PX4_DEBUG("ADS7953 probing failed (%i)", ret); + return ret; + } + + ret |= rw_msg(&recv_data[0], 0, false); + ret |= rw_msg(&recv_data[0], 0, true); + + if (ret != PX4_OK || (recv_data[0] >> 4) != 1U) { + PX4_DEBUG("ADS7953 probing failed (%i)", ret); + return PX4_ERROR; + } + + return PX4_OK; +} + +int ADS7953::rw_msg(uint8_t *recv_data, uint8_t ch, bool change_channel) +{ + uint8_t send_data[2]; + + if (change_channel) { + send_data[0] = 0x10 | (ch >> 1); + send_data[1] = 0x00 | (ch << 7); + + } else { + send_data[0] = 0x00; + send_data[1] = 0x00; + } + + return transfer(&send_data[0], &recv_data[0], 2); +} + +int ADS7953::get_measurements() +{ + uint8_t recv_data[2]; + int count = 0; + uint16_t mask = 0x00; + uint8_t idx = 0; + + while (count < NUM_CHANNELS) { + if (rw_msg(&recv_data[0], idx, true) == PX4_OK) { + uint8_t ch_id = (recv_data[0] >> 4); + + //check if we already have a measurement for the returned channel + if (!(mask & (1U << ch_id))) { + mask |= (1U << ch_id); + count++; + _adc_report.channel_id[ch_id] = ch_id; + _adc_report.raw_data[ch_id] = ((((uint16_t) recv_data[0]) & 0x0F) << 8) | recv_data[1]; + } + + } else { + perf_count(_comms_errors); + } + + // Find index to measure next + for (int i = 1; i <= NUM_CHANNELS; i++) { + uint8_t candidate_id = (idx + i) % NUM_CHANNELS; + + if (!(mask & (1U << candidate_id))) { + idx = candidate_id; + break; + } + } + } + + return 0; +} + +void ADS7953::RunImpl() +{ + perf_begin(_cycle_perf); + get_measurements(); + _adc_report.timestamp = hrt_absolute_time(); + _adc_report_pub.publish(_adc_report); + perf_end(_cycle_perf); + + for (unsigned i = 0; i < PX4_MAX_ADC_CHANNELS; ++i) { + _adc_report.channel_id[i] = -1; + } +} diff --git a/src/drivers/adc/ads7953/ADS7953.h b/src/drivers/adc/ads7953/ADS7953.h new file mode 100644 index 0000000000..7d955a274f --- /dev/null +++ b/src/drivers/adc/ads7953/ADS7953.h @@ -0,0 +1,45 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace time_literals; + + +class ADS7953 : public device::SPI, public I2CSPIDriver, public ModuleParams +{ +public: + ADS7953(const I2CSPIDriverConfig &config); + ~ADS7953() override; + static void print_usage(); + + int init() override; + void RunImpl(); + int probe() override; + + +private: + static constexpr int NUM_CHANNELS = 16; + uORB::PublicationMulti _adc_report_pub{ORB_ID(adc_report)}; + + static const hrt_abstime SAMPLE_INTERVAL{10_ms}; + perf_counter_t _cycle_perf; + perf_counter_t _comms_errors; + + DEFINE_PARAMETERS( + (ParamFloat) _adc_ads7953_refv + ) + adc_report_s _adc_report{}; + + int get_measurements(); + int rw_msg(uint8_t *recv_data, uint8_t ch, bool change_channel); +}; diff --git a/src/drivers/adc/ads7953/CMakeLists.txt b/src/drivers/adc/ads7953/CMakeLists.txt new file mode 100644 index 0000000000..fbb25e5f5d --- /dev/null +++ b/src/drivers/adc/ads7953/CMakeLists.txt @@ -0,0 +1,46 @@ +############################################################################ +# +# 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 drivers__adc__ads7953 + MAIN ads7953 + COMPILE_FLAGS + SRCS + ADS7953.cpp + ADS7953.h + ads7953_main.cpp + MODULE_CONFIG + module.yaml + DEPENDS + px4_work_queue + ) diff --git a/src/drivers/adc/ads7953/Kconfig b/src/drivers/adc/ads7953/Kconfig new file mode 100644 index 0000000000..a50f4c8b26 --- /dev/null +++ b/src/drivers/adc/ads7953/Kconfig @@ -0,0 +1,5 @@ +menuconfig DRIVERS_ADC_ADS7953 + bool "ADS7953 driver" + default n + ---help--- + Enable support for ADS7953 diff --git a/src/drivers/adc/ads7953/ads7953_main.cpp b/src/drivers/adc/ads7953/ads7953_main.cpp new file mode 100644 index 0000000000..9c9de10faf --- /dev/null +++ b/src/drivers/adc/ads7953/ads7953_main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +#include +#include +#include "ADS7953.h" + +void ADS7953::print_usage() +{ + PRINT_MODULE_USAGE_NAME("ads7953", "driver"); + PRINT_MODULE_USAGE_SUBCATEGORY("adc"); + PRINT_MODULE_USAGE_COMMAND("start"); + PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(false, true); + PRINT_MODULE_USAGE_DEFAULT_COMMANDS(); +} + +extern "C" int ads7953_main(int argc, char *argv[]) +{ + using ThisDriver = ADS7953; + BusCLIArguments cli{false, true}; + cli.spi_mode = SPIDEV_MODE0; + cli.default_spi_frequency = 10 * 1000 * 1000; + const char *name = MODULE_NAME; + const char *verb = cli.parseDefaultArguments(argc, argv); + + if (!verb) { + ThisDriver::print_usage(); + return -1; + } + + BusInstanceIterator iterator(name, cli, DRV_ADC_DEVTYPE_ADS7953); + + if (!strcmp(verb, "start")) { + return ThisDriver::module_start(cli, iterator); + } + + if (!strcmp(verb, "stop")) { + return ThisDriver::module_stop(iterator); + } + + if (!strcmp(verb, "status")) { + return ThisDriver::module_status(iterator); + } + + ThisDriver::print_usage(); + return -1; +} diff --git a/src/drivers/adc/ads7953/module.yaml b/src/drivers/adc/ads7953/module.yaml new file mode 100644 index 0000000000..9097daeb08 --- /dev/null +++ b/src/drivers/adc/ads7953/module.yaml @@ -0,0 +1,29 @@ +__max_num_config_instances: &max_num_config_instances 1 + +module_name: ADS7953 + +parameters: + - group: ADC + definitions: + ADC_ADS7953_EN: + description: + short: Enable ADS7953 + long: | + Enable the driver for the ADS7953 board + type: boolean + reboot_required: true + default: 0 + + ADC_ADS7953_REFV: + description: + short: Applied reference Voltage. + long: | + The voltage applied to the ADS7953 board as reference + type: float + unit: V + min: 2.0 + max: 3.0 + decimal: 2 + increment: 0.01 + reboot_required: true + default: 2.5 diff --git a/src/drivers/adc/board_adc/ADC.cpp b/src/drivers/adc/board_adc/ADC.cpp index 7bf553f9b4..936f0971ac 100644 --- a/src/drivers/adc/board_adc/ADC.cpp +++ b/src/drivers/adc/board_adc/ADC.cpp @@ -410,6 +410,7 @@ ADC driver. )DESCR_STR"); PRINT_MODULE_USAGE_NAME("adc", "driver"); + PRINT_MODULE_USAGE_SUBCATEGORY("adc"); PRINT_MODULE_USAGE_COMMAND("start"); PRINT_MODULE_USAGE_COMMAND("test"); PRINT_MODULE_USAGE_PARAM_FLAG('n', "Do not publish ADC report, only system power", true); diff --git a/src/drivers/adc/board_adc/ADC.hpp b/src/drivers/adc/board_adc/ADC.hpp index 47f9538814..c765d596b4 100644 --- a/src/drivers/adc/board_adc/ADC.hpp +++ b/src/drivers/adc/board_adc/ADC.hpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -110,7 +111,7 @@ private: const uint32_t _base_address; px4_adc_msg_t *_samples{nullptr}; /**< sample buffer */ - uORB::Publication _to_adc_report{ORB_ID(adc_report)}; + uORB::PublicationMulti _to_adc_report{ORB_ID(adc_report)}; uORB::Publication _to_system_power{ORB_ID(system_power)}; #ifdef BOARD_GPIO_VDD_5V_COMP_VALID diff --git a/src/drivers/adc/tla2528/CMakeLists.txt b/src/drivers/adc/tla2528/CMakeLists.txt new file mode 100644 index 0000000000..1d77bfe65a --- /dev/null +++ b/src/drivers/adc/tla2528/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# 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 drivers__adc__tla2528 + MAIN tla2528 + COMPILE_FLAGS + SRCS + tla2528.cpp + tla2528_main.cpp + MODULE_CONFIG + module.yaml + DEPENDS + px4_work_queue + ) diff --git a/src/drivers/adc/tla2528/Kconfig b/src/drivers/adc/tla2528/Kconfig new file mode 100644 index 0000000000..ea3ae7e317 --- /dev/null +++ b/src/drivers/adc/tla2528/Kconfig @@ -0,0 +1,5 @@ +menuconfig DRIVERS_ADC_TLA2528 + bool "TLA2528 driver" + default n + ---help--- + Enable support for TLA2528 diff --git a/src/drivers/adc/tla2528/module.yaml b/src/drivers/adc/tla2528/module.yaml new file mode 100644 index 0000000000..b9059ddf04 --- /dev/null +++ b/src/drivers/adc/tla2528/module.yaml @@ -0,0 +1,30 @@ +__max_num_config_instances: &max_num_config_instances 1 + +module_name: TLA2528 + +parameters: + - group: ADC + definitions: + ADC_TLA2528_EN: + description: + short: Enable TLA2528 + long: | + Enable the driver for the TLA2528 + type: boolean + reboot_required: true + default: 0 + + + ADC_TLA2528_REFV: + description: + short: Applied reference Voltage. + long: | + The voltage applied to the TLA2528 board as reference + type: float + unit: V + min: 2.0 + max: 3.0 + decimal: 2 + increment: 0.01 + reboot_required: true + default: 2.5 diff --git a/src/drivers/adc/tla2528/tla2528.cpp b/src/drivers/adc/tla2528/tla2528.cpp new file mode 100644 index 0000000000..f6f3948ef7 --- /dev/null +++ b/src/drivers/adc/tla2528/tla2528.cpp @@ -0,0 +1,326 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ +#include "tla2528.h" +#include + +#define READ 0x10 +#define WRITE 0x08 +#define SET_BIT 0x18 +#define CLEAR_BIT 0x20 + +#define SYSTEM_STATUS 0x00 +#define GENERAL_CFG 0x01 +#define DATA_CFG 0x02 +#define OSR_CFG 0x03 +#define OPMODE_CFG 0x04 +#define PIN_CFG 0x05 +#define GPIO_CFG 0x07 +#define GPO_DRIVE_CFG 0x09 +#define GPO_VALUE 0x0B +#define GPI_VALUE 0x0D +#define SEQUENCE_CFG 0x10 +#define CHANNEL_SEL 0x11 +#define AUTO_SEQ_CH_SEL 0x12 + +TLA2528::TLA2528(const I2CSPIDriverConfig &config) : + I2C(config), + I2CSPIDriver(config), + ModuleParams(nullptr), + _cycle_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": single-sample")), + _comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors")) +{ + static_assert(arraySize(adc_report_s::channel_id) >= NUM_CHANNELS, "TLA2528 reports 8 channels"); +} + +TLA2528::~TLA2528() +{ + ScheduleClear(); + perf_free(_cycle_perf); + perf_free(_comms_errors); +} + +int TLA2528::init() +{ + int ret = I2C::init(); + + if (ret != PX4_OK) { + PX4_DEBUG("I2C::init failed (%i)", ret); + return ret; + } + + _adc_report.device_id = this->get_device_id(); + _adc_report.v_ref = _adc_tla2528_refv.get(); + _adc_report.resolution = 4096; + + ScheduleClear(); + ScheduleOnInterval(SAMPLE_INTERVAL, SAMPLE_INTERVAL); + return PX4_OK; +} + +int TLA2528::init_calibrate() +{ + uint8_t send_data[3]; + send_data[0] = SET_BIT; + send_data[1] = GENERAL_CFG; + send_data[2] = 0x02; + int ret = transfer(&send_data[0], 3, nullptr, 0); + + if (ret != PX4_OK) { + PX4_DEBUG("TLA2528::Initializing Calibration failed (%i)", ret); + perf_count(_comms_errors); + } + + return ret; +} + +int TLA2528::poll_calibrate() +{ + uint8_t send_data[2]; + uint8_t recv_data; + send_data[0] = READ; + send_data[1] = GENERAL_CFG; + int ret = transfer(&send_data[0], 2, nullptr, 0); + ret |= transfer(nullptr, 0, &recv_data, 1); + + if (recv_data & 2u) { + PX4_DEBUG("TLA2528::Calibration not yet finished"); + perf_count(_comms_errors); + return PX4_ERROR; + } + + return ret; +} + +int TLA2528::init_reset() +{ + uint8_t send_data[3]; + send_data[0] = SET_BIT; + send_data[1] = GENERAL_CFG; + send_data[2] = 0x01; + int ret = transfer(&send_data[0], 3, nullptr, 0); + + if (ret != PX4_OK) { + PX4_DEBUG("TLA2528::Initializing Reset failed (%i)", ret); + perf_count(_comms_errors); + } + + return ret; +} + +int TLA2528::poll_reset() +{ + uint8_t send_data[2]; + uint8_t recv_data; + send_data[0] = READ; + send_data[0] = GENERAL_CFG; + int ret = transfer(&send_data[0], 2, nullptr, 0); + ret |= transfer(nullptr, 0, &recv_data, 1); + + if (ret != PX4_OK) { + perf_count(_comms_errors); + return ret; + } + + if (recv_data & 1u) { + PX4_DEBUG("TLA2528::Reset not finished"); + return PX4_ERROR; + } + + return ret; +} + +void TLA2528::adc_get() +{ + // Start sequential read + uint8_t send_data[3] = {SET_BIT, SEQUENCE_CFG, 0x10}; + uint8_t recv_data[2]; + int ret = transfer(&send_data[0], 3, nullptr, 0); + + if (ret != PX4_OK) { + perf_count(_comms_errors); + return; + } + + // Read data + for (int i = 0; i < NUM_CHANNELS; i++) { + ret = transfer(nullptr, 0, &recv_data[0], 2); + + if (ret == PX4_OK) { + uint16_t tmp = ((uint16_t)recv_data[0]) << 8; + uint16_t measurement = (tmp | recv_data[1]) >> 4; + uint8_t ch_id = recv_data[1] & 0x0F; + + _adc_report.channel_id[i] = ch_id; + _adc_report.raw_data[i] = measurement; + + } else { + perf_count(_comms_errors); + } + } + + // Stop sequential read + send_data[0] = CLEAR_BIT; + send_data[1] = SEQUENCE_CFG; + send_data[2] = 0x10; + transfer(&send_data[0], 3, nullptr, 0); + return; +} + +int TLA2528::probe() +{ + for (int i = 0; i < 3; i++) { + // Set device in debug mode (should respond with 0xA5AX to all reads) + uint8_t send_data[3] = {SET_BIT, DATA_CFG, 0x80}; + int ret = transfer(&send_data[0], 3, nullptr, 0); + + // Read + uint8_t recv_data[2]; + send_data[0] = SET_BIT; + send_data[0] = DATA_CFG; + ret |= transfer(&send_data[0], 2, nullptr, 0); + ret |= transfer(nullptr, 0, &recv_data[0], 2); + + // Turn debug mode off + send_data[0] = CLEAR_BIT; + send_data[1] = DATA_CFG; + send_data[2] = 0x80; + ret |= transfer(&send_data[0], 3, nullptr, 0); + + if (recv_data[0] == 165 && recv_data[1] >= 160 && ret == PX4_OK) { + return PX4_OK; + } + + px4_sleep(1); + } + + return PX4_ERROR; +} + +int TLA2528::configure() +{ + uint8_t send_data[3]; + // Configure pins as analog + send_data[0] = SET_BIT; + send_data[1] = PIN_CFG; + send_data[2] = 0x00; + int ret = transfer(&send_data[0], 3, nullptr, 0); + + // Append channel-id to measurements + send_data[0] = SET_BIT; + send_data[1] = DATA_CFG; + send_data[2] = 0x10; + ret |= transfer(&send_data[0], 3, nullptr, 0); + + // Activate all pins + send_data[0] = SET_BIT; + send_data[1] = AUTO_SEQ_CH_SEL; + send_data[2] = 0xFF; + ret |= transfer(&send_data[0], 3, nullptr, 0); + + // Set seq-mode + send_data[0] = SET_BIT; + send_data[1] = SEQUENCE_CFG; + send_data[2] = 0x01; + ret |= transfer(&send_data[0], 3, nullptr, 0); + + if (ret != PX4_OK) { + perf_count(_comms_errors); + PX4_DEBUG("TLA2528::Configuring failed (%i)", ret); + } + + return ret; +} + +void TLA2528::exit_and_cleanup() +{ + I2CSPIDriverBase::exit_and_cleanup(); // nothing to do +} + +void TLA2528::RunImpl() +{ + if (should_exit()) { + PX4_INFO("stopping"); + return; // stop and return immediately to avoid unexpected schedule from stopping procedure + } + + int ret; + + switch (_state) { + case STATE::RESET: + ret = init_reset(); + + if (ret == PX4_OK) { + _state = STATE::CONFIGURE; + } + + break; + + case STATE::CONFIGURE: + ret = poll_reset(); + ret |= configure(); + ret |= init_calibrate(); + + if (ret == PX4_OK) { + _state = STATE::CALIBRATE; + + } else { + _state = STATE::RESET; + } + + break; + + case STATE::CALIBRATE: + ret = poll_calibrate(); + + if (ret == PX4_OK) { + _state = STATE::WORK; + + } else { + _state = STATE::RESET; + } + + break; + + case STATE::WORK: + perf_begin(_cycle_perf); + adc_get(); + _adc_report.timestamp = hrt_absolute_time(); + _adc_report_pub.publish(_adc_report); + perf_end(_cycle_perf); + break; + } + + for (unsigned i = 0; i < arraySize(adc_report_s::channel_id); ++i) { + _adc_report.channel_id[i] = -1; + } +} diff --git a/src/drivers/adc/tla2528/tla2528.h b/src/drivers/adc/tla2528/tla2528.h new file mode 100644 index 0000000000..818d59b214 --- /dev/null +++ b/src/drivers/adc/tla2528/tla2528.h @@ -0,0 +1,85 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +using namespace time_literals; + +class TLA2528 : public device::I2C, public I2CSPIDriver, public ModuleParams +{ +public: + TLA2528(const I2CSPIDriverConfig &config); + ~TLA2528() override; + + static void print_usage(); + int init() override; + void RunImpl(); + int probe() override; + +private: + static const hrt_abstime SAMPLE_INTERVAL{10_ms}; + static constexpr int NUM_CHANNELS = 8; + + perf_counter_t _cycle_perf; + perf_counter_t _comms_errors; + + uORB::PublicationMulti _adc_report_pub{ORB_ID(adc_report)}; + adc_report_s _adc_report{}; + + DEFINE_PARAMETERS( + (ParamFloat) _adc_tla2528_refv + ) + + int init_reset(); + int poll_reset(); + int configure(); + int init_calibrate(); + int poll_calibrate(); + void adc_get(); + void exit_and_cleanup() override; + + enum class STATE : uint8_t { + RESET, + CONFIGURE, + CALIBRATE, + WORK + }; + STATE _state{STATE::RESET}; +}; diff --git a/src/drivers/adc/tla2528/tla2528_main.cpp b/src/drivers/adc/tla2528/tla2528_main.cpp new file mode 100644 index 0000000000..e2463cfca3 --- /dev/null +++ b/src/drivers/adc/tla2528/tla2528_main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ +#include +#include +#include "tla2528.h" + +void TLA2528::print_usage() +{ + PRINT_MODULE_USAGE_NAME("TLA2528", "driver"); + PRINT_MODULE_USAGE_SUBCATEGORY("adc"); + PRINT_MODULE_USAGE_COMMAND("start"); + PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false); + PRINT_MODULE_USAGE_DEFAULT_COMMANDS(); +} + +extern "C" int tla2528_main(int argc, char *argv[]) +{ + using ThisDriver = TLA2528; + BusCLIArguments cli{true, false}; + + cli.default_i2c_frequency = 400000; + cli.i2c_address = 0x10; + const char *name = MODULE_NAME; + const char *verb = cli.parseDefaultArguments(argc, argv); + + if (!verb) { + ThisDriver::print_usage(); + return -1; + } + + BusInstanceIterator iterator(name, cli, DRV_ADC_DEVTYPE_TLA2528); + + if (!strcmp(verb, "start")) { + return ThisDriver::module_start(cli, iterator); + } + + if (!strcmp(verb, "stop")) { + return ThisDriver::module_stop(iterator); + } + + if (!strcmp(verb, "status")) { + return ThisDriver::module_status(iterator); + } + + ThisDriver::print_usage(); + return -1; +} diff --git a/src/drivers/barometer/ms5837/MS5837.cpp b/src/drivers/barometer/ms5837/MS5837.cpp index 933d3a1a32..4bd4d11c9a 100644 --- a/src/drivers/barometer/ms5837/MS5837.cpp +++ b/src/drivers/barometer/ms5837/MS5837.cpp @@ -332,14 +332,13 @@ int MS5837::_collect() } else { /* pressure calculation, result in Pa */ - int32_t P = (((raw * _SENS) >> 21) - _OFF) >> 13; - + int32_t pressure_pascal = ((((raw * _SENS) >> 21) - _OFF) >> 13) * 10; // publish sensor_baro_s sensor_baro{}; sensor_baro.timestamp_sample = timestamp_sample; sensor_baro.device_id = get_device_id(); - sensor_baro.pressure = P; + sensor_baro.pressure = pressure_pascal; sensor_baro.temperature = _last_temperature; sensor_baro.error_count = perf_event_count(_comms_errors); sensor_baro.timestamp = hrt_absolute_time(); diff --git a/src/drivers/bootloaders/CMakeLists.txt b/src/drivers/bootloaders/CMakeLists.txt index 0972160fdf..3123ea9d54 100644 --- a/src/drivers/bootloaders/CMakeLists.txt +++ b/src/drivers/bootloaders/CMakeLists.txt @@ -43,6 +43,17 @@ target_link_libraries(drivers_bootloaders PRIVATE crc) # generate bootloader_app_shared_t if(NOT "${PX4_BOARD_LABEL}" MATCHES "canbootloader") + # Check if UAVCAN board identity variables are defined + # These are only set for UAVCAN node boards (CAN peripherals like can-gps, cannode, etc.) + if(NOT DEFINED uavcanblid_hw_version_major OR NOT DEFINED uavcanblid_hw_version_minor OR + NOT DEFINED uavcanblid_sw_version_major OR NOT DEFINED uavcanblid_sw_version_minor) + message(FATAL_ERROR + "CONFIG_DRIVERS_BOOTLOADERS is only supported on UAVCAN node boards.\n" + "This board (${PX4_BOARD}) does not have UAVCAN board identity defined.\n" + "Please disable CONFIG_DRIVERS_BOOTLOADERS in boardconfig (make ${PX4_CONFIG} boardconfig).\n" + "Note: This option is only needed for CAN peripheral boards (e.g., can-gps, cannode, can-flow).") + endif() + set(HW_MAJOR ${uavcanblid_hw_version_major}) set(HW_MINOR ${uavcanblid_hw_version_minor}) set(SW_MAJOR ${uavcanblid_sw_version_major}) diff --git a/src/drivers/bootloaders/Kconfig b/src/drivers/bootloaders/Kconfig index a630d51277..4d75c553e4 100644 --- a/src/drivers/bootloaders/Kconfig +++ b/src/drivers/bootloaders/Kconfig @@ -1,5 +1,7 @@ menuconfig DRIVERS_BOOTLOADERS bool "bootloaders" default n + depends on BOARD_ROMFSROOT = "cannode" || BOARD_ROMFSROOT = "" ---help--- Enable support for bootloaders + Note: This is only supported on UAVCAN node boards (CAN peripherals) diff --git a/src/drivers/differential_pressure/auav/AUAV.cpp b/src/drivers/differential_pressure/auav/AUAV.cpp index 2533399a35..66f8a3b46b 100644 --- a/src/drivers/differential_pressure/auav/AUAV.cpp +++ b/src/drivers/differential_pressure/auav/AUAV.cpp @@ -65,6 +65,7 @@ AUAV::AUAV(const I2CSPIDriverConfig &config) : _sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")), _comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors")) { + I2C::_retries = 5; } AUAV::~AUAV() @@ -130,15 +131,21 @@ int AUAV::init() int AUAV::probe() { - uint8_t res_data = 0; - int status = transfer(nullptr, 0, &res_data, sizeof(res_data)); + uint8_t res_data; - /* Check that the sensor is active. Reported in bit 6 of the status byte */ - if ((res_data & 0x40) == 0) { - status = PX4_ERROR; + for (unsigned i = 0; i < 10; i++) { + res_data = 0; + int status = transfer(nullptr, 0, &res_data, 1); + + /* Check that the sensor is active. Reported in bit 6 of the status byte */ + if (status == PX4_OK && (res_data & 0x40)) { + return PX4_OK; + } + + px4_usleep(10'000); } - return status; + return PX4_ERROR; } void AUAV::handle_state_read_calibdata() diff --git a/src/drivers/differential_pressure/auav/AUAV_Absolute.hpp b/src/drivers/differential_pressure/auav/AUAV_Absolute.hpp index 624ef27079..603649a783 100644 --- a/src/drivers/differential_pressure/auav/AUAV_Absolute.hpp +++ b/src/drivers/differential_pressure/auav/AUAV_Absolute.hpp @@ -51,6 +51,8 @@ static constexpr uint8_t EEPROM_ABS_ES = 0x38; /* Measurement rate is 50Hz */ static constexpr unsigned ABS_MEAS_RATE = 50; static constexpr int64_t ABS_CONVERSION_INTERVAL = (1000000 / ABS_MEAS_RATE); /* microseconds */ +/* reading too fast can yield all zero data -> incorrect sensor reading */ +static_assert(ABS_CONVERSION_INTERVAL >= 7000, "Conversion interval is too fast"); /* Conversions */ static constexpr float MBAR_TO_PA = 100.0f; diff --git a/src/drivers/differential_pressure/auav/AUAV_Differential.hpp b/src/drivers/differential_pressure/auav/AUAV_Differential.hpp index 412066a6ac..168fb322b6 100644 --- a/src/drivers/differential_pressure/auav/AUAV_Differential.hpp +++ b/src/drivers/differential_pressure/auav/AUAV_Differential.hpp @@ -51,6 +51,8 @@ static constexpr uint8_t EEPROM_DIFF_ES = 0x34; /* Measurement rate is 100Hz */ static constexpr unsigned DIFF_MEAS_RATE = 100; static constexpr int64_t DIFF_CONVERSION_INTERVAL = (1000000 / DIFF_MEAS_RATE); /* microseconds */ +/* reading too fast can yield all zero data -> incorrect sensor reading */ +static_assert(DIFF_CONVERSION_INTERVAL >= 7000, "Conversion interval is too fast"); /* Conversions */ static constexpr float INH_TO_PA = 249.08f; diff --git a/src/drivers/drv_sensor.h b/src/drivers/drv_sensor.h index 1f74122014..01d2c70f92 100644 --- a/src/drivers/drv_sensor.h +++ b/src/drivers/drv_sensor.h @@ -260,6 +260,12 @@ #define DRV_INS_DEVTYPE_SBG 0xEC +#define DRV_ADC_DEVTYPE_ADS7953 0xED +#define DRV_ADC_DEVTYPE_TLA2528 0xEF + + +#define DRV_TEMP_DEVTYPE_MCP9808 0xEE + #define DRV_DEVTYPE_UNUSED 0xff #endif /* _DRV_SENSOR_H */ diff --git a/src/drivers/gps/devices b/src/drivers/gps/devices index 0b9695881b..caf5158061 160000 --- a/src/drivers/gps/devices +++ b/src/drivers/gps/devices @@ -1 +1 @@ -Subproject commit 0b9695881bd1e8f830ab4538ab3acc0050019eba +Subproject commit caf5158061bd10e79c9f042abb62c86bc6f3e7a7 diff --git a/src/drivers/gps/gps.cpp b/src/drivers/gps/gps.cpp index 1b61662335..e7dbab947a 100644 --- a/src/drivers/gps/gps.cpp +++ b/src/drivers/gps/gps.cpp @@ -84,9 +84,11 @@ using namespace device; using namespace time_literals; -#define TIMEOUT_1HZ 1300 //!< Timeout time in mS, 1000 mS (1Hz) + 300 mS delta for error -#define TIMEOUT_5HZ 500 //!< Timeout time in mS, 200 mS (5Hz) + 300 mS delta for error -#define TIMEOUT_DUMP_ADD 450 //!< Additional time in mS to account for RTCM3 parsing and dumping +#define TIMEOUT_1HZ 1300 //!< Timeout time in mS, 1000 mS (1Hz) + 300 mS delta for error +#define TIMEOUT_5HZ 500 //!< Timeout time in mS, 200 mS (5Hz) + 300 mS delta for error +#define TIMEOUT_INIT_1HZ (3 * TIMEOUT_1HZ) //!< Timeout time in mS, used until GPS is healthy +#define TIMEOUT_INIT_5HZ (3 * TIMEOUT_5HZ) //!< Timeout time in mS, used until GPS is healthy +#define TIMEOUT_DUMP_ADD 450 //!< Additional time in mS to account for RTCM3 parsing and dumping enum class gps_driver_mode_t { None = 0, @@ -178,6 +180,7 @@ private: char _port[20] {}; ///< device / serial port path bool _healthy{false}; ///< flag to signal if the GPS is ok + bool _cfg_wiped{false}; ///< flag to signal if the config was already wiped bool _mode_auto; ///< if true, auto-detect which GPS is attached gps_driver_mode_t _mode; ///< current mode @@ -939,7 +942,7 @@ GPS::run() param_get(handle, &gps_cfg_wipe); } - gpsConfig.cfg_wipe = static_cast(gps_cfg_wipe); + gpsConfig.cfg_wipe = static_cast(gps_cfg_wipe) && !_cfg_wiped; if (_helper && _helper->configure(_baudrate, gpsConfig) == 0) { @@ -995,19 +998,26 @@ GPS::run() } int helper_ret; - unsigned receive_timeout = TIMEOUT_5HZ; + + /* After being configured (especially in combination with FLASH wipes) the GPS may require + * additional time before outputting the first navigation data. To account for this, there is + * an init timeout. As soon as the GPS is healthy, the timeout is decreased. This allows for + * a quick reaction to a connection loss. */ + unsigned receive_timeout = TIMEOUT_INIT_5HZ; + unsigned healthy_timeout = TIMEOUT_5HZ; if ((ubx_mode == GPSDriverUBX::UBXMode::RoverWithMovingBase) || (ubx_mode == GPSDriverUBX::UBXMode::RoverWithMovingBaseUART1)) { /* The MB rover will wait as long as possible to compute a navigation solution, * possibly lowering the navigation rate all the way to 1 Hz while doing so. */ - receive_timeout = TIMEOUT_1HZ; + receive_timeout = TIMEOUT_INIT_1HZ; + healthy_timeout = TIMEOUT_1HZ; } if (_dump_communication_mode != gps_dump_comm_mode_t::Disabled) { /* Dumping the RTCM3/UBX data requires additional parsing and storing of data via uORB. * Without additional time this can lead to timeouts. */ - receive_timeout += TIMEOUT_DUMP_ADD; + healthy_timeout += TIMEOUT_DUMP_ADD; } while ((helper_ret = _helper->receive(receive_timeout)) > 0 && !should_exit()) { @@ -1067,6 +1077,12 @@ GPS::run() // // PX4_WARN("module found: %s", mode_str); _healthy = true; + receive_timeout = healthy_timeout; + } + + /* Do not wipe the FLASH config multiple times. */ + if (!_cfg_wiped) { + _cfg_wiped = true; } } diff --git a/src/drivers/ins/ilabs/ILabs.cpp b/src/drivers/ins/ilabs/ILabs.cpp index 98f169357d..1c81a818ab 100644 --- a/src/drivers/ins/ilabs/ILabs.cpp +++ b/src/drivers/ins/ilabs/ILabs.cpp @@ -236,34 +236,42 @@ void ILabs::Run() { if (!result) { PX4_ERR("Sensor initializing error"); - ScheduleDelayed(1_s); + _sensor.deinit(); + _time_initialized.store(0); + _time_last_valid_imu_data.store(0); + ScheduleDelayed(3_s); return; } _time_initialized.store(hrt_absolute_time()); } - // check for timeout const hrt_abstime time_initialized = _time_initialized.load(); const hrt_abstime time_last_valid_imu_data = _time_last_valid_imu_data.load(); - if (_param_ilabs_mode.get() == ILabsMode::FULL_INS && time_last_valid_imu_data != 0 && - hrt_elapsed_time(&time_last_valid_imu_data) < 3_s) { - // update sensor_selection if configured in INS mode + // Update sensor_selection for FULL_INS mode + if (_param_ilabs_mode.get() == ILabsMode::FULL_INS && time_initialized != 0 && time_last_valid_imu_data != 0 && + hrt_elapsed_time(&time_last_valid_imu_data) < 3_s) { + if ((_px4_accel.get_device_id() != 0) && (_px4_gyro.get_device_id() != 0)) { sensor_selection_s sensor_selection{}; sensor_selection.accel_device_id = _px4_accel.get_device_id(); sensor_selection.gyro_device_id = _px4_gyro.get_device_id(); - sensor_selection.timestamp = _time_initialized.load(); + sensor_selection.timestamp = time_initialized; _sensor_selection_pub.publish(sensor_selection); } else { PX4_ERR("Sensor not initialized"); } } - if (time_initialized != 0 && hrt_elapsed_time(&time_last_valid_imu_data) > 5_s && - time_last_valid_imu_data != 0 && hrt_elapsed_time(&time_last_valid_imu_data) > 1_s) { - PX4_ERR("Timeout, reinitializing"); + // Missing data handling + if (time_initialized != 0 && time_last_valid_imu_data != 0 && + hrt_elapsed_time(&time_last_valid_imu_data) > 3_s) { + PX4_ERR("Timeout: no new data from sensor. Reinitializing"); _sensor.deinit(); + _time_initialized.store(0); + _time_last_valid_imu_data.store(0); + ScheduleDelayed(3_s); + return; } ScheduleDelayed(100_ms); diff --git a/src/drivers/ins/ilabs/ILabs.h b/src/drivers/ins/ilabs/ILabs.h index 82b94541db..3754dce982 100644 --- a/src/drivers/ins/ilabs/ILabs.h +++ b/src/drivers/ins/ilabs/ILabs.h @@ -80,6 +80,10 @@ private: void Run() override; void processData(InertialLabs::SensorsData *sensordata); static void processDataProxy(void *context, InertialLabs::SensorsData *data) { + if (!context || !data) { + return; + } + ILabs *self = static_cast(context); self->processData(data); } diff --git a/src/drivers/ins/ilabs/libilabs/include/sensor.h b/src/drivers/ins/ilabs/libilabs/include/sensor.h index f8c29bef0a..504cabbc53 100644 --- a/src/drivers/ins/ilabs/libilabs/include/sensor.h +++ b/src/drivers/ins/ilabs/libilabs/include/sensor.h @@ -35,6 +35,7 @@ #include +#include #include #include "data.h" @@ -61,12 +62,15 @@ public: private: static void *updateDataThreadHelper(void *context) { + if (!context) { + return nullptr; + } Sensor *sensor = reinterpret_cast(context); sensor->updateData(); return nullptr; } - void resetSerial(); + bool initSerialPort(const char *serialDeviceName); bool moveToBufferStart(const uint8_t *pos); bool skipPackageInBufferStart(); bool movePackageHeaderToBufferStart(); @@ -74,15 +78,16 @@ private: bool parseUDDPayload(); - device::Serial *_serial{nullptr}; - pthread_t _threadId; - bool _processInThread{false}; + device::Serial *_serial{nullptr}; + pthread_t _threadId{0}; + px4::atomic_bool _processInThread{false}; // callback. C-style class method pointer void *_context{nullptr}; DataHandler _dataHandler{nullptr}; - bool _isInitialized{false}; + px4::atomic_bool _isInitialized{false}; + px4::atomic_bool _isDeinitInProcess{false}; uint8_t _buf[BUFFER_SIZE]{}; uint16_t _bufOffset{0}; diff --git a/src/drivers/ins/ilabs/libilabs/src/sensor.cpp b/src/drivers/ins/ilabs/libilabs/src/sensor.cpp index fa79551188..ba6427536c 100644 --- a/src/drivers/ins/ilabs/libilabs/src/sensor.cpp +++ b/src/drivers/ins/ilabs/libilabs/src/sensor.cpp @@ -86,72 +86,72 @@ Sensor::~Sensor() { } bool Sensor::init(const char *serialDeviceName, void *context, DataHandler dataHandler) { - if (_isInitialized) { - PX4_ERR("Serial device already initialized. Deinitialize first."); + if (_isInitialized.load()) { + PX4_WARN("Serial device already initialized. Deinitialize first"); + return false; + } + if (_isDeinitInProcess.load()) { + PX4_WARN("Deinitialization is in progress. Please wait until it completes before re-initializing"); return false; } - if (serialDeviceName[0] == '\0') { PX4_ERR("Empty serial device name"); return false; } - if (!context || !dataHandler) { PX4_ERR("Empty data handler callback"); return false; } - _serial = new device::Serial(serialDeviceName, BAUDRATE); - if (_serial == nullptr) { - PX4_ERR("Error creating serial device: %s", serialDeviceName); - px4_sleep(1); // NOLINT(concurrency-mt-unsafe) + if (!initSerialPort(serialDeviceName)) { return false; } - if (!_serial->isOpen() && !_serial->open()) { - // Open the UART. If this is successful then the UART is ready to use. - if (!_serial->open()) { - PX4_ERR("Error opening serial device: %s", serialDeviceName); - px4_sleep(1); // NOLINT(concurrency-mt-unsafe) - resetSerial(); - return false; - } - - PX4_INFO("Serial device opened sucessfully: %s", serialDeviceName); - - _serial->flush(); - } _context = context; _dataHandler = dataHandler; - _processInThread = true; + _processInThread.store(true); const int result = pthread_create(&_threadId, nullptr, &Sensor::updateDataThreadHelper, this); if (result) { PX4_ERR("Cant create working thread"); - _processInThread = false; - px4_sleep(1); // NOLINT(concurrency-mt-unsafe) - resetSerial(); + deinit(); return false; } - pthread_detach(_threadId); - _isInitialized = true; + _isInitialized.store(true); return true; } void Sensor::deinit() { - _processInThread = false; - _isInitialized = false; - resetSerial(); + if (_isDeinitInProcess.load()) { + PX4_WARN("Deinitialization already in process"); + return; + } + + _isDeinitInProcess.store(true); + _isInitialized.store(false); + _processInThread.store(false); + // Wait to be shure, that operations with UART are finished + px4_sleep(1); // NOLINT(concurrency-mt-unsafe) + if (_serial) { + (void)_serial->close(); + delete _serial; + _serial = nullptr; + } + + _context = nullptr; + _dataHandler = nullptr; + _bufOffset = 0; + _isDeinitInProcess.store(false); } bool Sensor::isInitialized() const { - return _isInitialized; + return _isInitialized.load(); } void Sensor::updateData() { - while (_processInThread) { + while (_processInThread.load()) { bool result = moveValidPackageToBufferStart(); if (!result) { continue; @@ -162,18 +162,40 @@ void Sensor::updateData() { continue; } - _dataHandler(_context, &_sensorData); + if (_dataHandler) { + _dataHandler(_context, &_sensorData); + } skipPackageInBufferStart(); } } -void Sensor::resetSerial() { +bool Sensor::initSerialPort(const char *serialDeviceName) { if (_serial) { - (void)_serial->close(); - delete _serial; - _serial = nullptr; + PX4_WARN("Serial port already initialized. Deinitialize first"); + return false; } + + _serial = new device::Serial(serialDeviceName, BAUDRATE); + if (_serial == nullptr) { + PX4_ERR("Error creating serial device: %s", serialDeviceName); + px4_sleep(1); // NOLINT(concurrency-mt-unsafe) + return false; + } + + if (!_serial->isOpen()) { + _serial->open(); + if (!_serial->isOpen()) { + PX4_ERR("Error opening serial device: %s", serialDeviceName); + deinit(); + return false; + } + PX4_INFO("Serial device opened sucessfully: %s", serialDeviceName); + } else { + PX4_INFO("Serial device already opened: %s", serialDeviceName); + } + _serial->flush(); + return true; } bool Sensor::moveToBufferStart(const uint8_t *pos) { @@ -201,7 +223,7 @@ bool Sensor::moveToBufferStart(const uint8_t *pos) { bool Sensor::skipPackageInBufferStart() { const MessageHeader *packageHeader = reinterpret_cast(_buf); if (!isMessageHeaderCorrect(packageHeader)) { - PX4_ERR("Incorrect message header in buffer start. Can't skip the package correctly."); + PX4_ERR("Incorrect message header in buffer start. Can't skip the package correctly"); return false; } @@ -239,7 +261,7 @@ bool Sensor::moveValidPackageToBufferStart() { return false; } - const ssize_t nRead = _serial->readAtLeast(&_buf[_bufOffset], freeBufByteCount, freeBufByteCount, 1000); + const ssize_t nRead = _serial->readAtLeast(&_buf[_bufOffset], freeBufByteCount, freeBufByteCount, 500); if (nRead != freeBufByteCount) { PX4_ERR("Can't read requested data from the serial device. Bytes requested: %d. Bytes read: %d", freeBufByteCount, static_cast(nRead)); @@ -546,8 +568,8 @@ bool Sensor::parseUDDPayload() { break; } default: { - PX4_ERR("Unknown message type: %d. Further package parsing result will be incorrect!", - messageType); + PX4_ERR("Unknown message type: %d. Further package parsing result will be incorrect", + messageType); messageLength = 0; break; } diff --git a/src/drivers/ins/vectornav/VectorNav.cpp b/src/drivers/ins/vectornav/VectorNav.cpp index e4e9821d47..0e6877a555 100644 --- a/src/drivers/ins/vectornav/VectorNav.cpp +++ b/src/drivers/ins/vectornav/VectorNav.cpp @@ -273,11 +273,11 @@ void VectorNav::sensorCallback(VnUartPacket *packet) const double lat = positionEstimatedLla.c[0]; const double lon = positionEstimatedLla.c[1]; - const float alt = positionEstimatedLla.c[2]; + const float alt_ellipsoid = positionEstimatedLla.c[2]; if (!_pos_ref.isInitialized()) { _pos_ref.initReference(lat, lon, time_now_us); - _gps_alt_ref = alt; + _gps_alt_ref = alt_ellipsoid; } const Vector2f pos_ned = _pos_ref.project(lat, lon); @@ -292,7 +292,7 @@ void VectorNav::sensorCallback(VnUartPacket *packet) local_position.x = pos_ned(0); local_position.y = pos_ned(1); - local_position.z = -(alt - _gps_alt_ref); + local_position.z = -(alt_ellipsoid - _gps_alt_ref); local_position.vx = velocityEstimatedNed.c[0]; local_position.vy = velocityEstimatedNed.c[1]; @@ -342,8 +342,10 @@ void VectorNav::sensorCallback(VnUartPacket *packet) global_position.timestamp_sample = time_now_us; global_position.lat = lat; global_position.lon = lon; - global_position.alt = alt; - global_position.alt = alt; + global_position.lat_lon_valid = true; + global_position.alt = alt_ellipsoid; // AMSL altitude is not available + global_position.alt_ellipsoid = alt_ellipsoid; + global_position.alt_valid = true; global_position.eph = positionUncertaintyEstimated; global_position.epv = positionUncertaintyEstimated; diff --git a/src/drivers/magnetometer/rm3100/rm3100.h b/src/drivers/magnetometer/rm3100/rm3100.h index 7e4737d48b..3057d98c27 100644 --- a/src/drivers/magnetometer/rm3100/rm3100.h +++ b/src/drivers/magnetometer/rm3100/rm3100.h @@ -91,8 +91,12 @@ #define RM3100_REVID 0x22 /* interface factories */ +#if defined(CONFIG_SPI) extern device::Device *RM3100_SPI_interface(int bus, uint32_t devid, int bus_frequency, spi_mode_e spi_mode); +#endif // CONFIG_SPI +#if defined(CONFIG_I2C) extern device::Device *RM3100_I2C_interface(int bus, int bus_frequency); +#endif // CONFIG_I2C #define RM3100_ADDRESS 0x20 diff --git a/src/drivers/magnetometer/rm3100/rm3100_i2c.cpp b/src/drivers/magnetometer/rm3100/rm3100_i2c.cpp index 3aeba5d57e..9a7826c314 100644 --- a/src/drivers/magnetometer/rm3100/rm3100_i2c.cpp +++ b/src/drivers/magnetometer/rm3100/rm3100_i2c.cpp @@ -39,6 +39,8 @@ #include +#if defined(CONFIG_I2C) + #include #include #include @@ -129,3 +131,5 @@ int RM3100_I2C::write(unsigned address, void *data, unsigned count) return transfer(&buf[0], count + 1, nullptr, 0); } + +#endif // CONFIG_I2C diff --git a/src/drivers/magnetometer/rm3100/rm3100_main.cpp b/src/drivers/magnetometer/rm3100/rm3100_main.cpp index be8571cced..3c3b51060f 100644 --- a/src/drivers/magnetometer/rm3100/rm3100_main.cpp +++ b/src/drivers/magnetometer/rm3100/rm3100_main.cpp @@ -45,12 +45,16 @@ I2CSPIDriverBase *RM3100::instantiate(const I2CSPIDriverConfig &config, int runt { device::Device *interface = nullptr; +#if defined(CONFIG_I2C) + if (config.bus_type == BOARD_I2C_BUS) { interface = RM3100_I2C_interface(config.bus, config.bus_frequency); - } else if (config.bus_type == BOARD_SPI_BUS) { - interface = RM3100_SPI_interface(config.bus, config.spi_devid, config.bus_frequency, config.spi_mode); - } + } else +#endif // CONFIG_I2C + if (config.bus_type == BOARD_SPI_BUS) { + interface = RM3100_SPI_interface(config.bus, config.spi_devid, config.bus_frequency, config.spi_mode); + } if (interface == nullptr) { PX4_ERR("alloc failed"); @@ -93,8 +97,12 @@ extern "C" int rm3100_main(int argc, char *argv[]) using ThisDriver = RM3100; int ch; BusCLIArguments cli{true, true}; +#if defined(CONFIG_I2C) cli.default_i2c_frequency = 400000; +#endif // CONFIG_I2C +#if defined(CONFIG_SPI) cli.default_spi_frequency = 1 * 1000 * 1000; +#endif // CONFIG_SPI while ((ch = cli.getOpt(argc, argv, "R:")) != EOF) { switch (ch) { @@ -111,7 +119,9 @@ extern "C" int rm3100_main(int argc, char *argv[]) return -1; } +#if defined(CONFIG_I2C) cli.i2c_address = RM3100_ADDRESS; +#endif // CONFIG_I2C BusInstanceIterator iterator(MODULE_NAME, cli, DRV_MAG_DEVTYPE_RM3100); diff --git a/src/drivers/magnetometer/rm3100/rm3100_spi.cpp b/src/drivers/magnetometer/rm3100/rm3100_spi.cpp index 3d8f84498a..b9da9f5493 100644 --- a/src/drivers/magnetometer/rm3100/rm3100_spi.cpp +++ b/src/drivers/magnetometer/rm3100/rm3100_spi.cpp @@ -39,6 +39,8 @@ #include +#if defined(CONFIG_SPI) + #include #include #include @@ -135,3 +137,5 @@ int RM3100_SPI::write(unsigned address, void *data, unsigned count) return transfer(&buf[0], &buf[0], count + 1); } + +#endif // CONFIG_SPI diff --git a/src/drivers/pca9685_pwm_out/PCA9685.cpp b/src/drivers/pca9685_pwm_out/PCA9685.cpp index 7eccd6c04b..f2a151ef44 100644 --- a/src/drivers/pca9685_pwm_out/PCA9685.cpp +++ b/src/drivers/pca9685_pwm_out/PCA9685.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2019-2022 PX4 Development Team. All rights reserved. + * Copyright (c) 2019-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 @@ -57,61 +57,61 @@ PCA9685::PCA9685(int bus, int addr): int PCA9685::init() { - int ret = I2C::init(); - - if (ret != PX4_OK) { return ret; } + return I2C::init(); +} +int PCA9685::configure() +{ uint8_t buf[2] = {}; buf[0] = PCA9685_REG_MODE1; buf[1] = PCA9685_DEFAULT_MODE1_CFG | PCA9685_MODE1_SLEEP_MASK; // put into sleep mode - ret = transfer(buf, 2, nullptr, 0); - - if (OK != ret) { - PX4_ERR("init: i2c::transfer returned %d", ret); - return ret; - } + int ret = transfer(buf, 2, nullptr, 0); #ifdef CONFIG_PCA9685_USE_EXTERNAL_CRYSTAL + /* EXTCLK is sticky, so writing it once is enough. Its not a problem when its written to 0 later. */ buf[1] = PCA9685_DEFAULT_MODE1_CFG | PCA9685_MODE1_SLEEP_MASK | PCA9685_MODE1_EXTCLK_MASK; - ret = transfer(buf, 2, nullptr, 0); // enable EXTCLK if possible - - if (OK != ret) { - PX4_ERR("init: i2c::transfer returned %d", ret); - return ret; - } - + ret |= transfer(buf, 2, nullptr, 0); #endif buf[0] = PCA9685_REG_MODE2; buf[1] = PCA9685_DEFAULT_MODE2_CFG; - ret = transfer(buf, 2, nullptr, 0); + ret |= transfer(buf, 2, nullptr, 0); + return ret; +} - if (OK != ret) { - PX4_ERR("init: i2c::transfer returned %d", ret); - return ret; +int PCA9685::registers_check() +{ + /* Check MODE1 register */ + uint8_t send_buf = PCA9685_REG_MODE1; + uint8_t recv_buf; + + int ret = transfer(&send_buf, 1, &recv_buf, 1); + uint8_t ignore_extclk_mask = ~PCA9685_MODE1_EXTCLK_MASK; + + if (ret != PX4_OK) { + return -EIO; + } + + if ((recv_buf & ignore_extclk_mask) != (PCA9685_DEFAULT_MODE1_CFG & ignore_extclk_mask)) { + return -EFAULT; + } + + /* Check MODE2 register */ + send_buf = PCA9685_REG_MODE2; + ret = transfer(&send_buf, 1, &recv_buf, 1); + + if (ret != PX4_OK) { + return -EIO; + } + + if (recv_buf != PCA9685_DEFAULT_MODE2_CFG) { + return -EFAULT; } return PX4_OK; } -int PCA9685::updatePWM(const uint16_t *outputs, unsigned num_outputs) -{ - if (num_outputs > PCA9685_PWM_CHANNEL_COUNT) { - num_outputs = PCA9685_PWM_CHANNEL_COUNT; - PX4_DEBUG("PCA9685 can only drive up to 16 channels"); - } - - uint16_t out[PCA9685_PWM_CHANNEL_COUNT]; - memcpy(out, outputs, sizeof(uint16_t) * num_outputs); - - for (unsigned i = 0; i < num_outputs; ++i) { - out[i] = calcRawFromPulse(out[i]); - } - - return writePWM(0, out, num_outputs); -} - int PCA9685::updateFreq(float freq) { uint16_t divider = (uint16_t)round((float)PCA9685_CLOCK_REFERENCE / freq / PCA9685_PWM_RES) - 1; @@ -160,30 +160,47 @@ int PCA9685::sleep() int PCA9685::wake() { - uint8_t buf[2] = { - PCA9685_REG_MODE1, - PCA9685_DEFAULT_MODE1_CFG - }; - return transfer(buf, 2, nullptr, 0); -} + uint8_t send_buf[2]; + uint8_t recv_buf; -int PCA9685::doRestart() -{ - uint8_t buf[2] = { - PCA9685_REG_MODE1, - PCA9685_DEFAULT_MODE1_CFG | PCA9685_MODE1_RESTART_MASK - }; - return transfer(buf, 2, nullptr, 0); + send_buf[0] = PCA9685_REG_MODE1; + int ret = transfer(&send_buf[0], 1, &recv_buf, 1); + + if (ret != PX4_OK) { + return PX4_ERROR; + } + + send_buf[1] = recv_buf & ~PCA9685_MODE1_SLEEP_MASK; // Clear sleep bit + ret |= transfer(&send_buf[0], 2, nullptr, 0); + px4_usleep(500); // wait for oscillator to stabilize + + if (recv_buf & PCA9685_MODE1_RESTART_MASK) { // Check if reset bit is set + send_buf[1] |= PCA9685_MODE1_RESTART_MASK; // Set restart bit + ret |= transfer(&send_buf[0], 2, nullptr, 0); + } + + ret |= transfer(&send_buf[0], 1, &recv_buf, 1); + + if (ret != PX4_OK || recv_buf & (PCA9685_MODE1_RESTART_MASK | PCA9685_MODE1_SLEEP_MASK)) { + return PX4_ERROR; + } + + return ret; } int PCA9685::probe() { - int ret = I2C::probe(); + for (int i = 0; i < 10; i++) { + uint8_t send_buf = PCA9685_REG_MODE1; - if (ret != PX4_OK) { return ret; } + if (transfer(&send_buf, 1, nullptr, 0) == PX4_OK) { + return PX4_OK; + } - uint8_t buf[2] = {0x00}; - return transfer(buf, 2, buf, 1); + px4_usleep(10'000); + } + + return PX4_ERROR; } int PCA9685::writePWM(uint8_t idx, const uint16_t *value, uint8_t num) diff --git a/src/drivers/pca9685_pwm_out/PCA9685.h b/src/drivers/pca9685_pwm_out/PCA9685.h index e8bd5eb4d8..d22b4cec22 100644 --- a/src/drivers/pca9685_pwm_out/PCA9685.h +++ b/src/drivers/pca9685_pwm_out/PCA9685.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2019 PX4 Development Team. All rights reserved. + * 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 @@ -95,13 +95,6 @@ public: int init() override; - /* - * Write new PWM value to device - * - * *output: pulse width, us - */ - int updatePWM(const uint16_t *outputs, unsigned num_outputs); - /* * Set PWM frequency to new value. * @@ -150,11 +143,14 @@ public: int wake(); /* - * If PCA9685 is put into sleep without clearing all the outputs, - * then the restart command will be available, and it can bring back PWM output without the - * need of updatePWM() call. - */ - int doRestart(); + * Configure the PCA9685 device with necessary settings. e.g. MODE1 or MODE2 + */ + int configure(); + + /* + * Verfy whether the registers of PCA9685 are in a consistent state + */ + int registers_check(); protected: int probe() override; diff --git a/src/drivers/pca9685_pwm_out/main.cpp b/src/drivers/pca9685_pwm_out/main.cpp index 60d0cc6340..2d22c36a77 100644 --- a/src/drivers/pca9685_pwm_out/main.cpp +++ b/src/drivers/pca9685_pwm_out/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2012-2022 PX4 Development Team. All rights reserved. + * Copyright (c) 2012-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 @@ -80,12 +80,15 @@ protected: private: perf_counter_t _cycle_perf; + perf_counter_t _comms_errors; + perf_counter_t _registers_invalid_reset; + perf_counter_t _registers_transfer_reset; enum class STATE : uint8_t { + CONFIGURE, INIT, - WAIT_FOR_OSC, RUNNING - } state{STATE::INIT}; + } _state{STATE::CONFIGURE}; PCA9685 *pca9685 = nullptr; uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s}; @@ -99,14 +102,22 @@ private: float param_pwm_freq, previous_pwm_freq; float param_schd_rate, previous_schd_rate; + bool param_update_failed = false; uint32_t param_duty_mode; + static constexpr uint8_t _transfer_fails_threshold = 10; + uint8_t _register_transfer_fails = 0; + void Run() override; + int registers_check(); }; PCA9685Wrapper::PCA9685Wrapper() : OutputModuleInterface(MODULE_NAME, px4::wq_configurations::hp_default), - _cycle_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")) + _cycle_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")), + _comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors")), + _registers_invalid_reset(perf_alloc(PC_COUNT, MODULE_NAME": registers invalid reset")), + _registers_transfer_reset(perf_alloc(PC_COUNT, MODULE_NAME": registers transfer reset")) { } @@ -119,6 +130,9 @@ PCA9685Wrapper::~PCA9685Wrapper() } perf_free(_cycle_perf); + perf_free(_comms_errors); + perf_free(_registers_invalid_reset); + perf_free(_registers_transfer_reset); } int PCA9685Wrapper::init() @@ -139,7 +153,7 @@ int PCA9685Wrapper::init() bool PCA9685Wrapper::updateOutputs(uint16_t *outputs, unsigned num_outputs, unsigned num_control_groups_updated) { - if (state != STATE::RUNNING) { return false; } + if (_state != STATE::RUNNING) { return false; } uint16_t low_level_outputs[PCA9685_PWM_CHANNEL_COUNT] = {}; num_outputs = num_outputs > PCA9685_PWM_CHANNEL_COUNT ? PCA9685_PWM_CHANNEL_COUNT : num_outputs; @@ -154,7 +168,7 @@ bool PCA9685Wrapper::updateOutputs(uint16_t *outputs, unsigned num_outputs, } if (pca9685->updateRAW(low_level_outputs, num_outputs) != PX4_OK) { - PX4_ERR("Failed to write PWM to PCA9685"); + perf_count(_comms_errors); return false; } @@ -176,69 +190,124 @@ void PCA9685Wrapper::Run() return; } - switch (state) { - case STATE::INIT: - updateParams(); - pca9685->updateFreq(param_pwm_freq); - previous_pwm_freq = param_pwm_freq; - previous_schd_rate = param_schd_rate; + switch (_state) { + case STATE::CONFIGURE: { + int ret = pca9685->configure(); - pca9685->wake(); - state = STATE::WAIT_FOR_OSC; - ScheduleDelayed(500); - break; + if (ret == PX4_OK) { + _state = STATE::INIT; + ScheduleNow(); - case STATE::WAIT_FOR_OSC: { - state = STATE::RUNNING; - ScheduleOnInterval(1000000 / param_schd_rate, 0); - } - break; - - case STATE::RUNNING: - perf_begin(_cycle_perf); - - _mixing_output.update(); - - // check for parameter updates - if (_parameter_update_sub.updated()) { - // clear update - parameter_update_s pupdate; - _parameter_update_sub.copy(&pupdate); - - // update parameters from storage - updateParams(); - - // apply param updates - if ((float)fabs(previous_pwm_freq - param_pwm_freq) > 0.01f) { - previous_pwm_freq = param_pwm_freq; - - ScheduleClear(); - - pca9685->sleep(); - pca9685->updateFreq(param_pwm_freq); - pca9685->wake(); - - // update of PWM freq will always trigger scheduling change - previous_schd_rate = param_schd_rate; - - state = STATE::WAIT_FOR_OSC; - ScheduleDelayed(500); - - } else if ((float)fabs(previous_schd_rate - param_schd_rate) > 0.01f) { - // case when PWM freq not changed but scheduling rate does - previous_schd_rate = param_schd_rate; - ScheduleClear(); - ScheduleOnInterval(1000000 / param_schd_rate, 1000000 / param_schd_rate); + } else { + perf_count(_comms_errors); + ScheduleDelayed(20_ms); } + + break; } - _mixing_output.updateSubscriptions(false); + case STATE::INIT: { + updateParams(); + int ret = pca9685->updateFreq(param_pwm_freq); + ret |= pca9685->wake(); - perf_end(_cycle_perf); - break; + if (ret == PX4_OK) { + previous_pwm_freq = param_pwm_freq; + previous_schd_rate = param_schd_rate; + _state = STATE::RUNNING; + ScheduleOnInterval(1000000 / param_schd_rate, 0); + + } else { + perf_count(_comms_errors); + _state = STATE::CONFIGURE; + ScheduleDelayed(20_ms); + } + + break; + } + + case STATE::RUNNING: { + perf_begin(_cycle_perf); + _mixing_output.update(); + + // check for parameter updates + if (_parameter_update_sub.updated() || param_update_failed) { + // clear update + parameter_update_s pupdate; + _parameter_update_sub.copy(&pupdate); + + // update parameters from storage + updateParams(); + + // apply param updates + if ((float)fabs(previous_pwm_freq - param_pwm_freq) > 0.01f) { + ScheduleClear(); + + int ret = pca9685->sleep(); + ret |= pca9685->updateFreq(param_pwm_freq); + ret |= pca9685->wake(); + + if (ret == PX4_OK) { + // update of PWM freq will always trigger scheduling change + param_update_failed = false; + previous_schd_rate = param_schd_rate; + previous_pwm_freq = param_pwm_freq; + ScheduleOnInterval(1000000 / param_schd_rate, 0); + + } else { + param_update_failed = true; + perf_count(_comms_errors); + ScheduleDelayed(20_ms); + break; + } + + } else if ((float)fabs(previous_schd_rate - param_schd_rate) > 0.01f) { + // case when PWM freq not changed but scheduling rate does + previous_schd_rate = param_schd_rate; + ScheduleClear(); + ScheduleOnInterval(1000000 / param_schd_rate, 1000000 / param_schd_rate); + } + } + + if (registers_check() != PX4_OK) { + _state = STATE::CONFIGURE; + ScheduleClear(); + ScheduleDelayed(20_ms); + } + + _mixing_output.updateSubscriptions(false); + + perf_end(_cycle_perf); + break; + } } } +int PCA9685Wrapper::registers_check() +{ + int reg_ret = pca9685->registers_check(); + + if (reg_ret == -EIO) { + _register_transfer_fails++; + + } else { + _register_transfer_fails = 0; + } + + if (reg_ret == -EFAULT) { + perf_count(_registers_invalid_reset); + return PX4_ERROR; + } + + if (_register_transfer_fails > _transfer_fails_threshold) { + perf_count(_registers_transfer_reset); + _register_transfer_fails = 0; + return PX4_ERROR; + } + + return PX4_OK; +} + int PCA9685Wrapper::print_usage(const char *reason) { if (reason) { diff --git a/src/drivers/power_monitor/ina220/ina220.cpp b/src/drivers/power_monitor/ina220/ina220.cpp index c8f52bf71c..bde68ce875 100644 --- a/src/drivers/power_monitor/ina220/ina220.cpp +++ b/src/drivers/power_monitor/ina220/ina220.cpp @@ -329,8 +329,6 @@ INA220::RunImpl() if (_ch_type == PM_CH_TYPE_VBATT) { _battery.setConnected(false); - _battery.updateVoltage(0.f); - _battery.updateCurrent(0.f); _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); } diff --git a/src/drivers/power_monitor/ina226/ina226.cpp b/src/drivers/power_monitor/ina226/ina226.cpp index f61a7c7b79..60fb333699 100644 --- a/src/drivers/power_monitor/ina226/ina226.cpp +++ b/src/drivers/power_monitor/ina226/ina226.cpp @@ -83,10 +83,10 @@ INA226::INA226(const I2CSPIDriverConfig &config, int battery_index) : _power_lsb = 25 * _current_lsb; // We need to publish immediately, to guarantee that the first instance of the driver publishes to uORB instance 0 - _battery.setConnected(false); - _battery.updateVoltage(0.f); - _battery.updateCurrent(0.f); + setConnected(false); _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); + + I2C::_retries = 5; } INA226::~INA226() @@ -226,14 +226,11 @@ INA226::collect() success = success && (read(INA226_REG_CURRENT, _current) == PX4_OK); // success = success && (read(INA226_REG_SHUNTVOLTAGE, _shunt) == PX4_OK); - if (!success) { - PX4_DEBUG("error reading from sensor"); - _bus_voltage = _power = _current = _shunt = 0; + if (setConnected(success)) { + _battery.updateVoltage(static_cast(_bus_voltage * INA226_VSCALE)); + _battery.updateCurrent(static_cast(_current * _current_lsb)); } - _battery.setConnected(success); - _battery.updateVoltage(static_cast(_bus_voltage * INA226_VSCALE)); - _battery.updateCurrent(static_cast(_current * _current_lsb)); _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); perf_end(_sample_perf); @@ -246,6 +243,7 @@ INA226::collect() } } + void INA226::start() { @@ -297,9 +295,7 @@ INA226::RunImpl() ScheduleDelayed(INA226_CONVERSION_INTERVAL); } else { - _battery.setConnected(false); - _battery.updateVoltage(0.f); - _battery.updateCurrent(0.f); + setConnected(false); _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); if (init() != PX4_OK) { @@ -308,6 +304,28 @@ INA226::RunImpl() } } +bool INA226::setConnected(bool state) +{ + // Filter out brief I2C failures for 2s + if (state) { + _connected = INA226_SAMPLE_FREQUENCY_HZ * 2; + + } else if (_connected > 0) { + _connected--; + } + + if (_connected > 0) { + _battery.setConnected(true); + + } else { + _battery.setConnected(false); + _battery.updateVoltage(0); + _battery.updateCurrent(0); + } + + return state; +} + void INA226::print_status() { diff --git a/src/drivers/power_monitor/ina226/ina226.h b/src/drivers/power_monitor/ina226/ina226.h index a402a079ab..a69695a1cc 100644 --- a/src/drivers/power_monitor/ina226/ina226.h +++ b/src/drivers/power_monitor/ina226/ina226.h @@ -206,6 +206,10 @@ private: int read(uint8_t address, int16_t &data); int write(uint8_t address, uint16_t data); + uint8_t _connected{0}; + // returns state unchanged + bool setConnected(bool state); + /** * Initialise the automatic measurement state machine and start it. * diff --git a/src/drivers/power_monitor/ina228/ina228.cpp b/src/drivers/power_monitor/ina228/ina228.cpp index e586590470..fd7494d3f3 100644 --- a/src/drivers/power_monitor/ina228/ina228.cpp +++ b/src/drivers/power_monitor/ina228/ina228.cpp @@ -98,11 +98,10 @@ INA228::INA228(const I2CSPIDriverConfig &config, int battery_index) : _power_lsb = 3.2f * _current_lsb; // We need to publish immediately, to guarantee that the first instance of the driver publishes to uORB instance 0 - _battery.setConnected(false); - _battery.updateVoltage(0.f); - _battery.updateCurrent(0.f); - _battery.updateTemperature(0.f); + setConnected(false); _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); + + I2C::_retries = 5; } INA228::~INA228() @@ -322,15 +321,12 @@ INA228::collect() //success = success && (read(INA228_REG_VSHUNT, _shunt) == PX4_OK); success = success && (read(INA228_REG_DIETEMP, _temperature) == PX4_OK); - if (!success) { - PX4_DEBUG("error reading from sensor"); - _bus_voltage = _power = _current = _shunt = 0; + if (setConnected(success)) { + _battery.updateVoltage(static_cast(_bus_voltage * INA228_VSCALE)); + _battery.updateCurrent(static_cast(_current * _current_lsb)); + _battery.updateTemperature(static_cast(_temperature * INA228_TSCALE)); } - _battery.setConnected(success); - _battery.updateVoltage(static_cast(_bus_voltage * INA228_VSCALE)); - _battery.updateCurrent(static_cast(_current * _current_lsb)); - _battery.updateTemperature(static_cast(_temperature * INA228_TSCALE)); _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); perf_end(_sample_perf); @@ -394,10 +390,7 @@ INA228::RunImpl() ScheduleDelayed(INA228_CONVERSION_INTERVAL); } else { - _battery.setConnected(false); - _battery.updateVoltage(0.f); - _battery.updateCurrent(0.f); - _battery.updateTemperature(0.f); + setConnected(false); _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); if (init() != PX4_OK) { @@ -406,6 +399,29 @@ INA228::RunImpl() } } +bool INA228::setConnected(bool state) +{ + // Filter out brief I2C failures for 2s + if (state) { + _connected = INA228_SAMPLE_FREQUENCY_HZ * 2; + + } else if (_connected > 0) { + _connected--; + } + + if (_connected > 0) { + _battery.setConnected(true); + + } else { + _battery.setConnected(false); + _battery.updateVoltage(0); + _battery.updateCurrent(0); + _battery.updateTemperature(0); + } + + return state; +} + void INA228::print_status() { diff --git a/src/drivers/power_monitor/ina228/ina228.h b/src/drivers/power_monitor/ina228/ina228.h index 46e152ff00..72a89e6dcb 100644 --- a/src/drivers/power_monitor/ina228/ina228.h +++ b/src/drivers/power_monitor/ina228/ina228.h @@ -356,6 +356,9 @@ private: Battery _battery; uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s}; + uint8_t _connected{0}; + // returns state unchanged + bool setConnected(bool state); int read(uint8_t address, int16_t &data); int write(uint8_t address, int16_t data); diff --git a/src/drivers/power_monitor/ina238/ina238.cpp b/src/drivers/power_monitor/ina238/ina238.cpp index a55f71b893..f42ae87764 100644 --- a/src/drivers/power_monitor/ina238/ina238.cpp +++ b/src/drivers/power_monitor/ina238/ina238.cpp @@ -90,11 +90,10 @@ INA238::INA238(const I2CSPIDriverConfig &config, int battery_index) : _register_cfg[2].clear_bits = ~_shunt_calibration; // We need to publish immediately, to guarantee that the first instance of the driver publishes to uORB instance 0 - _battery.setConnected(false); - _battery.updateVoltage(0.f); - _battery.updateCurrent(0.f); - _battery.updateTemperature(0.f); + setConnected(false); _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); + + I2C::_retries = 5; } INA238::~INA238() @@ -178,11 +177,8 @@ int INA238::probe() int INA238::Reset() { - int ret = PX4_ERROR; - _retries = 3; - if (RegisterWrite(Register::CONFIG, (uint16_t)(ADC_RESET_BIT)) != PX4_OK) { return ret; } @@ -254,13 +250,11 @@ int INA238::collect() success = success && (RegisterRead(Register::CURRENT, (uint16_t &)current) == PX4_OK); success = success && (RegisterRead(Register::DIETEMP, (uint16_t &)temperature) == PX4_OK); - if (success) { + if (setConnected(success)) { _battery.updateVoltage(static_cast(bus_voltage * INA238_VSCALE)); _battery.updateCurrent(static_cast(current * _current_lsb)); _battery.updateTemperature(static_cast(temperature * INA238_TSCALE)); - _battery.setConnected(success); - _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); } @@ -276,8 +270,7 @@ int INA238::collect() perf_count(_bad_register_perf); success = false; - _battery.setConnected(success); - + setConnected(false); _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); } } @@ -338,10 +331,7 @@ void INA238::RunImpl() ScheduleDelayed(INA238_CONVERSION_INTERVAL); } else { - _battery.setConnected(false); - _battery.updateVoltage(0.f); - _battery.updateCurrent(0.f); - _battery.updateTemperature(0.f); + setConnected(false); _battery.updateAndPublishBatteryStatus(hrt_absolute_time()); if (init() != PX4_OK) { @@ -354,6 +344,29 @@ void INA238::RunImpl() } } +bool INA238::setConnected(bool state) +{ + // Filter out brief I2C failures for 2s + if (state) { + _connected = INA238_SAMPLE_FREQUENCY_HZ * 2; + + } else if (_connected > 0) { + _connected--; + } + + if (_connected > 0) { + _battery.setConnected(true); + + } else { + _battery.setConnected(false); + _battery.updateVoltage(0); + _battery.updateCurrent(0); + _battery.updateTemperature(0); + } + + return state; +} + void INA238::print_status() { I2CSPIDriverBase::print_status(); diff --git a/src/drivers/power_monitor/ina238/ina238.h b/src/drivers/power_monitor/ina238/ina238.h index 7d888aef54..62750c44c4 100644 --- a/src/drivers/power_monitor/ina238/ina238.h +++ b/src/drivers/power_monitor/ina238/ina238.h @@ -154,6 +154,9 @@ private: Battery _battery; uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s}; + uint8_t _connected{0}; + // returns state unchanged + bool setConnected(bool state); int read(uint8_t address, uint16_t &data); int write(uint8_t address, uint16_t data); diff --git a/src/drivers/pwm_out/module.yaml b/src/drivers/pwm_out/module.yaml index 8c2049cceb..2c5e54e83d 100644 --- a/src/drivers/pwm_out/module.yaml +++ b/src/drivers/pwm_out/module.yaml @@ -8,6 +8,7 @@ actuator_output: disarmed: { min: 800, max: 2200, default: 1000 } min: { min: 800, max: 1400, default: 1000 } max: { min: 1600, max: 2200, default: 2000 } + center: { min: 800, max: 2200} failsafe: { min: 800, max: 2200 } extra_function_groups: [ pwm_fmu ] pwm_timer_param: diff --git a/src/drivers/rc/crsf_rc/CrsfParser.cpp b/src/drivers/rc/crsf_rc/CrsfParser.cpp index a81fe930f5..a56fa0e686 100644 --- a/src/drivers/rc/crsf_rc/CrsfParser.cpp +++ b/src/drivers/rc/crsf_rc/CrsfParser.cpp @@ -57,8 +57,10 @@ enum CRSF_PAYLOAD_SIZE { CRSF_PAYLOAD_SIZE_GPS = 15, CRSF_PAYLOAD_SIZE_BATTERY = 8, CRSF_PAYLOAD_SIZE_LINK_STATISTICS = 10, + CRSF_PAYLOAD_SIZE_LINK_STATISTICS_TX = -1, CRSF_PAYLOAD_SIZE_RC_CHANNELS = 22, CRSF_PAYLOAD_SIZE_ATTITUDE = 6, + CRSF_PAYLOAD_SIZE_ELRS_STATUS = -1, // unclear how large this message is }; enum CRSF_PACKET_TYPE { @@ -68,6 +70,8 @@ enum CRSF_PACKET_TYPE { CRSF_PACKET_TYPE_OPENTX_SYNC = 0x10, CRSF_PACKET_TYPE_RADIO_ID = 0x3A, CRSF_PACKET_TYPE_RC_CHANNELS_PACKED = 0x16, + CRSF_PACKET_TYPE_LINK_STATISTICS_RX = 0x1C, + CRSF_PACKET_TYPE_LINK_STATISTICS_TX = 0x1D, CRSF_PACKET_TYPE_ATTITUDE = 0x1E, CRSF_PACKET_TYPE_FLIGHT_MODE = 0x21, // Extended Header Frames, range: 0x28 to 0x96 @@ -76,6 +80,7 @@ enum CRSF_PACKET_TYPE { CRSF_PACKET_TYPE_PARAMETER_SETTINGS_ENTRY = 0x2B, CRSF_PACKET_TYPE_PARAMETER_READ = 0x2C, CRSF_PACKET_TYPE_PARAMETER_WRITE = 0x2D, + CRSF_PACKET_TYPE_ELRS_STATUS = 0x2E, CRSF_PACKET_TYPE_COMMAND = 0x32, // MSP commands CRSF_PACKET_TYPE_MSP_REQ = 0x7A, // response request using msp sequence as command @@ -114,18 +119,22 @@ enum PARSER_STATE { typedef struct { uint8_t packet_type; - uint32_t packet_size; + int32_t packet_size; bool (*processor)(const uint8_t *data, const uint32_t size, CrsfPacket_t *const new_packet); } CrsfPacketDescriptor_t; static bool ProcessChannelData(const uint8_t *data, const uint32_t size, CrsfPacket_t *const new_packet); static bool ProcessLinkStatistics(const uint8_t *data, const uint32_t size, CrsfPacket_t *const new_packet); +static bool ProcessLinkStatisticsTx(const uint8_t *data, const uint32_t size, CrsfPacket_t *const new_packet); +static bool ProcessElrsStatus(const uint8_t *data, const uint32_t size, CrsfPacket_t *const new_packet); -#define CRSF_PACKET_DESCRIPTOR_COUNT 2 -static const CrsfPacketDescriptor_t crsf_packet_descriptors[CRSF_PACKET_DESCRIPTOR_COUNT] = { +static const CrsfPacketDescriptor_t crsf_packet_descriptors[] = { {CRSF_PACKET_TYPE_RC_CHANNELS_PACKED, CRSF_PAYLOAD_SIZE_RC_CHANNELS, ProcessChannelData}, {CRSF_PACKET_TYPE_LINK_STATISTICS, CRSF_PAYLOAD_SIZE_LINK_STATISTICS, ProcessLinkStatistics}, + {CRSF_PACKET_TYPE_LINK_STATISTICS_TX, CRSF_PAYLOAD_SIZE_LINK_STATISTICS_TX, ProcessLinkStatisticsTx}, + {CRSF_PACKET_TYPE_ELRS_STATUS, CRSF_PAYLOAD_SIZE_ELRS_STATUS, ProcessElrsStatus}, }; +#define CRSF_PACKET_DESCRIPTOR_COUNT (sizeof(crsf_packet_descriptors) / sizeof(CrsfPacketDescriptor_t)) static enum PARSER_STATE parser_state = PARSER_STATE_HEADER; static uint32_t working_index = 0; @@ -134,6 +143,11 @@ static uint32_t working_segment_size = HEADER_SIZE; #define RX_QUEUE_BUFFER_SIZE 200 static QueueBuffer_t rx_queue; static uint8_t rx_queue_buffer[RX_QUEUE_BUFFER_SIZE]; +#ifdef CONFIG_RC_CRSF_INJECT +static QueueBuffer_t inject_queue; +static uint8_t inject_queue_buffer[RX_QUEUE_BUFFER_SIZE]; +static uint8_t temp_queue_buffer[RX_QUEUE_BUFFER_SIZE]; +#endif static uint8_t process_buffer[CRSF_MAX_PACKET_LEN]; static CrsfPacketDescriptor_t *working_descriptor = NULL; @@ -142,6 +156,9 @@ static CrsfPacketDescriptor_t *FindCrsfDescriptor(const enum CRSF_PACKET_TYPE pa void CrsfParser_Init(void) { QueueBuffer_Init(&rx_queue, rx_queue_buffer, RX_QUEUE_BUFFER_SIZE); +#ifdef CONFIG_RC_CRSF_INJECT + QueueBuffer_Init(&inject_queue, inject_queue_buffer, RX_QUEUE_BUFFER_SIZE); +#endif } static float ConstrainF(const float x, const float min, const float max) @@ -201,7 +218,7 @@ static bool ProcessLinkStatistics(const uint8_t *data, const uint32_t size, Crsf new_packet->message_type = CRSF_MESSAGE_TYPE_LINK_STATISTICS; new_packet->link_statistics.uplink_rssi_1 = data[0]; - new_packet->link_statistics.uplink_rssi_2 = data[1]; + new_packet->link_statistics.uplink_rssi_2 = data[1]; new_packet->link_statistics.uplink_link_quality = data[2]; new_packet->link_statistics.uplink_snr = data[3]; new_packet->link_statistics.active_antenna = data[4]; @@ -214,6 +231,34 @@ static bool ProcessLinkStatistics(const uint8_t *data, const uint32_t size, Crsf return true; } +static bool ProcessLinkStatisticsTx(const uint8_t *data, const uint32_t size, CrsfPacket_t *const new_packet) +{ + new_packet->message_type = CRSF_MESSAGE_TYPE_LINK_STATISTICS_TX; + + new_packet->link_statistics_tx.uplink_rssi = data[0]; + new_packet->link_statistics_tx.uplink_rssi_pct = data[1]; + new_packet->link_statistics_tx.uplink_link_quality = data[2]; + new_packet->link_statistics_tx.uplink_snr = data[3]; + new_packet->link_statistics_tx.downlink_power = data[4]; + new_packet->link_statistics_tx.uplink_fps = data[5]; + + return true; +} + +static bool ProcessElrsStatus(const uint8_t *data, const uint32_t size, CrsfPacket_t *const new_packet) +{ + new_packet->message_type = CRSF_MESSAGE_TYPE_ELRS_STATUS; + + // Try: crsf_rc inject 0x2E 0x13 0x50 0xFB 0x53 0x31 0x63 0x63 0x63 0x63 + + new_packet->elrs_status.packets_bad = data[2]; + new_packet->elrs_status.packets_good = (data[3] << 8) | data[4]; + new_packet->elrs_status.flags = data[5]; + strlcpy(new_packet->elrs_status.message, (const char *)&data[6], sizeof(new_packet->elrs_status.message)); + + return true; +} + static CrsfPacketDescriptor_t *FindCrsfDescriptor(const enum CRSF_PACKET_TYPE packet_type) { uint32_t i; @@ -232,6 +277,13 @@ bool CrsfParser_LoadBuffer(const uint8_t *buffer, const uint32_t size) return QueueBuffer_AppendBuffer(&rx_queue, buffer, size); } +#ifdef CONFIG_RC_CRSF_INJECT +bool CrsfParser_InjectBuffer(const uint8_t *buffer, const uint32_t size) +{ + return QueueBuffer_AppendBuffer(&inject_queue, buffer, size); +} +#endif + uint32_t CrsfParser_FreeQueueSize(void) { return RX_QUEUE_BUFFER_SIZE - QueueBuffer_Count(&rx_queue); @@ -280,16 +332,21 @@ bool CrsfParser_TryParseCrsfPacket(CrsfPacket_t *const new_packet, CrsfParserSta // If we know what this packet is... if (working_descriptor != NULL) { // Validate length - if (packet_size != working_descriptor->packet_size + PACKET_SIZE_TYPE_SIZE) { - parser_statistics->invalid_known_packet_sizes++; - parser_state = PARSER_STATE_HEADER; - working_segment_size = HEADER_SIZE; - working_index = 0; - buffer_count = QueueBuffer_Count(&rx_queue); - continue; - } + if (working_descriptor->packet_size == -1) { + working_segment_size = packet_size - PACKET_SIZE_TYPE_SIZE; - working_segment_size = working_descriptor->packet_size; + } else { + if (packet_size != working_descriptor->packet_size + PACKET_SIZE_TYPE_SIZE) { + parser_statistics->invalid_known_packet_sizes++; + parser_state = PARSER_STATE_HEADER; + working_segment_size = HEADER_SIZE; + working_index = 0; + buffer_count = QueueBuffer_Count(&rx_queue); + continue; + } + + working_segment_size = working_descriptor->packet_size; + } } else { // We don't know what this packet is, so we'll let the parser continue @@ -349,7 +406,37 @@ bool CrsfParser_TryParseCrsfPacket(CrsfPacket_t *const new_packet, CrsfParserSta parser_state = PARSER_STATE_HEADER; if (valid_packet) { +#ifdef CONFIG_RC_CRSF_INJECT + + if (!QueueBuffer_IsEmpty(&inject_queue)) { + // copy the remaining bytes from the rx queue to the temp buffer + const uint32_t temp_size = QueueBuffer_Count(&rx_queue); + + if (temp_size) { + QueueBuffer_PeekBuffer(&rx_queue, 0, temp_queue_buffer, temp_size); + // clear the rx queue + QueueBuffer_Dequeue(&rx_queue, QueueBuffer_Count(&rx_queue)); + } + + // append the inject queue to the rx queue + uint8_t inject_byte; + + while (QueueBuffer_Get(&inject_queue, &inject_byte)) { + QueueBuffer_Append(&rx_queue, inject_byte); + } + + if (temp_size) { + // append the temp buffer back to the rx queue + QueueBuffer_AppendBuffer(&rx_queue, temp_queue_buffer, temp_size); + } + + } else { + return true; + } + +#else return true; +#endif } break; diff --git a/src/drivers/rc/crsf_rc/CrsfParser.hpp b/src/drivers/rc/crsf_rc/CrsfParser.hpp index c0bf0e8494..4c4b10217b 100644 --- a/src/drivers/rc/crsf_rc/CrsfParser.hpp +++ b/src/drivers/rc/crsf_rc/CrsfParser.hpp @@ -43,6 +43,7 @@ #include #include +#include #define CRSF_CHANNEL_COUNT 16 @@ -63,6 +64,22 @@ struct CrsfLinkStatistics_t { int8_t downlink_snr; }; +struct CrsfLinkStatisticsTx_t { + uint8_t uplink_rssi; + uint8_t uplink_rssi_pct; + uint8_t uplink_link_quality; + int8_t uplink_snr; + uint8_t downlink_power; + uint8_t uplink_fps; +}; + +struct CrsfElrsStatus_t { + uint8_t packets_bad; + uint16_t packets_good; + uint8_t flags; + char message[48]; +}; + struct CrsfParserStatistics_t { uint32_t disposed_bytes; uint32_t crcs_valid_known_packets; @@ -75,6 +92,8 @@ struct CrsfParserStatistics_t { enum CRSF_MESSAGE_TYPE { CRSF_MESSAGE_TYPE_RC_CHANNELS, CRSF_MESSAGE_TYPE_LINK_STATISTICS, + CRSF_MESSAGE_TYPE_LINK_STATISTICS_TX, + CRSF_MESSAGE_TYPE_ELRS_STATUS, }; typedef struct { @@ -83,10 +102,15 @@ typedef struct { union { CrsfChannelData_t channel_data; CrsfLinkStatistics_t link_statistics; + CrsfLinkStatisticsTx_t link_statistics_tx; + CrsfElrsStatus_t elrs_status; }; } CrsfPacket_t; void CrsfParser_Init(void); bool CrsfParser_LoadBuffer(const uint8_t *buffer, const uint32_t size); +#ifdef CONFIG_RC_CRSF_INJECT +bool CrsfParser_InjectBuffer(const uint8_t *buffer, const uint32_t size); +#endif uint32_t CrsfParser_FreeQueueSize(void); bool CrsfParser_TryParseCrsfPacket(CrsfPacket_t *const new_packet, CrsfParserStatistics_t *const parser_statistics); diff --git a/src/drivers/rc/crsf_rc/CrsfRc.cpp b/src/drivers/rc/crsf_rc/CrsfRc.cpp index 9e311da18e..95aa9412ed 100644 --- a/src/drivers/rc/crsf_rc/CrsfRc.cpp +++ b/src/drivers/rc/crsf_rc/CrsfRc.cpp @@ -178,8 +178,11 @@ void CrsfRc::Run() Crc8Init(0xd5); + _input_rc.rssi = -1; _input_rc.rssi_dbm = NAN; _input_rc.link_quality = -1; + _input_rc.rc_frame_rate = 0; + _input_rc.link_snr = -1; CrsfParser_Init(); } @@ -213,8 +216,30 @@ void CrsfRc::Run() case CRSF_MESSAGE_TYPE_LINK_STATISTICS: _last_packet_seen = time_now_us; - _input_rc.rssi_dbm = -(float)new_crsf_packet.link_statistics.uplink_rssi_1; + _input_rc.rssi_dbm = -(float)(new_crsf_packet.link_statistics.active_antenna ? + new_crsf_packet.link_statistics.uplink_rssi_2 : + new_crsf_packet.link_statistics.uplink_rssi_1); + + if (time_now_us - _last_stats_tx_seen > 500_ms) { + // We haven't received link statistics tx in a while, use an approximation + _input_rc.rssi = (1.f - _input_rc.rssi_dbm / -130.f) * _input_rc.RSSI_MAX; + } + _input_rc.link_quality = new_crsf_packet.link_statistics.uplink_link_quality; + _input_rc.rc_frame_rate = new_crsf_packet.link_statistics.rf_mode; + _input_rc.link_snr = new_crsf_packet.link_statistics.uplink_snr; + break; + + case CRSF_MESSAGE_TYPE_LINK_STATISTICS_TX: + _last_packet_seen = time_now_us; + _last_stats_tx_seen = time_now_us; + _input_rc.rssi = new_crsf_packet.link_statistics_tx.uplink_rssi_pct; + break; + + case CRSF_MESSAGE_TYPE_ELRS_STATUS: + _last_packet_seen = time_now_us; + _input_rc.rc_lost_frame_count = new_crsf_packet.elrs_status.packets_bad; + _input_rc.rc_total_frame_count = new_crsf_packet.elrs_status.packets_good; break; default: @@ -342,14 +367,17 @@ void CrsfRc::Run() } // If no communication - if (time_now_us - _last_packet_seen > 100_ms) { + if (time_now_us - _last_packet_seen > 500_ms) { // Invalidate link statistics + _input_rc.rssi = -1; _input_rc.rssi_dbm = NAN; _input_rc.link_quality = -1; + _input_rc.rc_frame_rate = 0; + _input_rc.link_snr = -1; } // If we have not gotten RC updates specifically - if (time_now_us - _input_rc.timestamp_last_signal > 50_ms) { + if (time_now_us - _input_rc.timestamp_last_signal > 500_ms) { _input_rc.rc_lost = 1; _input_rc.rc_failsafe = 1; @@ -359,7 +387,6 @@ void CrsfRc::Run() } _input_rc.channel_count = CRSF_CHANNEL_COUNT; - _input_rc.rssi = -1; _input_rc.rc_ppm_frame_length = 0; _input_rc.input_source = input_rc_s::RC_INPUT_SOURCE_PX4FMU_CRSF; _input_rc.timestamp = hrt_absolute_time(); @@ -518,6 +545,43 @@ int CrsfRc::print_status() int CrsfRc::custom_command(int argc, char *argv[]) { +#ifdef CONFIG_RC_CRSF_INJECT + + if (!strcmp(argv[0], "start")) { + if (is_running()) { + return print_usage("already running"); + } + + int ret = CrsfRc::task_spawn(argc, argv); + + if (ret) { + return ret; + } + } + + if (!is_running()) { + return print_usage("not running"); + } + + // crsf_rc inject 0x7C 0xC8 0xEA 0x30 0x02 0x59 0x31 0x00 0x6A + if (!strcmp(argv[0], "inject")) { + const uint8_t length = argc; + uint8_t buf[100]; + buf[0] = 0xC8; // sync byte + buf[1] = length; + uint8_t i = 0; + + for (; i < length - 1; i++) { + buf[i + 2] = (uint8_t) strtol(argv[i + 1], nullptr, 16); + } + + buf[i + 2] = Crc8Calc(buf + 2, length - 1); // CRC + CrsfParser_InjectBuffer(buf, length + 2); + return PX4_OK; + } + +#endif + return print_usage("unknown command"); } @@ -538,7 +602,9 @@ This module parses the CRSF RC uplink protocol and generates CRSF downlink telem PRINT_MODULE_USAGE_SUBCATEGORY("radio_control"); PRINT_MODULE_USAGE_COMMAND("start"); PRINT_MODULE_USAGE_PARAM_STRING('d', "/dev/ttyS3", "", "RC device", true); - +#ifdef CONFIG_RC_CRSF_INJECT + PRINT_MODULE_USAGE_COMMAND_DESCR("inject", "Inject frame data bytes (for testing)"); +#endif PRINT_MODULE_USAGE_DEFAULT_COMMANDS(); return 0; diff --git a/src/drivers/rc/crsf_rc/CrsfRc.hpp b/src/drivers/rc/crsf_rc/CrsfRc.hpp index c3b0a4ec54..a47b361903 100644 --- a/src/drivers/rc/crsf_rc/CrsfRc.hpp +++ b/src/drivers/rc/crsf_rc/CrsfRc.hpp @@ -100,6 +100,7 @@ private: uint32_t _bytes_rx{0}; hrt_abstime _last_packet_seen{0}; + hrt_abstime _last_stats_tx_seen{0}; CrsfParserStatistics_t _packet_parser_statistics{0}; diff --git a/src/drivers/rc/crsf_rc/Kconfig b/src/drivers/rc/crsf_rc/Kconfig index 21096275af..6c42bec5ff 100644 --- a/src/drivers/rc/crsf_rc/Kconfig +++ b/src/drivers/rc/crsf_rc/Kconfig @@ -3,3 +3,13 @@ menuconfig DRIVERS_RC_CRSF_RC default n ---help--- Enable support for crsf rc + +if DRIVERS_RC_CRSF_RC + +config RC_CRSF_INJECT + bool "Inject CRSF RC" + default n + ---help--- + Enable this to inject CRSF RC commands. + +endif # DRIVERS_RC_CRSF_RC diff --git a/src/drivers/temperature_sensor/Kconfig b/src/drivers/temperature_sensor/Kconfig new file mode 100644 index 0000000000..af8c27e657 --- /dev/null +++ b/src/drivers/temperature_sensor/Kconfig @@ -0,0 +1,3 @@ +menu "TEMPERATURE_SENSOR" +rsource "*/Kconfig" +endmenu #TEMPERATURE_SENSOR diff --git a/src/drivers/temperature_sensor/mcp9808/CMakeLists.txt b/src/drivers/temperature_sensor/mcp9808/CMakeLists.txt new file mode 100644 index 0000000000..108858606b --- /dev/null +++ b/src/drivers/temperature_sensor/mcp9808/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# 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 drivers__temperature_sensor__mcp9808 + MAIN mcp9808 + COMPILE_FLAGS + SRCS + mcp9808_main.cpp + mcp9808.cpp + mcp9808.h + DEPENDS + px4_work_queue + ) diff --git a/src/drivers/temperature_sensor/mcp9808/Kconfig b/src/drivers/temperature_sensor/mcp9808/Kconfig new file mode 100644 index 0000000000..f0f9f04145 --- /dev/null +++ b/src/drivers/temperature_sensor/mcp9808/Kconfig @@ -0,0 +1,5 @@ +menuconfig DRIVERS_TEMPERATURE_SENSOR_MCP9808 + bool "MCP9808 temperature sensor" + default n + ---help--- + Enable support MCP9808 temperature sensor diff --git a/src/drivers/temperature_sensor/mcp9808/mcp9808.cpp b/src/drivers/temperature_sensor/mcp9808/mcp9808.cpp new file mode 100644 index 0000000000..a6a997e9a2 --- /dev/null +++ b/src/drivers/temperature_sensor/mcp9808/mcp9808.cpp @@ -0,0 +1,160 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +#include "mcp9808.h" + +MCP9808::MCP9808(const I2CSPIDriverConfig &config) : + I2C(config), + I2CSPIDriver(config), + _cycle_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": single-sample")), + _comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors")) +{ + _sensor_temp.device_id = get_device_id(); +} + +MCP9808::~MCP9808() +{ + ScheduleClear(); + perf_free(_cycle_perf); + perf_free(_comms_errors); +} + +void MCP9808::RunImpl() +{ + perf_begin(_cycle_perf); + + float temperature = read_temperature(); + + if (std::isnan(temperature)) { + + perf_count(_comms_errors); + + } else { + _sensor_temp.timestamp = hrt_absolute_time(); + _sensor_temp.temperature = temperature; + + _sensor_temp_pub.publish(_sensor_temp); + } + + perf_end(_cycle_perf); +} + +int MCP9808::probe() +{ + uint16_t manuf_id, device_id; + int ret = read_reg(MCP9808_REG_MANUF_ID, manuf_id); + + if (ret != PX4_OK) { + return ret; + } + + ret = read_reg(MCP9808_REG_DEVICE_ID, device_id); + + if (ret != PX4_OK) { + return ret; + } + + // Verify manufacturer and device ID + if (manuf_id != 0x0054 || device_id != 0x0400) { + PX4_ERR("MCP9808 not found (manuf_id: 0x%04X, device_id: 0x%04X)", manuf_id, device_id); + return PX4_ERROR; + } + + PX4_INFO("MCP9808 found (manuf_id: 0x%04X, device_id: 0x%04X)", manuf_id, device_id); + return PX4_OK; +} + +int MCP9808::init() +{ + int ret = I2C::init(); + + if (ret != PX4_OK) { + PX4_ERR("I2C init failed"); + return ret; + } + + PX4_DEBUG("I2C initialized successfully"); + + ret = write_reg(MCP9808_REG_CONFIG, 0x0000); // Ensure default configuration + + if (ret != PX4_OK) { + PX4_ERR("Configuration failed"); + return ret; + } + + _sensor_temp_pub.advertise(); + + ScheduleOnInterval(200_ms); // Sample at 5 Hz + return PX4_OK; +} + +float MCP9808::read_temperature() +{ + uint16_t temp_raw = 0; + + if (read_reg(MCP9808_REG_AMBIENT_TEMP, temp_raw) != PX4_OK) { + return NAN; + } + + float temp = (temp_raw & 0x0FFF) / 16.0f; + + if (temp_raw & 0x1000) { + temp -= 256.0f; + } + + return temp; +} + +int MCP9808::read_reg(uint8_t address, uint16_t &data) +{ + uint8_t addr = address; + uint8_t buffer[2] = {}; // Buffer to hold the raw data + + // Read 2 bytes from the register + int ret = transfer(&addr, 1, buffer, 2); + + if (ret != PX4_OK) { + return ret; + } + + // Combine bytes (big-endian) + data = (buffer[0] << 8) | buffer[1]; + + return PX4_OK; +} + +int MCP9808::write_reg(uint8_t address, uint16_t value) +{ + uint8_t buf[3] = {address, static_cast(value >> 8), static_cast(value & 0xFF)}; + return transfer(buf, sizeof(buf), nullptr, 0); +} diff --git a/src/drivers/temperature_sensor/mcp9808/mcp9808.h b/src/drivers/temperature_sensor/mcp9808/mcp9808.h new file mode 100644 index 0000000000..a13d5c46be --- /dev/null +++ b/src/drivers/temperature_sensor/mcp9808/mcp9808.h @@ -0,0 +1,75 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +using namespace time_literals; + +#define MCP9808_REG_CONFIG 0x01 +#define MCP9808_REG_AMBIENT_TEMP 0x05 +#define MCP9808_REG_MANUF_ID 0x06 +#define MCP9808_REG_DEVICE_ID 0x07 +#define MCP9808_REG_RESOLUTION 0x08 + +class MCP9808 : public device::I2C, public I2CSPIDriver +{ +public: + MCP9808(const I2CSPIDriverConfig &config); + ~MCP9808() override; + + int init() override; + int probe() override; + void RunImpl(); + static void print_usage(); + +protected: + void print_status(); + +private: + uORB::PublicationMulti _sensor_temp_pub{ORB_ID(sensor_temp)}; + int read_reg(uint8_t address, uint16_t &data); + int write_reg(uint8_t address, uint16_t value); + float read_temperature(); + sensor_temp_s _sensor_temp{}; + perf_counter_t _cycle_perf; + perf_counter_t _comms_errors; +}; diff --git a/src/drivers/temperature_sensor/mcp9808/mcp9808_main.cpp b/src/drivers/temperature_sensor/mcp9808/mcp9808_main.cpp new file mode 100644 index 0000000000..57cccaeaea --- /dev/null +++ b/src/drivers/temperature_sensor/mcp9808/mcp9808_main.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** + * + * 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 mcp9808_main.cpp + * @author TedObrien + * + * Driver for the Microchip MCP9080 Temperature Sensor connected via I2C. + */ + +#include "mcp9808.h" +#include + +void MCP9808::print_usage() +{ + PRINT_MODULE_USAGE_NAME("mcp9808", "driver"); + PRINT_MODULE_USAGE_COMMAND("start"); + PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false); + PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(0x18); + PRINT_MODULE_USAGE_DEFAULT_COMMANDS(); +} + +void MCP9808::print_status() +{ + I2CSPIDriverBase::print_status(); + perf_print_counter(_cycle_perf); + perf_print_counter(_comms_errors); +} + +extern "C" int mcp9808_main(int argc, char *argv[]) +{ + using ThisDriver = MCP9808; + BusCLIArguments cli{true, false}; + cli.default_i2c_frequency = 400000; + cli.i2c_address = 0x18; + + const char *verb = cli.parseDefaultArguments(argc, argv); + + if (!verb) { + ThisDriver::print_usage(); + return -1; + } + + BusInstanceIterator iterator(MODULE_NAME, cli, DRV_TEMP_DEVTYPE_MCP9808); + + if (!strcmp(verb, "start")) { + return ThisDriver::module_start(cli, iterator); + } + + if (!strcmp(verb, "stop")) { + return ThisDriver::module_stop(iterator); + } + + if (!strcmp(verb, "status")) { + return ThisDriver::module_status(iterator); + } + + ThisDriver::print_usage(); + return -1; +} diff --git a/src/drivers/temperature_sensor/mcp9808/mcp9808_params.c b/src/drivers/temperature_sensor/mcp9808/mcp9808_params.c new file mode 100644 index 0000000000..8dc0b5241c --- /dev/null +++ b/src/drivers/temperature_sensor/mcp9808/mcp9808_params.c @@ -0,0 +1,41 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +/** + * Enable MCP9808 temperature sensor (external I2C) + * + * @reboot_required true + * @group Sensors + * @boolean + */ +PARAM_DEFINE_INT32(SENS_EN_MCP9808, 0); diff --git a/src/drivers/uavcan/actuators/esc.cpp b/src/drivers/uavcan/actuators/esc.cpp index cefc5b276d..15b5504c45 100644 --- a/src/drivers/uavcan/actuators/esc.cpp +++ b/src/drivers/uavcan/actuators/esc.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2014 PX4 Development Team. All rights reserved. + * Copyright (C) 2014-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 @@ -74,20 +74,13 @@ UavcanEscController::init() _uavcan_pub_raw_cmd.getTransferSender().setIfaceMask(iface_mask); } - char param_name[17]; - - for (unsigned i = 0; i < MAX_ACTUATORS; ++i) { - snprintf(param_name, sizeof(param_name), "UAVCAN_EC_FUNC%d", i + 1); - _param_handles[i] = param_find(param_name); - } - _initialized = true; return res; } void -UavcanEscController::update_outputs(uint16_t outputs[MAX_ACTUATORS], unsigned total_outputs) +UavcanEscController::update_outputs(uint16_t outputs[MAX_ACTUATORS], uint8_t output_array_size) { // TODO: configurable rate limit const auto timestamp = _node.getMonotonicTime(); @@ -100,26 +93,10 @@ UavcanEscController::update_outputs(uint16_t outputs[MAX_ACTUATORS], unsigned to uavcan::equipment::esc::RawCommand msg = {}; - // directly output values from mixer - for (unsigned i = 0; i < total_outputs; i++) { + for (unsigned i = 0; i < output_array_size; i++) { msg.cmd.push_back(static_cast(outputs[i])); } - // but only output as many channels as are configured - uint8_t min_size = 0; - - for (int i = 0; i < MAX_ACTUATORS; i++) { - int32_t val = 0; - - if (param_get(_param_handles[i], &val) == 0) { - if (val > 0) { - min_size = i + 1; - } - } - } - - msg.cmd.resize(min_size); - _uavcan_pub_raw_cmd.broadcast(msg); } diff --git a/src/drivers/uavcan/actuators/esc.hpp b/src/drivers/uavcan/actuators/esc.hpp index e758bb1030..e488cf823a 100644 --- a/src/drivers/uavcan/actuators/esc.hpp +++ b/src/drivers/uavcan/actuators/esc.hpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2014 PX4 Development Team. All rights reserved. + * Copyright (C) 2014-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 @@ -71,7 +71,7 @@ public: bool initialized() { return _initialized; }; - void update_outputs(uint16_t outputs[MAX_ACTUATORS], unsigned total_outputs); + void update_outputs(uint16_t outputs[MAX_ACTUATORS], uint8_t output_array_size); /** * Sets the number of rotors and enable timer @@ -114,7 +114,4 @@ private: uavcan::INode &_node; uavcan::Publisher _uavcan_pub_raw_cmd; uavcan::Subscriber _uavcan_sub_status; - - - param_t _param_handles[MAX_ACTUATORS] {PARAM_INVALID}; }; diff --git a/src/drivers/uavcan/uavcan_main.cpp b/src/drivers/uavcan/uavcan_main.cpp index 37e36c2217..28f64049db 100644 --- a/src/drivers/uavcan/uavcan_main.cpp +++ b/src/drivers/uavcan/uavcan_main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2014-2022 PX4 Development Team. All rights reserved. + * Copyright (c) 2014-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 @@ -1082,7 +1082,19 @@ bool UavcanMixingInterfaceESC::updateOutputs(uint16_t outputs[MAX_ACTUATORS], un unsigned num_control_groups_updated) { if (_esc_controller.initialized()) { - _esc_controller.update_outputs(outputs, num_outputs); + // num_outputs is the maximum possible number of outputs (8) + // output_array_size adapts to the highest output index that is mapped (4 for a quad) + // this allows for sending less CAN frames depending on what output indices are mapped + uint8_t output_array_size = 0; + + for (int i = MAX_ACTUATORS - 1; i >= 0; i--) { + if (mixingOutput().isFunctionSet(i)) { + output_array_size = i + 1; + break; + } + } + + _esc_controller.update_outputs(outputs, output_array_size); } return true; diff --git a/src/drivers/uavcannode/Publishers/BatteryInfo.hpp b/src/drivers/uavcannode/Publishers/BatteryInfo.hpp index 686dc05086..00b409400a 100644 --- a/src/drivers/uavcannode/Publishers/BatteryInfo.hpp +++ b/src/drivers/uavcannode/Publishers/BatteryInfo.hpp @@ -36,6 +36,7 @@ #include "UavcanPublisherBase.hpp" #include +#include #include #include @@ -47,15 +48,18 @@ namespace uavcannode class BatteryInfo : public UavcanPublisherBase, private uORB::SubscriptionCallbackWorkItem, - private uavcan::Publisher + private uavcan::Publisher, + private uavcan::Publisher { public: BatteryInfo(px4::WorkItem *work_item, uavcan::INode &node) : UavcanPublisherBase(uavcan::equipment::power::BatteryInfo::DefaultDataTypeID), uORB::SubscriptionCallbackWorkItem(work_item, ORB_ID(battery_status)), - uavcan::Publisher(node) + uavcan::Publisher(node), + uavcan::Publisher(node) { - this->setPriority(uavcan::TransferPriority::MiddleLower); + uavcan::Publisher::setPriority(uavcan::TransferPriority::MiddleLower); + uavcan::Publisher::setPriority(uavcan::TransferPriority::MiddleLower); } void PrintInfo() override @@ -65,36 +69,63 @@ public: uORB::SubscriptionCallbackWorkItem::get_topic()->o_name, uavcan::equipment::power::BatteryInfo::getDataTypeFullName(), uavcan::equipment::power::BatteryInfo::DefaultDataTypeID); + printf("\t%s -> %s:%d\n", + uORB::SubscriptionCallbackWorkItem::get_topic()->o_name, + ardupilot::equipment::power::BatteryInfoAux::getDataTypeFullName(), + ardupilot::equipment::power::BatteryInfoAux::DefaultDataTypeID); } } void BroadcastAnyUpdates() override { - // battery_status -> uavcan::equipment::power::BatteryInfo + // battery_status -> uavcan::equipment::power::BatteryInfo & ardupilot::equipment::power::BatteryInfoAux battery_status_s battery; if (uORB::SubscriptionCallbackWorkItem::update(&battery)) { + ardupilot::equipment::power::BatteryInfoAux battery_info_aux{}; + + battery_info_aux.timestamp.usec = battery.timestamp; + + for (uint8_t i = 0; i < battery.cell_count && i < arraySize(battery_status_s::voltage_cell_v); i++) { + battery_info_aux.voltage_cell.push_back(battery.voltage_cell_v[i]); + } + + battery_info_aux.cycle_count = battery.cycle_count; + battery_info_aux.over_discharge_count = battery.over_discharge_count; + battery_info_aux.max_current = battery.current_a; + battery_info_aux.nominal_voltage = battery.nominal_voltage; + battery_info_aux.is_powering_off = battery.is_powering_off; + battery_info_aux.battery_id = battery.id; + + uavcan::Publisher::broadcast(battery_info_aux); + uavcan::equipment::power::BatteryInfo battery_info{}; battery_info.voltage = battery.voltage_v; - battery_info.current = fabs(battery.current_a); + battery_info.current = battery.current_a; battery_info.temperature = battery.temperature - atmosphere::kAbsoluteNullCelsius; // convert from C to K - battery_info.full_charge_capacity_wh = battery.capacity; - battery_info.remaining_capacity_wh = battery.remaining * battery.capacity; - battery_info.state_of_charge_pct = battery.remaining * 100; + battery_info.full_charge_capacity_wh = battery.full_charge_capacity_wh; + battery_info.remaining_capacity_wh = battery.remaining_capacity_wh; + battery_info.state_of_charge_pct = battery.remaining * 100.0f; battery_info.state_of_charge_pct_stdev = battery.max_error; + battery_info.battery_id = battery.id; battery_info.model_instance_id = 0; // TODO: what goes here? - battery_info.model_name = "ARK BMS Rev 0.2"; - battery_info.battery_id = battery.serial_number; - battery_info.hours_to_full_charge = 0; // TODO: Read BQ40Z80_TIME_TO_FULL + battery_info.model_name = "PX4 CAN Battery"; + + // State of health battery_info.state_of_health_pct = battery.state_of_health; - if (battery.current_a > 0.0f) { - battery_info.status_flags = uavcan::equipment::power::BatteryInfo::STATUS_FLAG_CHARGING; + uint8_t status_flags = 0; - } else { - battery_info.status_flags = uavcan::equipment::power::BatteryInfo::STATUS_FLAG_IN_USE; + if (battery.connected) { + status_flags |= uavcan::equipment::power::BatteryInfo::STATUS_FLAG_IN_USE; } + if (battery.warning == battery_status_s::STATE_CHARGING) { + status_flags |= uavcan::equipment::power::BatteryInfo::STATUS_FLAG_CHARGING; + } + + battery_info.status_flags = status_flags; + uavcan::Publisher::broadcast(battery_info); // ensure callback is registered diff --git a/src/lib/mixer_module/mixer_module.cpp b/src/lib/mixer_module/mixer_module.cpp index b038268d84..fe1b818f86 100644 --- a/src/lib/mixer_module/mixer_module.cpp +++ b/src/lib/mixer_module/mixer_module.cpp @@ -120,6 +120,8 @@ void MixingOutput::initParamHandles(const uint8_t instance_start) _param_handles[i].disarmed = param_find(param_name); snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "MIN", i + instance_start); _param_handles[i].min = param_find(param_name); + snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "CENT", i + instance_start); + _param_handles[i].center = param_find(param_name); snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "MAX", i + instance_start); _param_handles[i].max = param_find(param_name); snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "FAIL", i + instance_start); @@ -142,9 +144,9 @@ void MixingOutput::printStatus() const PX4_INFO_RAW("Channel Configuration:\n"); for (unsigned i = 0; i < _max_num_outputs; i++) { - PX4_INFO_RAW("Channel %i: func: %3i, value: %i, failsafe: %d, disarmed: %d, min: %d, max: %d\n", i, + PX4_INFO_RAW("Channel %i: func: %3i, value: %i, failsafe: %d, disarmed: %d, min: %d, max: %d, center: %d\n", i, (int)_function_assignment[i], _current_output_value[i], - actualFailsafeValue(i), _disarmed_value[i], _min_value[i], _max_value[i]); + actualFailsafeValue(i), _disarmed_value[i], _min_value[i], _max_value[i], _center_value[i]); } } @@ -173,6 +175,10 @@ void MixingOutput::updateParams() _min_value[i] = val; } + if (_param_handles[i].center != PARAM_INVALID && param_get(_param_handles[i].center, &val) == 0) { + _center_value[i] = val; + } + if (_param_handles[i].max != PARAM_INVALID && param_get(_param_handles[i].max, &val) == 0) { _max_value[i] = val; } @@ -183,6 +189,7 @@ void MixingOutput::updateParams() _max_value[i] = tmp; } + if (_param_handles[i].failsafe != PARAM_INVALID && param_get(_param_handles[i].failsafe, &val) == 0) { _failsafe_value[i] = val; } @@ -372,6 +379,14 @@ void MixingOutput::setAllMinValues(uint16_t value) } } +void MixingOutput::setAllCenterValues(uint16_t value) +{ + for (unsigned i = 0; i < MAX_ACTUATORS; i++) { + _param_handles[i].center = PARAM_INVALID; + _center_value[i] = value; + } +} + void MixingOutput::setAllMaxValues(uint16_t value) { for (unsigned i = 0; i < MAX_ACTUATORS; i++) { @@ -528,10 +543,34 @@ uint16_t MixingOutput::output_limit_calc_single(int i, float value) const value = -1.f * value; } - const float output = math::interpolate(value, -1.f, 1.f, - static_cast(_min_value[i]), static_cast(_max_value[i])); + float output = _disarmed_value[i]; + + if (_function_assignment[i] >= OutputFunction::Servo1 + && _function_assignment[i] <= OutputFunction::ServoMax + && _param_handles[i].center != PARAM_INVALID + && _center_value[i] >= 800 + && _center_value[i] <= 2200) { + + /* bi-linear interpolation */ + if (value < 0.0f) { + output = math::interpolate(value, -1.f, 0.0f, + static_cast(_min_value[i]), static_cast(_center_value[i])); + + } else { + output = math::interpolate(value, 0.0f, 1.0f, + static_cast(_center_value[i]), static_cast(_max_value[i])); + } + + } + + // Everything except servos, or if center is not set + else { + output = math::interpolate(value, -1.f, 1.f, + static_cast(_min_value[i]), static_cast(_max_value[i])); + } return math::constrain(lroundf(output), 0L, static_cast(UINT16_MAX)); + } void diff --git a/src/lib/mixer_module/mixer_module.hpp b/src/lib/mixer_module/mixer_module.hpp index 7ed8ed8a73..4fdc0f2904 100644 --- a/src/lib/mixer_module/mixer_module.hpp +++ b/src/lib/mixer_module/mixer_module.hpp @@ -167,16 +167,19 @@ public: void setAllFailsafeValues(uint16_t value); void setAllDisarmedValues(uint16_t value); void setAllMinValues(uint16_t value); + void setAllCenterValues(uint16_t value); void setAllMaxValues(uint16_t value); /** Disarmed values: disarmedValue < minValue needs to hold */ uint16_t &disarmedValue(int index) { return _disarmed_value[index]; } uint16_t &minValue(int index) { return _min_value[index]; } + uint16_t ¢erValue(int index) { return _center_value[index]; } uint16_t &maxValue(int index) { return _max_value[index]; } param_t functionParamHandle(int index) const { return _param_handles[index].function; } param_t disarmedParamHandle(int index) const { return _param_handles[index].disarmed; } param_t minParamHandle(int index) const { return _param_handles[index].min; } + param_t centerParamHandle(int index) const { return _param_handles[index].center; } param_t maxParamHandle(int index) const { return _param_handles[index].max; } /** @@ -228,6 +231,7 @@ private: param_t function{PARAM_INVALID}; param_t disarmed{PARAM_INVALID}; param_t min{PARAM_INVALID}; + param_t center{PARAM_INVALID}; param_t max{PARAM_INVALID}; param_t failsafe{PARAM_INVALID}; }; @@ -240,6 +244,7 @@ private: uint16_t _failsafe_value[MAX_ACTUATORS] {}; uint16_t _disarmed_value[MAX_ACTUATORS] {}; uint16_t _min_value[MAX_ACTUATORS] {}; + uint16_t _center_value[MAX_ACTUATORS] {}; uint16_t _max_value[MAX_ACTUATORS] {}; uint16_t _current_output_value[MAX_ACTUATORS] {}; ///< current output values (reordered) uint16_t _reverse_output_mask{0}; ///< reverses the interval [min, max] -> [max, min], NOT motor direction diff --git a/src/lib/mixer_module/mixer_module_tests.cpp b/src/lib/mixer_module/mixer_module_tests.cpp index 7db9a8c513..7f3a6feede 100644 --- a/src/lib/mixer_module/mixer_module_tests.cpp +++ b/src/lib/mixer_module/mixer_module_tests.cpp @@ -54,6 +54,7 @@ static constexpr int MAX_NUM_OUTPUTS = 8; static constexpr int DISARMED_VALUE = 900; static constexpr int FAILSAFE_VALUE = 800; static constexpr int MIN_VALUE = 1000; +static constexpr int CENTER_VALUE = 1500; static constexpr int MAX_VALUE = 2000; class MixerModuleTest : public ::testing::Test @@ -188,6 +189,7 @@ TEST_F(MixerModuleTest, basic) mixing_output.setAllDisarmedValues(DISARMED_VALUE); mixing_output.setAllFailsafeValues(FAILSAFE_VALUE); mixing_output.setAllMinValues(MIN_VALUE); + mixing_output.setAllCenterValues(CENTER_VALUE); mixing_output.setAllMaxValues(MAX_VALUE); EXPECT_EQ(test_module.num_updates, 0); @@ -281,6 +283,7 @@ TEST_F(MixerModuleTest, arming) mixing_output.setAllDisarmedValues(DISARMED_VALUE); mixing_output.setAllFailsafeValues(FAILSAFE_VALUE); mixing_output.setAllMinValues(MIN_VALUE); + mixing_output.setAllCenterValues(CENTER_VALUE); mixing_output.setAllMaxValues(MAX_VALUE); test_module.sendMotors({1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f}); @@ -488,6 +491,7 @@ TEST_F(MixerModuleTest, OutputLimitCalcSingle) mixing_output.setAllMinValues(MIN_VALUE); // default range [1000,2000] mixing_output.setAllMaxValues(MAX_VALUE); + mixing_output.setAllCenterValues(CENTER_VALUE); // Set center to middle value EXPECT_EQ(mixing_output.output_limit_calc_single(0, -1.f), 1000); // In range EXPECT_EQ(mixing_output.output_limit_calc_single(0, -.5f), 1250); EXPECT_EQ(mixing_output.output_limit_calc_single(0, 0.f), 1500); @@ -503,6 +507,7 @@ TEST_F(MixerModuleTest, OutputLimitCalcSingle) mixing_output.setAllMinValues(0); // lower range [0,20] mixing_output.setAllMaxValues(20); + mixing_output.setAllCenterValues(10); // Set center to middle value EXPECT_EQ(mixing_output.output_limit_calc_single(0, -1.f), 0); // In range EXPECT_EQ(mixing_output.output_limit_calc_single(0, -.5f), 5); EXPECT_EQ(mixing_output.output_limit_calc_single(0, 0.f), 10); @@ -518,6 +523,7 @@ TEST_F(MixerModuleTest, OutputLimitCalcSingle) mixing_output.setAllMinValues(20); // inverted range [20,0] mixing_output.setAllMaxValues(0); + mixing_output.setAllCenterValues(10); // Set center to middle value EXPECT_EQ(mixing_output.output_limit_calc_single(0, -1.f), 20); // In range EXPECT_EQ(mixing_output.output_limit_calc_single(0, -.5f), 15); EXPECT_EQ(mixing_output.output_limit_calc_single(0, 0.f), 10); diff --git a/src/lib/rate_control/CMakeLists.txt b/src/lib/rate_control/CMakeLists.txt index f95b133eea..2370b2eb5d 100644 --- a/src/lib/rate_control/CMakeLists.txt +++ b/src/lib/rate_control/CMakeLists.txt @@ -34,6 +34,8 @@ px4_add_library(RateControl rate_control.cpp rate_control.hpp + gain_compression.cpp + gain_compression.hpp ) target_compile_options(RateControl PRIVATE ${MAX_CUSTOM_OPT_LEVEL}) target_include_directories(RateControl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/lib/rate_control/gain_compression.cpp b/src/lib/rate_control/gain_compression.cpp new file mode 100644 index 0000000000..7e1e172de4 --- /dev/null +++ b/src/lib/rate_control/gain_compression.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +#include "gain_compression.hpp" + +using matrix::Vector3f; +using namespace time_literals; + +GainCompression3d::GainCompression3d(ModuleParams *parent) : ModuleParams(parent) +{ + updateParams(); + _gain_compression_pub.advertise(); +} + +void GainCompression3d::reset() +{ + for (unsigned i = 0; i < 3; i++) { + _compression_gains[i].reset(); + } +} + +void GainCompression3d::updateParams() +{ + ModuleParams::updateParams(); + + for (unsigned i = 0; i < 3; i++) { + _compression_gains[i].setCompressionGainMin(_param_fw_gc_gain_min.get()); + } +} + +void GainCompression3d::update(const Vector3f &input, const float dt) +{ + if (!_param_fw_gc_en.get()) { + reset(); + _gains.setOne(); + return; + } + + Vector3f hpf; + Vector3f lpf; + const float sample_freq = 1.f / math::constrain(dt, 1e-3f, 100e-3f); + + for (unsigned i = 0; i < 3; i++) { + _compression_gains[i].setLpfCutoffFrequency(sample_freq, _kLpfCutoffFrequency); + _compression_gains[i].setHpfCutoffFrequency(sample_freq, _kHpfCutoffFrequency); + + _gains(i) = _compression_gains[i].update(input(i), dt); + + hpf(i) = _compression_gains[i].getSpectralDamperHpf(); + lpf(i) = _compression_gains[i].getSpectralDamperLpf(); + } + + const hrt_abstime now = hrt_absolute_time(); + + if ((now - _time_last_publication) > 100_ms) { + gain_compression_s msg; + msg.timestamp = now; + _gains.copyTo(msg.compression_gains); + hpf.copyTo(msg.spectral_damper_hpf); + lpf.copyTo(msg.spectral_damper_out); + _gain_compression_pub.publish(msg); + + _time_last_publication = now; + } +} + +float GainCompression::update(const float input, const float dt) +{ + _hpf = _alpha_hpf * _hpf + _alpha_hpf * (input - _input_prev); + _lpf.update(_hpf * _hpf); + + _input_prev = input; + + const float ka = fmaxf(_compression_gain - _compression_gain_min, 0.f); + const float spectral_damping = -_kSpectralDamperGain * ka * _lpf.getState(); + + const float leakage = _kLeakageGain * (1.f - _compression_gain); + + const float ka_dot = spectral_damping + leakage; + _compression_gain = math::constrain(_compression_gain + ka_dot * dt, _compression_gain_min, 1.f); + + return _compression_gain; +} diff --git a/src/lib/rate_control/gain_compression.hpp b/src/lib/rate_control/gain_compression.hpp new file mode 100644 index 0000000000..20611e9ac9 --- /dev/null +++ b/src/lib/rate_control/gain_compression.hpp @@ -0,0 +1,119 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +/* Description: + * This class produces a multiplicative gain that can be used on the output of a controller + * to dynamically reduce the loop gain when oscillations are detected. + * + * Algorithm based on + * Orr, Jeb, and Tannen Van Zwieten. "Robust, practical adaptive control for launch vehicles." + * AIAA Guidance, Navigation, and Control Conference. 2012. + * https://ntrs.nasa.gov/api/citations/20120015662/downloads/20120015662.pdf + */ + +#pragma once + +// PX4 includes +#include + +// Libraries +#include +#include + +// uORB includes +#include +#include + +class GainCompression +{ +public: + void reset() { _compression_gain = 1.f; } + float update(float input, float dt); + + void setLpfCutoffFrequency(float sample_freq, float cutoff) + { + _lpf.setCutoffFreq(sample_freq, cutoff); + } + void setHpfCutoffFrequency(float sample_freq, float cutoff) { _alpha_hpf = sample_freq / (sample_freq + 2.f * M_PI_F * cutoff); } + + float getSpectralDamperHpf() const { return _hpf * _hpf; } + float getSpectralDamperLpf() const { return _lpf.getState(); } + void setCompressionGainMin(float gain_min) { _compression_gain_min = gain_min; } + +private: + float _compression_gain{1.f}; + float _compression_gain_min{0.3f}; + + float _alpha_hpf{0.f}; + float _hpf{0.f}; + + float _input_prev{0.f}; + + AlphaFilter _lpf; + + static constexpr float _kSpectralDamperGain{200.f}; // tuned based on flight test data to obtain a quick response + static constexpr float _kLeakageGain{0.1f}; // 1/time_constant, slow enough to not interfere with the controller + +}; + +class GainCompression3d : public ModuleParams +{ +public: + GainCompression3d(ModuleParams *parent); + ~GainCompression3d() = default; + + void reset(); + void update(const matrix::Vector3f &input, float dt); + const matrix::Vector3f &getGains() const { return _gains; }; + + +protected: + void updateParams() override; + +private: + // uORB publications + uORB::Publication _gain_compression_pub{ORB_ID(gain_compression)}; + + GainCompression _compression_gains[3]; + matrix::Vector3f _gains{1.f, 1.f, 1.f}; + + hrt_abstime _time_last_publication{0}; + + static constexpr float _kLpfCutoffFrequency{5.f}; // Just above the control bandwidth of most UAVs + static constexpr float _kHpfCutoffFrequency{2.f * _kLpfCutoffFrequency}; // 1 Octave above LPF cutoff, as recommended by the reference paper + + DEFINE_PARAMETERS( + (ParamBool) _param_fw_gc_en, + (ParamFloat) _param_fw_gc_gain_min + ) +}; diff --git a/src/lib/rate_control/gain_compression_params.c b/src/lib/rate_control/gain_compression_params.c new file mode 100644 index 0000000000..7a3cda5660 --- /dev/null +++ b/src/lib/rate_control/gain_compression_params.c @@ -0,0 +1,53 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +/** + * Enable rate gain compression + * + * @boolean + * @group FW Rate Control + */ +PARAM_DEFINE_INT32(FW_GC_EN, 1); + +/** + * Compression gain lower limit + * + * The range of the compression gain is between this parameter and 1.0 + * + * @min 0.0 + * @max 1.0 + * @increment 0.01 + * @decimal 2 + * @group FW Rate Control + */ +PARAM_DEFINE_FLOAT(FW_GC_GAIN_MIN, 0.3f); diff --git a/src/lib/wind_estimator/WindEstimator.hpp b/src/lib/wind_estimator/WindEstimator.hpp index 462f88ff26..dbdf854da9 100644 --- a/src/lib/wind_estimator/WindEstimator.hpp +++ b/src/lib/wind_estimator/WindEstimator.hpp @@ -94,6 +94,14 @@ public: void set_beta_gate(uint8_t gate_size) {_beta_gate = gate_size; } void set_scale_init(float scale_init) {_scale_init = 1.f / math::constrain(scale_init, 0.1f, 10.f); } + void reset_scale_to_init() + { + _state(INDEX_TAS_SCALE) = _scale_init; + auto P_wind = _P.slice<2, 2>(0, 0); + _P.setZero(); + _P.slice<2, 2>(0, 0) = P_wind; + } + private: enum { INDEX_W_N = 0, diff --git a/src/modules/airspeed_selector/AirspeedValidator.hpp b/src/modules/airspeed_selector/AirspeedValidator.hpp index ec78b9ef8f..f902e8a9de 100644 --- a/src/modules/airspeed_selector/AirspeedValidator.hpp +++ b/src/modules/airspeed_selector/AirspeedValidator.hpp @@ -121,6 +121,7 @@ public: void set_tas_scale_apply(int tas_scale_apply) { _tas_scale_apply = tas_scale_apply; } void set_CAS_scale_validated(float scale) { _CAS_scale_validated = scale; } void set_scale_init(float scale) { _wind_estimator.set_scale_init(scale); } + void reset_scale_estimator() { _wind_estimator.reset_scale_to_init(); } void set_enable_data_stuck_check(bool enable) { _data_stuck_check_enabled = enable; } void set_enable_innovation_check(bool enable) { _innovation_check_enabled = enable; } diff --git a/src/modules/airspeed_selector/airspeed_selector_main.cpp b/src/modules/airspeed_selector/airspeed_selector_main.cpp index b3209e2f33..94a8b9cd8a 100644 --- a/src/modules/airspeed_selector/airspeed_selector_main.cpp +++ b/src/modules/airspeed_selector/airspeed_selector_main.cpp @@ -494,10 +494,24 @@ void AirspeedModule::update_params() param_get(_param_handle_fw_thr_max, &_param_fw_thr_max); } + const float prev_scale[MAX_NUM_AIRSPEED_SENSORS] = { + _param_airspeed_scale[0], + _param_airspeed_scale[1], + _param_airspeed_scale[2] + }; + _param_airspeed_scale[0] = _param_airspeed_scale_1.get(); _param_airspeed_scale[1] = _param_airspeed_scale_2.get(); _param_airspeed_scale[2] = _param_airspeed_scale_3.get(); + for (int i = 0; i < MAX_NUM_AIRSPEED_SENSORS; i++) { + if (fabsf(_param_airspeed_scale[i] - prev_scale[i]) > FLT_EPSILON) { + _airspeed_validator[i].set_scale_init(_param_airspeed_scale[i]); + _airspeed_validator[i].reset_scale_estimator(); + _airspeed_validator[i].set_CAS_scale_validated(_param_airspeed_scale[i]); + } + } + _wind_estimator_sideslip.set_wind_process_noise_spectral_density(_param_aspd_wind_nsd.get()); _wind_estimator_sideslip.set_tas_scale_process_noise_spectral_density(_param_aspd_scale_nsd.get()); _wind_estimator_sideslip.set_tas_noise(_param_west_tas_noise.get()); diff --git a/src/modules/airspeed_selector/airspeed_selector_params.c b/src/modules/airspeed_selector/airspeed_selector_params.c index a7db4cb30c..34d74cbfc5 100644 --- a/src/modules/airspeed_selector/airspeed_selector_params.c +++ b/src/modules/airspeed_selector/airspeed_selector_params.c @@ -95,7 +95,6 @@ PARAM_DEFINE_INT32(ASPD_SCALE_APPLY, 2); * @min 0.5 * @max 2.0 * @decimal 2 - * @reboot_required true * @group Airspeed Validator * @volatile */ @@ -109,7 +108,6 @@ PARAM_DEFINE_FLOAT(ASPD_SCALE_1, 1.0f); * @min 0.5 * @max 2.0 * @decimal 2 - * @reboot_required true * @group Airspeed Validator * @volatile */ @@ -123,7 +121,6 @@ PARAM_DEFINE_FLOAT(ASPD_SCALE_2, 1.0f); * @min 0.5 * @max 2.0 * @decimal 2 - * @reboot_required true * @group Airspeed Validator * @volatile */ diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index 4f6bfa0faf..3923eb379f 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -638,7 +638,7 @@ transition_result_t Commander::arm(arm_disarm_reason_t calling_reason, bool run_ events::send(events::ID("commander_armed_by"), events::Log::Info, "Armed by {1}", calling_reason); - if (_param_com_home_en.get() && !_mission_in_progress) { + if (_param_com_home_en.get() && !_mission_in_progress && !_config_overrides.disable_auto_set_home) { _home_position.setHomePosition(); } @@ -1850,7 +1850,8 @@ void Commander::run() _mission_in_progress = (_vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION) && !_mission_result_sub.get().finished; - _home_position.update(_param_com_home_en.get(), !isArmed() && _vehicle_land_detected.landed && !_mission_in_progress); + _home_position.update(_param_com_home_en.get(), !isArmed() && _vehicle_land_detected.landed && !_mission_in_progress + && !_config_overrides.disable_auto_set_home); handleAutoDisarm(); @@ -2140,7 +2141,7 @@ void Commander::landDetectorUpdate() } // automatically set or update home position - if (_param_com_home_en.get() && !_mission_in_progress) { + if (_param_com_home_en.get() && !_mission_in_progress && !_config_overrides.disable_auto_set_home) { // set the home position when taking off if (!_vehicle_land_detected.landed) { if (was_landed) { diff --git a/src/modules/commander/ModeManagement.cpp b/src/modules/commander/ModeManagement.cpp index b26bb99993..ae2dee41ff 100644 --- a/src/modules/commander/ModeManagement.cpp +++ b/src/modules/commander/ModeManagement.cpp @@ -232,6 +232,7 @@ void ModeManagement::checkNewRegistrations(UpdateRequest &update_request) static_assert(sizeof(request.name) == sizeof(reply.name), "size mismatch"); memcpy(reply.name, request.name, sizeof(request.name)); reply.request_id = request.request_id; + reply.not_user_selectable = request.not_user_selectable; reply.px4_ros2_api_version = register_ext_component_request_s::LATEST_PX4_ROS2_API_VERSION; // validate @@ -562,6 +563,10 @@ void ModeManagement::updateActiveConfigOverrides(uint8_t nav_state, config_overr current_overrides.disable_auto_disarm = true; } + if (executor_overrides.disable_auto_set_home) { + current_overrides.disable_auto_set_home = true; + } + if (executor_overrides.defer_failsafes) { current_overrides.defer_failsafes = true; current_overrides.defer_failsafes_timeout_s = executor_overrides.defer_failsafes_timeout_s; diff --git a/src/modules/commander/commander_params.c b/src/modules/commander/commander_params.c index 2c53e36c66..0f3a97de4b 100644 --- a/src/modules/commander/commander_params.c +++ b/src/modules/commander/commander_params.c @@ -198,18 +198,6 @@ PARAM_DEFINE_INT32(COM_HOME_IN_AIR, 0); */ PARAM_DEFINE_INT32(COM_RC_IN_MODE, 3); -/** - * Manual control input arm/disarm command duration - * - * The default value of 1000 requires the stick to be held in the arm or disarm position for 1 second. - * - * @group Commander - * @min 100 - * @max 1500 - * @unit ms - */ -PARAM_DEFINE_INT32(COM_RC_ARM_HYST, 1000); - /** * Time-out for auto disarm after landing * @@ -243,14 +231,16 @@ PARAM_DEFINE_FLOAT(COM_DISARM_LAND, 2.0f); PARAM_DEFINE_FLOAT(COM_DISARM_PRFLT, 10.0f); /** - * GPS preflight check + * Arming without GNSS configuration * - * Measures taken when a check defined by EKF2_GPS_CHECK is failing. + * Configures whether arming is allowed without GNSS, for modes that require a global position + * (specifically, in those modes when a check defined by EKF2_GPS_CHECK fails). + * The settings deny arming and warn, allow arming and warn, or silently allow arming. * * @group Commander * @value 0 Deny arming - * @value 1 Warning only - * @value 2 Disabled + * @value 1 Allow arming (with warning) + * @value 2 Allow arming (no warning) */ PARAM_DEFINE_INT32(COM_ARM_WO_GPS, 1); @@ -258,8 +248,7 @@ PARAM_DEFINE_INT32(COM_ARM_WO_GPS, 1); * Arm switch is a momentary button * * 0: Arming/disarming triggers on switch transition. - * 1: Arming/disarming triggers when holding the momentary button down - * for COM_RC_ARM_HYST like the stick gesture. + * 1: Arming/disarming triggers when holding the momentary button down like the stick gesture. * * @group Commander * @boolean diff --git a/src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp b/src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp index 46fea5f33e..f6e216b855 100644 --- a/src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp +++ b/src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp @@ -32,6 +32,7 @@ ****************************************************************************/ #include +#include #include "ActuatorEffectivenessControlSurfaces.hpp" @@ -74,6 +75,40 @@ void ActuatorEffectivenessControlSurfaces::updateParams() return; } + // Helper to check if a PWM center parameter is enabled, and clamp it to valid range + auto check_pwm_center = [](const char *prefix, int channel) -> bool { + char param_name[20]; + snprintf(param_name, sizeof(param_name), "%s_CENT%d", prefix, channel); + param_t param = param_find(param_name); + + if (param != PARAM_INVALID) + { + int32_t value; + + if (param_get(param, &value) == PX4_OK && value != -1) { + // Clamp PWM center to valid range [800, 2200] + if (value < 800 || value > 2200) { + int32_t clamped = (value < 800) ? 800 : 2200; + PX4_WARN("%s_CENT%d (%d) out of range, clamping to %d", prefix, channel, (int)value, (int)clamped); + param_set(param, &clamped); + } + + return true; + } + } + + return false; + }; + + // Check if any PWM_MAIN or PWM_AUX center is configured + bool pwm_center_set = false; + + for (int i = 1; i <= 8; i++) { + if (check_pwm_center("PWM_MAIN", i) || check_pwm_center("PWM_AUX", i)) { + pwm_center_set = true; + } + } + for (int i = 0; i < _count; i++) { param_get(_param_handles[i].type, (int32_t *)&_params[i].type); @@ -84,6 +119,20 @@ void ActuatorEffectivenessControlSurfaces::updateParams() } param_get(_param_handles[i].trim, &_params[i].trim); + + // If PWM center is set and CA_SV_CS trim is non-zero, warn and reset to 0 + if (pwm_center_set && fabsf(_params[i].trim) > FLT_EPSILON) { + /* EVENT + * @description Display warning in GCS when TRIM settings were present and now CENTER are set. + */ + events::send(events::ID("control_surfaces_reset_trim"), events::Log::Warning, + "CA_SV_CS{1}_TRIM ({2}) is reset to 0 as PWM CENTER is used", i, _params[i].trim); + + _params[i].trim = 0.0f; + // Update the parameter storage + param_set(_param_handles[i].trim, &_params[i].trim); + } + param_get(_param_handles[i].scale_flap, &_params[i].scale_flap); param_get(_param_handles[i].scale_spoiler, &_params[i].scale_spoiler); diff --git a/src/modules/control_allocator/module.yaml b/src/modules/control_allocator/module.yaml index 99d0d5ed85..dd36a2d070 100644 --- a/src/modules/control_allocator/module.yaml +++ b/src/modules/control_allocator/module.yaml @@ -312,7 +312,11 @@ parameters: CA_SV_CS${i}_TRIM: description: short: Control Surface ${i} trim - long: Can be used to add an offset to the servo control. + long: | + Can be used to add an offset to the servo control. + + NOTE: Do not use for PWM servos. Use the PWM CENTER parameters instead (e.g., PWM_MAIN_CENT, PWM_AUX_CENT) instead. + This parameter can only be set if all PWM Center parameters are set to default. type: float decimal: 2 min: -1.0 diff --git a/src/modules/ekf2/EKF/aid_sources/airspeed/airspeed_fusion.cpp b/src/modules/ekf2/EKF/aid_sources/airspeed/airspeed_fusion.cpp index 2e324663de..245c12cd69 100644 --- a/src/modules/ekf2/EKF/aid_sources/airspeed/airspeed_fusion.cpp +++ b/src/modules/ekf2/EKF/aid_sources/airspeed/airspeed_fusion.cpp @@ -96,7 +96,8 @@ void Ekf::controlAirDataFusion(const imuSample &imu_delayed) _innov_check_fail_status.flags.reject_airspeed = _aid_src_airspeed.innovation_rejected; // TODO: remove this redundant flag - const bool continuing_conditions_passing = _control_status.flags.in_air + const bool continuing_conditions_passing = _control_status.flags.in_air && (_control_status.flags.fixed_wing + || _control_status.flags.in_transition_to_fw) && !_control_status.flags.fake_pos; const bool is_airspeed_significant = airspeed_sample.true_airspeed > _params.ekf2_arsp_thr; diff --git a/src/modules/ekf2/EKF/common.h b/src/modules/ekf2/EKF/common.h index c8d61754aa..57fcb0d859 100644 --- a/src/modules/ekf2/EKF/common.h +++ b/src/modules/ekf2/EKF/common.h @@ -267,6 +267,7 @@ struct systemFlagUpdate { bool is_fixed_wing{false}; bool gnd_effect{false}; bool constant_pos{false}; + bool in_transition_to_fw{false}; }; struct parameters { @@ -611,6 +612,8 @@ uint64_t gnss_fault : uint64_t yaw_manual : 1; ///< 46 - true if yaw has been reset manually uint64_t gnss_hgt_fault : 1; ///< 47 - true if GNSS measurements (alt) have been declared faulty and are no longer used + uint64_t in_transition_to_fw : 1; ///< 48 - true if the vehicle is in transition to fw + } flags; uint64_t value; }; diff --git a/src/modules/ekf2/EKF/control.cpp b/src/modules/ekf2/EKF/control.cpp index 0998f86b43..95ee21c014 100644 --- a/src/modules/ekf2/EKF/control.cpp +++ b/src/modules/ekf2/EKF/control.cpp @@ -58,6 +58,7 @@ void Ekf::controlFusionModes(const imuSample &imu_delayed) set_in_air_status(system_flags_delayed.in_air); set_is_fixed_wing(system_flags_delayed.is_fixed_wing); + set_in_transition_to_fw(system_flags_delayed.in_transition_to_fw); if (system_flags_delayed.gnd_effect) { set_gnd_effect(); diff --git a/src/modules/ekf2/EKF/estimator_interface.cpp b/src/modules/ekf2/EKF/estimator_interface.cpp index 5c30c72afc..64ee74f1d4 100644 --- a/src/modules/ekf2/EKF/estimator_interface.cpp +++ b/src/modules/ekf2/EKF/estimator_interface.cpp @@ -159,7 +159,7 @@ void EstimatorInterface::setMagData(const magSample &mag_sample) #endif // CONFIG_EKF2_MAGNETOMETER #if defined(CONFIG_EKF2_GNSS) -void EstimatorInterface::setGpsData(const gnssSample &gnss_sample) +void EstimatorInterface::setGpsData(const gnssSample &gnss_sample, const bool pps_compensation) { if (!_initialised) { return; @@ -177,8 +177,10 @@ void EstimatorInterface::setGpsData(const gnssSample &gnss_sample) } } + const int64_t delay = pps_compensation ? 0 : static_cast(_params.ekf2_gps_delay * 1000); + const int64_t time_us = gnss_sample.time_us - - static_cast(_params.ekf2_gps_delay * 1000) + - delay - static_cast(_dt_ekf_avg * 5e5f); // seconds to microseconds divided by 2 if (time_us >= static_cast(_gps_buffer->get_newest().time_us + _min_obs_interval_us)) { diff --git a/src/modules/ekf2/EKF/estimator_interface.h b/src/modules/ekf2/EKF/estimator_interface.h index 64d3e4ffc3..0c3f9bf7be 100644 --- a/src/modules/ekf2/EKF/estimator_interface.h +++ b/src/modules/ekf2/EKF/estimator_interface.h @@ -89,7 +89,7 @@ public: void setIMUData(const imuSample &imu_sample); #if defined(CONFIG_EKF2_GNSS) - void setGpsData(const gnssSample &gnss_sample); + void setGpsData(const gnssSample &gnss_sample, const bool pps_compensation = false); const gnssSample &get_gps_sample_delayed() const { return _gps_sample_delayed; } @@ -200,6 +200,8 @@ public: // set vehicle is fixed wing status void set_is_fixed_wing(bool is_fixed_wing) { _control_status.flags.fixed_wing = is_fixed_wing; } + void set_in_transition_to_fw(bool in_transition) { _control_status.flags.in_transition_to_fw = in_transition; } + // set flag if static pressure rise due to ground effect is expected // use _params.ekf2_gnd_eff_dz to adjust for expected rise in static pressure // flag will clear after GNDEFFECT_TIMEOUT uSec diff --git a/src/modules/ekf2/EKF2.cpp b/src/modules/ekf2/EKF2.cpp index f93f59085f..c82c447686 100644 --- a/src/modules/ekf2/EKF2.cpp +++ b/src/modules/ekf2/EKF2.cpp @@ -2452,8 +2452,12 @@ void EKF2::UpdateGpsSample(ekf2_timestamps_s &ekf2_timestamps) const float altitude_amsl = static_cast(vehicle_gps_position.altitude_msl_m); const float altitude_ellipsoid = static_cast(vehicle_gps_position.altitude_ellipsoid_m); + // if pps_compensation is active but not valid, the timestamp_sample will be equal to timestamp + const bool pps_compensation = vehicle_gps_position.timestamp_sample > 0 + && vehicle_gps_position.timestamp_sample != vehicle_gps_position.timestamp; + gnssSample gnss_sample{ - .time_us = vehicle_gps_position.timestamp, + .time_us = pps_compensation ? vehicle_gps_position.timestamp_sample : vehicle_gps_position.timestamp, .lat = vehicle_gps_position.latitude_deg, .lon = vehicle_gps_position.longitude_deg, .alt = altitude_amsl, @@ -2471,7 +2475,7 @@ void EKF2::UpdateGpsSample(ekf2_timestamps_s &ekf2_timestamps) .spoofed = vehicle_gps_position.spoofing_state == sensor_gps_s::SPOOFING_STATE_DETECTED, }; - _ekf.setGpsData(gnss_sample); + _ekf.setGpsData(gnss_sample, pps_compensation); const float geoid_height = altitude_ellipsoid - altitude_amsl; @@ -2618,6 +2622,7 @@ void EKF2::UpdateSystemFlagsSample(ekf2_timestamps_s &ekf2_timestamps) // let the EKF know if the vehicle motion is that of a fixed wing (forward flight only relative to wind) flags.is_fixed_wing = (vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING); + flags.in_transition_to_fw = vehicle_status.in_transition_to_fw; #if defined(CONFIG_EKF2_SIDESLIP) diff --git a/src/modules/ekf2/params_gnss.yaml b/src/modules/ekf2/params_gnss.yaml index bcc186e0ba..319846316d 100644 --- a/src/modules/ekf2/params_gnss.yaml +++ b/src/modules/ekf2/params_gnss.yaml @@ -20,8 +20,8 @@ parameters: EKF2_GPS_MODE: description: short: Fusion reset mode - long: 'Automatic: reset on fusion timeout if no other source of position is available - Dead-reckoning: reset on fusion timeout if no source of velocity is available' + long: 'Automatic: reset on fusion timeout if no other source of position is available. + Dead-reckoning: reset on fusion timeout if no source of velocity is available.' type: enum values: 0: Automatic @@ -29,7 +29,9 @@ parameters: default: 0 EKF2_GPS_DELAY: description: - short: GPS measurement delay relative to IMU measurements + short: GPS measurement delay relative to IMU measurement + long: GPS measurement delay relative to IMU measurement if PPS time correction + is not available/enabled (PPS_CAP_ENABLE). type: float default: 110 min: 0 diff --git a/src/modules/flight_mode_manager/tasks/Auto/FlightTaskAuto.cpp b/src/modules/flight_mode_manager/tasks/Auto/FlightTaskAuto.cpp index 3a77075f11..e2ebb11bd0 100644 --- a/src/modules/flight_mode_manager/tasks/Auto/FlightTaskAuto.cpp +++ b/src/modules/flight_mode_manager/tasks/Auto/FlightTaskAuto.cpp @@ -44,15 +44,12 @@ bool FlightTaskAuto::activate(const trajectory_setpoint_s &last_setpoint) { bool ret = FlightTask::activate(last_setpoint); + // Set setpoints equal current state. _position_setpoint = _position; _velocity_setpoint = _velocity; _yaw_setpoint = _yaw; _yawspeed_setpoint = 0.0f; - // Set setpoints equal current state. - _velocity_setpoint = _velocity; - _position_setpoint = _position; - Vector3f vel_prev{last_setpoint.velocity}; Vector3f pos_prev{last_setpoint.position}; Vector3f accel_prev{last_setpoint.acceleration}; diff --git a/src/modules/flight_mode_manager/tasks/Transition/FlightTaskTransition.cpp b/src/modules/flight_mode_manager/tasks/Transition/FlightTaskTransition.cpp index 727d7cd529..8192bfdd3d 100644 --- a/src/modules/flight_mode_manager/tasks/Transition/FlightTaskTransition.cpp +++ b/src/modules/flight_mode_manager/tasks/Transition/FlightTaskTransition.cpp @@ -57,6 +57,9 @@ bool FlightTaskTransition::activate(const trajectory_setpoint_s &last_setpoint) _vel_z_filter.reset(_velocity(2)); } + const Vector2f acceleration_xy{_sub_vehicle_local_position.get().ax, _sub_vehicle_local_position.get().ay}; + _accel_filter.reset(acceleration_xy); + if (_sub_vehicle_status.get().in_transition_to_fw) { _gear.landing_gear = landing_gear_s::GEAR_UP; @@ -86,21 +89,27 @@ bool FlightTaskTransition::update() // calculate a horizontal acceleration vector which corresponds to an attitude composed of pitch up by _param_fw_psp_off // and zero roll angle - float pitch_setpoint = math::radians(_param_fw_psp_off); + float tilt_setpoint = math::radians(_param_fw_psp_off); + Vector2f horizontal_acceleration_direction; if (!_sub_vehicle_status.get().in_transition_to_fw) { - pitch_setpoint = computeBackTranstionPitchSetpoint(); + tilt_setpoint = computeBackTransitionTiltSetpoint(); + const Vector2f velocity_xy{_velocity}; + horizontal_acceleration_direction = -velocity_xy.unit_or_zero(); + + } else { + // Forward transition: use heading direction + horizontal_acceleration_direction = Dcm2f(_yaw) * Vector2f(-1.0f, 0.0f); } - // Calculate horizontal acceleration components to follow a pitch setpoint with the current vehicle heading - const Vector2f horizontal_acceleration_direction = Dcm2f(_yaw) * Vector2f(-1.0f, 0.0f); - _acceleration_setpoint.xy() = tanf(pitch_setpoint) * CONSTANTS_ONE_G * horizontal_acceleration_direction; + _acceleration_setpoint.xy() = tanf(tilt_setpoint) * CONSTANTS_ONE_G * horizontal_acceleration_direction; _yaw_setpoint = NAN; + _yawspeed_setpoint = 0.f; return ret; } -float FlightTaskTransition::computeBackTranstionPitchSetpoint() +float FlightTaskTransition::computeBackTransitionTiltSetpoint() { const Vector2f position_xy{_position}; const Vector2f velocity_xy{_velocity}; @@ -109,8 +118,11 @@ float FlightTaskTransition::computeBackTranstionPitchSetpoint() float deceleration_setpoint = _param_vt_b_dec_mss; - if (_sub_position_sp_triplet.get().current.valid && _sub_vehicle_local_position.get().xy_global - && position_xy.isAllFinite() && velocity_xy.isAllFinite()) { + const float max_hor_pos_uncertainty_limit = 10.f; + + if (_sub_vehicle_local_position.get().eph < max_hor_pos_uncertainty_limit + && _sub_position_sp_triplet.get().current.valid + && _sub_vehicle_local_position.get().xy_global && position_xy.isAllFinite() && velocity_xy.isAllFinite()) { Vector2f position_setpoint_local; _geo_projection.project(_sub_position_sp_triplet.get().current.lat, _sub_position_sp_triplet.get().current.lon, position_setpoint_local(0), position_setpoint_local(1)); @@ -129,13 +141,13 @@ float FlightTaskTransition::computeBackTranstionPitchSetpoint() deceleration_setpoint = math::min(deceleration_setpoint, 2.f * _param_vt_b_dec_mss); } - // Pitch up to reach a negative accel_in_flight_direction otherwise we decelerate too slow - const Vector2f acceleration_xy{_sub_vehicle_local_position.get().ax, _sub_vehicle_local_position.get().ay}; + const Vector2f acceleration_xy_raw{_sub_vehicle_local_position.get().ax, _sub_vehicle_local_position.get().ay}; + const Vector2f acceleration_xy = _accel_filter.update(acceleration_xy_raw, _deltatime); const float deceleration = -acceleration_xy.dot(velocity_xy_direction); // Zero when velocity invalid const float deceleration_error = deceleration_setpoint - deceleration; // Update back-transition deceleration error integrator _decel_error_bt_int += (_param_vt_b_dec_i * deceleration_error) * _deltatime; - _decel_error_bt_int = math::constrain(_decel_error_bt_int, 0.f, DECELERATION_INTEGRATOR_LIMIT); + _decel_error_bt_int = math::constrain(_decel_error_bt_int, 0.f, kDecelerationIntegratorLimit); return _decel_error_bt_int; } diff --git a/src/modules/flight_mode_manager/tasks/Transition/FlightTaskTransition.hpp b/src/modules/flight_mode_manager/tasks/Transition/FlightTaskTransition.hpp index 12687223b5..a226ee9f6b 100644 --- a/src/modules/flight_mode_manager/tasks/Transition/FlightTaskTransition.hpp +++ b/src/modules/flight_mode_manager/tasks/Transition/FlightTaskTransition.hpp @@ -61,8 +61,9 @@ public: bool update() override; private: - static constexpr float VERTICAL_VELOCITY_TIME_CONSTANT = 2.0f; - static constexpr float DECELERATION_INTEGRATOR_LIMIT = .3f; + static constexpr float kVerticalVelocityTimeConstant = 2.0f; + static constexpr float kDecelerationIntegratorLimit = 0.3f; + static constexpr float kAccelerationFilterTimeConstant = 0.05f; uORB::SubscriptionData _sub_vehicle_status{ORB_ID(vehicle_status)}; uORB::SubscriptionData _sub_position_sp_triplet{ORB_ID(position_setpoint_triplet)}; @@ -71,8 +72,9 @@ private: float _param_vt_b_dec_i{0.f}; float _param_vt_b_dec_mss{0.f}; - AlphaFilter _vel_z_filter{VERTICAL_VELOCITY_TIME_CONSTANT}; + AlphaFilter _vel_z_filter{kVerticalVelocityTimeConstant}; + AlphaFilter _accel_filter{kAccelerationFilterTimeConstant}; float _decel_error_bt_int{0.f}; ///< Backtransition deceleration error integrator value - float computeBackTranstionPitchSetpoint(); + float computeBackTransitionTiltSetpoint(); }; diff --git a/src/modules/fw_att_control/FixedwingAttitudeControl.cpp b/src/modules/fw_att_control/FixedwingAttitudeControl.cpp index f658eb56c2..ec856e942d 100644 --- a/src/modules/fw_att_control/FixedwingAttitudeControl.cpp +++ b/src/modules/fw_att_control/FixedwingAttitudeControl.cpp @@ -48,6 +48,7 @@ FixedwingAttitudeControl::FixedwingAttitudeControl(bool vtol) : /* fetch initial parameter values */ parameters_update(); _landing_gear_wheel_pub.advertise(); + _attitude_sp_pub.advertise(); } FixedwingAttitudeControl::~FixedwingAttitudeControl() diff --git a/src/modules/fw_att_control/fw_pitch_controller.h b/src/modules/fw_att_control/fw_pitch_controller.h index a71168f190..d8a40ab636 100644 --- a/src/modules/fw_att_control/fw_pitch_controller.h +++ b/src/modules/fw_att_control/fw_pitch_controller.h @@ -64,11 +64,11 @@ public: float get_body_rate_setpoint() { return _body_rate_setpoint; } private: - float _tc; - float _max_rate_pos; - float _max_rate_neg; - float _euler_rate_setpoint; - float _body_rate_setpoint; + float _tc{}; + float _max_rate_pos{}; + float _max_rate_neg{}; + float _euler_rate_setpoint{}; + float _body_rate_setpoint{}; }; #endif // FW_PITCH_CONTROLLER_H diff --git a/src/modules/fw_att_control/fw_roll_controller.h b/src/modules/fw_att_control/fw_roll_controller.h index a14277e3f0..5e47f0ffd0 100644 --- a/src/modules/fw_att_control/fw_roll_controller.h +++ b/src/modules/fw_att_control/fw_roll_controller.h @@ -63,10 +63,10 @@ public: float get_body_rate_setpoint() { return _body_rate_setpoint; } private: - float _tc; - float _max_rate; - float _euler_rate_setpoint; - float _body_rate_setpoint; + float _tc{}; + float _max_rate{}; + float _euler_rate_setpoint{}; + float _body_rate_setpoint{}; }; #endif // FW_ROLL_CONTROLLER_H diff --git a/src/modules/fw_att_control/fw_yaw_controller.h b/src/modules/fw_att_control/fw_yaw_controller.h index 7e97618a26..e6f9ff9795 100644 --- a/src/modules/fw_att_control/fw_yaw_controller.h +++ b/src/modules/fw_att_control/fw_yaw_controller.h @@ -71,9 +71,9 @@ public: float get_body_rate_setpoint() { return _body_rate_setpoint; } private: - float _max_rate; - float _euler_rate_setpoint; - float _body_rate_setpoint; + float _max_rate{}; + float _euler_rate_setpoint{}; + float _body_rate_setpoint{}; }; #endif // FW_YAW_CONTROLLER_H diff --git a/src/modules/fw_autotune_attitude_control/fw_autotune_attitude_control.cpp b/src/modules/fw_autotune_attitude_control/fw_autotune_attitude_control.cpp index 48633f3e73..cc34f92bf5 100644 --- a/src/modules/fw_autotune_attitude_control/fw_autotune_attitude_control.cpp +++ b/src/modules/fw_autotune_attitude_control/fw_autotune_attitude_control.cpp @@ -562,6 +562,8 @@ void FwAutotuneAttitudeControl::updateStateMachine(hrt_abstime now) mavlink_log_critical(&mavlink_log_pub, "Autotune aborted before finishing"); _state = state::fail; + _state_start_time = now; + } else if (timeout) { // Skip to next axis mavlink_log_critical(&mavlink_log_pub, "Autotune axis timeout, skipping to next axis"); @@ -586,9 +588,11 @@ void FwAutotuneAttitudeControl::updateStateMachine(hrt_abstime now) _state = state::fail; // safety fallback break; } + + _state_start_time = now; } - _state_start_time = now; + } } diff --git a/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp b/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp index 9c5647f1a5..53005d8ba5 100644 --- a/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp +++ b/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp @@ -70,6 +70,7 @@ FwLateralLongitudinalControl::FwLateralLongitudinalControl(bool is_vtol) : _attitude_sp_pub(is_vtol ? ORB_ID(fw_virtual_attitude_setpoint) : ORB_ID(vehicle_attitude_setpoint)), _loop_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")) { + _attitude_sp_pub.advertise(); _tecs_status_pub.advertise(); _flight_phase_estimation_pub.advertise(); _fixed_wing_lateral_status_pub.advertise(); diff --git a/src/modules/fw_rate_control/FixedwingRateControl.cpp b/src/modules/fw_rate_control/FixedwingRateControl.cpp index 8bbd44c98c..3ae3272cfa 100644 --- a/src/modules/fw_rate_control/FixedwingRateControl.cpp +++ b/src/modules/fw_rate_control/FixedwingRateControl.cpp @@ -150,7 +150,7 @@ FixedwingRateControl::vehicle_land_detected_poll() } } -float FixedwingRateControl::get_airspeed_and_update_scaling() +float FixedwingRateControl::get_airspeed_and_update_scaling(float dt) { _airspeed_validated_sub.update(); const bool airspeed_valid = PX4_ISFINITE(_airspeed_validated_sub.get().calibrated_airspeed_m_s) @@ -163,6 +163,13 @@ float FixedwingRateControl::get_airspeed_and_update_scaling() /* prevent numerical drama by requiring 0.5 m/s minimal speed */ airspeed = math::max(0.5f, _airspeed_validated_sub.get().calibrated_airspeed_m_s); + if (dt > 1.f) { + _airspeed_filter_for_torque_scaling.reset(airspeed); + + } else { + airspeed = _airspeed_filter_for_torque_scaling.update(airspeed, dt); + } + } else { // VTOL: if we have no airspeed available and we are in hover mode then assume the lowest airspeed possible // this assumption is good as long as the vehicle is not hovering in a headwind which is much larger @@ -274,7 +281,7 @@ void FixedwingRateControl::Run() if (_vcontrol_mode.flag_control_rates_enabled) { - const float airspeed = get_airspeed_and_update_scaling(); + const float airspeed = get_airspeed_and_update_scaling(dt); /* reset integrals where needed */ if (_rates_sp.reset_integral) { @@ -284,6 +291,7 @@ void FixedwingRateControl::Run() // Reset integrators if the aircraft is on ground or not in a state where the fw attitude controller is run if (_landed || !_in_fw_or_transition_wo_tailsitter_transition) { + _gain_compression.reset(); _rate_control.resetIntegral(); } @@ -363,10 +371,11 @@ void FixedwingRateControl::Run() _rate_control.setFeedForwardGain(scaled_gain_ff); // Run attitude RATE controllers which need the desired attitudes from above, add trim. - const Vector3f angular_acceleration_setpoint = _rate_control.update(rates, body_rates_setpoint, angular_accel, dt, - _landed); + const Vector3f angular_acceleration_setpoint = _rate_control.update(rates, body_rates_setpoint, angular_accel, dt, _landed); - Vector3f control_u = angular_acceleration_setpoint * _airspeed_scaling * _airspeed_scaling; + Vector3f control_u = _gain_compression.getGains().emult(angular_acceleration_setpoint * _airspeed_scaling * _airspeed_scaling); + + _gain_compression.update(control_u, dt); // Special case yaw in Acro: if the parameter FW_ACRO_YAW_EN is not set then don't rate-control yaw if (!_vcontrol_mode.flag_control_attitude_enabled && _vcontrol_mode.flag_control_manual_enabled @@ -410,6 +419,7 @@ void FixedwingRateControl::Run() } else { // full manual + _gain_compression.reset(); _rate_control.resetIntegral(); } diff --git a/src/modules/fw_rate_control/FixedwingRateControl.hpp b/src/modules/fw_rate_control/FixedwingRateControl.hpp index 2d87e86d8a..54cf23be00 100644 --- a/src/modules/fw_rate_control/FixedwingRateControl.hpp +++ b/src/modules/fw_rate_control/FixedwingRateControl.hpp @@ -34,9 +34,11 @@ #pragma once #include +#include #include #include +#include #include #include #include @@ -132,6 +134,9 @@ private: hrt_abstime _last_run{0}; + static constexpr float _kAirspeedFilterTimeConstant{1.f}; + AlphaFilter _airspeed_filter_for_torque_scaling{_kAirspeedFilterTimeConstant}; + float _airspeed_scaling{1.0f}; bool _landed{true}; @@ -208,6 +213,7 @@ private: ) RateControl _rate_control; ///< class for rate control calculations + GainCompression3d _gain_compression{this}; void updateActuatorControlsStatus(float dt); @@ -219,5 +225,5 @@ private: void vehicle_manual_poll(); void vehicle_land_detected_poll(); - float get_airspeed_and_update_scaling(); + float get_airspeed_and_update_scaling(float dt); }; diff --git a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp index 33ab49eb32..0320870e08 100644 --- a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp +++ b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.cpp @@ -108,36 +108,45 @@ void InternalCombustionEngineControl::Run() const hrt_abstime now = hrt_absolute_time(); - UserOnOffRequest user_request = UserOnOffRequest::Off; - switch (static_cast(_param_ice_on_source.get())) { case ICESource::ArmingState: { - if (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED) { - user_request = UserOnOffRequest::On; - } + _user_request = vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED ? UserOnOffRequest::On : + UserOnOffRequest::Off; } break; case ICESource::Aux1: { if (manual_control_setpoint.aux1 > 0.5f) { - user_request = UserOnOffRequest::On; + _user_request = UserOnOffRequest::On; + + } else if (manual_control_setpoint.aux1 < -0.5f) { + _user_request = UserOnOffRequest::Off; } } break; case ICESource::Aux2: { if (manual_control_setpoint.aux2 > 0.5f) { - user_request = UserOnOffRequest::On; + _user_request = UserOnOffRequest::On; + + } else if (manual_control_setpoint.aux2 < -0.5f) { + _user_request = UserOnOffRequest::Off; } } break; + + case ICESource::VtolStatus: { + _user_request = (vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING + || vehicle_status.in_transition_to_fw) ? UserOnOffRequest::On : UserOnOffRequest::Off; + } + break; } switch (_state) { case State::Stopped: { controlEngineStop(); - if (user_request == UserOnOffRequest::On && !maximumAttemptsReached()) { + if (_user_request == UserOnOffRequest::On && !maximumAttemptsReached()) { _state = State::Starting; _state_start_time = now; @@ -148,7 +157,7 @@ void InternalCombustionEngineControl::Run() case State::Starting: { - if (user_request == UserOnOffRequest::Off) { + if (_user_request == UserOnOffRequest::Off) { _state = State::Stopped; _starting_retry_cycle = 0; PX4_INFO("ICE: Stopped"); @@ -196,7 +205,7 @@ void InternalCombustionEngineControl::Run() case State::Running: { controlEngineRunning(throttle_in); - if (user_request == UserOnOffRequest::Off) { + if (_user_request == UserOnOffRequest::Off) { _state = State::Stopped; _starting_retry_cycle = 0; PX4_INFO("ICE: Stopped"); @@ -217,7 +226,7 @@ void InternalCombustionEngineControl::Run() case State::Fault: { - if (user_request == UserOnOffRequest::Off) { + if (_user_request == UserOnOffRequest::Off) { _state = State::Stopped; _starting_retry_cycle = 0; PX4_INFO("ICE: Stopped"); @@ -243,10 +252,10 @@ void InternalCombustionEngineControl::Run() _throttle_control_slew_rate.setForcedValue(0.f); } - publishControl(now, user_request); + publishControl(now); } -void InternalCombustionEngineControl::publishControl(const hrt_abstime now, const UserOnOffRequest user_request) +void InternalCombustionEngineControl::publishControl(const hrt_abstime now) { internal_combustion_engine_control_s ice_control{}; ice_control.timestamp = now; @@ -254,7 +263,7 @@ void InternalCombustionEngineControl::publishControl(const hrt_abstime now, cons ice_control.ignition_on = _ignition_on; ice_control.starter_engine_control = _starter_engine_control; ice_control.throttle_control = _throttle_control; - ice_control.user_request = static_cast(user_request); + ice_control.user_request = static_cast(_user_request); _internal_combustion_engine_control_pub.publish(ice_control); internal_combustion_engine_status_s ice_status; diff --git a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp index 01884e4967..4b1cfedeb3 100644 --- a/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp +++ b/src/modules/internal_combustion_engine_control/InternalCombustionEngineControl.hpp @@ -102,12 +102,13 @@ private: enum class UserOnOffRequest { Off, On - }; + } _user_request{UserOnOffRequest::Off}; enum class ICESource { ArmingState, Aux1, Aux2, + VtolStatus, }; hrt_abstime _state_start_time{0}; @@ -126,7 +127,7 @@ private: void controlEngineStartup(const hrt_abstime now); void controlEngineFault(); bool maximumAttemptsReached(); - void publishControl(const hrt_abstime now, const UserOnOffRequest user_request); + void publishControl(const hrt_abstime now); // Starting state specifics static constexpr float DELAY_BEFORE_RESTARTING{1.f}; diff --git a/src/modules/internal_combustion_engine_control/module.yaml b/src/modules/internal_combustion_engine_control/module.yaml index e0e9a69c57..4e3ca311cd 100644 --- a/src/modules/internal_combustion_engine_control/module.yaml +++ b/src/modules/internal_combustion_engine_control/module.yaml @@ -19,6 +19,7 @@ parameters: 0: On arming - disarming 1: Aux1 2: Aux2 + 3: On Vtol Transitions ICE_CHOKE_ST_DUR: description: diff --git a/src/modules/logger/logged_topics.cpp b/src/modules/logger/logged_topics.cpp index bdca16eae3..3a9e51704d 100644 --- a/src/modules/logger/logged_topics.cpp +++ b/src/modules/logger/logged_topics.cpp @@ -73,6 +73,7 @@ void LoggedTopics::add_default_topics() add_optional_topic("flaps_setpoint", 1000); add_optional_topic("flight_phase_estimation", 1000); add_optional_topic("fuel_tank_status", 10); + add_optional_topic("gain_compression", 100); add_topic("gimbal_manager_set_attitude", 500); add_optional_topic("generator_status"); add_optional_topic("gps_dump"); @@ -123,6 +124,7 @@ void LoggedTopics::add_default_topics() add_optional_topic("sensor_gyro_fft", 50); add_topic("sensor_selection"); add_topic("sensors_status_imu", 200); + add_optional_topic("sensor_temp", 100); add_optional_topic("spoilers_setpoint", 1000); add_topic("system_power", 500); add_optional_topic("takeoff_status", 1000); diff --git a/src/modules/manual_control/ManualControl.cpp b/src/modules/manual_control/ManualControl.cpp index 517639100c..263cbaa027 100644 --- a/src/modules/manual_control/ManualControl.cpp +++ b/src/modules/manual_control/ManualControl.cpp @@ -309,9 +309,9 @@ void ManualControl::updateParams() { ModuleParams::updateParams(); - _stick_arm_hysteresis.set_hysteresis_time_from(false, _param_com_rc_arm_hyst.get() * 1_ms); - _stick_disarm_hysteresis.set_hysteresis_time_from(false, _param_com_rc_arm_hyst.get() * 1_ms); - _button_arm_hysteresis.set_hysteresis_time_from(false, _param_com_rc_arm_hyst.get() * 1_ms); + _stick_arm_hysteresis.set_hysteresis_time_from(false, 1_s); + _stick_disarm_hysteresis.set_hysteresis_time_from(false, 1_s); + _button_arm_hysteresis.set_hysteresis_time_from(false, 1_s); _stick_kill_hysteresis.set_hysteresis_time_from(false, _param_man_kill_gest_t.get() * 1_s); _selector.setRcInMode(_param_com_rc_in_mode.get()); diff --git a/src/modules/manual_control/ManualControl.hpp b/src/modules/manual_control/ManualControl.hpp index 660a125665..42856bb650 100644 --- a/src/modules/manual_control/ManualControl.hpp +++ b/src/modules/manual_control/ManualControl.hpp @@ -148,7 +148,6 @@ private: (ParamFloat) _param_com_rc_stick_ov, (ParamBool) _param_man_arm_gesture, (ParamFloat) _param_man_kill_gest_t, - (ParamInt) _param_com_rc_arm_hyst, (ParamBool) _param_com_arm_swisbtn, (ParamInt) _param_fltmode_1, (ParamInt) _param_fltmode_2, diff --git a/src/modules/mavlink/mavlink b/src/modules/mavlink/mavlink index b401fe0238..d6a7eeaf43 160000 --- a/src/modules/mavlink/mavlink +++ b/src/modules/mavlink/mavlink @@ -1 +1 @@ -Subproject commit b401fe0238b9647f8ea18d58d9e968b79b347916 +Subproject commit d6a7eeaf43319ce6da19a1973ca40180a4210643 diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 589856c15b..52d4f554e5 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -54,6 +54,7 @@ #include #include +#include #include #include @@ -82,6 +83,8 @@ static pthread_mutex_t mavlink_module_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t mavlink_event_buffer_mutex = PTHREAD_MUTEX_INITIALIZER; +static px4::atomic mavlink_instance_count {0}; + events::EventBuffer *Mavlink::_event_buffer = nullptr; Mavlink *mavlink_module_instances[MAVLINK_COMM_NUM_BUFFERS] {}; @@ -161,6 +164,7 @@ Mavlink::~Mavlink() if (_instance_id >= 0) { mavlink_module_instances[_instance_id] = nullptr; + mavlink_instance_count.fetch_sub(1); } // if this instance was responsible for checking events then select a new mavlink instance @@ -265,6 +269,7 @@ Mavlink::set_instance_id() if (mavlink_module_instances[instance_id] == nullptr) { mavlink_module_instances[instance_id] = this; _instance_id = instance_id; + mavlink_instance_count.fetch_add(1); return true; } } @@ -463,6 +468,11 @@ Mavlink::forward_message(const mavlink_message_t *msg, Mavlink *self) } } + // Avoid locking/iteration when there is no instance to forward to. + if (mavlink_instance_count.load() <= 1) { + return; + } + // If it's a message only for us, we keep it if (target_system_id == self->get_system_id() && target_component_id == self->get_component_id()) { return; @@ -1178,8 +1188,8 @@ Mavlink::configure_stream(const char *stream_name, const float rate) } // if we reach here, the stream list does not contain the stream. - // flash constrained target's don't include all streams, and some are only available for the development dialect -#if defined(CONSTRAINED_FLASH) || !defined(MAVLINK_DEVELOPMENT_H) + // flash constrained target's don't include all streams +#if defined(CONSTRAINED_FLASH) return PX4_OK; #else PX4_WARN("stream %s not found", stream_name); @@ -1409,9 +1419,13 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream) configure_stream_local("GIMBAL_DEVICE_ATTITUDE_STATUS", 1.0f); configure_stream_local("GIMBAL_DEVICE_SET_ATTITUDE", 5.0f); configure_stream_local("GIMBAL_MANAGER_STATUS", 0.5f); +#if defined(MAVLINK_MSG_ID_GLOBAL_POSITION) configure_stream_local("GLOBAL_POSITION", 5.0f); +#endif configure_stream_local("GLOBAL_POSITION_INT", 5.0f); +#if defined(MAVLINK_MSG_ID_GNSS_INTEGRITY) configure_stream_local("GNSS_INTEGRITY", 1.0f); +#endif configure_stream_local("GPS2_RAW", 1.0f); configure_stream_local("GPS_GLOBAL_ORIGIN", 1.0f); configure_stream_local("GPS_RAW_INT", 5.0f); @@ -1484,7 +1498,9 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream) configure_stream_local("GIMBAL_DEVICE_SET_ATTITUDE", 5.0f); configure_stream_local("GIMBAL_MANAGER_STATUS", 0.5f); configure_stream_local("GLOBAL_POSITION_INT", 50.0f); +#if defined(MAVLINK_MSG_ID_GNSS_INTEGRITY) configure_stream_local("GNSS_INTEGRITY", 1.0f); +#endif configure_stream_local("GPS2_RAW", unlimited_rate); configure_stream_local("GPS_GLOBAL_ORIGIN", 1.0f); configure_stream_local("GPS_RAW_INT", unlimited_rate); @@ -1645,7 +1661,9 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream) configure_stream_local("ESTIMATOR_STATUS", 5.0f); configure_stream_local("EXTENDED_SYS_STATE", 2.0f); configure_stream_local("GLOBAL_POSITION_INT", 10.0f); +#if defined(MAVLINK_MSG_ID_GNSS_INTEGRITY) configure_stream_local("GNSS_INTEGRITY", 1.0f); +#endif configure_stream_local("GPS2_RAW", unlimited_rate); configure_stream_local("GPS_GLOBAL_ORIGIN", 1.0f); configure_stream_local("GPS_RAW_INT", unlimited_rate); @@ -1744,10 +1762,14 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream) configure_stream_local("CURRENT_MODE", 0.5f); configure_stream_local("ESTIMATOR_STATUS", 1.0f); configure_stream_local("EXTENDED_SYS_STATE", 1.0f); +#if defined(MAVLINK_MSG_ID_GLOBAL_POSITION) configure_stream_local("GLOBAL_POSITION", 10.0f); +#endif configure_stream_local("GLOBAL_POSITION_INT", 10.0f); configure_stream_local("GPS_GLOBAL_ORIGIN", 1.0f); +#if defined(MAVLINK_MSG_ID_GNSS_INTEGRITY) configure_stream_local("GNSS_INTEGRITY", 1.0f); +#endif configure_stream_local("GPS2_RAW", unlimited_rate); configure_stream_local("GPS_RAW_INT", unlimited_rate); configure_stream_local("HOME_POSITION", 0.5f); @@ -1797,9 +1819,8 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream) configure_stream_local("GIMBAL_DEVICE_ATTITUDE_STATUS", 1.0f); configure_stream_local("GIMBAL_MANAGER_STATUS", 0.5f); configure_stream_local("GIMBAL_DEVICE_SET_ATTITUDE", 2.0f); - configure_stream_local("ESC_INFO", 0.2f); - configure_stream_local("ESC_STATUS", 0.5f); - + configure_stream_local("ESC_INFO", 1.0f); + configure_stream_local("ESC_STATUS", 2.0f); configure_stream_local("ADSB_VEHICLE", 1.0f); configure_stream_local("ATTITUDE_TARGET", 0.5f); configure_stream_local("AVAILABLE_MODES", 0.3f); @@ -1809,7 +1830,9 @@ Mavlink::configure_streams_to_default(const char *configure_single_stream) configure_stream_local("ESTIMATOR_STATUS", 1.0f); configure_stream_local("EXTENDED_SYS_STATE", 0.5f); configure_stream_local("GLOBAL_POSITION_INT", 2.0f); +#if defined(MAVLINK_MSG_ID_GLOBAL_POSITION) configure_stream_local("GLOBAL_POSITION", 2.0f); +#endif configure_stream_local("GPS_GLOBAL_ORIGIN", 1.0f); configure_stream_local("GPS2_RAW", 2.0f); configure_stream_local("GPS_RAW_INT", 2.0f); diff --git a/src/modules/mavlink/mavlink_timesync.cpp b/src/modules/mavlink/mavlink_timesync.cpp index c9df0a4126..18746283dc 100644 --- a/src/modules/mavlink/mavlink_timesync.cpp +++ b/src/modules/mavlink/mavlink_timesync.cpp @@ -65,6 +65,8 @@ MavlinkTimesync::handle_message(const mavlink_message_t *msg) rsync.tc1 = now * 1000ULL; rsync.ts1 = tsync.ts1; + rsync.target_component = msg->compid; + rsync.target_system = msg->sysid; mavlink_msg_timesync_send_struct(_mavlink.get_channel(), &rsync); diff --git a/src/modules/mavlink/streams/AVAILABLE_MODES.hpp b/src/modules/mavlink/streams/AVAILABLE_MODES.hpp index c0d7730188..27e5852129 100644 --- a/src/modules/mavlink/streams/AVAILABLE_MODES.hpp +++ b/src/modules/mavlink/streams/AVAILABLE_MODES.hpp @@ -38,6 +38,7 @@ #include #include #include +#include class MavlinkStreamAvailableModes : public MavlinkStream { @@ -71,6 +72,8 @@ private: char name[sizeof(register_ext_component_reply_s::name)] {}; }; ExternalModeName *_external_mode_names{nullptr}; + uint8_t _not_user_selectable_mask{0}; + static_assert(MAX_NUM_EXTERNAL_MODES <= (sizeof(_not_user_selectable_mask) * CHAR_BIT), "Mask too small"); uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)}; uORB::Subscription _register_ext_component_reply_sub{ORB_ID(register_ext_component_reply)}; @@ -116,6 +119,10 @@ private: } else if (_external_mode_names) { strncpy(available_modes.mode_name, _external_mode_names[external_mode_index].name, sizeof(available_modes.mode_name)); available_modes.mode_name[sizeof(available_modes.mode_name) - 1] = '\0'; + + if ((_not_user_selectable_mask & (1 << external_mode_index)) > 0) { + available_modes.properties |= MAV_MODE_PROPERTY_NOT_USER_SELECTABLE; + } } } else { // Internal @@ -205,6 +212,13 @@ private: if (_external_mode_names && mode_index < MAX_NUM_EXTERNAL_MODES) { memcpy(_external_mode_names[mode_index].name, reply.name, sizeof(ExternalModeName::name)); + + if (reply.not_user_selectable) { + _not_user_selectable_mask |= (1 << mode_index); + + } else { + _not_user_selectable_mask &= ~(1 << mode_index); + } } dynamic_update = true; diff --git a/src/modules/mavlink/streams/ESC_INFO.hpp b/src/modules/mavlink/streams/ESC_INFO.hpp index 609112ed0a..d4066a2332 100644 --- a/src/modules/mavlink/streams/ESC_INFO.hpp +++ b/src/modules/mavlink/streams/ESC_INFO.hpp @@ -34,7 +34,9 @@ #ifndef ESC_INFO_HPP #define ESC_INFO_HPP +#include #include +#include class MavlinkStreamESCInfo : public MavlinkStream { @@ -49,50 +51,121 @@ public: unsigned get_size() override { - static constexpr unsigned size_per_batch = MAVLINK_MSG_ID_ESC_INFO_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES; - return _esc_status_sub.advertised() ? size_per_batch * _number_of_batches : 0; + static constexpr unsigned message_size = MAVLINK_MSG_ID_ESC_INFO_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES; + return _esc_status_subs.advertised_count() * message_size; } private: explicit MavlinkStreamESCInfo(Mavlink *mavlink) : MavlinkStream(mavlink) {} - uORB::Subscription _esc_status_sub{ORB_ID(esc_status)}; - uint8_t _number_of_batches{0}; + uORB::SubscriptionMultiArray _esc_status_subs{ORB_ID::esc_status}; + + static constexpr uint8_t MAX_ESC_OUTPUTS = 12; // See output_functions.hpp + static constexpr uint8_t ESCS_PER_MSG = MAVLINK_MSG_ESC_INFO_FIELD_TEMPERATURE_LEN; + static constexpr uint8_t MAX_NUM_MSGS = MAX_ESC_OUTPUTS / ESCS_PER_MSG; + + static constexpr hrt_abstime ESC_TIMEOUT = 100000; + + struct EscOutputInterfaceInfo { + uint16_t counter; + uint8_t esc_count; + uint8_t esc_connectiontype; + uint8_t esc_online_flags; + }; + + struct EscInfo { + hrt_abstime timestamp; + uint16_t failure_flags; + uint32_t error_count; + int16_t temperature; + bool online; + }; + + int _total_esc_count = {}; + EscOutputInterfaceInfo _interface[MAX_NUM_MSGS] = {}; + EscInfo _escs[MAX_ESC_OUTPUTS] = {}; + + void update_data() override + { + int subscriber_count = math::min(_esc_status_subs.size(), MAX_NUM_MSGS); + + for (int i = 0; i < subscriber_count; i++) { + esc_status_s esc = {}; + + if (_esc_status_subs[i].update(&esc)) { + _interface[i].counter = esc.counter; + _interface[i].esc_count = esc.esc_count; + _interface[i].esc_connectiontype = esc.esc_connectiontype; + + // Capture online_flags, we will map from index to motor number + uint8_t online_flags = esc.esc_online_flags; + _interface[i].esc_online_flags = 0; + + for (int j = 0; j < esc_status_s::CONNECTED_ESC_MAX; j++) { + bool is_motor = ((int)esc.esc[j].actuator_function >= esc_report_s::ACTUATOR_FUNCTION_MOTOR1) && + ((int)esc.esc[j].actuator_function <= esc_report_s::ACTUATOR_FUNCTION_MOTOR12); + + if (is_motor) { + // Map OutputFunction number to index + int index = (int)esc.esc[j].actuator_function - esc_report_s::ACTUATOR_FUNCTION_MOTOR1; + _escs[index].online = online_flags & (1 << j); + _escs[index].failure_flags = esc.esc[j].failures; + _escs[index].error_count = esc.esc[j].esc_errorcount; + _escs[index].timestamp = esc.esc[j].timestamp; + _escs[index].temperature = esc.esc[j].esc_temperature * 100.f; + } + } + } + } + + int count = 0; + + for (int i = 0; i < MAX_NUM_MSGS; i++) { + count += _interface[i].esc_count; + } + + _total_esc_count = count; + } bool send() override { - static constexpr uint8_t batch_size = MAVLINK_MSG_ESC_INFO_FIELD_TEMPERATURE_LEN; - esc_status_s esc_status; + bool updated = false; - if (_esc_status_sub.update(&esc_status)) { - mavlink_esc_info_t msg{}; + for (int i = 0; i < MAX_NUM_MSGS; i++) { - msg.time_usec = esc_status.timestamp; - msg.counter = esc_status.counter; - msg.count = esc_status.esc_count; - msg.connection_type = esc_status.esc_connectiontype; - msg.info = esc_status.esc_online_flags; + hrt_abstime now = hrt_absolute_time(); - // Ceil value of integer division. For 1-4 esc => 1 batch, 5-8 esc => 2 batches etc - _number_of_batches = ceilf((float)esc_status.esc_count / batch_size); + mavlink_esc_info_t msg = {}; + msg.index = i * ESCS_PER_MSG; + msg.time_usec = now; + msg.counter = _interface[i].counter; + msg.count = _total_esc_count; + msg.connection_type = _interface[i].esc_connectiontype; + msg.info = _interface[i].esc_online_flags; - for (int batch_number = 0; batch_number < _number_of_batches; batch_number++) { - msg.index = batch_number * batch_size; + bool atleast_one_esc_updated = false; - for (int esc_index = 0; esc_index < batch_size ; esc_index++) { - msg.failure_flags[esc_index] = esc_status.esc[esc_index].failures; - msg.error_count[esc_index] = esc_status.esc[esc_index].esc_errorcount; - msg.temperature[esc_index] = static_cast(esc_status.esc[esc_index].esc_temperature * - 100.f); // convert to centiDegrees + for (int j = 0; j < ESCS_PER_MSG; j++) { + + EscInfo &esc = _escs[i * ESCS_PER_MSG + j]; + + msg.info |= (esc.online << j); + + if ((esc.timestamp != 0) && (esc.timestamp + ESC_TIMEOUT) > now) { + msg.failure_flags[j] = esc.failure_flags; + msg.error_count[j] = esc.error_count; + msg.temperature[j] = esc.temperature; + atleast_one_esc_updated = true; } - - mavlink_msg_esc_info_send_struct(_mavlink->get_channel(), &msg); } - return true; + if (atleast_one_esc_updated) { + mavlink_msg_esc_info_send_struct(_mavlink->get_channel(), &msg); + updated = true; + } } - return false; + return updated; } }; diff --git a/src/modules/mavlink/streams/ESC_STATUS.hpp b/src/modules/mavlink/streams/ESC_STATUS.hpp index 54c11cbd8e..925f77ab81 100644 --- a/src/modules/mavlink/streams/ESC_STATUS.hpp +++ b/src/modules/mavlink/streams/ESC_STATUS.hpp @@ -34,7 +34,9 @@ #ifndef ESC_STATUS_HPP #define ESC_STATUS_HPP +#include #include +#include class MavlinkStreamESCStatus : public MavlinkStream { @@ -49,46 +51,88 @@ public: unsigned get_size() override { - static constexpr unsigned size_per_batch = MAVLINK_MSG_ID_ESC_STATUS_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES; - return _esc_status_sub.advertised() ? size_per_batch * _number_of_batches : 0; + static constexpr unsigned message_size = MAVLINK_MSG_ID_ESC_STATUS_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES; + return _esc_status_subs.advertised_count() * message_size; } private: explicit MavlinkStreamESCStatus(Mavlink *mavlink) : MavlinkStream(mavlink) {} - uORB::Subscription _esc_status_sub{ORB_ID(esc_status)}; - uint8_t _number_of_batches{0}; + uORB::SubscriptionMultiArray _esc_status_subs{ORB_ID::esc_status}; + + static constexpr uint8_t MAX_ESC_OUTPUTS = 12; // See output_functions.hpp + static constexpr uint8_t ESCS_PER_MSG = MAVLINK_MSG_ESC_STATUS_FIELD_RPM_LEN; + static constexpr uint8_t MAX_NUM_MSGS = MAX_ESC_OUTPUTS / ESCS_PER_MSG; + static constexpr hrt_abstime ESC_TIMEOUT = 100000; + + struct EscStatus { + hrt_abstime timestamp; + int32_t rpm; + float voltage; + float current; + }; + + EscStatus _escs[MAX_ESC_OUTPUTS] = {}; + + void update_data() override + { + int subscriber_count = math::min(_esc_status_subs.size(), MAX_NUM_MSGS); + + for (int i = 0; i < subscriber_count; i++) { + esc_status_s esc = {}; + + if (_esc_status_subs[i].update(&esc)) { + for (int j = 0; j < esc_status_s::CONNECTED_ESC_MAX; j++) { + + bool is_motor = ((int)esc.esc[j].actuator_function >= esc_report_s::ACTUATOR_FUNCTION_MOTOR1) && + ((int)esc.esc[j].actuator_function <= esc_report_s::ACTUATOR_FUNCTION_MOTOR12); + + if (is_motor) { + // Map OutputFunction number to index + int index = (int)esc.esc[j].actuator_function - esc_report_s::ACTUATOR_FUNCTION_MOTOR1; + _escs[index].timestamp = esc.esc[j].timestamp; + _escs[index].rpm = esc.esc[j].esc_rpm; + _escs[index].voltage = esc.esc[j].esc_voltage; + _escs[index].current = esc.esc[j].esc_current; + } + } + } + } + } bool send() override { - static constexpr uint8_t batch_size = MAVLINK_MSG_ESC_STATUS_FIELD_RPM_LEN; - esc_status_s esc_status; + bool updated = false; - if (_esc_status_sub.update(&esc_status)) { - mavlink_esc_status_t msg{}; + for (int i = 0; i < MAX_NUM_MSGS; i++) { - msg.time_usec = esc_status.timestamp; + hrt_abstime now = hrt_absolute_time(); - // Ceil value of integer division. For 1-4 esc => 1 batch, 5-8 esc => 2 batches etc - _number_of_batches = ceilf((float)esc_status.esc_count / batch_size); + mavlink_esc_status_t msg = {}; + msg.index = i * ESCS_PER_MSG; + msg.time_usec = now; - for (int batch_number = 0; batch_number < _number_of_batches; batch_number++) { - msg.index = batch_number * batch_size; + bool atleast_one_esc_updated = false; - for (int esc_index = 0; esc_index < batch_size - && msg.index + esc_index < esc_status_s::CONNECTED_ESC_MAX; esc_index++) { - msg.rpm[esc_index] = esc_status.esc[msg.index + esc_index].esc_rpm; - msg.voltage[esc_index] = esc_status.esc[msg.index + esc_index].esc_voltage; - msg.current[esc_index] = esc_status.esc[msg.index + esc_index].esc_current; + for (int j = 0; j < ESCS_PER_MSG; j++) { + + EscStatus &esc = _escs[i * ESCS_PER_MSG + j]; + + if ((esc.timestamp != 0) && (esc.timestamp + ESC_TIMEOUT) > now) { + msg.rpm[j] = esc.rpm; + msg.voltage[j] = esc.voltage; + msg.current[j] = esc.current; + atleast_one_esc_updated = true; } - - mavlink_msg_esc_status_send_struct(_mavlink->get_channel(), &msg); } - return true; + if (atleast_one_esc_updated) { + mavlink_msg_esc_status_send_struct(_mavlink->get_channel(), &msg); + updated = true; + } } - return false; + return updated; } }; diff --git a/src/modules/navigator/mission_block.cpp b/src/modules/navigator/mission_block.cpp index 168debf23a..63a51042b1 100644 --- a/src/modules/navigator/mission_block.cpp +++ b/src/modules/navigator/mission_block.cpp @@ -1027,10 +1027,18 @@ void MissionBlock::updateFailsafeChecks() void MissionBlock::updateMaxHaglFailsafe() { const float target_alt = _navigator->get_position_setpoint_triplet()->current.alt; + const float max_alt = math::min(_navigator->get_local_position()->hagl_max_z, _navigator->get_local_position()->hagl_max_xy); + const float terrain_alt = _navigator->get_global_position()->terrain_alt; + const bool terrain_alt_valid = _navigator->get_global_position()->terrain_alt_valid; - if (_navigator->get_global_position()->terrain_alt_valid - && ((target_alt - _navigator->get_global_position()->terrain_alt) - > math::min(_navigator->get_local_position()->hagl_max_z, _navigator->get_local_position()->hagl_max_xy))) { + // If the HAGL failsafe is declared during front transition, we enter a + // FW hold at the current low altitude while not having finished the + // transition. This is dangerous and worse than possibly fusing neither + // optical flow nor airspeed for a couple seconds, so we bypass the + // failsafe here. + const bool in_transition_to_fw = _navigator->get_vstatus()->in_transition_to_fw; + + if (!in_transition_to_fw && terrain_alt_valid && (target_alt - terrain_alt) > max_alt) { // Handle case where the altitude setpoint is above the maximum HAGL (height above ground level) mavlink_log_info(_navigator->get_mavlink_log_pub(), "Target altitude higher than max HAGL\t"); events::send(events::ID("navigator_fail_max_hagl"), events::Log::Error, "Target altitude higher than max HAGL"); diff --git a/src/modules/navigator/navigator_main.cpp b/src/modules/navigator/navigator_main.cpp index 3430bc0162..c7bdd337b5 100644 --- a/src/modules/navigator/navigator_main.cpp +++ b/src/modules/navigator/navigator_main.cpp @@ -652,6 +652,10 @@ void Navigator::run() _vtol_takeoff.setTransitionAltitudeAbsolute(cmd.param7); + if (std::fabs(cmd.param2 - 3.0f) < FLT_EPSILON) { // Specified transition direction + _vtol_takeoff.setTransitionDirection(cmd.param4); + } + // after the transition the vehicle will establish on a loiter at this position _vtol_takeoff.setLoiterLocation(matrix::Vector2d(cmd.param5, cmd.param6)); diff --git a/src/modules/navigator/rtl_direct_mission_land.cpp b/src/modules/navigator/rtl_direct_mission_land.cpp index 7e8b3d4aa4..7fdbe1add5 100644 --- a/src/modules/navigator/rtl_direct_mission_land.cpp +++ b/src/modules/navigator/rtl_direct_mission_land.cpp @@ -122,6 +122,7 @@ void RtlDirectMissionLand::setActiveMissionItems() { WorkItemType new_work_item_type{WorkItemType::WORK_ITEM_TYPE_DEFAULT}; position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet(); + const position_setpoint_s current_setpoint_copy = pos_sp_triplet->current; // Climb to altitude if (_needs_climbing && _work_item_type == WorkItemType::WORK_ITEM_TYPE_DEFAULT) { @@ -203,8 +204,6 @@ void RtlDirectMissionLand::setActiveMissionItems() _mission_item.autocontinue = true; _mission_item.time_inside = 0.0f; - - pos_sp_triplet->previous = pos_sp_triplet->current; } if (num_found_items > 0) { @@ -213,6 +212,12 @@ void RtlDirectMissionLand::setActiveMissionItems() mission_item_to_position_setpoint(_mission_item, &pos_sp_triplet->current); + // Only set the previous position item if the current one really changed + if ((_work_item_type != WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND) && + !position_setpoint_equal(&pos_sp_triplet->current, ¤t_setpoint_copy)) { + pos_sp_triplet->previous = current_setpoint_copy; + } + // prevent lateral guidance from loitering at a waypoint as part of a mission landing if the altitude // is not achieved. const bool fw_on_mission_landing = _vehicle_status_sub.get().vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING diff --git a/src/modules/navigator/rtl_mission_fast.cpp b/src/modules/navigator/rtl_mission_fast.cpp index a8a7809549..bb73fd6952 100644 --- a/src/modules/navigator/rtl_mission_fast.cpp +++ b/src/modules/navigator/rtl_mission_fast.cpp @@ -108,6 +108,7 @@ void RtlMissionFast::setActiveMissionItems() { WorkItemType new_work_item_type{WorkItemType::WORK_ITEM_TYPE_DEFAULT}; position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet(); + const position_setpoint_s current_setpoint_copy = pos_sp_triplet->current; /* Skip VTOL/FW Takeoff item if in air, fixed-wing and didn't start the takeoff already*/ if ((_mission_item.nav_cmd == NAV_CMD_VTOL_TAKEOFF || _mission_item.nav_cmd == NAV_CMD_TAKEOFF) && @@ -175,17 +176,20 @@ void RtlMissionFast::setActiveMissionItems() _mission_item.autocontinue = true; _mission_item.time_inside = 0.0f; - pos_sp_triplet->previous = pos_sp_triplet->current; } - - if (num_found_items > 0) { mission_item_to_position_setpoint(next_mission_items[0u], &pos_sp_triplet->next); } mission_item_to_position_setpoint(_mission_item, &pos_sp_triplet->current); + // Only set the previous position item if the current one really changed + if ((_work_item_type != WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND) && + !position_setpoint_equal(&pos_sp_triplet->current, ¤t_setpoint_copy)) { + pos_sp_triplet->previous = current_setpoint_copy; + } + if (_vehicle_status_sub.get().vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING && isLanding() && _mission_item.nav_cmd == NAV_CMD_WAYPOINT) { pos_sp_triplet->current.alt_acceptance_radius = FLT_MAX; diff --git a/src/modules/navigator/vtol_takeoff.cpp b/src/modules/navigator/vtol_takeoff.cpp index 686886a911..b78f5f6e21 100644 --- a/src/modules/navigator/vtol_takeoff.cpp +++ b/src/modules/navigator/vtol_takeoff.cpp @@ -71,8 +71,15 @@ VtolTakeoff::on_active() position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet(); _mission_item.nav_cmd = NAV_CMD_WAYPOINT; - _mission_item.yaw = wrap_pi(get_bearing_to_next_waypoint(_mission_item.lat, - _mission_item.lon, _loiter_location(0), _loiter_location(1))); + + if (!PX4_ISFINITE(_transition_direction_deg)) { + _mission_item.yaw = wrap_pi(get_bearing_to_next_waypoint(_navigator->get_home_position()->lat, + _navigator->get_home_position()->lon, _loiter_location(0), _loiter_location(1))); + + } else { + _mission_item.yaw = wrap_pi(math::radians(_transition_direction_deg)); + } + _mission_item.force_heading = true; mission_item_to_position_setpoint(_mission_item, &pos_sp_triplet->current); pos_sp_triplet->current.cruising_speed = -1.f; diff --git a/src/modules/navigator/vtol_takeoff.h b/src/modules/navigator/vtol_takeoff.h index 3ba32ce7df..162209893d 100644 --- a/src/modules/navigator/vtol_takeoff.h +++ b/src/modules/navigator/vtol_takeoff.h @@ -55,6 +55,7 @@ public: void on_active() override; void setTransitionAltitudeAbsolute(const float alt_amsl) {_transition_alt_amsl = alt_amsl; } + void setTransitionDirection(const float tran_bear) {_transition_direction_deg = tran_bear; } void setLoiterLocation(matrix::Vector2d loiter_location) { _loiter_location = loiter_location; } void setLoiterHeight(const float height_m) { _loiter_height = height_m; } @@ -73,6 +74,7 @@ private: float _takeoff_alt_msl{0.f}; matrix::Vector2d _loiter_location; float _loiter_height{0}; + float _transition_direction_deg{NAN}; DEFINE_PARAMETERS( (ParamFloat) _param_loiter_alt diff --git a/src/modules/sensors/vehicle_gps_position/CMakeLists.txt b/src/modules/sensors/vehicle_gps_position/CMakeLists.txt index 12b625ead6..c82a636118 100644 --- a/src/modules/sensors/vehicle_gps_position/CMakeLists.txt +++ b/src/modules/sensors/vehicle_gps_position/CMakeLists.txt @@ -36,6 +36,8 @@ px4_add_library(vehicle_gps_position VehicleGPSPosition.hpp gps_blending.cpp gps_blending.hpp + PpsTimeSync.cpp + PpsTimeSync.hpp ) target_link_libraries(vehicle_gps_position PRIVATE diff --git a/src/modules/sensors/vehicle_gps_position/PpsTimeSync.cpp b/src/modules/sensors/vehicle_gps_position/PpsTimeSync.cpp new file mode 100644 index 0000000000..44df911b6f --- /dev/null +++ b/src/modules/sensors/vehicle_gps_position/PpsTimeSync.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** + * + * 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 PpsTimeSync.cpp + * + * PPS-based time synchronization implementation + */ + +#include "PpsTimeSync.hpp" +#include +#include + +void PpsTimeSync::process_pps(const pps_capture_s &pps) +{ + if (pps.timestamp == 0 || pps.rtc_timestamp == 0) { + return; + } + + _pps_hrt_timestamp = pps.timestamp; + _pps_rtc_timestamp = pps.rtc_timestamp; + _time_offset = (int64_t)pps.rtc_timestamp - (int64_t)pps.timestamp; + _initialized = true; + _updated = true; +} + +uint64_t PpsTimeSync::correct_gps_timestamp(uint64_t gps_fc_timestamp, uint64_t gps_utc_timestamp) +{ + if (!is_valid()) { + return gps_fc_timestamp; + } + + const int64_t corrected_fc_timestamp = (int64_t)gps_utc_timestamp - _time_offset; + + if (_updated) { + const int64_t correction_amount = corrected_fc_timestamp - (int64_t)gps_fc_timestamp; + + if (math::abs_t(correction_amount) > kPpsMaxCorrectionUs) { + PX4_DEBUG("PPS: Correction too large: %" PRId64 " us (%.1f ms), rejecting", + correction_amount, (double)correction_amount / 1000.0); + return gps_fc_timestamp; + } + + // Additional sanity check: corrected timestamp should not be too far in the future (0.1s) + const uint64_t now = hrt_absolute_time(); + + if ((uint64_t)corrected_fc_timestamp > now + 100000) { + return gps_fc_timestamp; + } + + _updated = false; + } + + return (uint64_t)corrected_fc_timestamp; +} + +bool PpsTimeSync::is_valid() const +{ + if (!_initialized) { + return false; + } + + uint64_t now = hrt_absolute_time(); + + if (now < _pps_hrt_timestamp) { + now = UINT64_MAX; + } + + return now - _pps_hrt_timestamp < kPpsStaleTimeoutUs; +} diff --git a/src/modules/sensors/vehicle_gps_position/PpsTimeSync.hpp b/src/modules/sensors/vehicle_gps_position/PpsTimeSync.hpp new file mode 100644 index 0000000000..433d13154b --- /dev/null +++ b/src/modules/sensors/vehicle_gps_position/PpsTimeSync.hpp @@ -0,0 +1,67 @@ +/**************************************************************************** + * + * 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 PpsTimeSync.hpp + * + * PPS-based time synchronization for GPS timestamp correction + */ + +#pragma once + +#include +#include +#include + +class PpsTimeSync +{ +public: + PpsTimeSync() = default; + ~PpsTimeSync() = default; + + void process_pps(const pps_capture_s &pps); + uint64_t correct_gps_timestamp(uint64_t gps_fc_timestamp, uint64_t gps_utc_timestamp); + +private: + bool is_valid() const; + + uint64_t _pps_hrt_timestamp{0}; // FC time when PPS pulse arrived (usec since boot) + uint64_t _pps_rtc_timestamp{0}; // GPS UTC time at PPS pulse (usec since Unix epoch) + int64_t _time_offset{0}; + + static constexpr uint64_t kPpsStaleTimeoutUs = 5'000'000; + static constexpr int64_t kPpsMaxCorrectionUs = 300'000; // max delay (max of EKF2_GPS_DELAY) + + bool _initialized{false}; + bool _updated{false}; +}; diff --git a/src/modules/sensors/vehicle_gps_position/VehicleGPSPosition.cpp b/src/modules/sensors/vehicle_gps_position/VehicleGPSPosition.cpp index 964b5fdecc..417001846c 100644 --- a/src/modules/sensors/vehicle_gps_position/VehicleGPSPosition.cpp +++ b/src/modules/sensors/vehicle_gps_position/VehicleGPSPosition.cpp @@ -104,6 +104,12 @@ void VehicleGPSPosition::Run() perf_begin(_cycle_perf); ParametersUpdate(); + pps_capture_s pps_capture; + + if (_pps_capture_sub.update(&pps_capture)) { + _pps_time_sync.process_pps(pps_capture); + } + // Check all GPS instance bool any_gps_updated = false; bool gps_updated = false; @@ -136,6 +142,7 @@ void VehicleGPSPosition::Run() gps_output.device_id = 0; } + gps_output.timestamp_sample = _pps_time_sync.correct_gps_timestamp(gps_output.timestamp, gps_output.time_utc_usec); _vehicle_gps_position_pub.publish(gps_output); } } diff --git a/src/modules/sensors/vehicle_gps_position/VehicleGPSPosition.hpp b/src/modules/sensors/vehicle_gps_position/VehicleGPSPosition.hpp index 971f24ae4a..c2d60e6db3 100644 --- a/src/modules/sensors/vehicle_gps_position/VehicleGPSPosition.hpp +++ b/src/modules/sensors/vehicle_gps_position/VehicleGPSPosition.hpp @@ -45,8 +45,10 @@ #include #include #include +#include #include "gps_blending.hpp" +#include "PpsTimeSync.hpp" using namespace time_literals; @@ -88,9 +90,12 @@ private: {this, ORB_ID(sensor_gps), 1}, }; + uORB::Subscription _pps_capture_sub{ORB_ID(pps_capture)}; + perf_counter_t _cycle_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")}; GpsBlending _gps_blending; + PpsTimeSync _pps_time_sync; DEFINE_PARAMETERS( (ParamInt) _param_sens_gps_mask, diff --git a/src/modules/sensors/vehicle_imu/VehicleIMU.cpp b/src/modules/sensors/vehicle_imu/VehicleIMU.cpp index b8c0a9547e..7ba258a66b 100644 --- a/src/modules/sensors/vehicle_imu/VehicleIMU.cpp +++ b/src/modules/sensors/vehicle_imu/VehicleIMU.cpp @@ -706,8 +706,8 @@ void VehicleIMU::UpdateIntegratorConfiguration() _gyro_integrator.set_reset_interval(roundf((gyro_integral_samples - 0.5f) * gyro_interval_us)); _gyro_integrator.set_reset_samples(gyro_integral_samples); - _backup_schedule_timeout_us = math::constrain((int)math::min(sensor_accel_s::ORB_QUEUE_LENGTH * accel_interval_us, - sensor_gyro_s::ORB_QUEUE_LENGTH * gyro_interval_us) / 2, 1000, 20000); + _backup_schedule_timeout_us = math::constrain((int)math::min((sensor_accel_s::ORB_QUEUE_LENGTH - 1) * accel_interval_us, + (sensor_gyro_s::ORB_QUEUE_LENGTH - 1) * gyro_interval_us), 1000, 20000); // gyro: find largest integer multiple of gyro_integral_samples for (int n = sensor_gyro_s::ORB_QUEUE_LENGTH; n > 0; n--) { @@ -716,6 +716,12 @@ void VehicleIMU::UpdateIntegratorConfiguration() } if (gyro_integral_samples % n == 0) { + // Make sure _backup_schedule_timeout_us is not smaller than normal scheduling interval + + if (_backup_schedule_timeout_us < n * gyro_interval_us) { + _backup_schedule_timeout_us = (n + 1) * gyro_interval_us; + } + _sensor_gyro_sub.set_required_updates(n); _sensor_gyro_sub.registerCallback(); diff --git a/src/modules/simulation/gz_plugins/CMakeLists.txt b/src/modules/simulation/gz_plugins/CMakeLists.txt index 7fc65c8b5b..16bfa6077c 100644 --- a/src/modules/simulation/gz_plugins/CMakeLists.txt +++ b/src/modules/simulation/gz_plugins/CMakeLists.txt @@ -70,11 +70,13 @@ if (gz-transport_FOUND) add_subdirectory(generic_motor) add_subdirectory(buoyancy) add_subdirectory(spacecraft_thruster) + add_subdirectory(motor_failure) + add_subdirectory(airspeed) # Add an alias target for each plugin if (TARGET GstCameraSystem) - add_custom_target(px4_gz_plugins ALL DEPENDS OpticalFlowSystem MovingPlatformController TemplatePlugin GenericMotorModelPlugin BuoyancySystemPlugin GstCameraSystem SpacecraftThrusterModelPlugin) + add_custom_target(px4_gz_plugins ALL DEPENDS OpticalFlowSystem MovingPlatformController TemplatePlugin GenericMotorModelPlugin BuoyancySystemPlugin GstCameraSystem SpacecraftThrusterModelPlugin MotorFailurePlugin AirSpeedPlugin) else() - add_custom_target(px4_gz_plugins ALL DEPENDS OpticalFlowSystem MovingPlatformController TemplatePlugin GenericMotorModelPlugin BuoyancySystemPlugin SpacecraftThrusterModelPlugin) + add_custom_target(px4_gz_plugins ALL DEPENDS OpticalFlowSystem MovingPlatformController TemplatePlugin GenericMotorModelPlugin BuoyancySystemPlugin SpacecraftThrusterModelPlugin MotorFailurePlugin AirSpeedPlugin) endif() endif() diff --git a/src/modules/simulation/gz_plugins/airspeed/AirSpeed.cpp b/src/modules/simulation/gz_plugins/airspeed/AirSpeed.cpp new file mode 100644 index 0000000000..8d0c74dab7 --- /dev/null +++ b/src/modules/simulation/gz_plugins/airspeed/AirSpeed.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +#include "AirSpeed.hpp" + +#include +#include + +using namespace px4; + +// Sign function taken from https://stackoverflow.com/a/4609795/8548472 +template int sign(T val) +{ + return (T(0) < val) - (val < T(0)); +} + +// Register the plugin +GZ_ADD_PLUGIN( + AirSpeed, + gz::sim::System, + AirSpeed::ISystemPreUpdate, + AirSpeed::ISystemConfigure +) + +void AirSpeed::Configure(const gz::sim::Entity &entity, + const std::shared_ptr &sdf, + gz::sim::EntityComponentManager &ecm, + gz::sim::EventManager &eventMgr) +{ + _entity = entity; + _model = gz::sim::Model(entity); + + const std::string link_name = sdf->Get("link_name"); + _link_entity = _model.LinkByName(ecm, link_name); + std::string model_name = _model.Name(ecm); + + if (!_link_entity) { + throw std::runtime_error("Airspeed::Configure: Link \"" + link_name + "\" was not found. " + "Please ensure that your model contains the corresponding link."); + } + + _link = gz::sim::Link(_link_entity); + + // Needed to report linear & angular velocity + _link.EnableVelocityChecks(ecm, true); + + _world_entity = gz::sim::worldEntity(ecm); + _world = gz::sim::World(_world_entity); + std::string world_name = _world.Name(ecm).value_or("default"); + + std::string airspeed_topic = "/world/" + world_name + "/model/" + model_name + + "/link/airspeed_link/sensor/air_speed/air_speed"; + _pub = _node.Advertise(airspeed_topic); + + std::string wind_topic = "/world/" + world_name + "/wind_info"; + + _node.Subscribe(wind_topic, &AirSpeed::windCallback, this); + + ///TODO: Read sdf for altitude home position +} + +void AirSpeed::PreUpdate(const gz::sim::UpdateInfo &_info, + gz::sim::EntityComponentManager &_ecm) +{ + const auto optional_pose = _link.WorldPose(_ecm); + + if (optional_pose.has_value()) { + _vehicle_position = optional_pose.value().Pos(); + _vehicle_attitude = optional_pose.value().Rot(); + + } else { + gzerr << "Unable to get pose" << std::endl; + } + + const auto optional_vel = _link.WorldLinearVelocity(_ecm); + + if (optional_vel.has_value()) { + _vehicle_velocity = optional_vel.value(); + + } else { + gzerr << "Unable to get linear velocity" << std::endl; + } + + // Compute the air density at the local altitude / temperature + const float alt_rel = _vehicle_position.Z(); // Z-component from ENU + const float alt_amsl = (float)_alt_home + alt_rel; + const float temperature_local = TEMPERATURE_MSL - LAPSE_RATE * alt_amsl; + const float density_ratio = powf(TEMPERATURE_MSL / temperature_local, 4.256f); + const float air_density = AIR_DENSITY_MSL / density_ratio; + + // Calculate differential pressure + noise in hPa + const float diff_pressure_noise = standard_normal_distribution_(random_generator_) * diff_pressure_stddev_; + // Body-relateive air velocity + gz::math::Vector3d air_relative_velocity = _vehicle_velocity - _wind_velocity; + gz::math::Vector3d body_velocity = _vehicle_attitude.RotateVectorReverse(air_relative_velocity); + // Calculate differential pressure in hPa + double diff_pressure = sign(body_velocity.X()) * 0.005 * (double)air_density * body_velocity.X() * body_velocity.X() + + (double)diff_pressure_noise; + gz::msgs::AirSpeed airspeed_msg; + airspeed_msg.set_diff_pressure(diff_pressure * 100.0); + _pub.Publish(airspeed_msg); +} + +void AirSpeed::windCallback(const gz::msgs::Wind &msg) +{ + _wind_velocity = gz::math::Vector3d(msg.linear_velocity().x(), msg.linear_velocity().y(), msg.linear_velocity().z()); +} diff --git a/src/modules/simulation/gz_plugins/airspeed/AirSpeed.hpp b/src/modules/simulation/gz_plugins/airspeed/AirSpeed.hpp new file mode 100644 index 0000000000..108ffd47f5 --- /dev/null +++ b/src/modules/simulation/gz_plugins/airspeed/AirSpeed.hpp @@ -0,0 +1,96 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +#pragma once + +#include +#include +#include +#include +#include +#include "gz/sim/components/LinearVelocity.hh" +#include + +#include + +#include + +namespace px4 +{ + +static constexpr float DEFAULT_HOME_ALT_AMSL = 488.0; // altitude AMSL at Irchel Park, Zurich, Switzerland [m] + +// international standard atmosphere (troposphere model - valid up to 11km) see [1] +static constexpr float TEMPERATURE_MSL = 288.15; // temperature at MSL [K] (15 [C]) +static constexpr float PRESSURE_MSL = 101325.0; // pressure at MSL [Pa] +static constexpr float LAPSE_RATE = 0.0065; // reduction in temperature with altitude for troposphere [K/m] +static constexpr float AIR_DENSITY_MSL = 1.225; // air density at MSL [kg/m^3] + +class AirSpeed: + public gz::sim::System, + public gz::sim::ISystemPreUpdate, + public gz::sim::ISystemConfigure +{ +public: + void PreUpdate(const gz::sim::UpdateInfo &_info, + gz::sim::EntityComponentManager &_ecm) final; + + void Configure(const gz::sim::Entity &entity, + const std::shared_ptr &sdf, + gz::sim::EntityComponentManager &ecm, + gz::sim::EventManager &eventMgr) override; + void windCallback(const gz::msgs::Wind &msg); + +private: + gz::sim::Entity _entity; + gz::sim::Model _model{gz::sim::kNullEntity}; + gz::sim::Entity _link_entity; + gz::sim::Link _link; + gz::sim::Entity _world_entity; + gz::sim::World _world; + + gz::transport::Node _node; + gz::transport::Node::Publisher _pub; + + gz::math::Quaterniond _vehicle_attitude; + gz::math::Vector3d _vehicle_velocity{0., 0., 0.}; + gz::math::Vector3d _vehicle_position{0., 0., 0.}; + gz::math::Vector3d _wind_velocity{0., 0., 0.}; + + std::default_random_engine random_generator_; + std::normal_distribution standard_normal_distribution_; + + float diff_pressure_stddev_{0.01f}; // [hPa] + float _alt_home{DEFAULT_HOME_ALT_AMSL}; +}; +} // end namespace px4 diff --git a/src/modules/simulation/gz_plugins/airspeed/CMakeLists.txt b/src/modules/simulation/gz_plugins/airspeed/CMakeLists.txt new file mode 100644 index 0000000000..2afd37c86e --- /dev/null +++ b/src/modules/simulation/gz_plugins/airspeed/CMakeLists.txt @@ -0,0 +1,57 @@ +############################################################################ +# +# 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. +# +############################################################################ + +project(AirSpeedPlugin) + + +add_library(${PROJECT_NAME} SHARED + AirSpeed.cpp +) + +target_link_libraries(${PROJECT_NAME} + PUBLIC px4_gz_msgs + PUBLIC ${GZ_SENSORS_TARGET} + PUBLIC ${GZ_PLUGIN_TARGET} + PUBLIC ${GZ_SIM_TARGET} + PUBLIC ${GZ_TRANSPORT_TARGET} +) + +target_include_directories(${PROJECT_NAME} + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} + PUBLIC ${CMAKE_CURRENT_BINARY_DIR} + PUBLIC px4_gz_msgs +) + +if (NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/px4_gz_plugins) +endif() diff --git a/src/modules/simulation/gz_plugins/motor_failure/CMakeLists.txt b/src/modules/simulation/gz_plugins/motor_failure/CMakeLists.txt new file mode 100644 index 0000000000..23ced01515 --- /dev/null +++ b/src/modules/simulation/gz_plugins/motor_failure/CMakeLists.txt @@ -0,0 +1,52 @@ +############################################################################ +# +# 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. +# +############################################################################ + +project(MotorFailurePlugin) + +add_library(${PROJECT_NAME} SHARED + MotorFailureSystem.cpp +) + +target_link_libraries(${PROJECT_NAME} + PUBLIC px4_gz_msgs + PUBLIC ${GZ_SENSORS_TARGET} + PUBLIC ${GZ_PLUGIN_TARGET} + PUBLIC ${GZ_SIM_TARGET} + PUBLIC ${GZ_TRANSPORT_TARGET} +) + +target_include_directories(${PROJECT_NAME} + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} + PUBLIC ${CMAKE_CURRENT_BINARY_DIR} + PUBLIC px4_gz_msgs +) diff --git a/src/modules/simulation/gz_plugins/motor_failure/MotorFailureSystem.cpp b/src/modules/simulation/gz_plugins/motor_failure/MotorFailureSystem.cpp new file mode 100644 index 0000000000..e6dd2955d7 --- /dev/null +++ b/src/modules/simulation/gz_plugins/motor_failure/MotorFailureSystem.cpp @@ -0,0 +1,221 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +#include "MotorFailureSystem.hpp" + +#include +#include +#include +#include +#include + +using namespace gz; +using namespace sim; +using namespace systems; + +////////////////////////////////////////////////// +void MotorFailureSystem::Configure(const Entity &_entity, + const std::shared_ptr &_sdf, + EntityComponentManager &_ecm, + EventManager &/*_eventMgr*/) +{ + this->_model = Model(_entity); + this->_model_entity = _entity; + + if (!this->_model.Valid(_ecm)) { + gzerr << "[MotorFailureSystem] plugin should be attached to a model " + << "entity. Failed to initialize." << std::endl; + return; + } + + // Get model name to use as namespace + std::string model_name = this->_model.Name(_ecm); + + // Get Gazebo Transport topic name for motor failure number subscription + if (_sdf->HasElement("MotorFailureTopic")) { + this->_gz_topic = _sdf->Get("MotorFailureTopic"); + + } else { + // Use Gazebo model-scoped topic naming convention + this->_gz_topic = "/model/" + model_name + "/motor_failure/motor_number"; + } + + // Subscribe to Gazebo Transport topic + if (!this->_node.Subscribe(this->_gz_topic, &MotorFailureSystem::MotorFailureNumberCallback, this)) { + gzerr << "[MotorFailureSystem] Error subscribing to topic [" << this->_gz_topic << "]" << std::endl; + return; + } + + gzmsg << "[MotorFailureSystem] Subscribed to Gazebo Transport topic: " << this->_gz_topic << std::endl; + gzmsg << "[MotorFailureSystem] Initialized for model: " << model_name << std::endl; +} + +////////////////////////////////////////////////// +void MotorFailureSystem::FindMotorJoints(EntityComponentManager &_ecm) +{ + if (this->_joints_found) { + return; + } + + // Find all joints with "rotor_X_joint" pattern + this->_motor_joints.clear(); + + // Get all joints in the model + auto joints = this->_model.Joints(_ecm); + + // Regular expression to match rotor joints (e.g., "rotor_0_joint", "rotor_1_joint") + std::regex motorPattern("rotor_(\\d+)_joint"); + std::smatch match; + + // Find rotor joints and sort by motor number + std::map motorMap; + + for (const auto &joint : joints) { + auto nameComp = _ecm.Component(joint); + + if (nameComp) { + std::string jointName = nameComp->Data(); + + // Try to match the joint name against the pattern + if (std::regex_match(jointName, match, motorPattern)) { + // Extract motor number from the first capture group + try { + int motorNumber = std::stoi(match[1].str()); + motorMap[motorNumber] = joint; + gzdbg << "[MotorFailureSystem] Found motor " << motorNumber + << ": " << jointName << std::endl; + + } catch (const std::exception &e) { + gzwarn << "[MotorFailureSystem] Failed to parse motor number from: " + << jointName << std::endl; + } + } + } + } + + // Convert map to vector for indexed access + for (const auto &pair : motorMap) { + // Ensure vector is large enough + if (pair.first >= static_cast(this->_motor_joints.size())) { + this->_motor_joints.resize(pair.first + 1, kNullEntity); + } + + this->_motor_joints[pair.first] = pair.second; + } + + if (!this->_motor_joints.empty()) { + gzmsg << "[MotorFailureSystem] Found " << this->_motor_joints.size() + << " motor joints" << std::endl; + this->_joints_found = true; + + } else { + gzwarn << "[MotorFailureSystem] No motor joints found in model" << std::endl; + } +} + +////////////////////////////////////////////////// +void MotorFailureSystem::ApplyMotorFailure(EntityComponentManager &_ecm) +{ + int32_t current_failure; + { + std::lock_guard lock(this->_motor_failure_mutex); + current_failure = this->_motor_failure_number; + } + + // Check if failure status changed + if (current_failure != this->_prev_motor_failure_number) { + if (current_failure > 0) { + gzerr << "[MotorFailureSystem] Motor " << current_failure << " failed!" << std::endl; + + } else if (current_failure == 0 && this->_prev_motor_failure_number > 0) { + gzerr << "[MotorFailureSystem] Motor " << this->_prev_motor_failure_number + << " recovered!" << std::endl; + } + + this->_prev_motor_failure_number = current_failure; + } + + // Apply motor failure if active (1-indexed motor number, convert to 0-indexed) + if (current_failure > 0 && current_failure <= static_cast(this->_motor_joints.size())) { + int motorIdx = current_failure - 1; + Entity jointEntity = this->_motor_joints[motorIdx]; + + if (jointEntity != kNullEntity) { + // Force joint velocity command to 0 + // This is done in PreUpdate to override MulticopterMotorModel's commands + auto jointVelCmd = _ecm.Component(jointEntity); + + if (jointVelCmd) { + *jointVelCmd = components::JointVelocityCmd({0.0}); + } + } + } +} + +////////////////////////////////////////////////// +void MotorFailureSystem::PreUpdate(const UpdateInfo &_info, + EntityComponentManager &_ecm) +{ + // Skip if paused + if (_info.paused) { + return; + } + + // Find motor joints on first update + if (!this->_joints_found) { + this->FindMotorJoints(_ecm); + + } else { + this->ApplyMotorFailure(const_cast(_ecm)); + } +} + +////////////////////////////////////////////////// +void MotorFailureSystem::MotorFailureNumberCallback(const gz::msgs::Int32 &_msg) +{ + std::lock_guard lock(this->_motor_failure_mutex); + this->_motor_failure_number = _msg.data(); + gzdbg << "[MotorFailureSystem] Received motor failure number: " + << this->_motor_failure_number << std::endl; +} + +// Register the plugin +GZ_ADD_PLUGIN( + MotorFailureSystem, + gz::sim::System, + MotorFailureSystem::ISystemConfigure, + MotorFailureSystem::ISystemPreUpdate +) + +GZ_ADD_PLUGIN_ALIAS(MotorFailureSystem, + "gz::sim::systems::MotorFailureSystem") diff --git a/src/modules/simulation/gz_plugins/motor_failure/MotorFailureSystem.hpp b/src/modules/simulation/gz_plugins/motor_failure/MotorFailureSystem.hpp new file mode 100644 index 0000000000..1f3c216128 --- /dev/null +++ b/src/modules/simulation/gz_plugins/motor_failure/MotorFailureSystem.hpp @@ -0,0 +1,123 @@ +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +#ifndef GZ_SIM_SYSTEMS_MOTORFAILURESYSTEM_HPP_ +#define GZ_SIM_SYSTEMS_MOTORFAILURESYSTEM_HPP_ + +#include +#include +#include +#include +#include +#include +#include +#include + +// Gazebo Transport includes +#include +#include + +namespace gz +{ +namespace sim +{ +// Inline bracket to help doxygen filtering. +inline namespace GZ_SIM_VERSION_NAMESPACE +{ +namespace systems +{ + +/// \brief This system subscribes to a Gazebo Transport topic to receive motor failure +/// commands and directly controls motor joints to simulate failures. +/// This allows simulating motor failures in multirotor vehicles. +class MotorFailureSystem: + public System, + public ISystemConfigure, + public ISystemPreUpdate +{ +public: + // Documentation inherited + void Configure(const Entity &_entity, + const std::shared_ptr &_sdf, + EntityComponentManager &_ecm, + EventManager &_eventMgr) override; + + // Documentation inherited + void PreUpdate(const gz::sim::UpdateInfo &_info, + gz::sim::EntityComponentManager &_ecm) override; + +private: + /// \brief Callback for Gazebo Transport motor failure number subscription + void MotorFailureNumberCallback(const gz::msgs::Int32 &_msg); + + /// \brief Find all motor joints in the model + void FindMotorJoints(gz::sim::EntityComponentManager &_ecm); + + /// \brief Apply motor failure (set velocity to 0) + void ApplyMotorFailure(gz::sim::EntityComponentManager &_ecm); + + /// \brief Gazebo Transport node for communication + gz::transport::Node _node; + + /// \brief Model entity + gz::sim::Entity _model_entity; + + /// \brief Model interface + gz::sim::Model _model; + + /// \brief Vector of motor joint entities (indexed by motor number) + std::vector _motor_joints; + + /// \brief Current motor failure number (-1 or 0 means no failure, 1-indexed motor number) + int32_t _motor_failure_number{-1}; + + /// \brief Previous motor failure number to detect changes + int32_t _prev_motor_failure_number{-1}; + + /// \brief Gazebo Transport topic name for subscribing to motor failure commands + /// Defaults to /model//motor_failure/motor_number if not specified in SDF + std::string _gz_topic{"/motor_failure/motor_number"}; + + /// \brief Mutex to protect _motor_failure_number + std::mutex _motor_failure_mutex; + + /// \brief Flag to indicate if motor joints have been found + bool _joints_found{false}; +}; + +} // namespace systems +} // namespace GZ_SIM_VERSION_NAMESPACE +} // namespace sim +} // namespace gz + +#endif // GZ_SIM_SYSTEMS_MOTORFAILURESYSTEM_HPP_ diff --git a/src/modules/simulation/gz_plugins/motor_failure/README.md b/src/modules/simulation/gz_plugins/motor_failure/README.md new file mode 100644 index 0000000000..8f1da6ed01 --- /dev/null +++ b/src/modules/simulation/gz_plugins/motor_failure/README.md @@ -0,0 +1,85 @@ +# Motor Failure System Plugin + +This Gazebo plugin enables motor failure simulation for multirotor vehicles in PX4 SITL. + +## Overview + +The Motor Failure System plugin subscribes to a Gazebo Transport topic to receive motor failure commands and directly controls motor joints to simulate failures. This allows simulating motor failures during flight testing. + +## Features + +- Gazebo Transport integration for receiving motor failure commands +- Automatic detection of motor joints (rotor_0_joint, rotor_1_joint, etc.) +- Direct joint velocity override in PreUpdate cycle +- Thread-safe motor failure number handling +- Configurable topic names via SDF + +## Configuration + +### SDF Parameters + +- `` (optional): Gazebo Transport topic for receiving motor failure commands + - Default: `/model//motor_failure/motor_number` + - Follows Gazebo model-scoped topic naming convention + - If specified: Uses the exact topic name provided + +### Example SDF Usage + +**IMPORTANT**: The MotorFailureSystem plugin must be declared **AFTER** the `gz-sim-multicopter-motor-model-system` plugin in your SDF file. This ensures the motor failure override runs after the motor model sets its velocity commands. + +```xml + + + + + + + + + + + + + + /custom/topic/name + +``` + +## Usage + +### Publishing Motor Failure Commands + +To trigger a motor failure, publish a message to the Gazebo Transport topic. + +For a vehicle with namespace `x500_0`: + +```bash +# Fail motor 1 (motors are 1-indexed: 1, 2, 3, 4, ...) +gz topic -t /model/x500_0/motor_failure/motor_number -m gz.msgs.Int32 -p "data: 1" + +# Clear motor failure (restore normal operation) +gz topic -t /model/x500_0/motor_failure/motor_number -m gz.msgs.Int32 -p "data: 0" +``` + +**Note**: Replace `x500_0` with your vehicle's model name. + +**Motor Numbering**: +- Motors are **1-indexed**: 1, 2, 3, 4, etc. +- `data: 0` clears the motor failure +- `data: -1` also clears the motor failure + +### Monitoring Motor Failure Status + +You can monitor the motor failure messages in the Gazebo console output. + + +## Notes + +- The plugin applies motor failure in the PreUpdate cycle by setting joint velocity to 0 +- **Plugin Declaration Order**: This plugin must be declared AFTER the MulticopterMotorModel plugin in the SDF file to ensure proper execution order diff --git a/src/modules/simulation/sensor_baro_sim/SensorBaroSim.cpp b/src/modules/simulation/sensor_baro_sim/SensorBaroSim.cpp index fc70998e9a..e7dd2bd991 100644 --- a/src/modules/simulation/sensor_baro_sim/SensorBaroSim.cpp +++ b/src/modules/simulation/sensor_baro_sim/SensorBaroSim.cpp @@ -155,7 +155,7 @@ void SensorBaroSim::Run() _baro_drift_pa += _baro_drift_pa_per_sec * dt; const float absolute_pressure_noisy = absolute_pressure + abs_pressure_noise + _baro_drift_pa; - // convert to hPa + // Apply pressure offset float pressure = absolute_pressure_noisy + _sim_baro_off_p.get(); // calculate temperature in Celsius diff --git a/src/modules/simulation/simulator_mavlink/sitl_targets_gazebo-classic.cmake b/src/modules/simulation/simulator_mavlink/sitl_targets_gazebo-classic.cmake index 649f0f99c8..693c0fa6e5 100644 --- a/src/modules/simulation/simulator_mavlink/sitl_targets_gazebo-classic.cmake +++ b/src/modules/simulation/simulator_mavlink/sitl_targets_gazebo-classic.cmake @@ -44,12 +44,20 @@ if(gazebo_FOUND) # project to build sitl_gazebo if necessary px4_add_git_submodule(TARGET git_sitl_gazebo-classic PATH "${PX4_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic") include(ExternalProject) + + # Set MAVLINK_DEVELOPMENT if using development dialect + set(GAZEBO_MAVLINK_ARGS) + if(CONFIG_MAVLINK_DIALECT STREQUAL "development") + list(APPEND GAZEBO_MAVLINK_ARGS -DMAVLINK_DEVELOPMENT=1) + endif() + ExternalProject_Add(sitl_gazebo-classic SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DSEND_ODOMETRY_DATA=ON -DGENERATE_ROS_MODELS=ON + ${GAZEBO_MAVLINK_ARGS} BINARY_DIR ${PX4_BINARY_DIR}/build_gazebo-classic INSTALL_COMMAND "" DEPENDS git_sitl_gazebo-classic diff --git a/src/modules/temperature_compensation/temperature_calibration/baro.cpp b/src/modules/temperature_compensation/temperature_calibration/baro.cpp index 7cee4739df..1bc0a2f98b 100644 --- a/src/modules/temperature_compensation/temperature_calibration/baro.cpp +++ b/src/modules/temperature_compensation/temperature_calibration/baro.cpp @@ -96,7 +96,7 @@ int TemperatureCalibrationBaro::update_sensor_instance(PerSensorData &data, int data.device_id = baro_data.device_id; - data.sensor_sample_filt[0] = 100.0f * baro_data.pressure; // convert from hPA to Pa + data.sensor_sample_filt[0] = baro_data.pressure; data.sensor_sample_filt[1] = baro_data.temperature; diff --git a/src/modules/uuv_att_control/uuv_att_control.cpp b/src/modules/uuv_att_control/uuv_att_control.cpp index c7186fc487..1a20eb13dc 100644 --- a/src/modules/uuv_att_control/uuv_att_control.cpp +++ b/src/modules/uuv_att_control/uuv_att_control.cpp @@ -237,15 +237,22 @@ void UUVAttitudeControl::control_attitude_geo(const vehicle_attitude_s &attitude void UUVAttitudeControl::generate_attitude_setpoint(float dt) { + const bool js_heave_sway_mode = joystick_heave_sway_mode(); + // Avoid accumulating absolute yaw error with arming stick gesture float roll = Eulerf(matrix::Quatf(_attitude_setpoint.q_d)).phi(); float pitch = Eulerf(matrix::Quatf(_attitude_setpoint.q_d)).theta(); float yaw = Eulerf(matrix::Quatf(_attitude_setpoint.q_d)).psi(); - // Integrate manual control inputs + float roll_setpoint = 0.0f; + float pitch_setpoint = 0.0f; float yaw_setpoint = yaw + _manual_control_setpoint.yaw * dt * _param_sgm_yaw.get(); - float roll_setpoint = roll + _manual_control_setpoint.roll * dt * _param_sgm_roll.get(); - float pitch_setpoint = pitch + -_manual_control_setpoint.pitch * dt * _param_sgm_pitch.get(); + + if (!js_heave_sway_mode) { + // Integrate roll/pitch from sticks + roll_setpoint = roll + _manual_control_setpoint.roll * dt * _param_sgm_roll.get(); + pitch_setpoint = pitch + -_manual_control_setpoint.pitch * dt * _param_sgm_pitch.get(); + } // Generate target quaternion Eulerf euler_sp(roll_setpoint, pitch_setpoint, yaw_setpoint); @@ -256,21 +263,52 @@ void UUVAttitudeControl::generate_attitude_setpoint(float dt) q_sp.copyTo(_attitude_setpoint.q_d); - _attitude_setpoint.thrust_body[0] = _manual_control_setpoint.throttle * _param_sgm_thrtl.get(); + // Thrust mapping + const float throttle_manual_attitude_gain = _param_sgm_thrtl.get(); + + if (js_heave_sway_mode) { + // XYZ thrust + _attitude_setpoint.thrust_body[0] = _manual_control_setpoint.throttle * throttle_manual_attitude_gain; // surge +x + _attitude_setpoint.thrust_body[1] = _manual_control_setpoint.roll * throttle_manual_attitude_gain; // sway +y + _attitude_setpoint.thrust_body[2] = -_manual_control_setpoint.pitch * throttle_manual_attitude_gain; // heave +z down + + } else { + // Throttle only on +x (surge) + _attitude_setpoint.thrust_body[0] = _manual_control_setpoint.throttle * throttle_manual_attitude_gain; + _attitude_setpoint.thrust_body[1] = 0.f; + _attitude_setpoint.thrust_body[2] = 0.f; + } _attitude_setpoint.timestamp = hrt_absolute_time(); } void UUVAttitudeControl::generate_rates_setpoint(float dt) { - // Integrate manual control inputs - _rates_setpoint.roll = _manual_control_setpoint.roll * dt * _param_rgm_roll.get(); - _rates_setpoint.pitch = -_manual_control_setpoint.pitch * dt * _param_rgm_pitch.get(); - _rates_setpoint.yaw = _manual_control_setpoint.yaw * dt * _param_rgm_yaw.get(); + const bool js_heave_sway_mode = joystick_heave_sway_mode(); + const float throttle_manual_rate_gain = _param_rgm_thrtl.get(); + + if (js_heave_sway_mode) { + // Hold pitch/roll level. Only yaw is a rate command. XYZ thrust + _rates_setpoint.roll = 0.0f; + _rates_setpoint.pitch = 0.0f; + _rates_setpoint.yaw = _manual_control_setpoint.yaw * dt * _param_rgm_yaw.get(); + + _rates_setpoint.thrust_body[0] = _manual_control_setpoint.throttle * throttle_manual_rate_gain; // surge +x + _rates_setpoint.thrust_body[1] = _manual_control_setpoint.roll * throttle_manual_rate_gain; // sway +y + _rates_setpoint.thrust_body[2] = -_manual_control_setpoint.pitch * throttle_manual_rate_gain; // heave +z down + + } else { + // Roll/pitch/yaw are rate commands; thrust only surge + _rates_setpoint.roll = _manual_control_setpoint.roll * dt * _param_rgm_roll.get(); + _rates_setpoint.pitch = -_manual_control_setpoint.pitch * dt * _param_rgm_pitch.get(); + _rates_setpoint.yaw = _manual_control_setpoint.yaw * dt * _param_rgm_yaw.get(); + + _rates_setpoint.thrust_body[0] = _manual_control_setpoint.throttle * throttle_manual_rate_gain; + _rates_setpoint.thrust_body[1] = 0.f; + _rates_setpoint.thrust_body[2] = 0.f; + } - _rates_setpoint.thrust_body[0] = _manual_control_setpoint.throttle * _param_rgm_thrtl.get(); _rates_setpoint.timestamp = hrt_absolute_time(); - } void UUVAttitudeControl::check_setpoint_validity(vehicle_attitude_s &v_att) @@ -352,13 +390,33 @@ void UUVAttitudeControl::Run() } else if (!_vcontrol_mode.flag_control_attitude_enabled && !_vcontrol_mode.flag_control_rates_enabled) { + /* Manual Control mode (e.g. gamepad,...) - raw feedthrough no assistance */ - constrain_actuator_commands(_manual_control_setpoint.roll * _param_mgm_roll.get(), - -_manual_control_setpoint.pitch * _param_mgm_pitch.get(), - _manual_control_setpoint.yaw * _param_mgm_yaw.get(), - _manual_control_setpoint.throttle * _param_mgm_thrtl.get(), - 0.f, - 0.f); + const bool js_heave_sway_mode = joystick_heave_sway_mode(); + + if (js_heave_sway_mode) { + // Keep roll/pitch level, yaw torque, full XYZ thrust + const float throttle_manual_gain = _param_mgm_thrtl.get(); + + const float roll_u = 0.0f; + const float pitch_u = 0.0f; + const float yaw_u = _manual_control_setpoint.yaw * _param_mgm_yaw.get(); + + const float thrust_x = _manual_control_setpoint.throttle * throttle_manual_gain; // surge + const float thrust_y = _manual_control_setpoint.roll * throttle_manual_gain; // sway + const float thrust_z = -_manual_control_setpoint.pitch * throttle_manual_gain; // heave + + constrain_actuator_commands(roll_u, pitch_u, yaw_u, thrust_x, thrust_y, thrust_z); + + } else { + // Pitch/roll/yaw torques from sticks, thrust only surge + constrain_actuator_commands(_manual_control_setpoint.roll * _param_mgm_roll.get(), + -_manual_control_setpoint.pitch * _param_mgm_pitch.get(), + _manual_control_setpoint.yaw * _param_mgm_yaw.get(), + _manual_control_setpoint.throttle * _param_mgm_thrtl.get(), + 0.f, + 0.f); + } } } else { diff --git a/src/modules/uuv_att_control/uuv_att_control.hpp b/src/modules/uuv_att_control/uuv_att_control.hpp index 76588848a3..390d64dbb8 100644 --- a/src/modules/uuv_att_control/uuv_att_control.hpp +++ b/src/modules/uuv_att_control/uuv_att_control.hpp @@ -149,7 +149,8 @@ private: (ParamFloat) _param_mgm_thrtl, (ParamFloat) _param_torque_sat, (ParamFloat) _param_thrust_sat, - (ParamFloat) _param_setpoint_max_age + (ParamFloat) _param_setpoint_max_age, + (ParamInt) _param_stick_mode ) @@ -171,4 +172,6 @@ private: void generate_rates_setpoint(float dt); void reset_attitude_setpoint(vehicle_attitude_s &v_att); void check_setpoint_validity(vehicle_attitude_s &v_att); + + inline bool joystick_heave_sway_mode() const { return _param_stick_mode.get() == 0; } }; diff --git a/src/modules/uuv_att_control/uuv_att_control_params.c b/src/modules/uuv_att_control/uuv_att_control_params.c index 08dea0ef41..2a62edbcdc 100644 --- a/src/modules/uuv_att_control/uuv_att_control_params.c +++ b/src/modules/uuv_att_control/uuv_att_control_params.c @@ -239,3 +239,12 @@ PARAM_DEFINE_FLOAT(UUV_THRUST_SAT, 0.1f); * @group UUV Attitude Control */ PARAM_DEFINE_FLOAT(UUV_SP_MAX_AGE, 2.0f); + +/** + * Stick mode selector (0=Heave/sway control, roll/pitch leveled; 1=Pitch/roll control) + * + * @group UUV Attitude Control + * @min 0 + * @max 1 + */ +PARAM_DEFINE_INT32(UUV_STICK_MODE, 0); diff --git a/src/modules/uxrce_dds_client/dds_topics.h.em b/src/modules/uxrce_dds_client/dds_topics.h.em index 7ff7605ccd..30ba6053ea 100644 --- a/src/modules/uxrce_dds_client/dds_topics.h.em +++ b/src/modules/uxrce_dds_client/dds_topics.h.em @@ -67,6 +67,7 @@ struct SendSubscription { uint32_t topic_size; UcdrSerializeMethod ucdr_serialize_method; uint64_t publish_interval_ms; + uint8_t orb_instance; }; // Subscribers for messages to send @@ -81,6 +82,7 @@ struct SendTopicsSubs { ucdr_topic_size_@(pub['simple_base_type'])(), &ucdr_serialize_@(pub['simple_base_type']), static_cast((@(pub.get('rate_limit', 0)) > 0) ? (1e3 / @(pub.get('rate_limit', 1e3))) : UXRCE_DEFAULT_POLL_INTERVAL_MS), + @(pub['instance']) }, @[ end for]@ }; @@ -98,13 +100,13 @@ bool SendTopicsSubs::init(uxrSession *session, uxrStreamId reliable_out_stream_i bool ret = true; for (unsigned idx = 0; idx < sizeof(send_subscriptions)/sizeof(send_subscriptions[0]); ++idx) { if (fds[idx].events == 0) { - fds[idx].fd = orb_subscribe(send_subscriptions[idx].orb_meta); + fds[idx].fd = orb_subscribe_multi(send_subscriptions[idx].orb_meta, send_subscriptions[idx].orb_instance); fds[idx].events = POLLIN; orb_set_interval(fds[idx].fd, send_subscriptions[idx].publish_interval_ms); } if (!create_data_writer(session, reliable_out_stream_id, participant_id, static_cast(send_subscriptions[idx].orb_meta->o_id), client_namespace, send_subscriptions[idx].topic, - send_subscriptions[idx].message_version, + send_subscriptions[idx].message_version, send_subscriptions[idx].orb_instance, send_subscriptions[idx].dds_type_name, send_subscriptions[idx].data_writer)) { ret = false; } diff --git a/src/modules/uxrce_dds_client/generate_dds_topics.py b/src/modules/uxrce_dds_client/generate_dds_topics.py index 3698c71e9e..957ff4b578 100644 --- a/src/modules/uxrce_dds_client/generate_dds_topics.py +++ b/src/modules/uxrce_dds_client/generate_dds_topics.py @@ -102,12 +102,24 @@ def process_message_type(msg_type): # topic_simple: eg vehicle_status msg_type['topic_simple'] = msg_type['topic'].split('/')[-1] +def process_message_instance(msg_type): + if 'instance' in msg_type: + # if instance is given, check if it is a non negative integer + if not (type(msg_type['instance']) is int and msg_type['instance'] >= 0) : + raise TypeError("`instance` must be a non negative integer") + # add trailing instance to topic name + msg_type['topic'] = f"{msg_type['topic']}{msg_type['instance']}" + else: + # if instance is not given, + msg_type['instance'] = 0 + merged_em_globals['namespace'] = namespace pubs_not_empty = msg_map['publications'] is not None if pubs_not_empty: for p in msg_map['publications']: process_message_type(p) + process_message_instance(p) merged_em_globals['publications'] = msg_map['publications'] if pubs_not_empty else [] diff --git a/src/modules/uxrce_dds_client/utilities.hpp b/src/modules/uxrce_dds_client/utilities.hpp index c2d038b3ed..346dc28455 100644 --- a/src/modules/uxrce_dds_client/utilities.hpp +++ b/src/modules/uxrce_dds_client/utilities.hpp @@ -50,7 +50,7 @@ static bool generate_topic_name(char *topic_name, const char *client_namespace, } static bool create_data_writer(uxrSession *session, uxrStreamId reliable_out_stream_id, uxrObjectId participant_id, - ORB_ID orb_id, const char *client_namespace, const char *topic, uint32_t message_version, const char *type_name, + ORB_ID orb_id, const char *client_namespace, const char *topic, uint32_t message_version, uint8_t instance, const char *type_name, uxrObjectId &datawriter_id) { // topic @@ -61,7 +61,7 @@ static bool create_data_writer(uxrSession *session, uxrStreamId reliable_out_str return false; } - uxrObjectId topic_id = topic_id_from_orb(orb_id); + uxrObjectId topic_id = topic_id_from_orb(orb_id, instance); uint16_t topic_req = uxr_buffer_create_topic_bin(session, reliable_out_stream_id, topic_id, participant_id, topic_name, type_name, UXR_REPLACE); diff --git a/src/modules/vtol_att_control/standard.cpp b/src/modules/vtol_att_control/standard.cpp index 5ab114ba16..6c5bba004e 100644 --- a/src/modules/vtol_att_control/standard.cpp +++ b/src/modules/vtol_att_control/standard.cpp @@ -180,7 +180,7 @@ void Standard::update_transition_state() return; } - memcpy(_v_att_sp, _mc_virtual_att_sp, sizeof(vehicle_attitude_setpoint_s)); + *_v_att_sp = *_mc_virtual_att_sp; } else { // we need a recent incoming (fw virtual) attitude setpoint, otherwise return (means the previous setpoint stays active) @@ -188,7 +188,7 @@ void Standard::update_transition_state() return; } - memcpy(_v_att_sp, _fw_virtual_att_sp, sizeof(vehicle_attitude_setpoint_s)); + *_v_att_sp = *_fw_virtual_att_sp; _v_att_sp->thrust_body[2] = -_fw_virtual_att_sp->thrust_body[0]; } @@ -198,11 +198,12 @@ void Standard::update_transition_state() float pitch_body = attitude_setpoint_euler.theta(); float yaw_body = attitude_setpoint_euler.psi(); - if (_v_control_mode->flag_control_climb_rate_enabled) { - roll_body = Eulerf(Quatf(_fw_virtual_att_sp->q_d)).phi(); - } - if (_vtol_mode == vtol_mode::TRANSITION_TO_FW) { + + if (_v_control_mode->flag_control_climb_rate_enabled) { + roll_body = Eulerf(Quatf(_fw_virtual_att_sp->q_d)).phi(); + } + if (_param_vt_psher_slew.get() <= FLT_EPSILON) { // just set the final target throttle value _pusher_throttle = _param_vt_f_trans_thr.get(); @@ -239,12 +240,24 @@ void Standard::update_transition_state() _v_att_sp->thrust_body[0] = _pusher_throttle; const Quatf q_sp(Eulerf(roll_body, pitch_body, yaw_body)); q_sp.copyTo(_v_att_sp->q_d); + mc_weight = math::constrain(mc_weight, 0.0f, 1.0f); } else if (_vtol_mode == vtol_mode::TRANSITION_TO_MC) { + // continually increase mc attitude control as we transition back to mc mode + if (_param_vt_b_trans_ramp.get() > FLT_EPSILON) { + mc_weight = _time_since_trans_start / _param_vt_b_trans_ramp.get(); + } + + mc_weight = math::constrain(mc_weight, 0.0f, 1.0f); + if (_v_control_mode->flag_control_climb_rate_enabled) { // control backtransition deceleration using pitch. pitch_body = Eulerf(Quatf(_mc_virtual_att_sp->q_d)).theta(); + + // blend roll setpoint between FW and MC + const float roll_body_fw = Eulerf(Quatf(_fw_virtual_att_sp->q_d)).phi(); + roll_body = mc_weight * roll_body + (1.0f - mc_weight) * roll_body_fw; } const Quatf q_sp(Eulerf(roll_body, pitch_body, yaw_body)); @@ -252,15 +265,8 @@ void Standard::update_transition_state() q_sp.copyTo(_v_att_sp->q_d); _pusher_throttle = 0.0f; - - // continually increase mc attitude control as we transition back to mc mode - if (_param_vt_b_trans_ramp.get() > FLT_EPSILON) { - mc_weight = _time_since_trans_start / _param_vt_b_trans_ramp.get(); - } } - mc_weight = math::constrain(mc_weight, 0.0f, 1.0f); - _mc_roll_weight = mc_weight; _mc_pitch_weight = mc_weight; _mc_yaw_weight = mc_weight; diff --git a/src/modules/vtol_att_control/vtol_att_control_params.c b/src/modules/vtol_att_control/vtol_att_control_params.c index 4b9452d3b6..96727f0c53 100644 --- a/src/modules/vtol_att_control/vtol_att_control_params.c +++ b/src/modules/vtol_att_control/vtol_att_control_params.c @@ -341,7 +341,7 @@ PARAM_DEFINE_FLOAT(VT_FW_DIFTHR_S_P, 1.f); PARAM_DEFINE_FLOAT(VT_FW_DIFTHR_S_Y, 0.1f); /** - * Backtransition deceleration setpoint to pitch I gain. + * Backtransition deceleration setpoint to tilt I gain. * * @unit rad s/m * @min 0 @@ -365,7 +365,7 @@ PARAM_DEFINE_FLOAT(VT_B_DEC_I, 0.1f); * @decimal 1 * @group VTOL Attitude Control */ -PARAM_DEFINE_FLOAT(VT_PITCH_MIN, -5.0f); +PARAM_DEFINE_FLOAT(VT_PITCH_MIN, 0.0f); /** * Minimum pitch angle during hover landing. @@ -380,7 +380,7 @@ PARAM_DEFINE_FLOAT(VT_PITCH_MIN, -5.0f); * @decimal 1 * @group VTOL Attitude Control */ -PARAM_DEFINE_FLOAT(VT_LND_PITCH_MIN, -5.0f); +PARAM_DEFINE_FLOAT(VT_LND_PITCH_MIN, 0.0f); /** * Spoiler setting while landing (hover) diff --git a/src/modules/vtol_att_control/vtol_type.cpp b/src/modules/vtol_att_control/vtol_type.cpp index def70ece07..8195df5f8b 100644 --- a/src/modules/vtol_att_control/vtol_type.cpp +++ b/src/modules/vtol_att_control/vtol_type.cpp @@ -515,12 +515,8 @@ float VtolType::pusher_assist() // limit forward actuation to [0, 0.9] forward_thrust = math::constrain(forward_thrust, 0.0f, 0.9f); - // Set the pitch to 0 if the pitch limit is negative (pitch down), but allow a positive (pitch up) pitch. - // This can be used for tiltrotor to make them hover with a positive angle of attack - const float pitch_new = pitch_setpoint_min > 0.f ? pitch_setpoint_min : 0.f; - // create corrected desired body z axis in heading frame - const Dcmf R_tmp = Eulerf(roll_new, pitch_new, 0.0f); + const Dcmf R_tmp = Eulerf(roll_new, pitch_setpoint_min, 0.0f); Vector3f tilt_new(R_tmp(0, 2), R_tmp(1, 2), R_tmp(2, 2)); // rotate the vector into a new frame which is rotated in z by the desired heading diff --git a/src/modules/zenoh/CMakeLists.txt b/src/modules/zenoh/CMakeLists.txt index 158b1e2333..5854b0fd88 100644 --- a/src/modules/zenoh/CMakeLists.txt +++ b/src/modules/zenoh/CMakeLists.txt @@ -52,7 +52,9 @@ if(NOT DEFINED CONFIG_PTHREAD_MUTEX_TYPES AND CONFIG_PLATFORM_NUTTX) message( SEND_ERROR "Pthread mutex is diabled, Zenoh will not function." ) endif() -set(Z_TRANSPORT_LEASE 60000 CACHE STRING "Link lease duration in milliseconds to announce to other zenoh nodes") # Match ROS2 RMW_ZENOH +# Match ROS2 rmw_zenoh settings +set(Z_TRANSPORT_LEASE 60000 CACHE STRING "Link lease duration in milliseconds to announce to other zenoh nodes") +set(Z_TRANSPORT_LEASE_EXPIRE_FACTOR 2 CACHE STRING "Link lease duration in milliseconds to announce to other zenoh nodes") set(FRAG_MAX_SIZE 512 CACHE STRING "Use this to override the maximum size for fragmented messages") set(BATCH_UNICAST_SIZE 256 CACHE STRING "Use this to override the maximum unicast batch size") @@ -72,7 +74,8 @@ target_compile_options(zenohpico_static PUBLIC -Wno-cast-align -Wno-type-limits -Wno-unused-variable -Wno-maybe-uninitialized - -Wno-conversion) + -Wno-conversion + -Wno-float-equal) target_compile_options(zenohpico_static PRIVATE -Wno-missing-prototypes) if(CONFIG_PLATFORM_NUTTX) diff --git a/src/modules/zenoh/Kconfig.topics b/src/modules/zenoh/Kconfig.topics index b16a0c41fa..1b59139374 100644 --- a/src/modules/zenoh/Kconfig.topics +++ b/src/modules/zenoh/Kconfig.topics @@ -645,6 +645,14 @@ menu "Zenoh publishers/subscribers" bool "rover_rate_status" default n + config ZENOH_PUBSUB_ROVER_SPEED_SETPOINT + bool "rover_speed_setpoint" + default n + + config ZENOH_PUBSUB_ROVER_SPEED_STATUS + bool "rover_speed_status" + default n + config ZENOH_PUBSUB_ROVER_STEERING_SETPOINT bool "rover_steering_setpoint" default n @@ -653,14 +661,6 @@ menu "Zenoh publishers/subscribers" bool "rover_throttle_setpoint" default n - config ZENOH_PUBSUB_ROVER_VELOCITY_SETPOINT - bool "rover_velocity_setpoint" - default n - - config ZENOH_PUBSUB_ROVER_VELOCITY_STATUS - bool "rover_velocity_status" - default n - config ZENOH_PUBSUB_RPM bool "rpm" default n @@ -705,6 +705,10 @@ menu "Zenoh publishers/subscribers" bool "sensor_gnss_relative" default n + config ZENOH_PUBSUB_SENSOR_GNSS_STATUS + bool "sensor_gnss_status" + default n + config ZENOH_PUBSUB_SENSOR_GPS bool "sensor_gps" default n @@ -741,6 +745,10 @@ menu "Zenoh publishers/subscribers" bool "sensor_selection" default n + config ZENOH_PUBSUB_SENSOR_TEMP + bool "sensor_temp" + default n + config ZENOH_PUBSUB_SENSOR_UWB bool "sensor_uwb" default n @@ -1103,10 +1111,10 @@ config ZENOH_PUBSUB_ALL_SELECTION select ZENOH_PUBSUB_ROVER_POSITION_SETPOINT select ZENOH_PUBSUB_ROVER_RATE_SETPOINT select ZENOH_PUBSUB_ROVER_RATE_STATUS + select ZENOH_PUBSUB_ROVER_SPEED_SETPOINT + select ZENOH_PUBSUB_ROVER_SPEED_STATUS select ZENOH_PUBSUB_ROVER_STEERING_SETPOINT select ZENOH_PUBSUB_ROVER_THROTTLE_SETPOINT - select ZENOH_PUBSUB_ROVER_VELOCITY_SETPOINT - select ZENOH_PUBSUB_ROVER_VELOCITY_STATUS select ZENOH_PUBSUB_RPM select ZENOH_PUBSUB_RTL_STATUS select ZENOH_PUBSUB_RTL_TIME_ESTIMATE @@ -1118,6 +1126,7 @@ config ZENOH_PUBSUB_ALL_SELECTION select ZENOH_PUBSUB_SENSOR_COMBINED select ZENOH_PUBSUB_SENSOR_CORRECTION select ZENOH_PUBSUB_SENSOR_GNSS_RELATIVE + select ZENOH_PUBSUB_SENSOR_GNSS_STATUS select ZENOH_PUBSUB_SENSOR_GPS select ZENOH_PUBSUB_SENSOR_GYRO select ZENOH_PUBSUB_SENSOR_GYRO_FFT @@ -1127,6 +1136,7 @@ config ZENOH_PUBSUB_ALL_SELECTION select ZENOH_PUBSUB_SENSOR_OPTICAL_FLOW select ZENOH_PUBSUB_SENSOR_PREFLIGHT_MAG select ZENOH_PUBSUB_SENSOR_SELECTION + select ZENOH_PUBSUB_SENSOR_TEMP select ZENOH_PUBSUB_SENSOR_UWB select ZENOH_PUBSUB_SENSORS_STATUS select ZENOH_PUBSUB_SENSORS_STATUS_IMU diff --git a/src/modules/zenoh/publishers/uorb_publisher.hpp b/src/modules/zenoh/publishers/uorb_publisher.hpp index 110cbea8eb..2f95fd319d 100644 --- a/src/modules/zenoh/publishers/uorb_publisher.hpp +++ b/src/modules/zenoh/publishers/uorb_publisher.hpp @@ -66,7 +66,7 @@ public: ~uORB_Zenoh_Publisher() override = default; // Update the uORB Subscription and broadcast a Zenoh ROS2 message - virtual int8_t update() override + virtual z_result_t update() override { #ifdef CONFIG_ZENOH_PUB_ON_MATCHING z_matching_status_t status; diff --git a/src/modules/zenoh/publishers/zenoh_publisher.cpp b/src/modules/zenoh/publishers/zenoh_publisher.cpp index 6bef35a714..e38af892ae 100644 --- a/src/modules/zenoh/publishers/zenoh_publisher.cpp +++ b/src/modules/zenoh/publishers/zenoh_publisher.cpp @@ -78,8 +78,10 @@ int Zenoh_Publisher::declare_publisher(z_owned_session_t s, const char *keyexpr, return 0; } -int8_t Zenoh_Publisher::publish(const uint8_t *buf, int size) +z_result_t Zenoh_Publisher::publish(const uint8_t *buf, int size) { + z_result_t ret; + z_publisher_put_options_t options; z_publisher_put_options_default(&options); @@ -87,12 +89,21 @@ int8_t Zenoh_Publisher::publish(const uint8_t *buf, int size) _attachment.time = hrt_absolute_time(); z_owned_bytes_t z_attachment; - z_bytes_from_static_buf(&z_attachment, (const uint8_t *)&_attachment, RMW_ATTACHEMENT_SIZE); + ret = z_bytes_from_static_buf(&z_attachment, (const uint8_t *)&_attachment, RMW_ATTACHEMENT_SIZE); + + if (ret != Z_OK) { + return ret; + } options.attachment = z_move(z_attachment); z_owned_bytes_t payload; - z_bytes_copy_from_buf(&payload, buf, size); + ret = z_bytes_copy_from_buf(&payload, buf, size); + + if (ret != Z_OK) { + return ret; + } + return z_publisher_put(z_loan(_pub), z_move(payload), &options); } diff --git a/src/modules/zenoh/publishers/zenoh_publisher.hpp b/src/modules/zenoh/publishers/zenoh_publisher.hpp index 89ae1f9f09..b787f39737 100644 --- a/src/modules/zenoh/publishers/zenoh_publisher.hpp +++ b/src/modules/zenoh/publishers/zenoh_publisher.hpp @@ -60,7 +60,7 @@ public: virtual int undeclare_publisher(); - virtual int8_t update() = 0; + virtual z_result_t update() = 0; virtual void print(); diff --git a/src/modules/zenoh/zenoh-pico b/src/modules/zenoh/zenoh-pico index ede74c3f5b..6ec4dc1995 160000 --- a/src/modules/zenoh/zenoh-pico +++ b/src/modules/zenoh/zenoh-pico @@ -1 +1 @@ -Subproject commit ede74c3f5b0ac190d074e796057c62848bb9a488 +Subproject commit 6ec4dc1995f185330e4f6faa8c719eb86f180deb diff --git a/src/modules/zenoh/zenoh.cpp b/src/modules/zenoh/zenoh.cpp index e8a4c62bdc..ec4bc5e06f 100644 --- a/src/modules/zenoh/zenoh.cpp +++ b/src/modules/zenoh/zenoh.cpp @@ -270,6 +270,7 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) #ifdef Z_SUBSCRIBE _zenoh_subscribers = (Zenoh_Subscriber **)malloc(sizeof(Zenoh_Subscriber *)*_sub_count); + memset(_zenoh_subscribers, 0x0, sizeof(Zenoh_Subscriber *)*_sub_count); if (_zenoh_subscribers) { char topic[TOPIC_INFO_SIZE]; @@ -305,6 +306,7 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) #endif } else { + _zenoh_subscribers[i] = NULL; PX4_ERR("Could not create a subscriber for type %s", type); } @@ -325,6 +327,7 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) #ifdef Z_PUBLISH _zenoh_publishers = (uORB_Zenoh_Publisher **)malloc(_pub_count * sizeof(uORB_Zenoh_Publisher *)); + memset(_zenoh_publishers, 0x0, _pub_count * sizeof(uORB_Zenoh_Publisher *)); if (_zenoh_publishers) { char topic[TOPIC_INFO_SIZE]; @@ -361,6 +364,7 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) #endif } else { + _zenoh_publishers[i] = NULL; PX4_ERR("Could not create a publisher for type %s", type); } @@ -384,7 +388,7 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds) void ZENOH::run() { - int8_t ret; + z_result_t ret; int i; _pub_count = _config.getPubCount(); _sub_count = _config.getSubCount(); @@ -395,6 +399,8 @@ void ZENOH::run() return; } + connected = true; + PX4_INFO("Starting reading/writing tasks..."); if (setupTopics(pfds) < 0) { @@ -451,6 +457,8 @@ void ZENOH::run() zp_stop_lease_task(z_session_loan_mut(&_s)); z_drop(z_session_move(&_s)); + + connected = false; exit_and_cleanup(); } @@ -496,7 +504,12 @@ Zenoh demo bridge int ZENOH::print_status() { - PX4_INFO("running"); + if (connected) { + PX4_INFO("Connected"); + + } else { + PX4_INFO("Connecting"); + } PX4_INFO("Publishers"); diff --git a/src/modules/zenoh/zenoh.h b/src/modules/zenoh/zenoh.h index 70ecdbd525..c3940a5582 100644 --- a/src/modules/zenoh/zenoh.h +++ b/src/modules/zenoh/zenoh.h @@ -97,11 +97,12 @@ private: Zenoh_Config _config; int _pub_count; - uORB_Zenoh_Publisher **_zenoh_publishers; + uORB_Zenoh_Publisher **_zenoh_publishers = nullptr; int _sub_count; - Zenoh_Subscriber **_zenoh_subscribers; + Zenoh_Subscriber **_zenoh_subscribers = nullptr; z_owned_session_t _s; + bool connected = false; px4_guid_t _px4_guid{}; diff --git a/test/mavsdk_tests/MAVSDK_VERSION b/test/mavsdk_tests/MAVSDK_VERSION index 7c69a55dbb..1e33456831 100644 --- a/test/mavsdk_tests/MAVSDK_VERSION +++ b/test/mavsdk_tests/MAVSDK_VERSION @@ -1 +1 @@ -3.7.0 +3.11.2 diff --git a/test/mavsdk_tests/autopilot_tester_figure_eight.cpp b/test/mavsdk_tests/autopilot_tester_figure_eight.cpp index 45142f579d..b855cc3ceb 100644 --- a/test/mavsdk_tests/autopilot_tester_figure_eight.cpp +++ b/test/mavsdk_tests/autopilot_tester_figure_eight.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * - * Copyright (c) 2023 PX4 Development Team. All rights reserved. + * Copyright (c) 2023-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 @@ -42,9 +42,6 @@ #include -// Fix build until this is moved to common.xml -#define MAVLINK_WIP -#include using namespace mavsdk::geometry; diff --git a/validation/module_schema.yaml b/validation/module_schema.yaml index 1e1baa1037..1f17bf5fb2 100644 --- a/validation/module_schema.yaml +++ b/validation/module_schema.yaml @@ -352,6 +352,28 @@ actuator_output: # ui only shows the param if this condition is true type: string regex: *condition_regex + center: + type: dict + schema: + min: + # Minimum center value + type: integer + min: 0 + max: 65536 + max: + # Maximum center value + type: integer + min: 0 + max: 65536 + default: + # Default center value + type: integer + min: 0 + max: 65536 + show_if: + # ui only shows the param if this condition is true + type: string + regex: *condition_regex failsafe: type: dict schema: