mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-07-24 15:27:41 +08:00
The per-channel send mutex is genuinely recursive: callers hold lock_send() while the MAVLink C library re-enters send_start()/send_finish() on the same mutex via MAVLINK_START_UART_SEND. On NuttX a recursive mutex only works with CONFIG_PTHREAD_MUTEX_TYPES; without it pthread_mutexattr_settype() is a no-op and the nested lock deadlocks. Only a handful of boards happened to enable the option (for Zenoh), so mavlink could deadlock at startup on most boards, e.g. when bringing up a USB link. Enable CONFIG_PTHREAD_MUTEX_TYPES on the NuttX boards that build mavlink, add a compile-time guard so a board missing the option fails the build loudly instead of deadlocking silently, and check the settype() return. Enabling the option is free in flash and RAM on these boards since they already enable CONFIG_PRIORITY_INHERITANCE / CONFIG_PTHREAD_MUTEX_ROBUST. Signed-off-by: Julian Oes <julian@oes.ch>