I have been trying to get my Raspberry Pi Zero to behave as a USB Mass Storage Device, following https://gist.github.com/gbaman/50b6cca61dd1c3f88f41 and other online documentation.
Steps to reproduce:
- Download Raspbian Jessie Lite or Raspbian Jessie Pixel and write to SD card using Win32DiskImager.
- Connect SD card, HDMI monitor and powered hub for keyboard, mouse and WiFi to Raspberry Pi Zero.
- Connect power, wait for reboot and login (user:
pi
, password:raspberry
). Enable dwc2 overlay and reboot:
echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt sudo reboot now
Create 400MiB disk image, format as FAT and load g_mass_storage driver:
sudo dd if=/dev/zero of=/usb-drive.img bs=1M count=400 sudo mkdosfs -F 32 /usb-drive.img sudo modprobe g_mass_storage file=/usb-drive.img stall=0
Disconnect USB hub.
I've tried then either connecting from the laptop (Windows 10 x64) to the Pi Zero (with a working USB OTG cable, of course) or powering from another USB port, waiting for a couple of minutes (or not waiting at all) and then connecting the USB OTG cable.
Further investigation
I do not have anything showing up in Disk Manager in Windows. I checked Device Manager and it is listed there as Unknown USB Device (Device Descriptor Failed).
Device status
Windows has stopped this device because it has reported problems. (Code 43)
A request for the USB device descriptor failed.
Events
Device not migrated
Device USB\VID_0000&PID_0002\5&21b40883&0&6 could not be migrated. Last Device Instance Id: USB\VID_0781&PID_557D\4C530008200730105360 Class Guid: {36FC9E60-C465-11CF-8056-444553540000} Location Path: Migration Rank: 0xF000FFFFFFFFF032 Present: false Status: 0xC0000719
Device configured (usb.inf)
Device USB\VID_0000&PID_0002\5&21b40883&0&6 was configured. Driver Name: usb.inf Class Guid: {36FC9E60-C465-11CF-8056-444553540000} Driver Date: 06/21/2006 Driver Version: 10.0.14393.0 Driver Provider: Microsoft Driver Section: BADDEVICE.Dev.NT Driver Rank: 0xFF0000 Matching Device Id: USB\DEVICE_DESCRIPTOR_FAILURE Outranked Drivers: usb.inf:USB\DEVICE_DESCRIPTOR_FAILURE:00FF2000 Device Updated: false Parent Device: USB\ROOT_HUB30\4&1070b0ca&0&0
Device not started
Device USB\VID_0000&PID_0002\5&21b40883&0&6 had a problem starting. Driver Name: usb.inf Class Guid: {36FC9E60-C465-11CF-8056-444553540000} Service: Lower Filters: Upper Filters: Problem: 0x2B Problem Status: 0x0
dmesg
log
Checking the device log with dmesg | grep "dwc2"
, there are many entries like this:
[ 79.760006] dwc2 20890000.usb: NYET/NAK/ACK/other in non-error case, 0x00000002
Another attempt
sudo dd if=/dev/zero of=/usb-drive.img bs=1M count=400
sudo mkdosfs -F 32 /usb-drive.img
echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt
echo "dwc2" | sudo tee -a /etc/modules
echo "g_mass_storage" | sudo tee -a /etc/modules
sudo touch /etc/modprobe.d/usb-drive.conf
echo "options g_mass_storage file=/usb-drive.img stall=0" | sudo tee -a /etc/modprobe.d/usb-drive.conf
Conclusion
I followed all the guides available online and further checked with the Linux docs and could not get it working.
Many people report in forums that the g_multi
driver works but requires a specific driver (RNDIS, to be exact) on the host to function. The problem is that I wish to boot GParted from the Pi Zero and cannot install RNDIS drivers on the laptop's BIOS/EFI firmware.
How do I configure the Raspberry Pi Zero to show itself as a Mass Storage Device? Is there something I have missed?
sleep 10 && sudo shutdown now
in step #5? Obviously, the mass storage target won't work if the Pi is shut down. – sfk Mar 27 '17 at 12:36/etc/modules/
and the parameters in/etc/modprobe.d/usb-drive.conf
, as outlined in “Another attempt”. – Toothbrush Mar 27 '17 at 14:31dmesg | grep "dwc2"
: "dwc2 20890000.usb: NYET/NAK/ACK/other in non-error case, 0x00000002". – Toothbrush Mar 30 '17 at 21:51