Trying to get Hardware-in-the-Loop to work with a CrazyFlie 2.1

Hello everyone, I am trying to set up HITL to work on a CrazyFlie 2.1. I’m aware that support for the CrazyFlie is a bit uncertain. I don’t think PX4 1.14.0+ works on the CrazyFlie 2.1. However, I am able to successfully arm and fly the drone using the “pr-crazyflie_fixes” branch, which i believe is based off of 1.13.0.

Once I switch to the HIL Quadcopter X, and launch the hitl sim (both jmavsim and gazebo classic), Qgroundcontrol shows a Pre-arm Check error:

And if I try to arm, I am greeted with an “Arming denied! Flight termination active” message:

The following is the dmesg output:
dmesg
HW arch: BITCRAZE_CRAZYFLIE21
FW git-hash: 53cdb802b1520beb523b1c0eccc3ada8dacaacd6
FW version: 1.13.0 0 (17629184)
FW git-branch: pr-more_crazyflie_fixes
OS: NuttX
OS version: Release 11.0.0 (184549631)
OS git-hash: c5c7d2b4f26f52f1dfb425ebde83328606b65d4f
Build datetime: Jan 30 2025 00:35:22
Build uri: localhost
Build variant: default
Toolchain: GNU GCC, 9.3.1 20200408 (release)
PX4GUID: 000100000000313232313232470f001b002a
MCU: STM32F40x, rev. ?
INFO [init] formatting /dev/mmcsd0
ERROR [init] format failed
INFO [param] selected parameter default file /fs/mtd_params
INFO [param] importing from ‘/fs/mtd_params’
INFO [parameters] BSON document size 673 bytes, decoded 673 bytes (INT32:17, FLOAT:15)
Board architecture defaults: /etc/init.d/rc.board_arch_defaults
Board defaults: /etc/init.d/rc.board_defaults
sercon: Registering CDC/ACM serial driver
sercon: Successfully registered the CDC/ACM serial driver
WARN [dataman] Could not open data manager file /fs/microsd/dataman
ERROR [dataman] dataman start failed
Loading airframe: /etc/init.d/airframes/1001_rc_quad_x.hil
ERROR [param] Parameter GPS_UBX_DYNMODEL not found.
ERROR [param] Parameter HIL_ACT_FUNC1 not found.
ERROR [param] Parameter HIL_ACT_FUNC2 not found.
ERROR [param] Parameter HIL_ACT_FUNC3 not found.
ERROR [param] Parameter HIL_ACT_FUNC4 not found.
ERROR [param] Parameter GPS_1_CONFIG not found.
ERROR [mixer] can’t open /dev/pwm_output0

ERROR [mixer] failed to load mixer
ERROR [init] Failed loading mixer: /etc/mixers/quad_x.main.mix
ERROR [mixer] can’t open /dev/pwm_output0

ERROR [mixer] failed to append mixer
ERROR [init] Failed appending mixer: /etc/mixers/pass.aux.mix
INFO [init] setting PWM_AUX_OUT none
ekf2 [606:237]
Board mavlink: /etc/init.d/rc.board_mavlink
ERROR [mavlink] DM_KEY_MISSION_STATE lock failed
WARN [mavlink] offboard mission init failed (-1)
INFO [mavlink] mode: Config, data rate: 100000 B/s on /dev/ttyACM0 @ 2000000B
INFO [logger] logger started (mode=all)
INFO [logger] log root dir created: /fs/microsd/log

NuttShell (NSH) NuttX-11.0.0
nsh> WARN [PreFlightCheck] Warning! Missing FMU SD Card.
INFO [mavlink] Starting mavlink shell
WARN [PreFlightCheck] Arming denied! Flight termination active

I have tried changing some parameters (listed below) to match those of the CrazyFlie 2.1, but still no luck in getting the HITL to work:
param set-default SYS_MC_EST_GROUP 2
param set-default SYS_HAS_MAG 0
param set-default EKF2_AID_MASK 2
param set-default EKF2_MAG_TYPE 5

Does anyone have an idea what could be the issue? I’m trying to get this to work for a school related project. Any help would be greatly appreciated.

I think I solved this, if anyone is interested.

As I mentioned, I am using an older version of PX4 from the “pr-crazyflie_fixes” branch. This version was seemingly before this commit was made, removing lockdown flags from causing a flight termination. So, once I modified the Commander.cpp accordingly, the drone was able to arm.

The next issue was with regard to the missing “HIL_ACT_FUCNC*” parameters. Once again, since I am using an older PX4 version, I needed to append “CONFIG_DRIVERS_PWM_OUT_SIM=y” into /boards/bitcraze/crazyflie21/default.px4board (as opposed to newer versions which use " “CONFIG_MODULES_SIMULATION_PWM_OUT_SIM=y”).

Once these were resolved, I was able to carry out the HITL simulation with the CrazyFlie 2.1