Commit Graph
22 Commits
Author SHA1 Message Date
Benjamin CabéandJacob Dahl 026e64b241 refactor(safety_button): use board macros for the button and LED (#29226)
* refactor(safety_button): use board macros for the button and LED

The driver read the safety button and wrote the safety LED as the GPIO pinsets GPIO_BTN_SAFETY and GPIO_LED_SAFETY of board_config.h, the LED active low. A board can now define BOARD_SAFETY_BUTTON(), true while the button is pressed, and BOARD_SAFETY_LED(on_true) instead, as the FIXMEs next to these GPIOs in the board_config.h of FMU-v5, FMU-v6X, FMU-v6XRT and 26 other boards suggest, for a button and an LED that aren't GPIO pinsets or whose polarity differs. The macros default to the GPIOs, so that the existing boards are unchanged.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>

* refactor(boards): drop the safety button and LED FIXMEs

The safety_button driver now takes either the GPIO pinsets or the
BOARD_SAFETY_BUTTON()/BOARD_SAFETY_LED() macros, so the GPIO
definitions are no longer something to replace.

Assisted-by: Claude:claude-opus-5-5

---------

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-29 18:34:36 -06:00
Benjamin CabéandFarhang ddc9474819 fix(boards/3dr/ctrl-n1): drive the PD10 LED push-pull, active high (#29372)
* fix(boards/3dr/ctrl-n1): drive the PD10 LED push-pull, active high

The LED on PD10 lights when the pin drives high, and the board has no
pull-up on that line. Configured as an open-drain output driven low to
switch it on, it never lit, in the application nor in the bootloader.
Drive it push-pull, initially low, and high to switch it on.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5

---------

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Co-authored-by: Farhang <46557204+farhangnaderi@users.noreply.github.com>
2026-10-21 15:16:35 -04:00
Jacob Dahl 633af12ea4 fix(boards): drive PWM outputs low at reset instead of input pull-up (#28746)
* fix(boards): drive PWM outputs low at reset instead of input pull-up

board_on_reset() was written in 2017 to put the FMU timer pins into a
driven low state so ESCs see a defined level from reset until the
output driver claims them. The fmu-v5 refactor in 54bd0a9f2a switched
the pin list to GPIO_INPUT|GPIO_PULLUP without comment, and the 2020
timer-config refactor propagated that as PX4_MAKE_GPIO_INPUT() to every
board derived from fmu-v5. The px4/fmu-v2..v4 lineage and later
px4/fmu-v6x (#19535) kept the driven low output.

A weak pull-up on the motor line is the state the AM32 bootloader
treats as "stay in the bootloader": it tests the pin against its own
pull-down and only jumps to the application on a clean low
(am32-firmware/AM32-bootloader#24). On boards where the MCU pin goes
straight to the ESC pad, a battery-only boot therefore leaves the ESCs
uninitialised (#27696, #28731). A weak pull in either direction also
leaves unassigned channels high impedance, so edges on a neighbouring
DShot line couple in and can spin a motor with no output assigned
(#26525). The 2021 attempt at pull-downs (#17686) hit the same problem
from the other side.

Switch the remaining STM32, kinetis and rt106x boards to
io_timer_channel_get_gpio_output(), matching the boards that already
drive low. The rt117x boards are unchanged because their input macro
has no pull.

The ARK boards additionally overrode the reset state with a pull-down
via PX4_GPIO_INIT_LIST; those entries are removed so the driven low
from board_on_reset() stands.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

* fix(boards): keep capture channels as inputs and cover the missed boards

Driving every timer pin low at reset also drove the capture channels on
fmu-v5, fmu-v5x, fmu-v6u, durandal-v1, pix32v5 and corvon/v5, where a GPS
PPS or camera output may be wired. Until pps_capture or camera_capture
claims the pin, that output would fight a push-pull low, so those
channels keep their previous input state.

The three fmu-v6xrt boards float their PWM pins through a different
input macro and zenfc/h743 landed after this branch was cut; all four now
drive low as well.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

---------

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-13 15:10:19 -06:00
Peter van der Perk 4890d11de8 feat(boards): upgrade NuttX to 12.12.0
boards: Disable MMC_IOC_CMD ioctl

NuttX default is Y, but it's not used

boards: Fix meminfo/free

boards: fix libc float setting

boards: Reduce flash usage

Using strerr short mode
Don't cache DNS entries (also saves some ram)

fix(boards): kakutef7 disable optical flow ekf2 to save flash

kakutef7 overflows with nuttx 12.12.0 also it doesn't have optical
flow drivers anyhow. Thus disable ekf2 optical flow
2026-09-03 12:31:07 -07:00
Jacob Dahl d983b6424f refactor(boards): remove dead defines from board_config.h (#28168)
* refactor(boards): remove unused INPUT_CAP* board defines

INPUT_CAP*_TIMER, INPUT_CAP*_CHANNEL and GPIO_INPUT_CAP* have never had a
consumer. They are present as far back as v1.8.0 (then in
src/drivers/boards/px4fmu-v5/board_config.h) and no code outside a
board_config.h has ever read them.

Input capture is configured in the board timer_config.cpp via
initIOTimerChannelCapture() and driven by
platforms/nuttx/.../io_pins/input_capture.c. On ten of these boards the
removed defines restate, in a second notation, exactly the channel
timer_config.cpp already declares -- fmu-v5x described T5C4 on PI0 and
declares initIOTimerChannelCapture({Timer5, Channel4}, {PortI, Pin0}).

Being unread, the duplicates drifted:

  - cuav/7-nano INPUT_CAP4 named GPIO_TIM4_CH1IN_2 on PD12 while its own
    INPUT_CAP4_TIMER said 15; the configured channel is T15C2 on PE6.
  - modalai/fc-v2 and sky-drones/smartap-airlink declare input capture
    pins while configuring no capture channel at all.

New boards kept inheriting the block by copying an existing
board_config.h.

Assisted-by: Claude:claude-opus-5[1m]
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

* refactor(boards): remove leftover BOARD_HAS_PWM defines

a8e75d174c ("boards: remove BOARD_HAS_PWM and use
DIRECT_PWM_OUTPUT_CHANNELS") dropped the last consumer in 2021, but the
board_config.h side of that cleanup was never finished and boards added
since have kept copying it in. Every remaining definition is a bare alias
of DIRECT_PWM_OUTPUT_CHANNELS, which is the macro actually read.

mamba-f405-mk2 defined it twice in the same header.

Assisted-by: Claude:claude-opus-5[1m]
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

* refactor(boards): remove leftover DIRECT_INPUT_TIMER_CHANNELS defines

c5c80e31b6 ("boards: remove DIRECT_INPUT_TIMER_CHANNELS from
board_config.h") removed the last consumer in 2021. These ten boards
either predate the sweep or were added afterwards by copying a
board_config.h that still carried it.

Assisted-by: Claude:claude-opus-5[1m]
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

* refactor(boards): remove unused BOARD_NUMBER_I2C_BUSES defines

Nothing reads BOARD_NUMBER_I2C_BUSES. The bus count actually in use is
PX4_NUMBER_I2C_BUSES, which each architecture sets in its micro_hal.h
(STM32_NI2C, KINETIS_NI2C, or a literal) and a board cannot influence.

The near-miss name is worse than a plain unused define: it reads like the
board is declaring its bus count when the value is inert.

Assisted-by: Claude:claude-opus-5[1m]
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

* refactor(boards): remove unused BOARD_DMA_NUM_DSHOT_CHANNELS defines

Nothing reads it. The dshot driver sizes its DMA buffers from
MAX_IO_TIMERS and MAX_NUM_CHANNELS_PER_TIMER, so the accompanying comment
describes a budget the board cannot actually declare.

Assisted-by: Claude:claude-opus-5[1m]
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

* refactor(boards/ark): remove dead board_config defines

cannode: the eight GPIO_TIM*_RESET pin configs were never added to
PX4_GPIO_INIT_LIST, unlike the GPIO_I2C1_{SCL,SDA}_RESET pair written
beside them, so nothing ever applied them.

fmu-v6s: ARKV6S_0 is a leftover from copying the fmu-v6x config. fmu-v6x
keys its SPI buses on the FMUM ID via initSPIFmumID(ARKV6X_0, ...), but
fmu-v6s has a single hardware version and uses the plain initSPIBus form,
so the ID is never referenced.

Assisted-by: Claude:claude-opus-5[1m]
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

---------

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-08-05 22:26:22 -06:00
DuoYuWangandJacob Dahl 05be273a35 fix(boards): enable CONFIG_FS_LARGEFILE for NuttX boards with MMC/SD (#28043)
* boards: enable CONFIG_FS_LARGEFILE for NuttX boards with MMC/SD

Without large file support, fsblkcnt_t/off_t are 32-bit and statfs
consumers (procfs /fs/usage, df) compute the volume size as
f_bsize * f_blocks in 32 bits, which wraps at 4GB. Boards with an
SD card or eMMC larger than 4GB report the wrong capacity, e.g. a
32GB SD card on FMU-V6X:

    nsh> ls -l /dev/mmcsd0
     brw-rw-rw-1850212352 /dev/mmcsd0   (= 31914983424 mod 2^32)
    nsh> df -h
      vfat       1749M      240K      1749M /fs/microsd

With CONFIG_FS_LARGEFILE=y the same card reports the full 29G.

This enables the option on the 77 boards that build the MMC/SD block
driver (CONFIG_MMCSD=y, SDIO or SPI). Boards without removable storage
and constrained-flash targets (CONFIG_BOARD_CONSTRAINED_FLASH=y) are
left unchanged.

Note: on the px4_firmware_nuttx-10.3.0+ branch the 64-bit file types
are additionally gated on CONFIG_HAVE_LONG_LONG, which is only defined
via nuttx/compiler.h include order, making the option unreliable. That
gating is fixed by the companion NuttX backport PR
(PX4/NuttX, branch backport-fs-largefile, upstream commit 92b2f1bd3d3).

Tested on a custom STM32H743 board with 8GB eMMC and on FMU-V6X with a
32GB SD card.

* fix(boards): enable CONFIG_FS_LARGEFILE for MMC/SD variant configs

The test/console/stackcheck/socketcan/sysview/cyphal/debug/cryptotest
variant configs of boards covered by the previous commit were missed,
leaving them with 32-bit off_t. fmu-v5 protected is intentionally
excluded: protected-mode syscall proxies keep 32-bit widths.

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

* chore(nuttx): bump submodule for FS_LARGEFILE backport

Picks up the backport of upstream NuttX 92b2f1bd3d3, which gates the
64-bit file types on CONFIG_FS_LARGEFILE alone instead of the
include-order-dependent CONFIG_HAVE_LONG_LONG.

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

---------

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-07-22 19:22:37 -06:00
Alexis Guijarro 0542e1f157 feat(boards/3dr/ctrl-n1): configure barometer as DPS368 (#27854) 2026-07-15 21:39:15 -04:00
Julian Oes 225c1b70ef fix(mavlink): require CONFIG_PTHREAD_MUTEX_TYPES for recursive send mutex
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>
2026-07-06 08:46:35 -07:00
Alexis Guijarro 25724b5244 fix(boards/3dr/ctrl-n1): board port fixes and driver corrections (#27405)
* fix(drivers/ak09940a): fix probe retry, devtype collision, and register naming

* fix(drivers/neopixel): check init return value and fix module name typo

* fix(boards/3dr/ctrl-n1): correct magnetometer i2c bus, LED indexing, chip variant for bootloader, and TIM3 conflict with srgbled_dma

* fix(boards/3dr/ctrl-n1): update bootloader for STM32H743VI
2026-05-20 11:04:29 -06:00
Alexis Guijarro c59f208cc7 feat(boards): add support for 3DR Control N1 flight controller (#27395)
* fix(srgbled_dma): stm32_dmasetup now works with H7 boards

* feat(drivers/ak09940a): add AKM AK09940A magnetometer driver

* feat(boards/3dr/ctrl-n1)!: add 3DR Control-N1 flight controller

* fix(boards/3dr/ctrl-n1): macro replacement list is now enclosed in parentheses

* fix(boards/3dr/ctrl-n1): applying copyright changes

* fix(boards/3dr/ctrl-n1): removing serial console
2026-05-19 13:13:54 -05:00
Julian Oes 1a3d232e7b fix(bootloader): remove broken PROTO_SET_DELAY boot-delay feature (#27081)
The bootloader boot-delay feature has been mechanically broken on
every modern FMU board since the STM32F7/H7 transition. It has three
independent bugs that prevent it from ever working:

1. Offset mismatch: BOOT_DELAY_ADDRESS is hardcoded to 0x1a0, but the
   NuttX vector table is 504 B (F76x) to 664 B (H743) long. The
   linker places _bootdelay_signature at ALIGN(32) past end of
   vectors (e.g. 0x2a0 on CubeOrange), never at 0x1a0. The bootloader
   reads random exception_common pointers in place of the magic and
   never matches BOOT_DELAY_SIGNATURE1/2. Verified on CubeOrange with
   objdump of cubepilot_cubeorange_default.elf.

2. Flash cache never flushes: fc_write() stores arbitrary writes in
   cache line 1 and only flushes on a very specific condition tied
   to the sequential firmware upload flow. A standalone write during
   PROTO_SET_DELAY is cached forever. fc_read() then returns the
   cached value, so the post-write verify lies and the bootloader
   reports success. Nothing ever reaches flash.

3. H7 write granularity: the STM32H7 flash controller requires a
   full 32-byte program cycle per write. Single 32-bit writes from
   flash_func_write_word() would not be accepted by the controller
   even if they reached it.

The feature has been silently dead on every H7/F7 FMU board for
years and no one noticed, which is strong evidence nothing actually
depends on it. Rather than fix it (which would mean rewriting
PROTO_SET_DELAY, the flash cache path, and the H7 flash programming
path), remove it.

Changes:
- bl.c: PROTO_SET_DELAY case now immediately NACKs (goto cmd_bad)
  so clients that still send the command get a clear rejection
  instead of the previous silent fake-success. The opcode stays in
  the protocol enum for backwards compatibility.
- bl.h: drop BOOT_DELAY_SIGNATURE1/2 and BOOT_DELAY_MAX.
- stm/stm32_common/main.c, nxp/imxrt_common/main.c: drop the
  startup boot-delay sig check block.
- image_toc.c: decouple find_toc() from BOOT_DELAY_ADDRESS.
  BOARD_IMAGE_TOC_OFFSET is now the required define when
  BOOTLOADER_USE_TOC is enabled. The body is wrapped in #ifdef
  BOOTLOADER_USE_TOC and falls back to a stub returning false when
  the TOC is not in use (no upstream board currently enables it).
- Linker scripts: strip EXTERN(_bootdelay_signature) and the
  FILL/. += 8 block from all 142 affected .ld files across boards/.
- hw_config.h: strip the #define BOOT_DELAY_ADDRESS and its comment
  block entry from all 48 affected boards.
- Tools/px4_uploader.py, Tools/teensy_uploader.py: remove --boot-delay,
  set_boot_delay(), and SET_BOOT_DELAY client-side counterpart.

Smoke-built on cubepilot_cubeorange_default and
cubepilot_cubeorange_bootloader; no link errors, no unresolved
symbols, flash usage unchanged.

Tested:
- New BL, new FW
- Old BL, old FW
- Old BL, new FW
- New BL, old FW
2026-04-29 13:04:03 +12:00
Andrew BrahimandJacob Dahl f0453f5694 fix(temperature_compensation): remove temp compensation from enclosed autopilots (#27015)
* fix(temperature_compensation): remove temp compensation from enclosed autopilots

Signed-off-by: dirksavage88 <dirksavage88@gmail.com>

* fix(temperature_compensation): remove from 3dr/mro

Signed-off-by: dirksavage88 <dirksavage88@gmail.com>

* fix(temperature_compensation): remove manually from 6x default kconfig

Signed-off-by: dirksavage88 <dirksavage88@gmail.com>

* fix(temperature_compensation): remove from modalai fc-vx boards

Signed-off-by: dirksavage88 <dirksavage88@gmail.com>

* fix(temperature_compensation): remove from all other boards

Signed-off-by: dirksavage88 <dirksavage88@gmail.com>

* Update boards/px4/sitl/default.px4board

---------

Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
2026-04-13 12:46:00 -04:00
Jacob Dahl 06db25c078 boards: remove CONFIG_COMMON_OPTICAL_FLOW from all non-CANnode hardware (#26315) 2026-01-21 10:51:09 -05:00
Alexis Guijarro a6d9e114be Revert "3DR Control Zero H7 OEM RevG: MTD driver fix (#25015)"
This reverts commit 26499b3c8b.
2025-11-24 10:37:45 -09:00
chfriedrich98 e266d1f22f rover: remove deprecated module 2025-07-10 10:11:58 +02:00
Alexis Guijarro 26499b3c8b 3DR Control Zero H7 OEM RevG: MTD driver fix (#25015) 2025-06-11 12:43:00 -04:00
Alexis Guijarro 82c2e6c159 3dr_ctrl-zero-h7-oem-revg: Adding missing module which prevented the USB interface to start 2025-06-04 11:43:26 -04:00
Silvan 8c1f7ec7c0 rename FWPositionController to FWModeManager
Signed-off-by: Silvan <silvan@auterion.com>
2025-05-26 14:47:38 +02:00
RomanBapst 779a55c6dc FW Position Controller rework
- split up old module into two, one handling setpoint generation, one control
- add lateral and longitudinal control setpoints topics that can also be
injected from companion computer
- add configuration topics that (optionally) configure the controller
with limits and momentary settings

Signed-off-by: RomanBapst <bapstroman@gmail.com>
2025-05-26 14:47:38 +02:00
Alexander Lerach 047578a844 Disarm PWM ESCs before reboot 2025-02-10 18:16:48 +01:00
PX4 BuildBot 51702efe94 boards: update all NuttX defconfigs 2024-10-02 15:08:38 -04:00
Alexis Guijarro c8501cc1d0 boards: Support for 3DR Control Zero H7 OEM Rev G board 2024-08-14 19:52:42 -04:00