Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

esp32: auto-detect the SPI flash size and automatically size the filesystem#17337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dpgeorge wants to merge2 commits intomicropython:master
base:master
Choose a base branch
Loading
fromdpgeorge:esp32-detect-flash-size

Conversation

dpgeorge
Copy link
Member

Summary

Currently in the esp32 port the size of the SPI flash must be configured at build time, eg 4MiB, 8MiB, etc. Also, the esp32 partition table must be configured at build time, which depends on the size of the SPI flash. A bigger flash means more can be allocated to the user filesystem.

This PR makes it so the SPI flash size is automatically determined at runtime, and the filesystem size is automatically set to take up as much room as possible.

This works by:

  1. Setting the SPI flash size to be 4MiB in the build.
  2. Removing thevfs partition from the esp32 partition table (only nvs, phy_init and firmware remains in the partition table).
  3. At boot, query the physical size of the SPI flash and use that as the actual size in the code.
  4. Automatically create aautofs partition which takes up the flash from 2MiB up to the end of flash.

This allows simplifying a lot of board configurations, and removing some board variants that just change the flash size.

It's also fully backwards compatible, in the following sense:

  1. Existing boards with MicroPython firmware will continue to work with the same filesystem, ie the filesystem won't be erased when the firmware is updated.
  2. If a user has a custom esp32 partition table and installs MicroPython as a bare app into the app partition, the new MicroPython firmware will honor the esp32 partition table and use eithervfs orffat partitions as the filesystem.

Eventually this mechanism will be extended:

  • to other ports, probably rp2 next
  • to allow users to customise the filesystem layout, and enable ROMFS partition(s) without rebuilding firmware

Testing

Tested with ESP32_GENERIC on a board with 4MiB of flash, and ESP32_GENERIC_S2 on a board with 16MiB flash. The filesystem size was correctly detected.

Trade-offs and Alternatives

  • Boards configured for OTA have not been changed, they still define the filesystem partition explicitly.
  • It may be that the physical flash size cannot be detected correctly, but I think the IDF has covered most cases by now.
  • Custom board definitions can override the auto detect feature by defining their ownMICROPY_BOARD_STARTUP macro.

robert-hh reacted with thumbs up emojiprojectgus reacted with rocket emoji
Signed-off-by: Damien George <damien@micropython.org>
And remove the ESP32_GENERIC_S3-FLASH_4M variant, because it's no longerneeded.Signed-off-by: Damien George <damien@micropython.org>
@dpgeorgedpgeorge requested review fromprojectgus and removed request forprojectgusMay 22, 2025 01:25
@Josverl
Copy link
Contributor

An observation and suggestions.

It took me a long time to understand how variants worked, and what options there are for configuration as there is little documentation, other than in comments in individual make and header files, and in PR comments such as this, which are hard to find later.
(Or perhaps I just failed to find the docs)

In this case there is a new macro defined, that can be overridden, and that is clearly described here.

I think it would be very helpful to add that to the Documentation, on a common or port level.
That would help tick the 'How can we teach this' checkbox.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@dpgeorge@Josverl

[8]ページ先頭

©2009-2025 Movatter.jp