Skip to content

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