-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Define vfs.rom_ioctl()
, add romfs commands to mpremote, and implement ROM partition support on stm32, rp2, esp32, esp8266
#16857
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
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9dd4cef
py/objarray: Add MP_DEFINE_MEMORYVIEW_OBJ convenience macro.
dpgeorge 89e6c58
extmod/modvfs: Add vfs.rom_ioctl function and its ioctl constants.
dpgeorge d4b8ca2
extmod/vfs: Add mp_vfs_mount_romfs_protected() helper.
dpgeorge 840b641
py/runtime: Automatically mount ROMFS as part of mp_init.
dpgeorge 0c98c60
tools/mpremote: Add romfs query, build and deploy commands.
dpgeorge bea7645
stm32: Implement vfs.rom_ioctl with support for internal/external flash.
dpgeorge 45c36f8
stm32/boards: Enable ROMFS partitions on PYBD_SFx boards.
dpgeorge 50a7362
rp2: Implement vfs.rom_ioctl with support for external flash.
dpgeorge 0255cb7
esp32: Implement vfs.rom_ioctl with support for external flash.
dpgeorge 75ff8e5
esp8266: Implement vfs.rom_ioctl with support for external flash.
dpgeorge 6bec36a
esp8266/boards: Add FLASH_2M_ROMFS variant with 320k ROM partition.
dpgeorge be0fce9
unix/main: Add coverage test for mounting ROMFS filesystem at startup.
dpgeorge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Notes: the offset of the partition table itself is set in | ||
# $IDF_PATH/components/partition_table/Kconfig.projbuild. | ||
# Name, Type, SubType, Offset, Size, Flags | ||
nvs, data, nvs, 0x9000, 0x6000, | ||
phy_init, data, phy, 0xf000, 0x1000, | ||
factory, app, factory, 0x10000, 0x1D0000, | ||
romfs, data, 0x8f, 0x1E0000, 0x20000, | ||
vfs, data, fat, 0x200000, 0x200000, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
ports/esp8266/boards/ESP8266_GENERIC/mpconfigvariant_FLASH_2M_ROMFS.mk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
LD_FILES = boards/esp8266_2MiB_ROMFS.ld | ||
|
||
MICROPY_PY_ESPNOW ?= 1 | ||
MICROPY_PY_BTREE ?= 1 | ||
MICROPY_VFS_FAT ?= 1 | ||
MICROPY_VFS_LFS2 ?= 1 | ||
|
||
# Add asyncio and extra micropython-lib packages (in addition to the port manifest). | ||
FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest_2MiB.py | ||
|
||
# Configure mpconfigboard.h. | ||
CFLAGS += -DMICROPY_ESP8266_2M -DMICROPY_VFS_ROM=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* GNU linker script for ESP8266 with 2M or more flash, and includes a ROMFS partition | ||
|
||
Flash layout: | ||
0x40200000 36k header + iram/dram init | ||
0x40209000 668k firmware (irom0) | ||
0x402c0000 320k ROMFS | ||
0x40300000 1M+ filesystem (not memory mapped) | ||
*/ | ||
|
||
MEMORY | ||
{ | ||
dport0_0_seg : org = 0x3ff00000, len = 16 | ||
dram0_0_seg : org = 0x3ffe8000, len = 80K | ||
iram1_0_seg : org = 0x40100000, len = 32K | ||
irom0_0_seg : org = 0x40209000, len = 1M - 36K - 320K | ||
FLASH_ROMFS : org = 0x402b0000, len = 320K | ||
} | ||
|
||
/* define ROMFS extents */ | ||
_micropy_hw_romfs_start = ORIGIN(FLASH_ROMFS); | ||
_micropy_hw_romfs_size = LENGTH(FLASH_ROMFS); | ||
|
||
/* define common sections and symbols */ | ||
INCLUDE boards/esp8266_common.ld |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got caught out that I couldn't import a Python module from the top-level of the rootfs without doing
sys.path.append('/rom')
. How about adding both/rom
and/rom/lib
to sys.path by default?(I'm thinking along the lines that the top-level is the application code either as .py files or package directories, and
/rom/lib
is managed by some future variant of 'mip install'.)I don't really see a downside - I guess someone might decide to put a lot of non-Python assets in the top level and slow down import a little, but that seems like a much less common pattern than putting a Python file there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding to the search path, ie
sys.path
, really does slow down imports. Because you need to stat.py
and.mpy
for each import (assuming the first fails), and then for packages you also need to stat__init__.py
and__init__.mpy
. This is something we need to optimise in general.So, I really wanted to keep
sys.path
down to a minimum. I did start out adding just/rom
to the path, but after discussion with you and Jim, changed that to/rom/lib
.The user can easily change the path themselves.
Note that neither
boot.py
normain.py
will execute from the ROMFS, because those boot up files are searched in the current directory.I'd really like to improve all this in MicroPython 2.0. But for now... maybe just keep it as
/rom/lib
and document it? Or change it to '/rom`? Or just omit altogether and make the user add it as they need?Side note:
mip install
won't work with/rom/lib
in the path before/flash/lib
, because it tries to install into the ROMFS...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a key question is what behaviour we want for (eventually) installing MIP packages into the ROMFS. I'd figured that it's desirable to keep them separated somewhere, so it's easy for the developer to see the difference between "my application" and "libraries I've installed from elsewhere". So my thinking was that
/rom/lib
would be the natural place to put the externa llibraries, as it mirrors the way it works now.I don't think there's any way to have this distinction and only add one entry to the path, though...
On balance I think it's preferable to have helpful/usable defaults. Then the developer who wants to optimise their package import speed can be the one who tweaks sys.path to remove entries they don't need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(But if we're going with one default entry only, probably
/rom
is less surprising for people building ROMFS from a directory and then using it on their board.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a good point. So maybe then the defaults can be
/rom
and/rom/lib
, which is how we recommend to layout a project. Then users can tweak as needed.I'll do a few benchmarks to see if adding a second path makes much of a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
/rom
and/rom/lib
are now added automatically tosys.path
.