-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
WIP: Python composable q/spi flash filesystems #5249
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
Conversation
…aces. Consolidate interfaces to machine.Spi Simplify configuration of drivers/spiflash device.
…ne.SPIFlash interfaces.
c534955
to
8cb494e
Compare
…s from mountpoint, filesystem type and block device.
8cb494e
to
f68f7b2
Compare
Thanks for this. I had a look through the commits and some of it is good but some of it is overkill and what seems to be unnecessary refactoring. From a high-level view, I agree it'd be good to provide a Python-level interface to construct/configure SPI-based block devices. But it doesn't necessarily need to take a SPI/QSPI object, it can just take an integer specifying which internal bus/flash to use. Eg One problem is how the user can specify the layout (partitioning) of the flash storage, if they are not building custom firmware. It's not really possible to do this in a (non frozen) script because that script must come from the filesystem, which doesn't yet exist. On esp32 there's a partition table which fills this role of laying out where the filesystem is, but even there it still needs a frozen Maybe we need a small "frozen boot sector" on each port which contains a (small) frozen Python script that brings up the initial filesystem (or whatever it wants to do) and which can be dynamically frozen via the user without rebuilding firmware. It can be as simple as storing a "bare" .mpy file in the first block of the flash, or even somewhere in internal flash. Well, this relates to the long-requested feature of dynamically frozen scripts. So perhaps that feature is needed first, before the filesystem layout can be configured via the user. That's a big digression, so in the meantime to make progress implementing |
typedef struct _mp_spiflash_t { | ||
const mp_spiflash_config_t *config; |
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.
The reason this config struct was separated out was so that it could be put in ROM, while the mp_spiflash_t
struct was kept small and in RAM. What was your reason to combine them?
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 did this early-on as I was still understanding the overall structure of spiflash subsystem, thinking it simplified things. For boards where the interfaces are hard-coded I can see how this makes sense though, probably better if I revert this change.
uint32_t (*read_cmd)(mp_obj_base_t *obj, uint8_t cmd, size_t len); | ||
void (*read_cmd_qaddr_qdata)(mp_obj_base_t *obj, uint8_t cmd, uint32_t addr, size_t len, uint8_t *dest); | ||
|
||
} mp_machine_qspi_p_t; |
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.
Wouldn't it be possible to just reuse mp_qspi_proto_t
(in drivers/bus/qspi.h) for this purpose?
Passing in python objects was done to allow defining a spiflash interface on any one of hardware spi, soft spi, hardware qspi or soft qspi.
Yes, this is exactly what's intended with this change, the start argument is already provided (just not shown in my python examples above).
I certainly intended to expose the internal flash (in a separate pr). A block interface for it is already written, perhaps it could be exposed behind the same python interface. It would just mean a bit of branching in C to point the interface to either the spiflash block interface or the pybflash one. |
Having the There is also unification that could happen in the spi device protocol structs - |
Fix usb_hid_gc_collect()
This PR has been a useful talking point towards planning a new / consolidated storage interface for micropython, but is not very helpful in its own right. As such it's better to close this and work as a team on an improved storage layer. |
This PR aims to simplify the definition and use of filesystems in general, but most specifically making it easier to create filesystems on spi and qspi flash chips.
The interfaces to these filesystems has been extended both for access from micropython at runtime, and in C for board definitions.
For example:
The machine.SPIFlash() constructor also takes a
start
argument which lets you offset the start of a filesystem, making it easy to have multiple separate filesystems present on a single flash chip.Example stm32 board definition
bdev.c
mpconfigboard.h
In conjunction with #5228 changing the format of the boot or any runtime filesystem to LittleFS should be as simple as
mpconfigboard.h
or
TODO: