2023年10月15日 星期日

usb otg file transfer to visual samba protocol raspberry-pi/bruno-silva/raspberry-pi-zero-wireless-smart-usb-flash-drive-samba-server/

https://www.geekering.com/categories/embedded-sytems/raspberry-pi/bruno-silva/raspberry-pi-zero-wireless-smart-usb-flash-drive-samba-server/
https://gist.github.com/gbaman/50b6cca61dd1c3f88f41#raspberry-pi-zero-otg-mode
https://forums.raspberrypi.com/viewtopic.php?t=208616
         USB Flash / Pendrive looking - WiFi network storage (Samba) client - Raspberry Pi Forums
         Networked USB Flash Drive USB visual  Flash Drive  Wi-Fi
https://m.totolink.net/portal/article/index/id/162/cid/6.html


How to setup Window File Sharing (SAMBA) of USB Storage?
         OTG USB Driver  Storage Device Mode
https://wiki.analog.com/resources/tools-software/linuxdsp/docs/linux-kernel-and-drivers/usb/start
https://community.nxp.com/t5/i-MX-Processors/How-to-use-USB-OTG-as-gadget-HID/m-p/612999?ru=206296&sr=stream
analog adsp  OTG USB Mass Storage Gadget USB OTG as gadget HID
How to use Flash Drive with STM32 || USB HOST MSC || CubeIDE

https://docs.freebsd.org/en/books/handbook/usb-device-mode/
28.2. USB Virtual Serial Ports 28.2.1. Configuring USB Device Mode Serial Ports
https://community.st.com/t5/stm32-mcus-products/multiple-usb-virtual-com-port/td-p/578645
Multiple USB virtual com port STMicroelectronics Community Serial to usb usb-to-32 serial


https://www.engineersgarage.com/usb-mass-storage-in-lpc1768-part-21-21/
https://hackaday.com/2015/12/27/turning-the-pi-zero-into-a-usb-gadget/
https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget?view=all
https://github.com/raspberrypi/linux/issues/1212

https://controllerstech.com/stm32-usb-msc/
          STM32 USB MSC Device using RAM/SD CARD ControllersTech

https://superuser.com/questions/1062991/linux-usb-mass-storage-emulation
http://www.linux-usb.org/gadget/file_storage.html
Backing Storage for the Mass Storage Gadget
          Converting Any USB Device to A Wireless USB using Raspberry Pi Zero
https://youtu.be/I5zA1lU5Tw0?si=Fl3__IP-m5jjyA24
          An Arduino that shows up like a disk drive?? YES! IT IS FINALLY HERE!
           How to fix a usb mass storage device problem
           Linux USB Mass Storage Emulation
           How To Fix A USB Mass Storage Device Problem [Tutorial]

https://superuser.com/questions/1062991/linux-usb-mass-storage-emulation

Tom Yan,

Thanks for your useful answer. I successfuly loaded the dummy-hcd module. Then, modprobe of the g_mass_storage module :

modprobe g_mass_storage file=/root/myUSBStorage/mass_storage.img stall=0 removable=y iSerialNumber=1234567890

I have now the following dmesg :


[  205.564158] g_mass_storage gadget: Mass Storage Function, version: 2009/09/11    
[  205.564164] g_mass_storage gadget: Number of LUNs=1    
[  205.564170]  lun0: LUN: removable file: /root/mass_storage.img    
[  205.564191] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11    
[  205.564194] g_mass_storage gadget: g_mass_storage ready    
[  205.780209] usb 3-1: new high-speed USB device number 2 using dummy_hcd    
[  205.952109] usb 3-1: New USB device found, idVendor=0525, idProduct=a4a5    
[  205.952124] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3    
[  205.952133] usb 3-1: Product: Mass Storage Gadget    
[  205.952140] usb 3-1: Manufacturer: Linux 3.11.0-15-generic with dummy_udc    
[  205.952145] usb 3-1: SerialNumber: 1234567890    
[  205.956075] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage    
[  206.020057] usb-storage 3-1:1.0: USB Mass Storage device detected    
[  206.020255] usb-storage 3-1:1.0: Quirks match for vid 0525 pid a4a5: 10000    
[  206.020477] scsi3 : usb-storage 3-1:1.0    
[  206.020856] usbcore: registered new interface driver usb-storage    
[  207.036061] scsi 3:0:0:0: Direct-Access     Linux    File-Stor Gadget 0311 PQ: 0 ANSI: 2    
[  207.036807] sd 3:0:0:0: Attached scsi generic sg2 type 0    
[  207.076081] sd 3:0:0:0: [sdb] 8192 512-byte logical blocks: (4.19 MB/4.00
MiB)    
[  207.088158] sd 3:0:0:0: [sdb] Write Protect is off    
[  207.088174] sd 3:0:0:0: [sdb] Mode Sense: 0f 00 00 00    
[  207.100210] sd 3:0:0:0: [sdb] Write cache: enabled, read cache: enabled,
doesn't support DPO or FUA
[  207.180419]  sdb: sdb1    
[  207.268281] sd 3:0:0:0: [sdb] Attached SCSI removable disk


FYI, I had to create the partition table and filesystem inside the emulation. I can now successfuly mount the emulated media.


mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/sdb1 on /mnt type vfat (rw)

Mathieu

USB Mass Storage

USB Mass Storage Device Class XMOS
https://www.xmos.com › download › AN0012... This application note shows how to create a USB device compliant to the standard USB mass storage device class on an XMOS multicore microcontroller.

USB Mass Storage Device Implementation Microchip Technology
https://ww1.microchip.com › Appnotes › doc7516 The USB Mass Storage device replaces Floppy, and can be used in many other applications: –. USB mouse for laptop with Mass Storage integrated. –. External Hard ...

USB Mass Storage Device (MSD) Host Bootloader NXP Semiconductors
https://www.nxp.com › docs › application-note The USB Host MSD bootloader provides an easy and reliable way to load user applications to devices. After a USB memory stick containing a valid s-record or.

http://www.xmos.com/published/glossary
http://www.xmos.com/published/xuddg
http://www.xmos.com/published/xmos-usb-device-design-guide
      USB flash drive
      memory card reader
      digital audio player
      digital camera
      external hard drive
The USB specification provides as standard device class for the implementation of USB mass storage.(http://www.usb.org/developers/docs/devclass_docs/usbmassbulk_10.pdf)

static unsigned char devDesc[] =
{
0x12, /* 0 bLength */
USB_DESCTYPE_DEVICE, /* 1 bdescriptorType */
0x00, /* 2 bcdUSB version */
0x02, /* 3 bcdUSB version */
0x00, /* 4 bDeviceClass - Specified by interface */
0x00, /* 5 bDeviceSubClass - Specified by interface */
0x00, /* 6 bDeviceProtocol - Specified by interface */
0x40, /* 7 bMaxPacketSize for EP0 - max = 64*/
(VENDOR_ID & 0xFF), /* 8 idVendor */
(VENDOR_ID >> 8), /* 9 idVendor */
(PRODUCT_ID & 0xFF), /* 10 idProduct */
(PRODUCT_ID >> 8), /* 11 idProduct */
(BCD_DEVICE & 0xFF), /* 12 bcdDevice */
(BCD_DEVICE >> 8), /* 13 bcdDevice */
0x01, /* 14 iManufacturer - index of string */
0x02, /* 15 iProduct - index of string */
0x03, /* 16 iSerialNumber - index of string */
0x01 /* 17 bNumConfigurations */

APPENDIX D - References
XMOS Tools User Guide
http://www.xmos.com/published/xtimecomposer-user-guide
XMOS xCORE Programming Guide
http://www.xmos.com/published/xmos-programming-guide
XMOS xCORE-USB Device Library:
http://www.xmos.com/published/xuddg
XMOS USB Device Design Guide:
http://www.xmos.com/published/xmos-usb-device-design-guide
USB Mass Storage Class Bulk-Only Transport
http://www.usb.org/developers/docs/devclass_docs/usbmassbulk_10.pdf
USB 2.0 Specification
http://www.usb.org/developers/docs/usb20_docs/usb_20_081114.zip
USB Mass Storage Specification For Bootability
http://www.usb.org/developers/docs/devclass_docs/usb_msc_boot_1.0.pdf
SCSI Command
http://en.wikipedia.org/wiki/SCSI_command
SCSI Commands Reference Manual (Seagate)
http://www.seagate.com/staticfiles/support/disc/manuals/Interface%20manuals/100293068c.pdf
USB Mass Storage Device Specification Overview5.

https://www.usb.org/sites/default/files/usbmassbulk_10.pdf
https://www.usb.org/documents?search=&type%5B0%5D=55&items_per_page=50

usb mass storage device protocol description control bulk interrupt
usb mass storage device id Description USB Mass Storage Device Generic USB Flash Disk
Mass Storage device Protocal Version USB 2.00 Current Speed High Speed Device Type Mass Storage Device Base Class SubClass Protocol Meaning 08h xxh

https://wiki.osdev.org/Universal_Serial_Bus

AN2554 Microchip Technology https://ww1.microchip.com › downloads › Appnotes— In summary, a USB Mass Storage Class Device. (MSD) consists of 1 control endpoint and 2 bulk endpoints. • Control endpoint (endpoint 0).

USB Peripheral Mass Storage Class Driver for ...Renesas https://www.renesas.com › document › apn › rx-f...This module operates in combination with the USB Basic Mini Host and Peripheral. Driver. It is referred to below as the USB PMSC FIT module.

Introduction to USB with STM32 - stm32mcu - ST Wiki STMicroelectronics https://wiki.st.com › wiki › Introduction...2.2 Mass Storage Class (MSC)↑. This class code is implemented to access and communicate with USB Mass Storage devices based on the “Bulk-Only Transport ...

USB Flash Drive Speed Tests - VID = bda, PID = 159 - NirSoft NirSoft http://usbspeed.nirsoft.net › ...In this page, you can find the speed test results of USB flash drives, made by USBDeview utility. USBDeview make this test by writing a large file into the USB ...

List of USB ID's  Linux USB http://www.linux-usb.org › usb... Pen Flash 8183 Hi-Speed Mass Storage Device 8185 SDCZ2 Cruzer Mini Flash Drive (older, thick) 8888 Card Reader 8889 SDDR-88 Imagemate 8-in-1 Reader 8919 ...