Skip to content

Adjust flash size from 2M to 4M for Arduino MMU compatibility#399

Merged
Jason2866 merged 2 commits into
developfrom
fix_C2_2M_hybrid
Feb 23, 2026
Merged

Adjust flash size from 2M to 4M for Arduino MMU compatibility#399
Jason2866 merged 2 commits into
developfrom
fix_C2_2M_hybrid

Conversation

@Jason2866
Copy link
Copy Markdown

@Jason2866 Jason2866 commented Feb 23, 2026

Description:

fix for crashing ESP32-C2 2MB and all other ESP32x variants with 2MB in Hybrid Compile mode.

Checklist:

  • The pull request is done against the latest develop branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR, more changes are allowed when changing boards.json
  • I accept the CLA

Summary by CodeRabbit

  • Bug Fixes
    • Improved flash memory configuration handling to ensure proper compatibility with specific board setups requiring adjusted memory allocation initialization.

Override 2MB flash size to 4MB for compatibility.
@Jason2866
Copy link
Copy Markdown
Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A logic override is added to the flash size configuration in the ESP-IDF builder. When flash size is detected as "2MB", the system logs an informational message and remaps it to "4MB" to ensure Arduino MMU page size compatibility.

Changes

Cohort / File(s) Summary
Flash Size Configuration Override
builder/frameworks/espidf.py
Added conditional logic in generate_board_specific_config to detect "2MB" flash size, log an informational message, and remap the value to "4MB" for Arduino MMU compatibility.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Poem

🐰 A flash that was small, just two megs in size,
Now quietly grows to four, much to our surprise!
The Arduino MMU smiles with glee,
As compatibility hops wild and free! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main change: remapping flash size from 2MB to 4MB for Arduino MMU compatibility, which matches the core modification in the code.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_C2_2M_hybrid

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 23, 2026

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@builder/frameworks/espidf.py`:
- Line 424: The print call uses an unnecessary f-string with no placeholders;
replace the print(f"Info: Detected 2MB flash size setting, override to 4MB for
Arduino MMU page size compatibility") with a plain string print("Info: Detected
2MB flash size setting, override to 4MB for Arduino MMU page size
compatibility") to remove the unused f-prefix in the print statement.
- Around line 423-425: generate_board_specific_config currently forces
flash_size="4MB" for any 2MB board but later the mismatch check still reads the
original board.get("upload.flash_size") into board_flash_size causing a spurious
warning; fix by applying the same remapping when computing board_flash_size
(i.e. normalize board.get("upload.flash_size") the same way you normalized
flash_size) or skip the mismatch check when the override flag is set, and
tighten the override guard so it only applies to esp32c2 (restrict the condition
that sets flash_size to "4MB" to MCU "esp32c2"); update references to
flash_size, board_flash_size, idf_flash_size and the SDK key
"ESPTOOLPY_FLASHSIZE" so both sides use the same normalized value.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c28413a and 50f69c8.

📒 Files selected for processing (1)
  • builder/frameworks/espidf.py

Comment thread builder/frameworks/espidf.py
Comment thread builder/frameworks/espidf.py Outdated
@Jason2866 Jason2866 merged commit 935cbb3 into develop Feb 23, 2026
1 check passed
@Jason2866 Jason2866 deleted the fix_C2_2M_hybrid branch February 23, 2026 14:05
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