Skip to content

Unify SDCard config option across ports, and enable machine.SDCard on stm32#19330

Open
dpgeorge wants to merge 5 commits into
micropython:masterfrom
dpgeorge:ports-unify-sdcard-config-option
Open

Unify SDCard config option across ports, and enable machine.SDCard on stm32#19330
dpgeorge wants to merge 5 commits into
micropython:masterfrom
dpgeorge:ports-unify-sdcard-config-option

Conversation

@dpgeorge

Copy link
Copy Markdown
Member

Summary

Ports mimxrt, esp32 and renesas-ra already have machine.SDCard, but they have their own config option to enable it, and a custom entry in the machine module. This PR unifies those ports so:

  • they all use the config option MICROPY_PY_MACHINE_SDCARD
  • they all use a common machine module dict entry now in extmod/modmachine.c

Then, machine.SDCard is enabled on the stm32 port. That just aliases to the existing pyb.SDCard class.

Note that the docs already mention machine.SDCard as being available on the stm32 port.

Testing

  • mimxrt port: building TEENSY40 before and after this PR, the firmware is unchanged except for the git hash and the ordering of entries in the machine module dict
  • renesas-ra port: building VK_RA6M5, same as for mimxrt, firmware unchanged except hash and ordering
  • esp32 port: tested ESP32_GENERIC, the machine.SDCard entry is still there
  • stm32 port: tested PYBV10, the machine.SDCard entry is identical to the pyb.SDCard entry

Trade-offs and Alternatives

Costs a tiny bit of code size on stm32, but makes it much more portable to access machine.SDCard.

Generative AI

Not used.

Similar to other classes in the `machine` module, `SDCard` is now there
for a port to use if it enables MICROPY_PY_MACHINE_SDCARD.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge requested a review from projectgus June 10, 2026 04:58
@dpgeorge dpgeorge added the ports Relates to multiple ports, or a new/proposed port label Jun 10, 2026
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.47%. Comparing base (1f50d05) to head (ff70b20).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19330   +/-   ##
=======================================
  Coverage   98.47%   98.47%           
=======================================
  Files         176      176           
  Lines       22845    22845           
=======================================
  Hits        22497    22497           
  Misses        348      348           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

Code size report:

Reference:  esp32: Rename the sdkconfig.spiram_xxx config snippets. [7e55a73]
Comparison: stm32: Enable machine.SDCard if board has pyb.SDCard. [merge of ff70b20]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +8 +0.002% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

dpgeorge added 4 commits June 10, 2026 15:22
This is now provided by the common one in `extmod/modmachine.c`.

Signed-off-by: Damien George <damien@micropython.org>
To unify this with other ports, and to enable the common `machine.SDCard`
entry in `extmod/modmachine.c`.

Signed-off-by: Damien George <damien@micropython.org>
To unify this with other ports, and to enable the common `machine.SDCard`
entry in `extmod/modmachine.c`.

Signed-off-by: Damien George <damien@micropython.org>
This aligns the stm32 port with other ports that have `machine.SDCard`.
The same `SDCard` class is used for this and the existing `pyb.SDCard`, and
its API matches the standard one.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge force-pushed the ports-unify-sdcard-config-option branch from 4f5110f to ff70b20 Compare June 10, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ports Relates to multiple ports, or a new/proposed port

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant