Skip to content

stm32: On Arduino boards, enable 4MiB ROMFS partition in external flash #16869

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

dpgeorge
Copy link
Member

@dpgeorge dpgeorge commented Mar 6, 2025

Summary

Split out from #8381, and a follow up to #16857 (comment)

This enables a 4MiB ROMFS partition on all three stm32 Arduino boards, using external QSPI flash. The ROMFS partition sits near the end of flash:

  • 11MiB filesystem
  • 4 MiB ROMFS
  • 1 MiB WiFi firmware (compatibility with alternate firmware)

Testing

TODO (although previously tested by @iabdalkader as part of #8381).

Trade-offs and Alternatives

This is most likely a breaking change for users, because the filesystem partition size has shrunk by 4MiB. And I don't think that will be easily detected because existing filesystems will mount and work correctly until the ROMFS is used. And then when ROMFS is used and the flash for that is written to, the original filesystem will probably still mount correctly because the initial filesystem data is unchanged.

@iabdalkader how do you want to manage this when users update the firmware? This is part of the reason why I didn't want to enable ROMFS on all the boards right now, because we don't have a good way of transitioning the flash partition from previous layout to new layout.

Copy link

github-actions bot commented Mar 6, 2025

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     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

@iabdalkader
Copy link
Contributor

@sebromero @ubidefeo

@iabdalkader
Copy link
Contributor

This is most likely a breaking change for users, because the filesystem partition size has shrunk by 4MiB. And I don't think that will be easily detected because existing filesystems will mount and work correctly until the ROMFS is used. And then when ROMFS is used and the flash for that is written to, the original filesystem will probably still mount correctly because the initial filesystem data is unchanged.

We will deploy "stock" romfs images along with 1.25.0, which will likely corrupt the filesystem as you've expected. However, romfs will be the main storage for all embedded assets moving forward, as we're already running out of flash on some boards (like the Nicla), so this change is unavoidable. When we deploy 1.25.0 we could display a warning and erase the filesystem as well.

@sebromero
Copy link
Contributor

sebromero commented Mar 6, 2025

We could indeed add a version check in our installer tool to at least warn the user and consequently perform an erase of the file system.

@Josverl
Copy link
Contributor

Josverl commented Mar 6, 2025

For Mpflash it should be possible to detect the step-ups to 1.25.0 and then, after confirmation:

  • extract the filesystem, or files on the filesystem to the host
  • erase , and flash
  • Wait for reboot, and the MCU to mount and format the flash
  • if needed: Extract the files from the downloaded image
  • re-upload the files.

Other tools can do this as well, if they can check the fw version up-front

@dpgeorge
Copy link
Member Author

When we deploy 1.25.0 we could display a warning and erase the filesystem as well.

OK, sounds good, you can manage user expectations on your side for this change.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
@dpgeorge dpgeorge force-pushed the stm32-boards-arduino-enable-romfs branch from b1c66d3 to 96ce08e Compare March 13, 2025 10:45
@dpgeorge
Copy link
Member Author

@iabdalkader I have now updated this after #16903, to name the partition #0. Please can you review it?

@iabdalkader
Copy link
Contributor

@iabdalkader I have now updated this after #16903, to name the partition #0. Please can you review it?

I can retest it again, later today.

@iabdalkader
Copy link
Contributor

Seems to be working fine. I tested build, deploy and read. Anything else to test? Otherwise it's good.

>>> import os
>>> os.listdir("/rom")
['test.txt']
>>> print(open("/rom/test.txt", "r").read())
HelloWorld!
``

@dpgeorge
Copy link
Member Author

Seems to be working fine. I tested build, deploy and read

Great, thanks, that should be enough.

@dpgeorge dpgeorge merged commit 96ce08e into micropython:master Mar 14, 2025
10 checks passed
@dpgeorge dpgeorge deleted the stm32-boards-arduino-enable-romfs branch March 14, 2025 03:28
@iabdalkader
Copy link
Contributor

I tested the address as well, using uctypes.addressof. The ROMFS should start at 0x00B00000 (11MiB) so this seems about right.

mpremote run ls_romfs.py 
addr: 0x00B00012  size: 12        alignment: NOT aligned name: test.txt

@dpgeorge
Copy link
Member Author

The address should be more like 0x90B00000, right?

@iabdalkader
Copy link
Contributor

The address should be more like 0x90B00000, right?

Yes, that's right. The CYW43 firmware for example is at 0x90F00000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy