Skip to content

Add experimental internal Flash Blackbox for AT32F435CMU7 - #2

Draft
FlyingRC-Official wants to merge 1 commit into
experimental/F435CMxx_FlashAsBlackboxfrom
codex/f435cmu7-internal-blackbox
Draft

FlyingRC-Official wants to merge 1 commit into
experimental/F435CMxx_FlashAsBlackboxfrom
codex/f435cmu7-internal-blackbox

Conversation

@FlyingRC-Official

Copy link
Copy Markdown
Owner

CMU7 boards without external Flash currently have no onboard Blackbox storage. This adds an opt-in FLYINGRCF435WINGMINI_CMU7_FLASH target that reserves Bank 2 as a 1,984 KiB NOR log volume and reuses the existing FlashFS, Blackbox and download interfaces. Firmware, configuration and extended defaults remain in Bank 1.

The backend checks chip capacity, boot selection and linker boundaries, validates erased destinations and write readback, and stops logging on errors. FlashFS now accounts for short writes correctly and preserves its cursor when internal erase is refused or fails. Erase is restricted to disarmed operation; existing external NOR/NAND asynchronous erase behavior is preserved. The FlyingRC CGU7/CMU7 board definitions are imported from the hardware branch without merging its unrelated changes.

Validation

  • Built FLYINGRCF435WINGMINI_CMU7_FLASH, FLYINGRCF435WINGMINI_CMU7, FLYINGRCF435WINGMINI, NEUTRONRCF435MINI and BETAFPVF435 with GCC 13.2.1.
  • Passed host tests exercising the production driver, driver registration/partition setup and FlashFS, including injected failures, short writes, ring wrap, EOF, erase guards and external FlashFS regression.
  • Verified actual ELF/HEX load addresses stay in Bank 1, normal/extended-defaults layouts work, and oversized firmware is rejected.

Hardware status

Draft pending bench validation. Real-chip programming behavior, control-loop timing, log download and power-loss recovery have not been tested. Writes and erase are synchronous; full erase is estimated at approximately 22 seconds typical and 198 seconds at the datasheet sector-time maximum. Flight readiness is not established.

Research, implementation details and bench procedure: docs/development/at32-internal-blackbox.md.

This PR contains one commit.

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T09:59:10.792106Z e35f7fa Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e35f7faa6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +17 to +20
command = [os.environ.get("CC", "cc"), "-std=c99", "-D_DARWIN_C_SOURCE", "-D_DEFAULT_SOURCE",
"-Wall", "-Wextra", "-Werror", "-fsanitize=undefined",
"-I" + str(here / "stubs"), "-I" + str(here.parents[1] / "main"),
str(here / source), "-o", str(binary)] + defines

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Compile the mapped-address harness without PIE

On Linux distributions where cc builds PIE executables by default, python3 src/test/at32_internal_flash/run_tests.py aborts immediately in resetVolume() because references to the absolute assembler symbols __flashlog_start and __flashlog_end are emitted relative to the executable load address, so at32InternalFlashInit() rejects the layout. The non-PIE flags are currently added only on Darwin; add the appropriate compile and link flags (for example -fno-pie and -no-pie) on Linux as well so the newly documented host test can execute.

Useful? React with 👍 / 👎.

Comment thread src/main/fc/cli.c
}

cliPrintLine("Done.");
cliPrintLine(flashGetGeometry()->totalSize ? "Done." : "Flash erase failed; reboot required.");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report an armed erase refusal instead of success

If the CLI is entered while the controller is still armed, the internal backend returns from flashfsEraseCompletely() without erasing anything, but its geometry remains valid, so this expression prints Done.. cliEnter() only sets ARMING_DISABLED_CLI and does not clear ARMED, making this path reachable and leaving the user believing the logs were erased; check the armed state before starting the command or propagate an erase result instead of inferring success from capacity.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

RAM / Flash usage vs. base branch — commit e35f7fa

No size baseline is available yet for this PR's base commit (no per-commit baseline has been published for it). This comment will show deltas once one exists — rebasing the PR refreshes its base commit.

Target Flash Δ RAM Δ
MATEKF405 625151 B (no baseline) 133256 B (no baseline)
MATEKF722 468475 B (no baseline) 123312 B (no baseline)
MATEKF765 646059 B (no baseline) 138768 B (no baseline)
MATEKH743 664339 B (no baseline) 139776 B (no baseline)

See RAM/flash optimization guide for techniques to reduce usage.

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