Skip to content

Fix: Move AntennaDeployer file system initialization from constructor to init()#345

Merged
Mikefly123 merged 4 commits intomainfrom
copilot/remove-file-creation-constructors
Mar 4, 2026
Merged

Fix: Move AntennaDeployer file system initialization from constructor to init()#345
Mikefly123 merged 4 commits intomainfrom
copilot/remove-file-creation-constructors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

File system operations in AntennaDeployer's constructor ran before the file system was ready on RP2350, causing unstable behavior at boot.

Description

Root cause: AntennaDeployer::AntennaDeployer() was calling Os::FileSystem::createDirectory and Os::File::open directly. On Zephyr/RP2350, constructors execute before the file system is mounted.

Fix: Moved all file system operations into a new init() method, consistent with the pattern already used by ModeManager and Authenticate.

// Before — file ops in constructor (unsafe)
AntennaDeployer::AntennaDeployer(const char* compName)
    : AntennaDeployerComponentBase(compName) {
    Os::FileSystem::createDirectory(ANTENNA_DIR_PATH, false);  // FS may not be ready
    // ... file open/write ...
}

// After — constructor is clean, file ops deferred to init()
AntennaDeployer::AntennaDeployer(const char* compName)
    : AntennaDeployerComponentBase(compName) {}

void AntennaDeployer::init(FwEnumStoreType instance) {
    AntennaDeployerComponentBase::init(instance);
    Os::FileSystem::createDirectory(ANTENNA_DIR_PATH, false);  // FS is ready here
    // ... file open/write ...
}

Related Issues/Tickets

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Z Tests
  • Manual testing (describe steps)

Verified the constructor no longer performs any file system calls. Boot-time behavior should be equivalent to ModeManager and Authenticate, which use the same init() deferral pattern.

Screenshots / Recordings (if applicable)

Checklist

  • Written detailed sdd with requirements, channels, ports, commands, telemetry defined and correctly formatted and spelled
  • Have written relevant integration tests and have documented them in the sdd
  • Have done a code review with
  • Have tested this PR on every supported board with correct board definitions

Further Notes / Considerations

Only AntennaDeployer was found to have file system calls in its constructor. ModeManager, Authenticate, and StartupManager all already defer file access to init() or handler methods.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: /usr/bin/curl curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] Making files in constructor</issue_title>
<issue_description>### Short summary

Making files in constructor

Steps to reproduce

Making files in constructor makes files b4 file systems is ready

Expected behavior

dont

Actual behavior

remove it pls

Logs / crash output

No response

Target board

RP2350 (Pico 2)</issue_description>

<agent_instructions>Hey copilot! Please analyze our codebase and identify if there are any components that are creating files in their constructors. This can cause unstable behavior and we should plan to refactor that functionality if it exists. </agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Mikefly123 <61564344+Mikefly123@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix file creation in constructors causing instability Fix: Move AntennaDeployer file system initialization from constructor to init() Feb 27, 2026
@Mikefly123 Mikefly123 requested a review from ineskhou February 27, 2026 20:53
@ineskhou ineskhou moved this to In review in V1.X.X Mar 2, 2026
Copy link
Copy Markdown
Contributor

@ineskhou ineskhou left a comment

Choose a reason for hiding this comment

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

Yep! Exactly what I expect, following the example of the mode manager.

Image

Shows the file writes still work as well

@Mikefly123 Mikefly123 marked this pull request as ready for review March 2, 2026 20:59
@Mikefly123 Mikefly123 enabled auto-merge (squash) March 4, 2026 17:57
@Mikefly123 Mikefly123 merged commit ca88f21 into main Mar 4, 2026
4 checks passed
@Mikefly123 Mikefly123 deleted the copilot/remove-file-creation-constructors branch March 4, 2026 17:58
@github-project-automation github-project-automation Bot moved this from In review to Done in V1.X.X Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Making files in constructor

3 participants