Commit Graph
1625 Commits
Author SHA1 Message Date
TheLukaDragar 99a3048735 build(nuttx): pin the merged i.MX RT ENET backports
Point platforms/nuttx/NuttX/nuttx at the PX4/NuttX branch tip, which now
has the merged backports:
- PX4/NuttX#447: arch/arm/imxrt: a fixed link when no PHY answers
  (apache/nuttx#20457)
- PX4/NuttX#449: arch/arm/imxrt: hold RX frames while the ENET TX ring
  is full (apache/nuttx#20562)

The tip also carries the i.MX 9 backports #439 to #445, which do not
touch arch/arm/src/imxrt.

Assisted-by: Claude:claude-opus-5
Signed-off-by: TheLukaDragar <lukadragarbusiness@gmail.com>
2026-11-16 14:49:35 +01:00
TheLukaDragar 41f1522d90 feat(boards/fmu-v6xrt): support Ethernet carriers without a PHY
- platforms/nuttx/NuttX/nuttx: bump to the backport of apache/nuttx
  eafd01cecc ("arch/arm/imxrt: a fixed link when no PHY answers").
- boards/px4/fmu-v6xrt: enable CONFIG_IMXRT_ENET_FIXED_LINK. The driver
  still probes the board's PHY list first. If no PHY answers, the MAC
  runs at 100 Mbps full duplex, so a carrier that wires the FMU's RMII
  bus straight to a switch port or another MAC brings eth0 up. Carriers
  with a PHY are unchanged.

Assisted-by: Claude:claude-opus-5
Signed-off-by: TheLukaDragar <lukadragarbusiness@gmail.com>
2026-11-16 14:49:35 +01:00
Jacob Dahl 91a4c21ca8 refactor(drivers): share the start/stop/status dispatch of I2C/SPI drivers (#29556)
90 driver main functions repeated the same three strcmp() checks and
calls. I2CSPIDriver<T>::module_main() does it once; drivers with extra
verbs keep their own dispatch.

Assisted-by: Claude:claude-opus-5-5
2026-11-10 15:58:59 -07:00
Peter van der Perk ca7b6d9819 fix(dshot): skip FlexIO in up_dshot_arm when no channel was initialised (#29677)
When no output is configured for DShot, init fails and the destructor
calls up_dshot_arm(false) before up_dshot_init() ever ran. Since the
FlexIO driver rework up_dshot_arm() writes SHIFTSIEN and TIMIEN
unconditionally, but FlexIO1 is still clock gated at that point and an
access to a gated i.MX RT peripheral stalls the bus: the app dies about
12 s after boot with no fault, before the USB autostart. Seen on the
RT1064 (MR-VMU-TROPIC); RT1176 boards init DShot successfully first.

Return early when the channel mask is empty.
2026-11-09 12:56:58 -07:00
Peter van der PerkandAndre Heinemans fec5cf5d14 fix(boards): address MR-NavQ95 review feedback
- USB VALID/CONNECTED set to 0
- TPM: reject OneShot when the clock can't support it, fix W1C status
  and hw channel indexing, scale TPM3 to its correct tick
- Set pad pulls through the iomux
- Calibrate LOOPSPERMSEC on hardware (159856)
- Drop I2C_LATEINIT, the ADC critical section and the FAT DMA pool
- Add validateSPIConfig
- Round the LPIT reload up
- Make imx9 its own CI chip family, with its own group and seeder
- Reject BDShot150 and fall back to plain DShot (also a long-standing
  bug on i.MX RT)

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
Co-authored-by: Andre Heinemans <andre.heinemans@nxp.com>
2026-11-06 07:32:53 -08:00
Peter van der PerkandAndre Heinemans 676b485702 feat(platform): add the NXP i.MX9 and i.MX95 NuttX platform layer
Add the PX4 arch layer for the i.MX9 family: ADC, HRT on LPTMR with
LPIT deadlines, TPM io timers, pin interrupts, LPSPI with chip selects
for all eight instances, critmon on the DWT cycle counter, a tone alarm
on a TPM channel, version reporting with the 128-bit ECID read from the
Fuse Status Block as the UUID, the board reset entry point, plus the
i.MX95 chip include set, the chip mapping in px4_impl_os.cmake and the
PX4_SOC_ARCH_ID_IMX95 id. DShot uses the shared NXP FlexIO driver with
the i.MX9 FlexIO base, offsets, IRQ, clock root and pad hooks.

Not implemented yet: reset of the M7 through the System Manager, LED
PWM and PWM input capture.

i.MX9 timer configs name their timers Timer::TPMn and mark DShot
capable ones with initIOTimerDshot(), so teach
output_groups_from_timer_config.py both forms.

Co-authored-by: Andre Heinemans <andre.heinemans@nxp.com>
2026-11-06 07:32:53 -08:00
Peter van der PerkandAndre Heinemans 38a6163bfc refactor(dshot): move the i.MX RT FlexIO DShot driver to nxp_common
The FlexIO block and the driver logic are the same on every NXP part
that has FlexIO. Move the driver next to the other shared NXP code and
gather the chip-specific pieces (FlexIO base, register offset prefix,
IRQ number, clock enable, pad configuration, unused-channel test) in one
block at the top, so another chip only has to provide that block.

Co-authored-by: Andre Heinemans <andre.heinemans@nxp.com>
2026-11-06 07:32:53 -08:00
Peter van der PerkandAndre Heinemans 5dcb5d825e build(nuttx): generate an MCUboot image when the board asks for it
Boards started by MCUboot, such as the i.MX95 flash build, need the
raw objcopy output wrapped in the MCUboot header and TLV trailer before
it boots. Add CONFIG_BOARD_MCUBOOT_IMGTOOL_ARGS, a board option holding
the imgtool sign arguments, and build <config>.signed.bin next to the
plain .bin from the NuttX CMake, the way Zephyr's west sign does. The
plain .bin and everything derived from it stay as they are.

A signing key is passed through BOARD_MCUBOOT_KEY in the environment
at configure time, so private keys stay out of the board files.

imgtool comes from PyPI via Tools/setup/requirements.txt. When it is
missing, CMake warns and skips the signed image instead of failing the
configure.

The .px4 package is only built when the board has a firmware.prototype,
so a board that boots through MCUboot and has no PX4 bootloader needs
no board_id.

Co-authored-by: Andre Heinemans <andre.heinemans@nxp.com>
2026-11-06 07:32:53 -08:00
Peter van der PerkandAndre Heinemans 224e046072 fix(work_queue): Extend I2C/SPI instances to support i.MX95
Co-authored-by: Andre Heinemans <andre.heinemans@nxp.com>
2026-11-06 07:32:53 -08:00
Peter van der PerkandAndre Heinemans 071f45d28a build(nuttx): build openamp and link it with the drivers
RPMsg based ttys and filesystems live in NuttX's openamp directory,
which the PX4 build did not compile. Build it and link it with the
driver and memory manager libraries it depends on, guarded by
CONFIG_OPENAMP so boards without RPMsg keep their build and link line.

Co-authored-by: Andre Heinemans <andre.heinemans@nxp.com>
2026-11-06 07:32:53 -08:00
Jacob Dahl ed3c3c5553 fix(dshot): reject invalid GCR telemetry symbols (#29553)
Illegal 5-bit GCR symbols decoded to 0x0, so a corrupted frame could alias a valid zero nibble and pass the 4-bit checksum, producing a false eRPM or EDT sample. Of all 2^20 received words the old decoder accepted 61440; only the 4096 valid codewords should pass.

Assisted-by: Claude:claude-opus-5-5
2026-10-31 13:39:05 -06:00
Jacob Dahl 9b2074abc3 refactor(platform): give PX4_INFO, PX4_WARN and PX4_ERR one entry point per level (#29552)
About 1700 call sites loaded the log level as the first argument of
px4_log_modulename(). Per-level functions drop that load and leave one
more register for the format arguments.

Assisted-by: Claude:claude-opus-5-5
2026-10-31 13:35:27 -06:00
Jacob Dahl 65b89bff03 refactor(platform): compile out module help text on NO_HELP boards (#29550)
CONSTRAINED_FLASH_NO_HELP only emptied the PRINT_MODULE_USAGE_* bodies,
so every call site and its strings stayed in flash. Make the helpers
no-op inlines there, as PRINT_MODULE_DESCRIPTION already is on NuttX;
only the usage line with the docs link is still printed.

Assisted-by: Claude:claude-opus-5-5
2026-10-31 13:27:45 -06:00
Jacob DahlandBalduin 5196d31507 refactor(uORB): share the SubscriptionMultiArray initialisation to save flash (#29547)
The constructor loop that assigns and subscribes every instance was
expanded into each of the ~55 SubscriptionMultiArray members in the
firmware. Move it into a non-template function in Subscription.cpp,
called with the array, its size and the topic.

px4_fmu-v6x_default: 1918712 -> 1917160 bytes of text, -1552 B.

Assisted-by: Claude:claude-fable-5-1

Co-authored-by: Balduin <balduin@auterion.com>
2026-10-31 11:57:26 -06:00
Jacob DahlandBalduin 5535d849a2 refactor(platform): out-line the ModuleParams constructor to save flash (#29545)
The constructor was defined in the header, so every one of the ~150
module and library classes deriving from ModuleParams expanded it into
its own constructor: the ListNode and child-list initialisation plus
the setParent() call, repeated per class.

Moving the body next to setParent() in module_params.cpp leaves a single
call at each site. px4_fmu-v6x_default: 1934288 -> 1932520 bytes of
text, -1768 B.

Assisted-by: Claude:claude-fable-5-1

Co-authored-by: Balduin <balduin@auterion.com>
2026-10-31 11:43:01 -06:00
Jacob DahlandBalduin 1ed0e63ca5 refactor(platform): out-line the I2CSPIDriverBase constructor to save flash (#29544)
The constructor was defined in the header, so each of the ~75 I2C/SPI
drivers expanded the ScheduledWorkItem and I2CSPIInstance initialisation
into its own constructor.

Moving the body to i2c_spi_buses.cpp leaves one call per driver.
px4_fmu-v6x_default: 1932520 -> 1930616 bytes of text, -1904 B.

Assisted-by: Claude:claude-fable-5-1

Co-authored-by: Balduin <balduin@auterion.com>
2026-10-31 11:42:43 -06:00
Jacob DahlandBalduin 9c1e218b1f refactor(platform): out-line ModuleParams::updateParams() to save flash (#29543)
The base implementation, which walks the child list and then calls
updateParamsImpl(), was defined in the class body. Every module that
calls updateParams() on a parameter update therefore inlined the list
walk. Define it in module_params.cpp next to setParent().

px4_fmu-v6x_default: 1917160 -> 1915056 bytes of text, -2104 B.

Assisted-by: Claude:claude-fable-5-1

Co-authored-by: Balduin <balduin@auterion.com>
2026-10-31 11:42:34 -06:00
abhijith cf5756b069 feat(boards/agam): add v6xrt secure boot (#28950)
Adds secureboot and bootloader_secureboot variants for fmu-v6xrt
(ed25519 image signing).

The image starts with the 0x2000 FlexSPI boot header, so the TOC sits
at 0x2800, past the vector table, and its first entry starts at
APP_LOAD_ADDRESS.

bl.c: apply APP_VECTOR_OFFSET to the vector base when the TOC has no
vectors entry. No change for boards with a zero offset.

Bootloader grows 8192 B to 96656 B (73.7% of 128 KB).

Tested on hardware: signed image boots; unsigned, tampered and
test-key-signed images are refused.

Signed-off-by: abhijithcv <abhijithcv1212@gmail.com>
2026-10-31 19:47:10 +13:00
Andrew Brahim 9f29d50f92 fix(vectornav): Lower scheduler priority (#28934)
* fix(vectornav): limit init based on retries, set max thread prio

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

* fix(vnav): set lower priority than max

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

* chore(vnav): remove unused variable

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

* fix(vnav): set scheduler priority definition in tasks header, base off of PX4_WQ_HP_BASE

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

---------

Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
2026-10-30 15:34:54 +01:00
Jacob Dahl ade867b1a5 fix(uORB): unregister callback subscriptions before the subclass is destroyed (#29515)
A publisher calls call() under the node lock until the subscription is
unregistered. SubscriptionBlocking, SubscriptionCallbackWorkItem and
the MCP CallbackHandler left that to ~SubscriptionCallback(), which runs
after the subclass is gone, so a publication during destruction aborted
with "pure virtual method called". SubscriptionBlocking could also signal
its already destroyed condition variable. SITL mag calibration in SIH hit
this on almost every side.

The new functional test aborts on both subscription types within about
a second without the fix.

Assisted-by: Claude:claude-opus-5-5
2026-10-29 18:15:15 -06:00
Julian Oes f7191cdb30 fix(canbootloader): bound the BeginFirmwareUpdate length and the progress math (#29485)
wait_for_beginfirmwareupdate() subtracted the source_node_id field from
the received length without checking the request was that long, so an
empty request wrapped the firmware path length to SIZE_MAX and the
following GetInfo and Read requests were built from far past the path
buffer. Keep waiting until a request long enough to hold the field
arrives.

The programming progress divided by fw_image_size / 100, which is zero
for images under 100 bytes, and an image down to the size of the app
descriptor is accepted. Scale the offset instead.

Reported by @doridoriJJ.

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

Signed-off-by: Julian Oes <julian@oes.ch>
2026-10-29 10:04:01 -06:00
alexcekay 9bc752fd9c fix(nuttx): bump submodule for the littlefs removed open file fix
Removing a file while it is open, for example time_save.bin which
time_persistor keeps open, could make its next sync overwrite the entry
that follows it, if the file was the last entry of a split metadata
pair. A directory hit by this fails every lookup with "Bad address".
This is a regression in littlefs v2.5.0. Pick up the local littlefs
patch until the fix is in a littlefs release.

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

Signed-off-by: alexcekay <alexander@auterion.com>
2026-10-26 17:22:22 +01:00
Jacob Dahl 04f662a16e fix(nuttx): point submodule at the merged 4-bit SD commit (#29438)
The previous bump pinned the PX4/NuttX#433 branch commit, which the squash merge replaced and the branch deletion left unreachable, so fresh clones fail to fetch the submodule. The merged commit has the identical tree.

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

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-26 08:47:56 -06:00
Benjamin Cabé cd2b157682 perf(uORB): skip subscription lookups until a device node is added (#29249)
While a topic has no device node, every Subscription::update(), copy(),
updated() and advertised() repeats the device node lookup and fails
again. Polling modules touch many optional topics on every loop: in a
SITL flight about 8% of all instructions, and about a quarter of each
MAVLink thread, were such failed lookups.

Device nodes are never removed, so a lookup that failed cannot succeed
before a node is added. Count the nodes added in DeviceMaster and only
retry the lookup once that count has changed. Protected builds, where
user space has no cheap access to it, keep retrying every time.

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

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-24 07:06:39 -08:00
Afonso Oliveira 1531f5d699 style(nuttx): write the Erbium fixed board ID as hex words
astyle indents the character-shift initializer as a continuation; the
same values as hex words with comments pass check_format.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Afonso Oliveira <afonso.oliveira707@gmail.com>
2026-10-23 22:42:28 +02:00
Afonso Oliveira af77d02acf Revert "fix(px4_work_queue): link px4_layer for the task functions it uses"
This reverts commit d92a0c6b3. In protected builds px4_work_queue is also
linked into the kernel image, where px4_layer's user-side objects collide
with the kernel ones (px4_fmu-v5_protected). The Erbium target no longer
needs the link dependency, since its modules pull in px4_task_spawn_cmd()
and px4_task_join() before px4_work_queue is linked.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Afonso Oliveira <afonso.oliveira707@gmail.com>
2026-10-23 22:42:28 +02:00
Afonso Oliveira d7e71f6931 feat(nuttx): add AIFoundry Erbium chip support
Erbium is a RISC-V RV64IMFC chip whose NuttX port is in PX4/NuttX. Add
the PX4 platform layer for it: HRT, board reset, critmon time base and
board identity, the riscv-none-elf toolchain file and the rv64imfc
compiler flags, which include -mno-fdiv because the ET-Minion core has
no hardware for FDIV.S and FSQRT.S.

The HRT reads the machine timer and runs its callouts in a task, since
the NuttX RISC-V trap path does not save the FP registers that callouts
may use.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Afonso Oliveira <afonso.oliveira707@gmail.com>
2026-10-23 22:42:28 +02:00
Afonso Oliveira 64cad67e04 build(nuttx): link the startup object of RISC-V chips
NuttX builds the startup code of a RISC-V chip as a separate head
object next to libarch instead of into it, so the final link did not
include the reset entry point. Declare the object as a byproduct of the
arch build and link it.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Afonso Oliveira <afonso.oliveira707@gmail.com>
2026-10-23 22:42:28 +02:00
Afonso Oliveira aa1724fa0c fix(px4_mtd): forward-declare the NuttX structs used in prototypes
px4_at24c_initialize() takes a struct i2c_master_s pointer. Without a
declaration in scope the struct is local to the prototype, which is an
error with -Werror on a target that does not include the NuttX I2C
headers before px4_mtd.h.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Afonso Oliveira <afonso.oliveira707@gmail.com>
2026-10-23 22:42:28 +02:00
Afonso Oliveira 9e2711ae1a fix(px4_work_queue): link px4_layer for the task functions it uses
WorkQueueManager starts and joins its thread with px4_task_spawn_cmd()
and px4_task_join() from px4_layer, but px4_work_queue did not declare
that dependency. Targets with many modules pull those objects in before
px4_work_queue is linked; a target with only a few system commands
fails to link.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Afonso Oliveira <afonso.oliveira707@gmail.com>
2026-10-23 22:42:28 +02:00
Afonso Oliveira d78ffbd1cb fix(nuttx): scale task stack sizes with the pointer size
Module stack sizes are tuned for 32-bit targets. The POSIX task spawn
and the work queues already pass them through PX4_STACK_ADJUSTED(),
which doubles them when pointers are 64-bit; px4_task_spawn_cmd() on
NuttX did not, so a 64-bit NuttX target overflows stacks such as the
SIH simulator's. On 32-bit targets PX4_STACK_ADJUSTED() leaves the size
unchanged.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Afonso Oliveira <afonso.oliveira707@gmail.com>
2026-10-23 22:42:28 +02:00
Alex Klimaj 56cbe4d4ee fix(nuttx): bump submodule for STM32 4-bit SD bus (#29388)
NuttX 12.12 switches an SD card to the 4-bit bus only when the host
driver reports SDIO_CAPS_4BIT. The STM32 SDIO and SDMMC drivers never
reported it, so STM32 boards with an SDIO/SDMMC card slot ran it on a
1-bit bus, cutting SD write throughput by about 40% against v1.18.
Pick up the backport that makes the drivers report it.

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

Signed-off-by: alexklimaj <alex@arkelectron.com>
2026-10-23 05:44:13 -08:00
Lourens Naude 4ce349a969 build(nuttx): bump submodule for the RT117x CAAM random number generator
Move to the fork tip, which adds the CAAM job ring and RNG drivers for
RT117x (PX4/NuttX#432) so a board can register /dev/random and
/dev/urandom backed by the hardware generator. The bump also carries
the RISC-V erbium emulator port that landed on the fork before it.

Assisted-by: Claude:claude-fable-5-1
2026-10-22 09:02:57 +02:00
Lourens Naude c283d61ef3 perf(uORB): skip the queue offset division for single-slot topics
Assisted-by: Claude:claude-fable-5-1
2026-10-22 08:26:26 +02:00
Lourens Naude d4a86b5d43 perf(uORB): publish through the node directly from the typed wrappers
Assisted-by: Claude:claude-fable-5-1
2026-10-22 08:26:26 +02:00
Lourens Naude 5abef6d065 perf(uORB): match nodes by ORB_ID instead of strcmp
Assisted-by: Claude:claude-fable-5-1
2026-10-22 08:26:26 +02:00
Lourens Naude 537b82d380 perf(uORB): check the exists bitset before allocating in advertise()
Assisted-by: Claude:claude-fable-5-1
2026-10-22 08:26:26 +02:00
Lourens Naude 9d65ba66ae perf(uORB): skip poll_notify() on publish without poll waiters
Assisted-by: Claude:claude-fable-5-1
2026-10-22 08:26:26 +02:00
Lourens Naude 427bf69cdd perf(uORB): load _last_update in callbacks only when an interval is set
Assisted-by: Claude:claude-fable-5-1
2026-10-22 08:26:26 +02:00
Lourens Naude 2a9be29e3c perf(uORB): check for new data before reading the clock in updated()
Assisted-by: Claude:claude-fable-5-1
2026-10-22 08:26:26 +02:00
Jukka LaitinenandHamish Willee 94fada627b feat(bootloader): Add support for standalone prepended TOC (#28228)
* feat(bootloader): Add flag BOOTLOADER_SKIP_VERIFY_SIG to skip post-flash signature check

In case the full image is not available in memory after flashing, the signature check
can't be performed. This is the case if flashing image in chunks to e.g. SD card or eMMC.

The image will be anyhow verified before booting, so the check is redundant.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* feat(bootloader/toc): Support separately signed TOC in front of the image

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* feat(bootloader): Add support for loading TOC separately into buffer

This changes the prototype of find_toc to pass the address and maximum length of the
area where TOC is to be searched, instead of just letting find_toc search from the
hard-coded APP_LOAD_ADDRESS.

This allows searching for TOC from a separately allocated buffer, which is useful for
a platform where the mass storage is not XIP, where one can first only load a TOC
separately. To keep it secure, the TOC itself needs to be separately signed though.

In image_toc.h two new flags are introduced by taking the reserved bits into use:

The TOC_FLAG2_RELATIVE_ADDRESSES can be set in case of entry being loaded from non-XIP
media to arbitrary addressed buffer; the address entry in TOC can be specified to be
an offset from the load address start instead of being an absolute address in memory.

The TOC_FLAG2_USE_SBI can be used with risc-v targets, in case the entry needs to be
booted via SBI interface.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* docs(secure bootloader): Add prepended toc documentation

Document the feature to add a separately signed TOC in front of the
image.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>

* docs(docs): Release note

* fix(bootloader/fmu-v6xrt): Increase bl stack by 200 bytes

It is on the edge and overflows if crypto functionality is added.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* feat(bootloader/fmu-v6xrt): Add signed boot targets for fmu-v6xrt

This adds these two new targets:
- px4_fmu-v6xrt_secureboot : Signed PX4 image, with prepended TOC, for v6xrt
- px4_fmu-v6xrt_bootloader_secureboot: Bootloader version to verify the signed image

Specifically, the implementation has
- px4board for both targets
- A new linker script for px4_fmu-v6xrt_secureboot, including the script.ld and
  overriding the "flash" memory area for start and size to account for prepended
  TOC structure
- TOC source and linker script
- Bootloader configurations added in hw_config.h

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

---------

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
2026-10-21 21:03:49 +11:00
Michael Rogov Papernov 3fe7acc19d refactor(events): move the message-less send() out of line
events::send(id, log_levels, message) was an inline function, so every
module using it got either a private clone or the body inlined at each
call site. The message is never part of the sent event: it only feeds
the build-time event generator and the optional console print.

Keep a thin inline wrapper so the compiler still drops the unused
message string, and build the event in one out-of-line function that
takes the two log levels as scalars to keep the call sites small. This
saves 1760 bytes of FLASH on px4_fmu-v6x and 1184 bytes on px4_fmu-v2.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Michael Rogov Papernov <michael@membrowse.com>
2026-10-20 16:45:03 +02:00
Jacob Dahl 8c5f4e0788 fix(px4_work_queue): don't touch a WorkItem after its Run() returns (#29278)
Modules that stop through ModuleBase::exit_and_cleanup() delete themselves
inside Run(), and since 9b62a1701d WorkQueue::Run() then clears
_run_in_progress in the freed object. ASAN aborts SITL on
`battery_simulator stop` and the stop of most other work queue modules.

Track the in-flight item in the WorkQueue instead, which lives until its
own Run() exits on the worker thread.

Assisted-by: Claude:claude-opus-5-5
2026-10-19 12:37:19 +13:00
Jacob Dahl 0436f3f76e fix(nuttx): bump submodule for the CAN socket IOB leak fix (#29281)
Closing a CAN socket returned the connection to the pool without freeing the frames queued on it, so their IOBs were lost from the pool the IP stack shares. The DroneCAN driver now closes its SocketCAN sockets on uavcan stop and after a failed init.

Assisted-by: Claude:claude-opus-5-5
2026-10-17 10:05:24 -06:00
e146fe4cc6 fix(uorb): keep shared topics advertised on publisher teardown (#29176)
* fix(dataman_client): keep request topic advertised on client teardown

* fix(uorb): keep shared topics advertised on publisher teardown

Single-instance publications share one advertised flag, so destroying one
publisher must not hide updates from the others.

Keep automatic unadvertising in PublicationMultiBase and remove the
DatamanClient workaround. Cover surviving publishers and instance reuse,
and reset retained input samples between test cases.

Tested: make tests (215/215), make format.
Signed-off-by: jonas <jonas.perolini@rigi.tech>
Assisted-by: Codex

* docs(uorb): correct unadvertise comments and document teardown

The unadvertise comment claimed it has no effect on single-instance
topics, which is how one publisher's teardown came to hide the others.
State what clearing the shared flag does, and document that only
PublicationMulti releases its instance on destruction.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: jonas <jonas.perolini@rigi.tech>

* test(uorb): keep test cases independent of retained samples

A destroyed single-instance publication now leaves its last sample
visible, so ManualControlTest, test_prec_takeoff and mixer_module_tests
passed only in declaration order and failed under --gtest_shuffle.
Reset with an inert sample where one exists, otherwise unadvertise the
test's own publications, and drop module outputs left over from a
previous case.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: jonas <jonas.perolini@rigi.tech>

* fix(boards): drop the PublicationBase destructor from the ITCM lists

The destructor is now trivial and no longer emitted, so itcm_check.py
fails on the missing section.

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

---------

Signed-off-by: jonas <jonas.perolini@rigi.tech>
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: jonas <jonas.perolini@rigi.tech>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-14 16:53:20 -06:00
Benjamin Cabé 9a1429ae90 fix(platforms): sleep with nanosleep() in px4_usleep() (#29218)
* fix(platforms/common): sleep with nanosleep() in px4_usleep()

Outside of the SITL lockstep build, px4_usleep() was usleep(). POSIX only requires usleep() to accept less than 1000000 microseconds and lets it fail with EINVAL from there; POSIX.1-2001 marked it obsolescent and POSIX.1-2008 removed it in favour of nanosleep(). glibc, NuttX and macOS sleep for longer anyway, but other implementations return EINVAL at once, and as no caller checks the result, the sleep would silently not happen. More than twenty call sites ask for a second or more, such as uorb top, mavlink, the ESC calibration or voxl2_io, and some durations are computed at run time, such as the one-second idle period of the POSIX HRT thread.

Outside of the lockstep build, px4_usleep() is now a px4_platform function that converts the microseconds to the timespec of nanosleep(), so the call sites keep passing microseconds of any duration. It is not inline: expanding the conversion at every call site grew px4_fmu-v6xrt_default by 4 kB of flash. QURT has no nanosleep(), which PX4 only stubs there, but its usleep() accepts a second or more, so px4_usleep() remains usleep() there. system_usleep() remains usleep(), for the wall-clock sleeps that bypass the lockstep scheduler.

A signal still ends the sleep early, with -1 and EINTR, rather than restarting it for the remaining time: on POSIX, the HRT and work queue threads sleep in px4_usleep(), and hrt_work_queue() and work_queue() wake them with SIGCONT, so a restarted sleep would delay hrt_call_*() callouts by up to a second. On NuttX, no PX4 code signals its tasks, and px4_task_delete() does not depend on the sleep returning: without cancellation points, which no board enables, task_delete() terminates the task wherever it is.

Failures are now -1 with errno, where the usleep() of NuttX returned the error number. No call site checks the result, so none changes. The sleep test now also sleeps for 1.2 s.

Assisted-by: Claude:opus-5.5

* perf(boards): keep the sleep path in ITCM on i.MX RT boards

The ITCM lists of these boards hold the sleep path of NuttX: usleep(), clock_nanosleep() and nxsig_nanosleep(). px4_usleep() now enters it through its own function and nanosleep(), which take the place of usleep(), so the path stays in ITCM. usleep() remains linked for the code that still calls it directly, such as the start-up code of the boards and NSH.

Assisted-by: Claude:opus-5.5

* fix(drivers): sleep for a second or more with px4_usleep()

bmi088_i2c, microstrain, frsky_telemetry and the bit rate detection of the kinetis, stm32 and stm32h7 UAVCAN drivers asked usleep() for a second or more, which POSIX doesn't require it to accept. The usleep() of NuttX accepts it, but px4_usleep() now does on every platform.

Assisted-by: Claude:opus-5.5
2026-10-14 10:36:30 -06:00
Benjamin Cabé 3fc3b141d7 feat(platforms/common): GUIDs of boards that override the UUID
Boards that override their UUID, such as SITL and the Linux boards, only had the functions that format the GUID, while DroneCAN and Cyphal send the GUID itself to the other nodes, so these drivers couldn't be linked for them. board_get_mfguid() and board_get_px4_guid() now give the bytes that the formatting functions print.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-12 12:45:09 +02:00
Jacob Dahl de52c98eff feat(cannode): bootloader update from the app and combined flash image (#28293)
* feat(bl_update): pet the watchdog during erase and program

CAN nodes start the IWDG in the bootloader, and nothing else pets it
while bl_update holds the scheduler lock.

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

* feat(nuttx): emit canbootloader to board extras and build bootloader+app image

canbootloader builds now write extras/<vendor>_<board>_bootloader.bin
like FMU bootloader builds do, which plugs CAN nodes into the existing
ROMFS / rc.board_bootloader_upgrade / jlink wiring. CAN node app builds
with that file also emit <config>_with_bootloader.bin (bootloader padded
to the app's ELF load address, followed by the CRC'd image) so a bare
board is flashed in one SWD step instead of two.

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

* feat(cannode): run rc.board_bootloader_upgrade at startup

The hook was only wired into the FMU rcS, so SYS_BL_UPDATE did nothing
on CAN nodes even with bl_update built in.

* feat(ark): enable bootloader update on CAN nodes

Ships the CAN bootloader in the app ROMFS so a node can rewrite it via
SYS_BL_UPDATE without SWD.

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

* docs(dronecan): bootloader update and combined image for CAN nodes

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

* build(ark): rebuild CAN node bootloaders from current main

The committed binaries predated the F412 chip-selection and linker fixes
and the NuttX 12.12 upgrade, so they no longer matched the source.

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

* feat(uavcannode): update the bootloader as soon as SYS_BL_UPDATE is set

Same approach as AP_Periph. Running the update on the next boot needed
two reboots and reported nothing over CAN: it ran before uavcannode
started, and the boot script printed "done" even when bl_update failed.
The node now flashes while running, skips an identical bootloader, and
the result reaches the flight controller through the existing log
message forwarding. A value left set from before boot is cleared rather
than acted on.

The flash routine moves into a library so uavcannode can call it.

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

* docs(dronecan): note that the combined CAN node image resets parameters

Found on the bench: the padding between bootloader and app covers the
parameter sectors, so every SWD flash of the combined image erases them.

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

* fix(nuttx): limit CAN bootloader extras and combined image to STM32

Every canbootloader build wrote its binary to the board's extras, so a
later nxp_ucans32k146 default or cyphal configure picked it up and failed
in prepend_bootloader.py: the S32K application loads at 0x6000, below
the 0x08000000 base the script and bl_update assume. CI only passed
because the canbootloader was built after both had configured.

Assisted-by: Claude:claude-fable-5-1

* fix(bl_update): pad the image before erasing and warn on every flash failure

The STM32F4 up_progmem_write() returns -EINVAL for an odd byte count,
which was only found out after sector 0 had been erased. An erase or
program failure also leaves the board without a bootloader, but only a
verify failure told the user to retry before rebooting.

Assisted-by: Claude:claude-fable-5-1

* fix(romfs): pack rc.board_bootloader_upgrade only where rcS runs it

CAN nodes with bl_update carried the script in their ROMFS although the
cannode rcS never sources it: uavcannode flashes the bootloader itself.

Assisted-by: Claude:claude-fable-5-1

* refactor(bl_update): move the flash routine to src/lib

The library lived under systemcmds, which is configured after drivers,
so uavcannode could only link it through a forward reference. The
watchdog is now selected by chip because the platform targets do not
exist yet when src/lib is configured.

Assisted-by: Claude:claude-fable-5-1

* docs(dronecan): the CAN bootloader is written to extras on STM32 only

Assisted-by: Claude:claude-fable-5-1
2026-10-06 15:42:33 -06:00
Igor Mišić b37b10a7c4 fix(vscode): set GZ_IP for the SITL (gz) debug configuration (#28994) 2026-10-05 11:27:01 +01:00
Peter van der Perk 47af69a503 build(nuttx): Update i.MXRT11XX clock startup
Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
2026-10-05 11:23:10 +02:00