Skip to content
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

USB Mass Storage emulation (DRAFT) #1060

Closed
wants to merge 2 commits into from

Conversation

kevinwallace
Copy link
Contributor

What's new

I created this hoping that I would be able to put a bunch of bootable ISOs on a microSD card, then emulate and boot off of them using my Flipper Zero. It turns out that it's WAY too slow for this to be usable (120~180kBps in my testing), but probably still fast enough for some uses of "Twin Duck" mode requested in #1040. Presenting this as a draft PR to get people's thoughts on integrating it with BadUSB.

Open questions:

  • "Mass Storage" app is a bit thrown together, mostly copied from BadUSB as a template. Should this be completely integrated into BadUSB or should both apps be kept?
  • USB stuff is currently implemented in applications/mass_storage/helpers/ instead of targets/f7/furi_hal/ like the other USB modes. Should it be moved there? SCSI code, too?
  • Dual USB Mass Storage + HID mode. How do we get them to play along? It might be possible to throw together a combined usb_device_descriptor and set of FuriHalUsbInterface functions that delegate to existing unmodified HID and Mass Storage functions, or it might be more involved. Haven't attempted this yet.
  • Speed. Can it be improved? If the bottleneck is SD SPI, then probably no. If the bottleneck is USB or FS code, maybe.

If someone is interested in taking this code, polishing it up, and integrating it with BadUSB -- or just using it as a starting point for their own independent implementation -- I would be thrilled. My personal use case didn't pan out, and I'm not likely to need "Twin Duck" myself, but it would be a shame to throw this out since it could be useful to others, and given the trial, error, blood, sweat, and tears it took to get to this point.

Here I am booting Debian off of my Flipper. GRUB took several minutes to load. :)

mass_storage_boot_debian

Verification

  • Create mass_storage/ dir on SD card and place disk images in it.
  • Open "Mass Storage" app (under plugins) and select your image
  • Connect Flipper to computer and access over USB Mass Storage interface

Checklist (For Reviewer)

  • PR has description of feature/bug or link to Confluence/Jira task
  • Description contains actions to verify feature/bugfix
  • I've built this code, uploaded it to the device and verified feature/bugfix

@kevinwallace kevinwallace marked this pull request as draft March 26, 2022 05:39
@DrZlo13
Copy link
Member

DrZlo13 commented Mar 26, 2022

Unfortunately, this is exactly the case, SD cards are very slow when connected via SPI, and the maximum theoretical speed is around 500 kbps. That is why we have abandoned the idea of mass storage emulation.

@skotopes
Copy link
Member

There are couple things that can improve speed:

  • DMA for SPI
  • Read Cache

@zhovner
Copy link
Member

zhovner commented Jul 8, 2022

Maybe it can be usable for tiny stuff like one file linux https://github.com/zhovner/OneFileLinux

@hedger hedger added WIP Work In Progress. Do not merge USB BadUSB + physical USB interface UI Affects UI Applications Non-core applications New Feature Contains an IMPLEMENTATION of a new feature labels Jul 20, 2022
@Woodie4
Copy link

Woodie4 commented Aug 20, 2022

+1 This would be amazing... I really hope this will get implemented

@Foul
Copy link
Contributor

Foul commented Aug 25, 2022

The best would be to use Ventoy (https://www.ventoy.net) on it... but don't absolutely know if it's possible... (i'm just a user..)

@kowalski7cc
Copy link
Contributor

The best would be to use Ventoy (https://www.ventoy.net) on it... but don't absolutely know if it's possible... (i'm just a user..)

For booting a full ISO it's too slow, but maybe could be just enough to boot rEFInd when your bootloader is broken.

Also maybe small payloads 🤔

@hramrach
Copy link
Contributor

I would say even if it's slow it can be useful.

Would be also nice if the data flipper collects could be accessed - that's typically small but might be useful to view from the PC.

@turmoni
Copy link

turmoni commented Feb 2, 2023

Just as a potential use case for even very slow mass storage emulation: I stumbled across this PR when looking to see if the Flipper Zero might be able to do one of the things that I want, which is to scan an RFID card and present its ID as a text file over USB.

@kevinwallace
Copy link
Contributor Author

Closing, subsumed by flipperdevices/flipperzero-good-faps#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Applications Non-core applications New Feature Contains an IMPLEMENTATION of a new feature UI Affects UI USB BadUSB + physical USB interface WIP Work In Progress. Do not merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants