feat: rebase OTAFIX onto adafruit mainline 0.11.0 (#25) - #32
feat: rebase OTAFIX onto adafruit mainline 0.11.0 (#25)#32jamesarich wants to merge 118 commits into
Conversation
This flag is also present in the Makefile and optimises the resulting binary for the size of the binary. Without that flag the flash consumption would be too high to fit inside the allocated space. Signed-off-by: Andreas Kurz <info@akurz.net>
In this repository CMake and Make co-exists. Unfortunately there was no documentation on how to properly use CMake so this is a starting point. Signed-off-by: Andreas Kurz <info@akurz.net>
…ith RTT printf retarget
add CONFIG_GPIO_AS_PINRESET
fix: CMake build producing too large binaries
…ixes chore: update uf2 submodule and fix a small typo
Adding Omnimo-nRF52840 board
fix: repair build with DEBUG=1 option
# Conflicts: # README.md
feat: add support for SoftDevice S340
fix boot loop due to wrong value read from REGOUT0
feat: finalize SoftDevice S340 support
Update buildsystem
…ompatibility with Nordic DFU apps) and WriteWithResponse (for improved reliability)
Improve bootloader version parsing from GIT_VERSION
…line board.h contract Mainline renamed BUTTON_1/BUTTON_2 to BUTTON_DFU/BUTTON_DFU_OTA, dropped BUTTONS_NUMBER, and provides PINNUM() from boards.h — the 14 boards that only exist here are translated mechanically. The 3 boards mainline also ships (t1000_e, both xiao) keep mainline's board.h and only gain the per-board DFU advertising name in board.mk. board.cmake files dropped: the CMake path was never wired here.
screen.c/images.c are OTAFIX's size-agnostic, Meshtastic-branded versions (OLED UF2 + BLE-OTA screens); boards.c gains the ST7735 controller init next to mainline's ST7789; UF2_VERSION carries submodule versions, with UF2_VERSION_BASE for the screen.
when booting into dfu mode, the default will ota dfu unless specifically directed to enter a different mode (cherry picked from commit db8dc4d)
Co-authored-by: Rastislav Vysoky <recrof@gmail.com> (cherry picked from commit 1d8194f)
) * fix: size CURRENT.UF2 to the real installed app, not the max region CURRENT.UF2 (the on-the-fly dump of whatever's currently flashed, generated by read_block()) has reported and generated content sized to TRUE_USER_FLASH_SIZE - the max possible app+SoftDevice region - rather than how big the actually-installed app is. On a RAK4631 running Meshtastic 2.7.26, that meant CURRENT.UF2 was ~390KB larger than the official firmware image (3728 vs 2966 UF2 blocks), padding out with whatever's physically sitting in flash past the real app+SD boundary. Copying CURRENT.UF2 back onto the drive to restore the app it came from - a workaround documented as working by users hitting stuck-in- DFU-mode bugs (adafruit#201) - reproducibly hung the device on real RAK4631 hardware while investigating the nrfx/tinyusb bump in #19, on both this repo's current bootloader and the bumped one (a control test on the unmodified bootloader hung the same way, ruling out the bump as the cause). adafruit#38 (2018) fixed a related CURRENT.UF2 problem by sizing it off bootloader_settings.bank_0_size - the real recorded size of the currently-installed app - instead of a fixed constant. That fix has no trace left in the current file; this restores the same idea (current_flash_size(), with the same zero/erased-flash fallback to the max region) grafted onto the current SoftDevice-decoupled code from adafruit#128, which computes the max bound differently (TRUE_USER_FLASH_SIZE) than the 2018 code did. Verified: all 14 boards still build via tools/build_all.py. Hardware retest of the exact CURRENT.UF2 dump-and-restore sequence that hung before is next. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: record real app size on UF2 app-flash completion ghostfat.c's current_flash_size() (this branch's other commit) reads bootloader_settings.bank_0_size to size CURRENT.UF2 to the real installed app. But tud_msc_write10_complete_cb()'s app-completion branch never set update_status.app_size before calling bootloader_dfu_update_process() - it stayed 0 from the initial memset, so bank_0_size was always recorded as 0 for any app flashed via plain UF2 drag-and-drop (as opposed to the DFU-serial protocol, which transmits size upfront and was unaffected). Verified on hardware: after this fix, CURRENT.UF2 exactly matches the real firmware size (1518592 bytes, matching the official release UF2 byte for byte) instead of the previous 1908736 bytes of padding. The CURRENT.UF2 dump-and-restore sequence that reproducibly hung the device before now completes in ~2 seconds with no hang. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 18758d9)
(cherry picked from commit f9f9f51)
this fixes the issue where boards wouldn't automatically boot to app after successful ota update when connected to usb host (cherry picked from commit 02fc9bd, applied by hand: mainline's block calls disable_softdevice())
(cherry picked from commit 7e69127)
fixes an issue introduced with lazy erase, where small packets could overflow the lazy erase buffer and flash write queue when PRNs were set above 3–4. introduces a packet accumulator at the transport layer to combine small packets before writing to flash. this reduces pressure on the lazy erase buffer and flash write queue, and also provides a modest speed boost for transfers using small packets. (cherry picked from commit 54a9e85)
CI workflow (pinned actions, scoped permissions, per-board matrix), agent and community docs, changelog, renovate config, DFU screenshots. Drops the s340 SoftDevice mainline still vendors (no ANT boards here) and regenerates supported_boards.md for the 17-board matrix. Mainline's removal of segger/ and docs/oldsettings.md is kept.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
Content resolution: this branch's tree wins everywhere — master's nrfx-3.x/tinyusb pins, linker shim and nrf_wdt rename are the bump this rebase deliberately leaves out (mainline pins nrfx v2.0.0). Only AGENTS.md takes master's newer text (#31). Merge exists so the PR is mergeable against master and CI runs.
|
RAK4631 hardware pass on
Not yet: BLE OTA via the Android app, display boards, the other 15. Found one real bug while testing: Side note for anyone repeating this: the 1200-baud touch is handled by the app, and 2.8.0 dev builds ignore it - use |
|
Correction on the |
|
BLE OTA via the Android app (snapshot 29321961, legacy DFU, PRN 5, packet 244) fails on |
…e on this base RAK4631, Android snapshot app, legacy DFU PRN 5: stream stops after the first 4K page (PRNs at 1220..4880, nothing at 6100) and the link drops on supervision timeout, twice. With this reverted the same transfer completes (729,528 B in 47 s). Mainline's upfront erase costs a few seconds before the transfer instead. Re-porting lazy erase onto mainline's pstorage/flash queue model is its own job. This reverts commit 1458940.
|
BLE OTA A/B, same RAK4631, same Android snapshot, same
So two things:
Ledger updated: Separately, the app's post-update BLE reconnect to the node timed out on the master run even though the node was up on USB - Android side, not this repo. |
|
App-jump wedge, what's been eliminated on the bench (each a separate bootloader flash + in-app OTA on the RAK4631):
Shape: attempt 1 (SoftDevice inherited from the app) connects, START is sent, then silence - ~5 s with lazy erase, ~21 s without (≈ the upfront erase of 729 KB) - link drops on supervision timeout, device stops advertising, LEDs solid, no reset until the DFU inactivity timeout (~60-90 s). After that reset (SD freshly enabled by the bootloader) the same transfer completes. Master streams on attempt 1. Still-open candidates, all mainline-only on this path: |
|
Why the wedge clears after ~90 s: it's the application's watchdog, not anything in the bootloader. Meshtastic's nRF52 firmware arms the WDT, a WDT can't be stopped, and app-jump keeps it running. The bootloader feeds it from |
|
Correction to the A/B table: master is not clean on app-jump either. It streams on attempt 1 but hangs for the same ~90 s after |
Correction: most of the app-jump "wedge" was a USB-connected-testing artifactRetested battery-only (RAK on battery, USB unplugged, stock app 29321961, this branch's bootloader So the earlier findings on this path need walking back:
What is real, battery-only: the transfer still stalls ~1-2 min at the start and burns the app's first retry cycle(s) before it catches. That is the upfront full-erase of the app region on Consequence for the WIP app-jump fix: the |
Lazy erase re-ported — validated on hardware ✅Branch Approach: keep mainline's pstorage untouched; do the on-demand erase synchronously in Change is one file, +61 lines. 17/17 boards build. Hardware, RAK4631, battery-only (USB perturbs BLE OTA — always test on battery): full 729528-byte image streams past the first-page boundary (where the old lazy erase died at ~4880) to completion — "Update Successful". Same node/app that stalled at 4880 with the async lazy erase, and that took ~20 s + a wasted retry with the erase reverted. Suggest this supersedes the (One orthogonal observation from the same testing: attempt 1 after the buttonless reboot consistently fails to connect (~5 s, "device not found") and the transfer succeeds on a later attempt, across all three bootloader variants — so it's the app/BLE reconnect timing, not the bootloader. Not chased here.) |
Remaining regression isolated: attempt-1 BLE supervision timeout. Parked pending an SWD probe.Captured with a clean logcat-to-file trace, battery-only, on The first post-reboot DFU connection dies on a BLE supervision timeout ~5 s after START_DFU, on every rebased variant (upfront-erase, old lazy erase, new re-port — so it is not erase-related). The SoftDevice stops servicing the link. The transfer then succeeds on a retry once the device comes back (~60-90 s worst case). Master streams attempt 1 clean battery-only, so this is a real rebase-side regression — the last one standing. Two fix attempts, both falsified on hardware:
Interrupt-level SD-state debugging is beyond blind iteration — needs the SWD probe (ordered). Parking this PR until it arrives. State of the branch when parked:
|
Checklist
tools/build_all.pypasses — 17/17 locally, GCC 13.3.Rel1Description of Change
The long-term half of #25. Branch is
adafruit/master(c67f0bc, 0.11.0) with OTAFIX re-applied on top as a thin delta — 10 commits instead of the 65+ oltaco carries. Flash for RAK4631 goes 34500 → 33856 bytes; SRAM 31330 → 31198.Layers
board.hcontract (BUTTON_DFU/BUTTON_DFU_OTAreplaceBUTTON_1/BUTTON_2,BUTTONS_NUMBERgone,PINNUMprovided byboards.h); the 14 boards only we ship were translated mechanically. The 3 boards mainline also has (t1000_e, bothxiao) keep mainline'sboard.hand only gain the per-board DFU name inboard.mk.board.cmakedropped (CMake was never wired).screen.c/images.c(size-agnostic, Meshtastic-branded), ST7735 init added beside mainline's ST7789,UF2_VERSION_BASE+ submodule versions in the version string.Reconciliation ledger — OTAFIX commit → outcome on the 0.11 base
25454a8HCI_RX_BUF_QUEUE_SIZE 163f7312eOTA resiliency (GPREGRET=0xA8 unconditional)if (_ota_was_connected)form; default-to-OTA covers the no-app case557f9cbper-board advertising nameDEVICE_NAMEwith#ifndef;board.mk -DDEVICE_NAMEworks as-isf9f9f51display in OTA modeafc721ahigh MTUdb8dc4ddefault to OTA DFUDEFAULT_TO_OTA_DFUblock stays but is off; OTAFIX's finer rule (not when UF2/serial/double-reset asked) is the behaviour Android relies on02fc9bdusb_teardown after OTA7e69127lazy erasepstorage_clear(CODE_PAGE_SIZE)now wrapped in mainline'sNRF_ERROR_NO_MEMretry loop; non-OTA branch uses mainline'sflash_nrf5x_erase54a9e85small-packet accumulatorprioritize_flash_writes_over_ble())1d8194fmax BLE TX power18758d9CURRENT.UF2 real size (#20)f41dab2nrfx 3.14 / tinyusb bump (#19)linker/nrf_common.ldalias shim is also unneeded. Re-bumping is a separate PRMainline features we now get for free
Flash/notification queue handling (
e1ea1c6, the one #25 called too entangled), DFU-mode exit timeout, opt-in dual-bank (DUALBANK_FW=1), opt-in signed firmware (SIGNED_FW=1, tinycrypt submodule), pending-interrupt clear before app jump, GCC 15 clean.Before un-drafting
CURRENT.UF2dump-and-restore (fix: size CURRENT.UF2 to the real installed app, not the max region #20 regression), serial DFU via in-app upgrade