Skip to content

AP_HAL_Zephyr: Buzzs new zephyr hal - #34319

Open
davidbuzz wants to merge 28 commits into
ArduPilot:masterfrom
davidbuzz:buzz-zephyr-v2
Open

davidbuzz wants to merge 28 commits into
ArduPilot:masterfrom
davidbuzz:buzz-zephyr-v2

Conversation

@davidbuzz

@davidbuzz davidbuzz commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds AP_HAL_Zephyr, a HAL backend running ArduPilot on Zephyr RTOS.
Includes Five initial board targets across Cortex-M7, Xtensa, RISC-V and a host build.

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Nothing here has flown. Every "verified" claim is bench work, named to a
board and a date. All five boards boot and run to some degree; coverage beyond that is uneven
and COMPARED_TO_CHIBIOS.md has the per-feature, per-board matrix.

  • mr_vmu_rt1176 took nearly all the hardware time: SPI/IMUs, bus DMA,
    UART/GPS, USB CDC MAVLink, RC in, PWM out, storage, SD logging, CAN/DroneCAN,
    crash dump and the resident bootloader.
  • ESP32S3Zephyr and CodeCell_C6: boot and USB CDC MAVLink, plus WiFi on the
    C6. Sensor, UART and storage rows are read off devicetree, not measured.
  • CubeOrangeZephyr: boot and run only. Open bug - micros() comes from TIM5
    and Scheduler::delay() measures ~68x short, so treat any micros()-derived
    number from that board as unverified.
  • native_sim: boot, storage and main loop. Not SITL - SITL replaces the HAL,
    native_sim exercises it.

Tools/CPUInfo/output-*.txt holds in-tree captures from all five Zephyr
targets plus two ChibiOS boards, so timings compare column for column.

Not a no-binary change: Tools/bootloaders/mr_vmu_rt1176_bl.bin is added, per
the existing ChibiOS convention, so firmware can reflash its own bootloader.

Description

Right now Board bring-up requires devicetree and Kconfig work, and i've started to demonstrate the ability to make the device tree overlay/s in hte generator. mr_vmu_rt1176 ->LPUART3 is generated the rest arent, yet.

waf board SoC Architecture
mr_vmu_rt1176 NXP i.MX RT1176 Cortex-M7
CubeOrangeZephyr ST STM32H743 Cortex-M7
ESP32S3Zephyr Espressif ESP32-S3 Xtensa LX7
native_sim host x86-64 Linux

Build. waf stays the top-level build and runs Zephyr's CMake build as a
sub-build, producing libzephyr.a to link against. Zephyr subsystems stay off
by default.

./Tools/scripts/zephyr_get_prerequisites.sh   # first time only
./waf configure --board=mr_vmu_rt1176
./waf copter

No west. Zephyr is an ordinary submodule. Its own dependency repos cannot
be, since git will not track paths inside another submodule's gitlink, so
Tools/scripts/zephyr_manifest_v4_4_0_map.tsv pins them: one row per
dependency with name, URL, commit and path. The prerequisites script reads
that map, creates every checkout, installs host packages, and fetches the
Espressif RF blobs against the SHA-256 in hal_espressif's own module.yml.

Parity gap to know before reading the code. There is no equivalent of
Shared_DMA. Every DMA channel is a fixed devicetree binding owned by one
peripheral at compile time, so no runtime borrow or evict and no contention
stats.

Docs. libraries/AP_HAL_Zephyr/README.md is the entry point, with
COMPARED_TO_CHIBIOS.md, ARCHITECTURAL.md, DEBUGGING.md,
PARITY_DETAIL.md, PROCESS.md and BOOTLOADER_SECURITY.md alongside it.
Per-board wiring is in hwdef/<board>/README.md.

More todo:

  • make an apj file (with git hash etc)
  • fill in "@SYS/threads.txt", uarts.txt, timers.txt
  • memory.txt should wrong number of memory regions
  • missing a lot of memory on orange: {brkval : 0, freemem : 65535, freemem32 : 80084}
  • remove or disable all the debug printfs

@davidbuzz davidbuzz changed the title Buzz zephyr v2 Buzzs new zephyr hal Sep 7, 2026
@davidbuzz
davidbuzz requested review from peterbarker and tpwrules and a lite review from Copilot and removed request for peterbarker and tpwrules September 7, 2026 22:49
@davidbuzz davidbuzz self-assigned this Sep 7, 2026

This comment was marked as low quality.

@tridge

tridge commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Deprecated — see below for the updated review.

Previous review (2026-09-08)

Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting.

Reviewed at head 7c95a9c820. Full report: https://uav.tridgell.net/DevCallReviews/2026_09_08/devcall_pr_reviews.html#pr34319

The bulk of this review was done at 50be295e20; you pushed seven commits during the run, so the 18-file / +268−52 delta to 7c95a9c820 was re-reviewed rather than assumed. That push closes three of the seven build blockers — thank you, and the status table below reflects the current head. This PR was deferred unreviewed by an earlier run today purely because of its size; it has now had four independent passes over three slices plus two cold passes and a cross-check.


The headline

All 59 failing CI checks are existing boards and tools broken by this PR. Not one of them is a new Zephyr target — no CI job builds a Zephyr board at all. Two reviewers independently fetched every failing job's log and built a ledger; both arrived at the same split: (a) new Zephyr target failing: 0; (b) existing board/test/tool broken by this PR: 59; (c) infrastructure or unrelated: 0.

That is the useful message, because with 59 red checks it looks like the port is failing when in fact the port isn't being built. Six of the seven root causes are one-line guard defects. The seventh is not.

Blocker status at 7c95a9c820

Blocker Status Evidence
BNO085 includes <zephyr/sys/printk.h> (23 jobs) FIXED by 9e81d8ad18 no zephyr/ include or printk remains
AP_InertialSensor_NONE outside its guard (12 jobs) FIXED by 2a7495059c HAL_INS_NONE branch is now // no INS device; detect() sits under #if ESP32 || ZEPHYR
CPUInfo unguarded tick symbols (1 job) FIXED by 589a9e7320 both sites guarded, incl. a non-Zephyr #else for ap_cyc_per_sec()
markdown lint / trailing whitespace FIXED afcd8b26b3, 7c95a9c820
APM_BUILD_Heli on every library object (10 jobs) STILL OPEN see below
AP_BOOTLOADER_MCUBOOT_AB undefined (8 jobs) STILL OPEN mcuboot_ab.h still included only inside #ifdef __ZEPHYR__
AP_BATTERY_ENABLED guarded before its header (2 jobs) STILL OPEN no AP_BattMonitor_config.h include above AP_DroneCAN.cpp:33
chain_profile.h enum comment breaks logger_metadata STILL OPEN multi-line trailing comment on AP_PHASE_SCHED_TASKS unchanged

The one that matters most

Every vehicle-dependent library object is compiled as APM_BUILD_Heli on a plain ./waf.

Tools/ardupilotwaf/ardupilotwaf.py:458 deletes the eager bld.ap_library() loop from ap_stlib(), and Tools/ardupilotwaf/ap_library.py:175 moves the call into process_ap_libraries — i.e. from wscript-recursion time to taskgen-post time. By then _select_programs_from_group() has populated bld.targets, so get_legacy_defines()'s 'heli' in bld.targets test (ardupilotwaf.py:140) is true for every vehicle.

Measured on fmuv3, clean tree, plain ./waf:

merge base this PR
exit code 0 1
undefined reference lines 0 33
APM_BUILD_DIRECTORY histogram AntennaTracker 17, ArduCopter 74, ArduPlane 64, ArduSub 37, Blimp 27, Rover 140 same, but Rover 38 and Heli 113
distinct AP_Vehicle.cpp.*.o 4 1 (all 8 byte-identical)

Proved by mutation: restoring the eager loop makes the head build green, restores the histogram, and restores the four distinct objects. Two reviewers reproduced this independently.

This is worse than a build break. ./waf copter is unaffected, which is why some CI jobs pass — but wherever the multi-vehicle link does succeed, you get library code silently compiled with the wrong vehicle's semantics, including scheduler defaults. Suggested fix: keep the eager bld.ap_library() in ap_stlib (it takes extra_defines fine), or stop get_legacy_defines() depending on mutable bld.targets. Related, same commit: ap_library.py replaced the stable idx=0 for common objects with a shared counter, so ./waf antennatracker followed by ./waf copter now leaves a single AP_Vehicle.cpp.2.o where the base leaves two.

Shared-code changes needing a decision, not a guard

  • wait_for_sample()'s new ~100 ms timeout is not board-gated (AP_InertialSensor.cpp:2116, :2172), so it applies to flying ChibiOS hardware. Compiled in a bounded no-samples harness against the real function bodies: base keeps waiting; head returns after 100,100 µs with _have_sample=1 and both new-data flags false. To be fair about the downstream effect — the cross-check established that get_delta_time() clamps to ten loop periods, so this does not feed an unbounded ≥100 ms timestep to the EKF, and I've withdrawn that part. What remains is that the main loop now continues past a total IMU failure instead of tripping the watchdog, on every board. Please put it behind #if CONFIG_HAL_BOARD == HAL_BOARD_ZEPHYR, or argue it on its own merits.
  • ExternalAHRS IMU detection is now keyed on parameters, not a working backend (AP_InertialSensor.cpp:1219-1223): enabled() is devtype != None and has_sensor() is a parameter bitmask; the old get_port() required backend != nullptr. So a type whose backend failed to construct or isn't compiled in still registers an AP_InertialSensor_ExternalAHRS as IMU 0, shifting _first_onboard_imu_instance and the real IMUs' numbering. serial_port is also an int8_t -1 reaching a uint8_t parameter, so 255 lands in make_bus_id().

Dependency

.gitmodules adds modules/zephyr → https://github.com/davidbuzz/zephyr.git, branch main_buzz. To be explicit that this is not the usual objection: a submodule pointer moving to an unmerged commit in an ArduPilot-owned repo is normal and expected here, and that is not what's being reported. This is a personal fork, and it needs an ArduPilot-owned home before merge regardless of the code. (check_branch_conventions.py also failed on reachability of the pin; a fresh compare during the cross-check found the SHA is now reachable from that fork's master, so that part may already be resolved.)

Separately, the 24 carried Zephyr patches under libraries/AP_HAL_Zephyr/zephyr/patches/ are never applied or verified by anything — no git apply/git am/patch -p1 in zephyr.py or the prerequisites script, and no SHA or hash check, so a stale patch is undetectable by construction. That's already true of pr-113193-udc-dwc2-dp-pullup, which is absent from the pinned tree, while 14 of the 24 are already in the fork. And Tools/scripts/zephyr_manifest_v4_4_0_map.tsv:31 pins hal_espressif at a SHA that doesn't exist upstream (upload-pack: not our ref; a control SHA fetches fine), so under set -euo pipefail the prerequisites script aborts before the SDK install — nobody but you can complete prerequisites for any board today.

Zephyr-only — not merge blockers for existing boards, but fix before anyone flies these targets

Every file cited here is byte-identical between 50be295e20 and 7c95a9c820, so all of it still applies.

  1. AnalogIn::read_pin_raw() null-dereferences for pins 2–3 (AnalogIn.cpp:140). _adc_ready comes from _adc1 only (:109), valid_analog_pin() accepts pin < 4, and _adc2 is legitimately null on mr_vmu_rt1176 — the code says so and even claims "see the null guard in read_pin_raw() below", which doesn't exist. BATT_VOLT_PIN=2 hard-faults the FC. One line.
  2. ap_lpi2c_hard_reset() is indexed 1-based and called 0-based (I2CDevice.cpp:61-73, call site :220). bases[] is {0, LPI2C1, LPI2C2, LPI2C3} but _bus is the 0-based AP index. So AP bus 0 returns without resetting — the exact case the function exists for — and AP bus 1 resets LPI2C1, possibly mid-transfer, from a thread not holding that bus's semaphore.
  3. Failed parameter writes are marked clean on ZMS/FRAM/SD (Storage.cpp:~437). ok is only ever set false by the ROM-flash branch; the other three discard their write results, then the dirty bit is cleared anyway — so a failed write leaves the retry queue and healthy() stays true, defeating the "Param storage failed" prearm you reinstated a few lines above. FRAM is CubeOrangeZephyr's backend. Also erase() has no ROM-flash branch and returns true unconditionally, and the dirty bit is cleared without re-checking whether write_block() re-dirtied the chunk during the write.
  4. micros64() on Xtensa overflows after 71.6 minutes (system.cpp:224). (xtensa_cycles64() * 17895697ULL) >> 32 — the scale factor is right, but the multiply overflows uint64 at 1,030,792,154,881 cycles = 4,294.967 s at 240 MHz, so the wrap extension buys nothing over a 32-bit µs counter. DeviceBus.cpp:209 compares this against absolute deadlines.
  5. CAN select() treats an absolute deadline as a relative timeout (CANIface.cpp:199). The ChibiOS implementation names it blocking_deadline and waits blocking_deadline - micros64(); AP_CANSensor.cpp:129 passes micros64() + timeout_us. At 60 s uptime a 1 ms wait becomes ~60 s. Also CANIface.cpp:81 installs a standard-ID filter only if the extended-ID one fails, so standard-ID sensors can't receive alongside DroneCAN; and can_send(…, K_NO_WAIT, nullptr, nullptr) at :126 selects Zephyr's synchronous path, which waits K_FOREVER for completion.
  6. thread_create() silently halves AP_Scripting's stack and returns success (Scheduler.cpp:888-915). Lua asks for 17 KB and gets 8192, with CONFIG_HW_STACK_PROTECTION=n on rt1176 so the overflow is silent corruption. It should return false.
  7. The device-bus pool caps at 4 and fails silently (DeviceBus.cpp:47, :282). A plain #define (not #ifndef), and the overflow returns nullptr with no printk and no INTERNAL_ERROR, unlike every neighbouring path — while your own comment at :216-223 allocates slots for six. To be fair: mr_vmu_rt1176 declares five buses but that doesn't prove five allocated threads (SPI1's sensor answers WHOAMI 0x44 and a failed probe registers no callback), so overflow on the default config isn't demonstrated — the latent capacity limit and the silent failure are the finding.
  8. A parameter-format change keeps the old parameters and never records the new version (AP_Vehicle/Parameters.cpp:13-33). The comment explains skipping StorageManager::erase(), but the #else also skips format_version.set_and_save(...), so a Zephyr board re-detects the mismatch on every subsequent boot. The set_and_save looks like collateral rather than intent.
  9. Board hwdefs contain silent no-ops because zephyr_hwdef.py:214-369 is an if/elif chain with no else: warn. Found: AP_DRONECAN_ENABLED, AP_LOGGER_ENABLED, AP_AIN_ENABLED, HAL_CAN_ENABLED, AP_NOTIFY_ENABLED in the ESP32S3/CodeCell hwdefs are read nowhere in the tree, so the claimed RAM savings never happen (the real names are HAL_ENABLE_DRONECAN_DRIVERS, HAL_LOGGING_ENABLED, and the per-backend AP_NOTIFY_*_ENABLED); CubeOrangeZephyr/hwdef.inc:291-292 sets HAL_BATT_VOLT_PIN 14 / HAL_BATT_CURR_PIN 15, which AnalogIn rejects as ≥ 4, so battery voltage and current can never be read; all 88 PAn/PBn lines are dropped so that board has no GPIO map at all; and hwdef.inc:130 includes a sdcard.inc that doesn't exist. Latent parser bugs worth fixing now: 1.5*MHZ parses to 1 Hz via int(float(…)) (five ChibiOS hwdefs use 7.5*MHZ, so the first port that copies one gets a 7 Hz SPI bus), and the I2C_ORDER filter tests startswith('I2C') so an LPI2Cn token is dropped and no bus lookup is emitted at all.
  10. CubeOrangeZephyr enables HAL_HAVE_IMU_HEATER, and AP_Arming.cpp:1133-1151 gates arming on IMU temperature. (Fairly: AP_BoardConfig implements the heating loop itself, so the absent Util::set_imu_temp() override isn't on its own proof the board can never heat — but it's untested and it gates arming.)
  11. Also: UARTDriver::_tx_dma_kick() (:716-740) advances bytes out of the ring before attempting uart_tx() and abandons them on failure, after _write() already reported them accepted — a torn MAVLink frame or truncated RTCM on the DMA path. AP_ExternalAHRS_BNO085::shtp_read() (:101-125) accepts a length of 1–3 and returns rd - 4, underflowing to ~65535 as uint16_t, then walked over a 384-byte buffer. GPIO::_attach_interrupt() ignores both Zephyr return codes and returns true. RCOutput::write() re-enables a channel disable_ch() turned off, and _apply_channel() discards pwm_set() errors including the zero-duty disable. GPIO::valid_pin() returns (pin >> 5) < 8 without consulting the pin table. Creating a fast-mode I2C device after a standard-mode one raises the shared bus clock and never restores it, and I2CDevice::_timeout_ms is stored but never read, so a wedged bus blocks forever — which also means the ap_lpi2c_hard_reset() recovery in (2) is never reached.

On the micros() defect — the tree records two explanations and neither survives

prj.conf:233 sets CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000000 for every board, and prj.conf:197-200 says that's only safe because "the board DTS now sets &systick { zephyr,min-timeout-cycles = <10000>; }". Only mr_vmu_rt1176_mimxrt1176_cm7.dts:1861-1863 has it — cube_orange_zephyr.dts has no &systick node at all, nor do the ESP32-S3 or CodeCell C6 files. That asymmetry is real and worth fixing regardless.

But the cost is smaller than the tree claims, and I initially got this wrong myself. At 480 MHz, CYC_PER_TICK = 480 and MIN_DELAY = MAX(1024, 30) = 1024 cycles = 2.13 µs, so the floor does exceed the 1 µs quantum and single-tick sleeps are clamped — delay_microseconds(1) costs ~2.1 µs, consistent with your own CPUInfo capture of 4.1 µs/call. What it does not explain is prj.conf's recorded "every k_msleep(1) returned in ~15 µs instead of 1000 µs": a 1 ms sleep is 1000 ticks = 480,000 cycles, three orders of magnitude above a 1024-cycle floor and well inside SysTick's 24-bit range, so it is never clamped. And the other explanation — COMPARED_TO_CHIBIOS.md:48-55 attributing it to TIM5 mis-scaling — doesn't hold either, since system.cpp:54-71 derives TIM5->PSC from LL_RCC_GetSystemClocksFreq(), whose plausible failure modes are 1× or 2× (the APB doubler), not 68×.

So: the missing DTS override is real with a modest cost, the ~68× symptom you measured is real and acknowledged, and both written-down mechanisms are wrong. Since micros() underpins the EKF, the scheduler and every filter time-step, that's worth pinning before the board is trusted — and the tooling exists and has already run on two other boards (output-mr_vmu_rt1176.zephyr.txt:19-25 has the micros-vs-k_uptime table; the CubeOrange capture is truncated before it). One CPUInfo run on the H7 would settle it.

