Skip to content

Harden standalone mode watchdog and SD-card mount lifecycle#209

Closed
CloudyPadmal with Copilot wants to merge 9 commits into
mainfrom
copilot/fix-comments-in-review-thread
Closed

Harden standalone mode watchdog and SD-card mount lifecycle#209
CloudyPadmal with Copilot wants to merge 9 commits into
mainfrom
copilot/fix-comments-in-review-thread

Conversation

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown

This addresses the PR #208 review-thread findings around standalone mode reliability and SD-card config validation. The update keeps scope to the commented areas: watchdog behavior in standalone state, FatFS mount lifetime/prototypes, and API/docs consistency.

  • Standalone state machine

    • Clear watchdog in Standalone() idle loop to match Standby() behavior and avoid resets while waiting for UART traffic.
  • Standalone SD mount lifecycle

    • Replace stack-scoped FatFS mount object with static standalone-scoped storage to avoid dangling mount pointers across function return.
    • Keep explicit unmount path and expose SDCARD_standalone_unmount() in the public header.
    • Ensure declaration visibility where used.
  • Config header validation + API contract clarity

    • Keep strict 5-byte "PSLAB" magic check and make intent explicit via STANDALONE_MAGIC_LEN + memcmp.
    • Use byte buffer type for raw header reads.
    • Align sdcard.h docs with implementation (SUCCESS/FAILED, exact 5-byte magic semantics).
#define STANDALONE_MAGIC_LEN 5
static FATFS s_standalone_drive;

if (f_mount(&s_standalone_drive, SDCARD_DRIVE, 1) != FR_OK) {
    return FAILED;
}

uint8_t buf[STANDALONE_MAGIC_LEN] = {0};
if (f_read(&file, buf, STANDALONE_MAGIC_LEN, &bytes_read) != FR_OK
    || bytes_read != STANDALONE_MAGIC_LEN) {
    f_close(&file);
    return false;
}
return memcmp(buf, "PSLAB", STANDALONE_MAGIC_LEN) == 0;

Copilot AI requested review from Copilot and removed request for Copilot July 6, 2026 20:29
CloudyPadmal and others added 3 commits July 6, 2026 20:31
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot July 6, 2026 20:31
Copilot AI requested review from Copilot and removed request for Copilot July 6, 2026 20:32
Copilot AI requested review from Copilot and removed request for Copilot July 6, 2026 20:33
Copilot AI requested review from Copilot and removed request for Copilot July 6, 2026 20:34
Copilot AI requested review from Copilot and removed request for Copilot July 6, 2026 20:35
Copilot AI requested review from Copilot and removed request for Copilot July 6, 2026 20:36
Copilot AI changed the title [WIP] Fix code based on review comments Harden standalone mode watchdog and SD-card mount lifecycle Jul 6, 2026
Copilot AI requested a review from CloudyPadmal July 6, 2026 20:37
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.

2 participants