SD card mount, eject and format, with hotplug detection#4
Conversation
Add the SD control commands carried over the interdevice link: SD_MOUNT, SD_EJECT and SD_FORMAT. Card maintenance (mount, format, the free space scan, card-removal recovery) runs on core1 behind a mutex so a multi-second operation never stalls the link; core0 claims the card per request with a try-lock and reports busy instead of waiting for it. Detect a card pulled while the slot sits idle by re-initing it on the dedicated SPI bus, and report a card that is present but carries no mountable filesystem as unformatted. Bump the protobufs submodule to the merged SD command definitions and regenerate the nanopb sources.
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
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 |
What does this PR do?
Follow-up to #3. Adds SD card control to the interdevice bridge so the main firmware can mount, eject and format the card behind the co-processor, and keeps the link responsive while the card is busy.
SD control commands
SD_MOUNT,SD_EJECTandSD_FORMATarrive over the link and are answered withsd_info. Without an eject a card is mounted on its own and kept mounted; after an eject it stays released until a mount is asked for, so it can be pulled safely.Non-blocking card access
Card maintenance (mount, format, the free space scan and card-removal recovery) can block for seconds, so it runs on core1 behind a mutex. Core0 claims the card per request with a try-lock and reports busy instead of waiting, so GPS forwarding and other requests keep flowing while the card is tied up.
Hotplug
A card pulled while the slot sits idle is detected by periodically re-initing it on the dedicated SPI bus (SdFat otherwise answers from cache and never notices). The raw probe and the formatter both run on SPI1 explicitly so they cannot re-mux the GPIO16/17 pins that carry the interdevice UART. A card that is present but carries no mountable filesystem is reported as
unformatted.Depends on the protobufs SD command definitions merged in meshtastic/protobufs#986; the submodule is bumped to that commit and the nanopb sources regenerated.