Checked and found genuinely neutral — stated explicitly, because with 59 red checks it's easy to assume the worst

  • AP_HAL_ChibiOS/hwdef/common/ffconf.h: preprocessing base and head against the same generated CubeOrange hwdef gives identical macro tables. No FATFS setting changed.
  • The AP_NavEKF3 O3 pragma is genuinely opt-in — EK3_OPTIMIZE_O3 is defined in exactly one place (CodeCell_C6/hwdef.dat:61); every other board still takes O2.
  • AP_Scheduler's default loop rate is #ifndef-guarded and overridden only by mr_vmu_rt1176.
  • ArduCopter/rate_thread.cpp's +41 lines are entirely inside the Zephyr guard — zero flash and zero RAM on a 1 MB F4.
  • bl_protocol.cpp is not a wire-protocol change: no new or altered PROTO_* commands, APP_VECTOR_OFFSET defaults to 0 so app_base and SCB_VTOR are numerically identical everywhere, and JUMP_MARK/JUMP_FAIL are do {} while (0) off-Zephyr.
  • The vendored monocypher is not a second divergent copy — it's the upstream Monocypher 3.1.2 optional ed25519 module, byte-identical apart from a provenance comment, with crypto_ed25519_check() verbatim, and nm on a ChibiOS image finds zero crypto_* symbols (dead-stripped, no flash cost). One caveat: it's currently dead code, since its only consumer is behind AP_MCUBOOT_AB_PUBKEY which is never defined — while AP_BOOTLOADER_MCUBOOT_AB is 1 on Zephyr, so the A/B adoption path today accepts a slot-1 image on SHA-256 integrity alone. Worth either wiring up or documenting unambiguously.
  • ./waf configure --board CubeOrange produces byte-identical ap_config.h, hwdef.h, ldscript.ld and processed_defaults.parm at both revisions; a key-by-key diff of all three c4che caches (177 keys) differs in exactly one, the new ZEPHYR_SHIP=False. list_boards is purely additive. ./waf clean still behaves identically on ChibiOS.
  • New board IDs AP_HW_CodeCell_C6 1251 and AP_HW_ESP32S3Zephyr 1252 are free and unique; validate_board_list.py passes. The committed mr_vmu_rt1176_bl.bin follows the existing convention (823 such binaries already live there). One gap: build_bootloaders.py discovers boards only from AP_HAL_ChibiOS/hwdef/*/hwdef-bl.dat, so this one can't be regenerated by the standard tool, and the commit records no SDK version.
  • AC_PosControl.cpp's GCC 14.3 workaround really is a false positive and behaviour is identical; measured cost on CubeOrange/GCC 10 -O2 is +2 bytes of .text.

Three changes here are genuine unrelated bug fixes that would merge immediately on their own: cmake.py:172 return self._original_run() (cmake configure failures were previously swallowed on all boards), ap_library.py:433 self.use → use, and the AP_Notify add_backend_helper nullptr check (a null NEW_NOTHROW result was previously dereferenced immediately, on every board).

Verdict: REQUEST CHANGES — with the reason kept narrow

The port itself is better than "unflown" usually implies. The semaphore mapping onto k_mutex is correct (recursive and priority-inheriting, which is exactly what WITH_SEMAPHORE needs), the thread-priority model carries static_asserts on the relationships rather than the numbers, the ring buffers reuse ArduPilot's own ByteBuffer, nearly every non-obvious constant carries a dated hardware measurement, and COMPARED_TO_CHIBIOS.md is an unusually honest self-assessment that mostly holds up against the code — several gaps I'd otherwise have reported are already in it, correctly worded. The one-subsystem-per-commit split is exactly what ArduPilot asks for and is the only reason 46k lines were reviewable at all.

What blocks it is that the shared-code layer isn't yet inert. ./waf configure --board CubeOrange && ./waf, plus ./waf bootloader, a SITL build, a Linux build and ./waf --targets=tool/CPUInfo, catches every remaining build blocker locally in one sitting.

A split the commit structure already supports, if it helps:

  1. Now, independently: the two unrelated bug fixes above (they're pure wins with no Zephyr content).
  2. The enabling layer — HAL_BOARD_ZEPHYR, minimize.h and the guard commits — once the remaining unconditional leaks are gated. Lands with zero behaviour change for existing boards.
  3. waf plus one board: mr_vmu_rt1176, the only one with real hardware time behind it. This is where the object/defines rework belongs, and it needs replacing rather than adjusting.
  4. The HAL drivers.
  5. The remaining four boards, one PR each — a30870ecc8, b47f290004, e2e10207dc and 6b35b89aeb are already self-contained.

Separately and before any of it: modules/zephyr needs an ArduPilot-owned home and a manifest that resolves.

@davidbuzz

Copy link
Copy Markdown
Contributor Author

response to ai: '59 failing CI' - most of this was a transient CI glitch this morning that peter was talking about. I have fixed a few smaller things too.

Comment thread libraries/AP_NavEKF3/AP_NavEKF3_core.h Resolved

@peterbarker peterbarker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partial review only - github interface started to explode.

Comment thread libraries/AP_Arming/AP_Arming.cpp Resolved
Comment thread libraries/AP_DroneCAN/AP_DroneCAN.cpp Resolved
Comment thread ArduCopter/rate_thread.cpp Resolved
Comment thread libraries/AP_DroneCAN/AP_DroneCAN.cpp Resolved
Comment thread libraries/AP_DroneCAN/AP_DroneCAN.cpp Resolved
Comment thread libraries/AP_HAL/board/minimize.h Resolved
Comment thread libraries/AP_HAL/board/zephyr.h Resolved
Comment thread Tools/AP_Bootloader/AP_Bootloader.cpp Resolved
Comment thread libraries/AP_HAL/board/chibios.h Resolved
davidbuzz and others added 27 commits October 8, 2026 21:21
… needs

A checkout now resolves modules/zephyr to one revision: 851d97ff1d on
davidbuzz/zephyr, branch main_buzz. That is Zephyr main a long way past
v4.4.0, at v4.4.0-7956-g851d97ff1d7 with VERSION 4.4.99. The fork
carries 21 local patches for parts the HAL needs: cdc_acm and ESP32 USB
serial RX, the dwc2 D+ pull-up for the ESP32 USB OTG PHY, ESP32 WiFi AP
mode and TX power limits, NXP i.MX RT lpspi, lpi2c, lpuart, igpio and
FlexPWM, an STM32 SPI interrupt fix, placement new and std::nothrow, and
C linkage for arch_num_cpus().

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- allocate HAL_BOARD_ZEPHYR and add the Zephyr board header
- drop the ESP32-C6 reference from the Zephyr board header
- drop the RISC-V double-precision case from the Zephyr board header

AI-assisted (GitHub Copilot).
…lasses

- add the Zephyr backend, hwdef and devicetree generators, board classes
- pad the built .apj so bin/<board>.apj boots
- place selected objects in RAM for Zephyr boards, and keep -Os
- drop the RISC-V Espressif devicetree root from the Zephyr generator
- apply the Zephyr ramtext rename only on the RT1176
- build EKF, AP_Math and Filter at -O3 on ESP32S3Zephyr
- map SERIAL_ORDER OTG1 to ESP32 usb_serial as a fallback

AI-assisted (GitHub Copilot).
…del everywhere

AI-assisted (GitHub Copilot).
- add ZephyrLEDStrip, a bit-banged SK6805 board LED for ESP32-C6
- remove the ZephyrLEDStrip backend

AI-assisted (GitHub Copilot).
…nd diagnostics

- route GCS_SEND_TEXT through one function, plus portability fixes
- trace FTP replies while diagnosing a stalled worker
- count the MAVFTP worker and reply path
- wake the FTP worker on a request, bound push_reply()
- add send-path counters to the MAVFTP diagnostics
- report the MAVFTP send counters over MAVLink
- guard the Zephyr-only FTPDIAG printk calls

AI-assisted (GitHub Copilot).
- give Zephyr the 10s io thread heartbeat timeout ESP32 uses
- time the io_timer phases to name the stuck-thread blocker
- move the io_timer diagnostic reporting off log_io
- drop a no-op left in the io_timer instrumentation

AI-assisted (GitHub Copilot).
…tion

- new HAL backend on Zephyr, four board targets and documentation
- drop references to the removed ESP32-C6 target
- put the mr_vmu_rt1176 console on USB CDC
- build CRSF telemetry for mr_vmu_rt1176
- implement is_dma_enabled() and bw_in_bytes_per_second()
- keep XIP usable across a ROM flash erase or program
- place the fault path in ITCM so a fault can be recorded
- carry the fault record across the reset and report it
- mr_vmu_rt1176 loop rate 190 Hz to 466-483 Hz
- fix the mr_vmu_rt1176 IMU rotation, HUD was inverted
- measure bus-callback cost and the CPU bands
- bound I2C retries, raise loop yield, extend ITCM
- dump the FlexPWM submodule registers for the motors
- check pad mux and counter advance in the FlexPWM dump
- fix defects in the bring-up diagnostics
- remove the remaining ESP32-C6 references
- fix ESP32S3Zephyr build broken by Cortex-M-only diagnostics
- let hwdef override pool, stack and bus sizes
- ESP32-S3 save FPU registers on context switch, trim RAM
- enable WiFi softAP on ESP32S3Zephyr
- ESP32S3Zephyr: size user thread stacks to 4 KB
- treat usb_serial as USB, quiet unmapped serial ports
- run ESP32-S3 as a dual-USB-port board

AI-assisted (GitHub Copilot).
…ernor hunting

- clear the spool-up block when the takeoff checks are compiled out
- stop the fast-rate governor hunting

AI-assisted (GitHub Copilot).
- bench scripts, Renode models and CPUInfo buses for the Zephyr port
- add the Zephyr ramtext section renamer
- drop the RISC-V frame-size exception from CPUInfo
- refetch @SYS/tasks.txt after 5s and never keep the first read

AI-assisted (GitHub Copilot).
- add pre-flight notes for mr_vmu_rt1176, plus the measurements
- record why the mr_vmu_rt1176 HUD was upside down (UNFLOWN)
- extend the mr_vmu_rt1176 day-2 pre-flight record
- start the attempt-3 pre-flight record for mr_vmu_rt1176
- record the FlexPWM register evidence in the attempt-3 notes
- record the attempt-3 outcome for mr_vmu_rt1176

AI-assisted (GitHub Copilot).
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Global Size Summary (Total Flash delta in bytes)

Built from 037b8fd rebased onto 1f1251a

Board Periph tracker blimp bootloader copter heli iofw plane rover sub
DrotekP3Pro _ _ _ * _ _ _ _ _ _
Durandal _ -1280 -1408 _ -2108 -2208 _ -2712 -2692 -2216
Hitec-Airspeed * _ _ _ _ _ _ _ _ _
KakuteF7 _ -496 -580 _ -512 -584 _ -1192 -1208 -852
MambaH743v4 _ -1140 -1252 _ -1812 -1936 _ -2268 -2616 -1812
MatekF405-CAN _ _ _ * _ _ _ _ _ _
MatekF405 _ -540 -624 _ -556 -628 _ -1236 -1252 -896
MatekH743-bdshot _ -1252 -1380 _ -2096 -2196 _ -2700 -2684 -2200
Pixhawk1-1M _ -524 -632 _ -1012 -1084 _ -1356 -1352 -928
disco _ +632 +532 _ -2092 -1750 _ -1132 -1348 -570
f103-GPS * _ _ _ _ _ _ _ _ _

@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: REQUEST CHANGES

Reviewed at head 037b8fd7b4.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/ardupilot/34319/1.html#pr34319

Re-reviewed at 037b8fd7b4 (previously 7f08566aac; the branch was squashed to 28 commits, so every earlier point was re-checked against the current tree rather than via an interdiff). The per-subsystem history is a real improvement.

What blocks at this head:

  1. AP_GPS change breaks the build of existing AP_Periph boards that define GPS_MAX_RATE_MS. The new defaults are inside that #ifndef, and MatekL431-GPS fails at libraries/AP_GPS/AP_GPS.cpp:892. libraries/AP_GPS/AP_GPS.cpp:90 (https://github.com/ArduPilot/ardupilot/pull/34319/files#diff-9ec3bf94de54f09861eca7a5fce5e211b60025607b8e27ae4fef0a0edfe541b0R90)
  2. CI is red. Both Renode missions fail building the bootloader on -Werror=type-limits at libraries/AP_HAL_Zephyr/UARTDriver.cpp:171, and lint, ruff, markdownlint and the submodule check also fail. libraries/AP_HAL_Zephyr/UARTDriver.cpp:171 (https://github.com/ArduPilot/ardupilot/pull/34319/files#diff-582878a1b2d43a76f71e48bfe5819039e1cc2f0d2ea3b1e4afd3ef5c49de04e3R171)
  3. Debug instrumentation in shared code: the FTP counter STATUSTEXTs every 2 s on all vehicles, the LOGDIAG globals in AP_Logger_File.cpp, and the "not for merge" RATELOOP printf in ArduCopter/rate_thread.cpp:464. Your notes already say these must come out. The fast-rate governor change wants its own PR. libraries/GCS_MAVLink/GCS_FTP.cpp:121 (https://github.com/ArduPilot/ardupilot/pull/34319/files#diff-4f12f26607b44951527f83d9bad9718a1e4b37d37de35fc0cbe7e30c4b3dc576R121)
  4. HAL_BARO_ALLOW_INIT_NO_BARO, the INS NONE fallback and the IMU wait escape apply to every Zephyr board, which disables the baro prearm check on CubeOrangeZephyr and mr_vmu_rt1176. Please make these hwdef settings for the sensorless targets only. libraries/AP_HAL/board/zephyr.h:106 (https://github.com/ArduPilot/ardupilot/pull/34319/files#diff-269d672be214f2a9471e97e76761b64bcedc4b6bf6907dc48387e3282759d216R106)
  5. RCOutput is still unserialised. force_safety_on() and dshot_tick() race (a completed safety request can be overwritten), and DShot reads the live _period_us[], bypassing cork/push. libraries/AP_HAL_Zephyr/RCOutput.cpp:317 (https://github.com/ArduPilot/ardupilot/pull/34319/files#diff-98bb7b0c217b971d24547aa1e1bae11324278a6b791d7e157041c4d82ec41b2aR317) libraries/AP_HAL_Zephyr/RCOutput.cpp:349 (https://github.com/ArduPilot/ardupilot/pull/34319/files#diff-98bb7b0c217b971d24547aa1e1bae11324278a6b791d7e157041c4d82ec41b2aR349)
  6. UART re-begin: after uart_rx_disable(), the RX timer can re-enable reception while _readbuf is being resized. This is UNCONFIRMED against the real driver's event timing, so please either show it cannot happen or quiesce the restart path during resize. libraries/AP_HAL_Zephyr/UARTDriver.cpp:277 (https://github.com/ArduPilot/ardupilot/pull/34319/files#diff-582878a1b2d43a76f71e48bfe5819039e1cc2f0d2ea3b1e4afd3ef5c49de04e3R277)

Should fix: board IDs 1252/1253 are inside the reserved Simplifly range; a write-only CAN select() blocks on RX; pinMode(OUTPUT) drives relay pins low on every status read; SD erase() hides failures and races _timer_tick(); STM32 timers share one period across channels with different rates; requested DShot150/300/1200 is sent at 600; WiFi TCP short sends lose data; the Zephyr bootloader never sees a watchdog reset; the mcuboot TLV walk is unbounded. The three root notes files and the allowed_subsystems.py change that admits them should go, and the description needs updating (CodeCell_C6, the 68x bug, script paths). A first flight log is still the main ask.

Not covered: no Zephyr build, hardware or Renode run here; modules/zephyr beyond the PWM drivers, the Renode C# models and the *.md set were not reviewed. One of the three passes was incomplete and did not reach most of the waf/Renode tooling, the board DTS/Kconfig/linker files, the GPIO/AnalogIn/DSP, Util and Scheduler sections, or the shared-library hunks, so no finding should be read as a clean bill for those areas. CI results are from the stored snapshot of this head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AIReview Copter EKF ExternalAHRS github_actions Pull requests that update GitHub Actions code MAVLink Python WikiNeeded needs wiki update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants