stm32: Generalise flash mounting code so it supports arbitrary FS. #5299
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.
This PR refactors and generalises the boot-mount routine on stm32 so that it can mount filesystems of arbitrary type. Ie it no longer assumes that the filesystem is FAT.
It does this by using
mp_vfs_mount()
which does auto-detection of the filesystem type.The idea with this is that the user could reformat the flash filesystem with littlefs (or other FS type) and then it would "just work". So the could would support both FAT at littlefs, it just depends how the flash is formatted.
But there are two problems with getting this latter part working:
To fix (1) requires splitting out the partition table. Since it's only really needed by the USB MSC, it's possible to split this partition stuff out from the storage driver (storage.c) and put it in the USB driver (usbd_msc_interface.c). That would then free up storage.c to abstract just the blocks on the block device(s).
To fix (2) is difficult. For the auto-mount code it would mean that the block size (and hence the block device) depends on the filesystem type (almost a chicken and egg problem). A simple way forward would be to just use a 512 block size for littlefs, and make it go through the flash write cache (this should work ok). Or switch to 4096 block size, but then FAT FS needs 4k blocks and is rather inefficient (although that's what esp8266 and esp32 do).
Things are simpler if there's no auto-detection. Then the user would need to configure the filesystem type at compile time. This PR would still be useful for that approach.