-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
drivers: disk: add fakefat disk driver #62286
base: main
Are you sure you want to change the base?
Conversation
@petejohanson You might find it useful for your fancy stuff. |
Interesting.. possibly useful for some of our testing scenarios or development with the posix targets. |
9843489
to
5e5d632
Compare
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 don't expect this to work.
The "ffdisk" name is horrible because it looks like typo. Why are you using such ridiculously short names recently (that are completely unreadable)? What's wrong with just using "fakefatdisk"?
/* | ||
* For now, we ignore write accesses from the (host) filesystem driver | ||
* to all sectors except the data area. Perhaps we can use some of these | ||
* to implement a mounted/unmounted state indication callback. | ||
*/ |
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.
How this is not leading to absolutely bizzare and pretty much impossible to debug issues?
The idea of abusing FAT file system for specific uses that can work is https://github.com/microsoft/uf2. Note that UF2 operates on different principle and is pretty much limited to write only.
The fakefat in my opinion cannot really work reliably, because host pretty much has complete control over MSC disks.
I believe MTP is the solution for exporting fixed amount of files, not MSC.
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.
How this is not leading to absolutely bizzare and pretty much impossible to debug issues?
What issues and for what use cases? The write accesses can be ignored because we do not change e.g. the FAT, what is emulated anyway.
The idea of abusing FAT file system for specific uses that can work is https://github.com/microsoft/uf2. Note that UF2 operates on different principle and is pretty much limited to write only.
This PR uses a similar principle (also similar to virtual_fs in daplink). One of my intentions is to use it to provide similar functionality as the DAPLink firmware. And I am pretty sure you can read emulated files in UF2 (and daplink's virtual_fs).
The fakefat in my opinion cannot really work reliably, because host pretty much has complete control over MSC disks.
I believe MTP is the solution for exporting fixed amount of files, not MSC.
It works very reliably for what it was developed for. It is not there to export arbitrary file systems or to be something like MTP.
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.
Virtual fs in daplink is actively checking for problems (e.g. data being sent sequential) while this implementation does not.
UF2 is operating on different principle. UF2 only assumes that files are written on sector boundary (i.e. file does not start in the middle of sector) and has plenty of padding.
What exactly do you not expect to work? Or what is not working for you? Where did you find |
Fakefat disk emulates a disk formatted with the FAT file system. The driver supports FAT16 and FAT32 emulation and multiple instances. A backend can register at least 15 emulated files on a disk instance. The file structure contain read and write callbacks that are called when the filesystem driver accesses the volume. A backend can have multiple files with read callbacks, but usually only one or zero with write callbacks. Fakefat disk can be used for testing or to map services such as firmware updates to a file on the emulated disk. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add FAT16 and FAT32 tests for the FFAT disk using ELM FAT file system support. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This sample has two volumes, FAT16 and FAT32, exported via new USB device MSC support. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
5e5d632
to
af3be53
Compare
When the host reorders the files, e.g. deletes a file and then creates a new one things will break.
Code is written for humans. It is annoying when something that can be mistaken as a typo has some very special meaning behind it. In my opinion longer names are generally better because such names avoid ambiguity and are especially helpful for newcomers. |
Fakefat disk emulates a disk formatted with the FAT file system.
The driver supports FAT16 and FAT32 emulation and multiple instances.
A backend can register at least 15 emulated files on a disk instance.
The file structure contain read and write callbacks that are called
when the filesystem driver accesses the volume. A backend can have
multiple files with read callbacks, but usually only one or zero with
write callbacks.
Fakefat disk can be used for testing or to map services such as
firmware updates to a file on the emulated disk.
Complementary to #53798
TODO:
documentation