Skip to content

ports/rp2: Add start/len support to rp2.Flash(). #9213

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

Closed
wants to merge 1 commit into from

Conversation

Gadgetoid
Copy link
Contributor

Allow support for partitioned flash on RP2.

First shot at starting #9208

Example _boot.py to mount separate / and /config partitions:

import os
import machine, rp2


# Try to mount the filesystem, and format the flash if it doesn't exist.
# Note: the flash requires the programming size to be aligned to 256 bytes.

USER_FLASH_SIZE = rp2.Flash().ioctl(4, 0) * rp2.Flash().ioctl(5, 0) # Extremely cursed
CONFIG_FS_SIZE = 48 * 1024 # 48k config filesystem

bdev_root = rp2.Flash(start=0, len=USER_FLASH_SIZE - CONFIG_FS_SIZE)
try:
    vfs_root = os.VfsLfs2(bdev_root, progsize=256)
except:
    os.VfsLfs2.mkfs(bdev_root, progsize=256)
    vfs_root = os.VfsLfs2(bdev_root, progsize=256)
os.mount(vfs_root, "/")

bdev_config = rp2.Flash(start=USER_FLASH_SIZE - CONFIG_FS_SIZE, len=CONFIG_FS_SIZE)
try:
    vfs_config = os.VfsLfs2(bdev_config, progsize=256)
except:
    os.VfsLfs2.mkfs(bdev_config, progsize=256)
    vfs_config = os.VfsLfs2(bdev_config, progsize=256)
os.mount(vfs_config, "/config")

del os, bdev_root, bdev_config, vfs_root, vfs_config, CONFIG_FS_SIZE

@Gadgetoid
Copy link
Contributor Author

Will conflict #8381

Allow support for partitioned flash on RP2.

Signed-off-by: Phil Howard <phil@gadgetoid.com>
@Gadgetoid
Copy link
Contributor Author

Thank you for your feedback. Much more concise (and precise 😬) change now.

@dpgeorge
Copy link
Member

dpgeorge commented Sep 8, 2022

Thanks for updating. Rebased and merged in 6aa3c94

@dpgeorge dpgeorge closed this Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 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