Skip to content

fix(uf2): leave DFU on eject on every board and time out an idle mounted drive - #108

Merged
jamesarich merged 2 commits into
masterfrom
fix/uf2-idle-and-eject-exit
Nov 21, 2026
Merged

jamesarich merged 2 commits into
masterfrom
fix/uf2-idle-and-eject-exit

Conversation

@jamesarich

@jamesarich jamesarich commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

A host eject only left UF2 mode on boards that define UF2_EXIT_ON_EJECT (t1000_e, mesh_tracker_x1), so on every other board the drive re-mounted and the board stayed in DFU. The 6 minute idle exit was also restarted by every UF2 drive read, so a host that keeps reading a mounted volume (macOS indexing, a remount) could hold a board with a valid application in DFU forever.

The flag was added with the single-button boards because they have no reset button to leave by; the history gives no reason to keep it per board, so an eject now leaves the DFU loop everywhere. The factory-erase path is unchanged, and with no valid application main() still brings the drive back. Only an accepted UF2 block, USB enumeration and BLE or serial traffic restart the idle timer; a copy in progress has already invalidated bank_0, so it is never cut off.

see #106

Testing: built sensecap_solar_p1, wiscore_rak4631_board, t1000_e, mesh_tracker_x1, heltec_t114 and xiao_nrf52840_ble with the repo shell (arm-none-eabi-gcc 13.3, not the CI-pinned 12.3); every image is within 8 B of master and fits its 38 KB region. Benched on a RAK4631 and a T1000-E from Linux (results in the comments); macOS is untested.

The README states the new rules and marks what 2.6.1 and earlier do. It overlaps #107 on one line, so whichever merges second needs a rebase.

Summary by CodeRabbit

  • Behavior Changes
    • Ejecting the UF2 drive now exits DFU on all boards and boots a valid application. If no application is available, the device returns to the drive; an eject immediately after factory erase still resets into UF2.
    • UF2 reads and host file-system writes no longer restart the six-minute inactivity timer. Accepted UF2 blocks, USB enumeration, and BLE or serial DFU activity do restart it.
  • Documentation
    • Updated guidance to clarify DFU button behavior and UF2 eject and inactivity behavior.

…ted drive

A host eject only left UF2 mode on boards that define `UF2_EXIT_ON_EJECT`, so on every other board the drive re-mounted and the board stayed in DFU. The 6 minute idle exit was also restarted by every UF2 drive read, so a host that keeps reading a mounted volume held the board in DFU indefinitely.

An eject now leaves the DFU loop on every board, with the factory-erase path unchanged, and only an accepted UF2 block or a USB mount restarts the idle timer. A board with no valid application still returns to the drive after an eject.
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PR changes UF2 eject behavior across boards and adjusts which USB mass-storage events restart the DFU inactivity timer. It removes board-specific UF2_EXIT_ON_EJECT definitions and updates related guidance, README text, and the changelog.

Changes: UF2 DFU behavior

Layer / File(s) Summary
Eject handling and documented outcomes
src/boards/*/board.h, src/usb/msc_uf2.c, CONTRIBUTING.md, README.md, changelog.md
The eject callback now leaves the DFU event loop when no factory-erase reset is pending, without checking UF2_EXIT_ON_EJECT. The board definitions and documentation describe the all-board eject behavior, including outcomes when no valid application exists or a factory erase is pending.
DFU activity timer triggers
src/usb/msc_uf2.c, AGENTS.md, README.md, changelog.md
MSC reads no longer mark DFU activity. Writes mark activity only when write_block() returns a positive value. The documentation describes the activity triggers and the earlier behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • Issue 106 reports that the USB DFU drive reappears after host eject. This PR changes eject handling so that it leaves UF2 mode on every board.

Possibly related PRs

Suggested reviewers: rcarteraz, hathach, oltaco

Merge Risk: Minimal · up to 584fb

This change makes ejecting the UF2 drive leave DFU mode on every board. It also stops idle reads of the mounted drive from restarting the six-minute timeout. No concrete defect was found, and the docs match the new behavior. The macOS, no-application, and factory-erase eject paths were not tested.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title 'fix(uf2): leave DFU on eject on every board and time out an idle mounted drive' matches the main changes. The changeset removes the UF2_EXIT_ON_EJECT board-specific gating so that ejecting …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title 'fix(uf2): leave DFU on eject on every board and time out an idle mounted drive' matches the main changes. The changeset removes the UF2_EXIT_ON_EJECT board-specific gating so that ejecting the UF2 drive leaves DFU on every board (msc_uf2.c, board.h removals, changelog). It also changes the idle timer so that drive reads no longer restart the six-minute timeout (msc_uf2.c read10 no longer calls dfu_activity(), write10 only counts positive blocks). The documentation updates in README, CONTRIBUTING, and changelog support both parts. The title is specific, uses a conventional commit prefix, and is a single sentence under 80 characters. It is accurate, and it does not need to list every file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

A rabbit watches UF2 blocks arrive,
Reads pass by; accepted writes keep time.
The host ejects, and DFU lets go,
Unless a factory reset waits below.
The drive returns when no app can boot,
And the timer follows activity’s route.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 671cf818-2a1f-4463-9951-f2b682aebebd
Commits

Reviewing files that changed from the base of the PR and between 5afc28d and 584fb23.

Files selected for processing: 7

  • AGENTS.md
  • CONTRIBUTING.md
  • README.md
  • changelog.md
  • src/boards/mesh_tracker_x1/board.h
  • src/boards/t1000_e/board.h
  • src/usb/msc_uf2.c
Files with no reviewable changes: 2

  • src/boards/mesh_tracker_x1/board.h
  • src/boards/t1000_e/board.h

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

…e idle timer

The README still described eject and the idle timer as 2.6.1 behaves. It now states both rules and marks the 2.6.1 and earlier behavior where it differs.
@jamesarich

Copy link
Copy Markdown
Collaborator Author

Benched on james-pc (Linux, udisks Drive.Eject) at 584fb23, one run per row. RAK4631 is on 2.6.0 before and after, T1000-E ends on the 2.6.1 release.

Board Test 2.6.0 / CI build 584fb23
RAK4631 eject, valid app stays in DFU, drive rescanned app back in 2 s
RAK4631 idle, unmounted app back after 6 min -
RAK4631 idle, O_DIRECT read every 20 s still in DFU after 510 s (26 reads) app back at 360 s (18 reads)
T1000-E eject, valid app app back in 2 s app back in 2 s

Not run: macOS, a board with no valid app, and the factory-erase eject path.

@jamesarich
jamesarich marked this pull request as ready for review November 21, 2026 12:49
@jamesarich
jamesarich added this pull request to the merge queue Nov 21, 2026
Merged via the queue into master with commit 25547b0 Nov 21, 2026
26 checks passed
@jamesarich
jamesarich deleted the fix/uf2-idle-and-eject-exit branch November 21, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant