Raspberry Pi Zero as read write mass storage - module

I am trying to setup a Raspberry Pi Zero as a mass storage with dwc2 and g_mass_storage (using the last Raspbian image available).
I created the data storage file with dd, made it a FAT32 fs with mkdosfs.
I looked for a lot of things. I spent some time to understand that options should be passed in /etc/modprobe.d/g_mass_storage.conf
It is finally seen in ubuntu. My problem is : it is in read only mode.
I tried to set the ro option to y or n without any impact on the behaviour. I changed permissions on the file (777), it changed nothing.
here is the current content of my /etc/modprobe.d/g_mass_storage.conf file :
options g_mass_storage file=/piusb.bin stall=0 removable=y ro=n
here is the of dmesg from the ubuntu :
[Today and now]usb 1-1.2: new high-speed USB device number 28 using ehci-pci
[ +0,299994] usb 1-1.2: device descriptor read/64, error -71
[ +0,959969] usb 1-1.2: device descriptor read/64, error -71
[ +0,187918] usb 1-1.2: new high-speed USB device number 29 using ehci-pci
[ +0,113925] usb 1-1.2: New USB device found, idVendor=0525, idProduct=a4a5
[ +0,000007] usb 1-1.2: New USB device strings: Mfr=3, Product=4, SerialNumber=0
[ +0,000004] usb 1-1.2: Product: Mass Storage Gadget
[ +0,000003] usb 1-1.2: Manufacturer: Linux 4.19.118+ with 20980000.usb
[ +0,001467] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[ +0,000246] usb-storage 1-1.2:1.0: Quirks match for vid 0525 pid a4a5: 10000
[ +0,000283] scsi host9: usb-storage 1-1.2:1.0
[ +1,009528] scsi 9:0:0:0: Direct-Access Linux File-Stor Gadget 0419 PQ: 0 ANSI: 2
[ +0,001079] sd 9:0:0:0: Attached scsi generic sg5 type 0
[ +0,001699] sd 9:0:0:0: Power-on or device reset occurred
[ +0,001211] sd 9:0:0:0: [sde] 67108864 512-byte logical blocks: (34.4 GB/32.0 GiB)
[ +0,000672] sd 9:0:0:0: [sde] Write Protect is on
[ +0,000016] sd 9:0:0:0: [sde] Mode Sense: 0f 00 80 00
[ +0,000740] sd 9:0:0:0: [sde] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ +0,005478] sde:
[ +0,002735] sd 9:0:0:0: [sde] Attached SCSI removable disk
What to do to get a read/write mass storage ?

I reproduced your problem. I had a similar problem with the module g_acm_ms on Raspberry Pi Zero W. If you configure the module in /etc/modprobe.d/, then the system ignores the parameter ro=0. Perhaps this is due to the order of initialization of kernel modules. I got around this by adding the module to the blacklist and writing the initialization in /etc/rc.local. Thus, I managed to get an emulation of a read/write mass storage.
All steps:
Create and format the file:
# dd bs=1M if=/dev/zero of="/piusb.bin" count=2048
# mkdosfs "/piusb.bin"
Add modules-load=dwc2,g_acm_ms to end of /boot/cmdline.txt (after rootwait)
Add the string dtoverlay=dwc2 in /boot/config.txt
Prevent module initialization at startup:
$ echo "blacklist g_acm_ms" | sudo tee -a "/etc/modprobe.d/blacklist-g_acm_ms.conf"
Add initialization in /etc/rc.local above exit 0:
# nano /etc/rc.local
Add string:
/sbin/modprobe file=/piusb.bin removable=y ro=0 stall=0
Reboot system:
# reboot -h
P.S.: If you don't want to use USB for console output, you can use g_mass_storage instead of g_acm_ms.

Related

How do I make a free VLM from kemp boot on a physical LoadMaster

I know this isn't the right place to ask this but this site has the most users on it. I recently bought a Kemp LoadMaster LM-2600 Load Balancer for my webservers. However, this unit didn't include an SSD because the previous owner decided to erase it. So, I downloaded the VirtualBox version of free VLM from kemp's website. Then, I used VBoxManage clonehd LMOS.vmdk LMOS.img --format RAW to turn the disk into a raw img file. Then, I used dd if=LMOS.img of=/dev/sdb to flash a USB with the os. Then, I booted my loadmaster with the USB.
The boot process went like normal until it finished booting and then the machine switched to runlevel 0 (Shutdown)
This is the logs I got when I plugged the USB into my computer (The log file was so big that stack overflow won't allow me to paste it here):
https://pastebin.com/5PbKzRi6
I noticed that it said something about eth0 being down so I plugged in an ethernet cable and booted it again. The same thing happened but I got a different error (The log was shorter so I labeled it):
-- BOOT --
2022-08-07T19:50:06+00:00 lb100 syslog-ng: syslog-ng starting up; version='3.25.1'
-- ERROR --
2022-08-07T19:50:07+00:00 lb100 raid_events_handler: RAID controller not detected yet (check # 0)
-- LOGIN --
2022-08-07T19:50:11+00:00 lb100 login: pam_unix(login:session): session opened for user bal by LOGIN(uid=0)
-- ERROR --
2022-08-07T19:50:14+00:00 lb100 raid_events_handler: RAID controller not detected yet (check # 1)
-- SHUTDOWN --
2022-08-07T19:50:15+00:00 lb100 init: Switching to runlevel: 0
2022-08-07T19:50:15+00:00 lb100 kernel: S99final (938): drop_caches: 1
2022-08-07T19:50:17+00:00 lb100 syslog-ng: syslog-ng shutting down; version='3.25.1'
2022-08-07T19:50:17+00:00 lb100 kernel: Kernel logging (proc) stopped.
2022-08-07T19:50:17+00:00 lb100 kernel: Kernel log daemon terminating.
2022-08-07T19:50:17+00:00 lb100 sslproxy: (815) caught signal 15
2022-08-07T19:50:17+00:00 lb100 raid_events_handler: stop
I have no idea what to do right now. I already tried everything I knew. What should I do?
Any help would be great,
Thanks!

Raspberry Pi 4B does not detect USB storage devices

I tried plugging two flash drives into a Raspberry Pi 4B one after another but the Pi does not seem to detect any of the drives. Here is the dmesg output
[ 177.737328] cpu cpu0: dev_pm_opp_set_rate: failed to find current OPP for freq 4294967186 (-34)
[ 180.446246] raspberrypi-clk soc:firmware:clocks: Failed to change fw-clk-arm frequency: -110
[ 181.036364] xhci_hcd 0000:01:00.0: Abort failed to stop command ring: -110
[ 181.052412] xhci_hcd 0000:01:00.0: Host halt failed, -110
[ 181.052421] xhci_hcd 0000:01:00.0: xHCI host controller not responding, assume dead
[ 181.052446] xhci_hcd 0000:01:00.0: HC died; cleaning up [ 181.052645] xhci_hcd 0000:01:00.0: Timeout while waiting for setup device command
[ 181.053349] usb 1-1: USB disconnect, device number 2
[ 181.536432] usb 1-1.3: device not accepting address 5, error -108
[ 181.536608] usb 1-1-port3: couldn't allocate usb_device
Any help is appreciated. Thanks in advance
USB problems in RPi typically happens because of a corrupted kernel, try to update it then give me a feedback.

ERROR: configuring avrdude for ATmega328P-XMINI (i think the evildoer is)->(avrdude: usbdev_send(): wrote -5 out of 7 bytes, err = Input/output error)

I have an ATmega328P-XMINI microchip (googling gave me a result that its an 8 bit chip).
Im new to embedded programming. And need some help getting on my way. For now im just trying to establish a connection with avrdude (im just trying to get a healthy connection loading code to the chip comes later). But i get this error. I dont know how to fix this or what is going wrong.
What i do know is that there is an usbdev input output error what i think is the culprit.
The other line exclaiming that the usb device is busy is also suspicous.
DISCLAIMER: I use gentoo and cause of this have no access to atmel studio (I have no access to windows programs).
command issued (tried with and without sudo):
sudo avrdude -p m328p -c xplainedmini
Error code:
avrdude: usb_open(): cannot read serial number "Connection timed out"
avrdude: usb_open(): cannot read product name "Connection timed out"
avrdude: usbdev_open(): WARNING: failed to set configuration 1: Device or resource busy
avrdude: usbdev_send(): wrote -5 out of 7 bytes, err = Input/output error
avrdude: jtag3_send(): failed to send command to serial port
avrdude: failed to sync with the JTAGICE3 in ISP mode
Dmesg after connecting:
[ 7704.920695] usb 2-2: new full-speed USB device number 6 using xhci_hcd
[ 7705.048875] usb 2-2: New USB device found, idVendor=03eb, idProduct=2145, bcdDevice=10.00
[ 7705.048877] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 7705.048878] usb 2-2: Product: mEDBG CMSIS-DAP
[ 7705.048880] usb 2-2: Manufacturer: ATMEL
[ 7705.048881] usb 2-2: SerialNumber: ATML2323051800004280
[ 7705.051076] hid-generic 0003:03EB:2145.0003: hiddev97,hidraw1: USB HID v1.11 Device [ATMEL mEDBG CMSIS-DAP] on usb-0000:00:14.0-2/input0
[ 7705.051145] cdc_acm 2-2:1.1: ttyACM0: USB ACM device
microchip documentation and product page
Any tips for debugging this problem in general im thankfull for.
Never mind i spent 20 minutes formulating the question and formatting it. Just to realize that plugging it out and in fixed it.
IM AN IDIOT!

Automount USB flash drive on Raspbian Stretch lite with udev

I'm using a udev rule to automount USB flash drives on my Raspberry Pi. I found this solution few months ago and I worked very well until I start using Raspbian Stretch lite.
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="\$env{mount_options},utf8,gid=100,umask=002"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/usbstick", RUN+="/bin/mount -o \$env{mount_options} /dev/%k /media/usbstick"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/usbstick", RUN+="/bin/rmdir /media/usbstick"
# Exit
LABEL="media_by_label_auto_mount_end"
And here is what I see in dmesg
[ 524.042731] usb 1-1.4: new high-speed USB device number 6 using dwc_otg
[ 524.174634] usb 1-1.4: New USB device found, idVendor=090c, idProduct=1000
[ 524.174649] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 524.174658] usb 1-1.4: Product: Flash Disk
[ 524.174666] usb 1-1.4: Manufacturer: USB
[ 524.174674] usb 1-1.4: SerialNumber: SCY0000000105542
[ 524.175515] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[ 524.175994] scsi host0: usb-storage 1-1.4:1.0
[ 525.399056] scsi 0:0:0:0: Direct-Access USB Flash Disk 1100 PQ: 0 ANSI: 4
[ 525.399986] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 525.400243] sd 0:0:0:0: [sda] 15974400 512-byte logical blocks: (8.18 GB/7.62 GiB)
[ 525.401232] sd 0:0:0:0: [sda] Write Protect is off
[ 525.401259] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[ 525.401948] sd 0:0:0:0: [sda] No Caching mode page found
[ 525.401965] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 525.415578] sda: sda1
[ 525.418642] sd 0:0:0:0: [sda] Attached SCSI removable disk
Do anybody has a similar solution that works with Raspbian Stretch lite?

How To Mount USD External Storage Drive on to ESXi 5.5 Host for VM backup

How To Mount USD External Storage Drive on to ESXi 5.5 Host for VM backup
After USB Drive plugin, "esxcli storage core device list" shows there is a usb drive attached. But unable to access it.
"esxcli storage core device list "
mpx.vmhba38:C0:T0:L0
Display Name: Local USB Direct-Access (mpx.vmhba38:C0:T0:L0)
Has Settable Display Name: false
Size: 1907729
Device Type: Direct-Access
Multipath Plugin: NMP
Devfs Path: /vmfs/devices/disks/mpx.vmhba38:C0:T0:L0
Vendor: Seagate
Model: BUP Slim BL
Revision: 0108
SCSI Level: 2
Is Pseudo: false
Status: on
Is RDM Capable: false
Is Local: true
Is Removable: true
Is SSD: false
Is Offline: false
Is Perennially Reserved: false
Queue Full Sample Size: 0
Queue Full Threshold: 0
Thin Provisioning Status: unknown
Attached Filters:
VAAI Status: unsupported
Other UIDs: vml.0000000000766d68626133383a303a30
Is Local SAS Device: false
Is USB: true
Is Boot USB Device: false
No of outstanding IOs with competing worlds: 32
"esxcli storage core path list -d mpx.vmhba38:C0:T0:L0"
usb.vmhba38-usb.0:0-mpx.vmhba38:C0:T0:L0
UID: usb.vmhba38-usb.0:0-mpx.vmhba38:C0:T0:L0
Runtime Name: vmhba38:C0:T0:L0
Device: mpx.vmhba38:C0:T0:L0
Device Display Name: Local USB Direct-Access (mpx.vmhba38:C0:T0:L0)
Adapter: vmhba38
Channel: 0
Target: 0
LUN: 0
Plugin: NMP
State: active
Transport: usb
Adapter Identifier: usb.vmhba38
Target Identifier: usb.0:0
Adapter Transport Details: Unavailable or path is unclaimed
Target Transport Details: Unavailable or path is unclaimed
Maximum IO Size: 122880
Note: I stopped usbarbitrator.
/etc/init.d/usbarbitrator status
usbarbitrator is not running
Please advice.
There are very few USB drives that work directly against an ESXi host, and versions prior to 6.0 had a very strict ruleset against mounting unsupported devices.
I'm assuming you're attempting to mount the USB drive as a VMFS volume, which is unsupported regardless of what version, however there is a list of supported devices that work for passthrough activities. I would assume these could be used as VMFS mounts as well: https://kb.vmware.com/kb/1021345
While it looks like you're following the proper steps, here's a detailed list that may help: https://kb.vmware.com/s/article/2065934
Alternatively, since USB performance is generally pretty slow on ESXi hosts, you could also perform your backup activities on the VM and then SCP the files off the ESXi host to the USB drive.