BeagleBone Pocket CAN0 and CAN1 doesn't work - linux

I have an issue with my beaglebone pocket and I need help. I try to setup can0 with an MCP2551 transceiver. I load BB-CAN0-00A0.dtbo and BB-CAN1-00A0.DTBO but i have no can device in /sys/class/net and device can0 and can1 doesn't exist.
This is my version.sh log
git:/opt/scripts/:[73593ebe3b7d3cc381eeb502d45ccb33a6ec5e78]
eeprom:[A335PBGL00A21748EPB00201]
model:[TI_AM335x_PocketBeagle]
dogtag:[BeagleBoard.org Debian Image 2018-08-30]
bootloader:[microSD]:[/dev/mmcblk0]:[U-Boot 2018.03-00002-gac9cce7c6a]:[location: dd MBR]
kernel:[4.14.67-ti-r73]
nodejs:[v6.14.4]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr4=/lib/firmware/BB-CAN0-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr5=/lib/firmware/BB-CAN1-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.4.20180803.0-0rcnee0~stretch+20180804]
pkg:[bb-wl18xx-firmware]:[1.20180517-0rcnee0~stretch+20180517]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
pkg:[librobotcontrol]:[1.0.2-git20180829.0-0rcnee0~stretch+20180830]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee1~stretch+20180328]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep pinctrl-single
[ 1.148050] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
[ 1.241720] pinctrl-single 44e10800.pinmux: pin PIN95 already requested by ocp:P1_28_pinmux; cannot claim for 481cc000.can
[ 1.253051] pinctrl-single 44e10800.pinmux: pin-95 (481cc000.can) status -22
[ 1.260180] pinctrl-single 44e10800.pinmux: could not request pin 95 (PIN95) from group pinmux_dcan0_pins on device pinctrl-single
[ 1.280383] pinctrl-single 44e10800.pinmux: pin PIN97 already requested by ocp:P2_09_pinmux; cannot claim for 481d0000.can
[ 1.291556] pinctrl-single 44e10800.pinmux: pin-97 (481d0000.can) status -22
[ 1.298668] pinctrl-single 44e10800.pinmux: could not request pin 97 (PIN97) from group pinmux_dcan1_pins on device pinctrl-single
dmesg | grep gpio-of-helper
[ 1.156291] gpio-of-helper ocp:cape-universal: ready
END
And my /boot/uEnv.txt:
uname_r=4.14.67-ti-r73
#uuid=
#dtb=
###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
###Master Enable
enable_uboot_overlays=1
###
###Overide capes with eeprom
#uboot_overlay_addr0=/lib/firmware/.dtbo
#uboot_overlay_addr1=/lib/firmware/.dtbo
#uboot_overlay_addr2=/lib/firmware/.dtbo
#uboot_overlay_addr3=/lib/firmware/.dtbo
###
###Additional custom capes
uboot_overlay_addr4=/lib/firmware/BB-CAN0-00A0.dtbo
uboot_overlay_addr5=/lib/firmware/BB-CAN1-00A0.dtbo
#uboot_overlay_addr6=/lib/firmware/.dtbo
#uboot_overlay_addr7=/lib/firmware/.dtbo
###
###Custom Cape
#dtb_overlay=/lib/firmware/.dtbo
###
###Disable auto loading of virtual capes (emmc/video/wireless/adc)
#disable_uboot_overlay_emmc=1
#disable_uboot_overlay_video=1
#disable_uboot_overlay_audio=1
#disable_uboot_overlay_wireless=1
#disable_uboot_overlay_adc=1
###
###PRUSS OPTIONS
###pru_rproc (4.4.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo
###pru_rproc (4.14.x-ti kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_uio (4.4.x-ti, 4.14.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
###
###Cape Universal Enable
enable_uboot_cape_universal=1
###
###Debug: disable uboot autoload of Cape
#disable_uboot_overlay_addr0=1
#disable_uboot_overlay_addr1=1
#disable_uboot_overlay_addr2=1
#disable_uboot_overlay_addr3=1
###
###U-Boot fdt tweaks... (60000 = 384KB)
#uboot_fdt_buffer=0x60000
###U-Boot Overlays###
cmdline=coherent_pool=1M net.ifnames=0 quiet
#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M net.ifnames=0 quiet video=HDMI-A-1:1024x768#60e
#Use an overlayfs on top of a read-only root filesystem:
#cmdline=coherent_pool=1M net.ifnames=0 quiet overlayroot=tmpfs
##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
If you have any suggestion, I don't understand what's wrong in my configuration.
Thanks

cape-universal can conflict with overlays that you're trying to load. Such as in this case.
A possible route is to disable cape-universal. Another option might be to try set things up at run-time. For a static hardware setup that won't change the former is much preferable though.
Please note that the default images for the BBB keep evolving and thus this is not an universal answer.

Related

How to find reasons why an udev rule is not applied?

I added an udev rule to generate a separate link to a special tty device. I took the vendor and product id from lsusb:
Bus 001 Device 016: ID abcd:1234 Foo Device
The dmesg output for the device is:
[ 369.384850] usb 1-1.1: new full-speed USB device number 4 using xhci_hcd
[ 369.470492] usb 1-1.1: New USB device found, idVendor=09d8, idProduct=0420
[ 369.470506] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 369.470515] usb 1-1.1: Product: TWN4/B1.06/CCL3.12/PRS1.04
[ 369.470522] usb 1-1.1: Manufacturer: OEM
[ 369.475188] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device
Normally the Debian system generates an ACM* tty for this device:
$ ls /dev/ttyACM*
/dev/ttyACM0
So I created /ect/udev/rules.d/99-bizrfid.rules:
ACTION=="add", ATTRS{idVendor}=="09d8", ATTRS{idProduct}=="0420", SYMLINK+="ttyMyDevice"
But ls /dev/tty* does not show ttyMyDevice.
What I tried so far without success:
Running udevadm trigger. This should apply the new udev rule.
I did a reboot.
I had a look to udevadm test /dev/ttyACM0. My udevrule is shown at the end. So I am sure that it had not been overridden. But I wonder about the 'unable to open' hint. Nevertheless this hint is present for other ttys, such as tty0 or ttyS0, too.
...
Reading rules file: /lib/udev/rules.d/98-systemd.rules
Reading rules file: /etc/udev/rules.d/99-bizrfid.rules
rules contain 49152 bytes tokens (4096 * 12 bytes), 12883 bytes strings
4240 strings (40079 bytes), 3515 de-duplicated (27922 bytes), 726 trie nodes used
unable to open device '/sys/dev/ttyACM0'
Unload module index
Unloaded link configuration context.
I reconnected the USB device.
I tried another udev rule. This rule is 100% correct because I use this rule already fo other devices. But it does not work for the ttyACM0:
ACTION=="add", KERNEL=="ttyACM*", MODE="0666"
I wonder why this is not working.
How to find reasons why an udev rule is not applied?
For the udev rule
/ect/udev/rules.d/99-bizrfid.rules I would add the SUBSYSTEM:
ACTION=="add", SUBSYSTEM=="tty", ATTRS{idVendor}=="09d8", ATTRS{idProduct}=="0420", SYMLINK+="ttyMyDevice"
You could add also ATTRS{manufacturer}==, but idVendor and idProduct are sufficient.
Otherwise it looks correct and the test run creates the symlink:
creating link '/dev/ttyMyDevice' to '/dev/ttyACM0'
According to the comments I the following can be tried to debug the problem:
Check the driver
Use dmesg to check the driver you are using and ensure that it is a generic one. If it is a custom compiled one, the problem could be inside your custom implementation. If it is a generic one, go on to step two. I found the driver name in the last line: cdc_acm
[ 369.384850] usb 1-1.1: new full-speed USB device number 4 using xhci_hcd
[ 369.470492] usb 1-1.1: New USB device found, idVendor=09d8, idProduct=0420
[ 369.470506] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 369.470515] usb 1-1.1: Product: TWN4/B1.06/CCL3.12/PRS1.04
[ 369.470522] usb 1-1.1: Manufacturer: OEM
[ 369.475188] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device
Check the user permissions
Ensure that the permission of your udev rule is correct:
chmod 644 99-myrule.rules
chown root:root 99-myrule.rules
Do a test run for the add-action
Check the output of udevadm test -a add $(udevadm info -q path -n /dev/ttyACM0). My output looks like this:
calling: test
version 232
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
=== trie on-disk ===
tool version: 232
file size: 8447696 bytes
header size 80 bytes
strings 1849040 bytes
nodes 6598576 bytes
Load module index
Found container virtualization none
timestamp of '/etc/systemd/network' changed
timestamp of '/usr/lib/systemd/network' changed
timestamp of '/lib/systemd/network' changed
Parsed configuration file /lib/systemd/network/99-default.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Skipping overridden file: /lib/udev/rules.d/99-bizrfid.rules.
Reading rules file: /lib/udev/rules.d/50-firmware.rules
...
Reading rules file: /lib/udev/rules.d/98-systemd.rules
Reading rules file: /etc/udev/rules.d/99-bizrfid.rules
rules contain 49152 bytes tokens (4096 * 12 bytes), 12900 bytes strings
4244 strings (40114 bytes), 3517 de-duplicated (27942 bytes), 728 trie nodes used
GROUP 20 /lib/udev/rules.d/50-udev-default.rules:26
IMPORT builtin 'hwdb' /lib/udev/rules.d/60-serial.rules:7
IMPORT builtin 'usb_id' /lib/udev/rules.d/60-serial.rules:8
/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1:1.0: if_class 2 protocol 0
IMPORT builtin 'hwdb' /lib/udev/rules.d/60-serial.rules:8
IMPORT builtin 'path_id' /lib/udev/rules.d/60-serial.rules:15
LINK 'serial/by-path/pci-0000:00:14.0-usb-0:1.1:1.0' /lib/udev/rules.d/60-serial.rules:16
IMPORT builtin skip 'usb_id' /lib/udev/rules.d/60-serial.rules:19
LINK 'serial/by-id/usb-OEM_TWN4_B1.06_CCF3.00_PRS1.04-if00' /lib/udev/rules.d/60-serial.rules:23
LINK 'ttyMyDevice' /etc/udev/rules.d/99-bizrfid.rules:1
handling device node '/dev/ttyACM0', devnum=c166:0, mode=0660, uid=0, gid=20
preserve permissions /dev/ttyACM0, 020660, uid=0, gid=20
preserve already existing symlink '/dev/char/166:0' to '../ttyACM0'
found 'c166:0' claiming '/run/udev/links/\x2fserial\x2fby-id\x2fusb-OEM_TWN4_B1.06_CCF3.00_PRS1.04-if00'
creating link '/dev/serial/by-id/usb-OEM_TWN4_B1.06_CCF3.00_PRS1.04-if00' to '/dev/ttyACM0'
preserve already existing symlink '/dev/serial/by-id/usb-OEM_TWN4_B1.06_CCF3.00_PRS1.04-if00' to '../../ttyACM0'
found 'c166:0' claiming '/run/udev/links/\x2fserial\x2fby-path\x2fpci-0000:00:14.0-usb-0:1.1:1.0'
creating link '/dev/serial/by-path/pci-0000:00:14.0-usb-0:1.1:1.0' to '/dev/ttyACM0'
preserve already existing symlink '/dev/serial/by-path/pci-0000:00:14.0-usb-0:1.1:1.0' to '../../ttyACM0'
creating link '/dev/ttyMyDevice' to '/dev/ttyACM0'
creating symlink '/dev/ttyMyDevice' to 'ttyACM0'
created db file '/run/udev/data/c166:0' for '/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1:1.0/tty/ttyACM0'
ACTION=add
DEVLINKS=/dev/serial/by-path/pci-0000:00:14.0-usb-0:1.1:1.0 /dev/serial/by-id/usb-OEM_TWN4_B1.06_CCF3.00_PRS1.04-if00 /dev/ttyMyDevice
DEVNAME=/dev/ttyACM0
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1:1.0/tty/ttyACM0
ID_BUS=usb
ID_MODEL=TWN4_B1.06_CCF3.00_PRS1.04
ID_MODEL_ENC=TWN4\x2fB1.06\x2fCCF3.00\x2fPRS1.04
ID_MODEL_FROM_DATABASE=Atom Processor Z36xxx/Z37xxx, Celeron N2000 Series USB xHCI
ID_MODEL_ID=0420
ID_PATH=pci-0000:00:14.0-usb-0:1.1:1.0
ID_PATH_TAG=pci-0000_00_14_0-usb-0_1_1_1_0
ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
ID_PCI_INTERFACE_FROM_DATABASE=XHCI
ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
ID_REVISION=0200
ID_SERIAL=OEM_TWN4_B1.06_CCF3.00_PRS1.04
ID_TYPE=generic
ID_USB_CLASS_FROM_DATABASE=Communications
ID_USB_DRIVER=cdc_acm
ID_USB_INTERFACES=:020201:0a0000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=OEM
ID_VENDOR_ENC=OEM
ID_VENDOR_FROM_DATABASE=Intel Corporation
ID_VENDOR_ID=09d8
MAJOR=166
MINOR=0
SUBSYSTEM=tty
TAGS=:systemd:
USEC_INITIALIZED=71480300178
Unload module index
Unloaded link configuration context.

Udev rule for input device

I have a camera device that has an input device listed under /dev/input. I would like to add that input device to the group plugdev.
When I plug in the camera:
[ 704.406837] input: See3CAM_CU51 as /devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.0/input/input21
[ 705.157657] hid-generic 0003:2560:C152.0007: hiddev0,hidraw4: USB HID v1.11 Device [e-con Systems See3CAM_CU51] on usb-0000:00:1
It's now symlinked under /dev/input/by-id
0 lrwxrwxrwx 1 root root 10 Aug 31 10:50 usb-e-con_Systems_See3CAM_CU51_172A0202-event-if00 -> ../event20
However, event20 has the following permissions:
0 crw-rw---- 1 root input 13, 84 Aug 31 10:50 event20
I've written udev rules for the hiddevice itself with success, but for some reason, I can't get the rule right for the input device. Here's what I've tried:
KERNEL=="input", ATTR{name}=="See3CAM_CU51", MODE="0666" GROUP="plugdev"
But it does not appear to work. There's not a huge deal of examples of changing the ownership of input devices out there (that I've found at least).
Update:
When I change my udev rule to
KERNEL=="input", MODE="0666" GROUP="plugdev"
that is, I leave out the device name, all my input devices in /dev/input have the correct permissions.
So basically, I'm saying "every input device gets set to mode 0666, and belong to the plugdev group", which works. But adding the ATTR{name}== breaks it.
Here's the output of udevadm info:
udevadm info -a -p /devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.0/input/input21
looking at device '/devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.0/input/input21':
KERNEL=="input21"
SUBSYSTEM=="input"
DRIVER==""
ATTR{name}=="See3CAM_CU51"
ATTR{phys}=="usb-0000:00:14.0-2/button"
ATTR{properties}=="0"
ATTR{uniq}==""
It should be working, I have the correct name set for the device, what stupid mistake am I making?
udev rules support string matching, you're probably looking for:
ACTION=="...", KERNEL=="input[0-9]*", SUBSYSTEM=="input", ...
to match on the specific action for any inputN devices, then you can add your ATTR filter(s) to select the specific device.

Mount USB device on router - OpenWrt

I am new to OpenWrt and Linux/Unix shell. Prior to this, was using dd-wrt for 2 years. Recently switched to OpenWrt and got the basic setup done(wifi/internet working). I need to install transmission my router. But, USB device won't mount.
The Details of the router are as follows:
Router Model:
Asus RT-N13U B1
Image flashed:
chaos_calmer 15.05.1 (openwrt-15.05.1-ramips-rt305x-rt-n13u-squashfs-sysupgrade.bin)
Usb Details:
Crusier Blade 16GB usb 2.0
Formatted to ext4 using GParted bootable cd
Drivers Installed:
kmod-usb-core(preinstalled)
kmod-usb-dwc2(preinstalled)
kmod-usb2
kmod-usb-storage
kmod-fs-ext4
kmod-scsi-core(preinstalled)
Here are permissions for dev/sda, /dev/sda1 and /mnt (set 777 manually):
~#ls -l /dev
brwxrwxrwx 1 root root 8, 0 Jan 17 21:56 sda
brwxrwxrwx 1 root root 8, 1 Jan 17 21:56 sda1
~#ls -l ..
drwxrwxrwx 2 root root 0 Jan 16 21:28 mnt
Error while mounting:
~# mount -t ext4 /dev/sda1 /mnt
mount: mounting /dev/sda1 on /mnt failed: No such file or directory
echo $?
255
sda1 is present inside dev and /mnt directory exists. Still it shows an error.
I have tried installing/reinstalling and then mounting, but for the same result. Also when I disconnect the USB sda and sda1 folders disappear and then reappear when USB is reconnected so I guess the device is being detected successfully.
What is it, that I am missing?
Edit:
Added edits as suggested in the comments.
dmesg output (The output is very big so linked it)
Edit 2:
Switched to LEDE 17. Is more stable and have had zero issues in the past week.
the critical part of the dmesg output is
[ 9.410000] mount_root: loading kmods from internal overlay
[ 9.940000] SCSI subsystem initialized
[ 9.960000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 9.980000] ehci-platform:EHCI generic platform driver [ 9.990000] usb-storage 1-1:1.0: no of_node; not parsing pinctrl DT
[ 9.990000] usb-storage 1-1:1.0: USB Mass Storage device detected
[ 10.010000] scsi host0: usb-storage 1-1:1.0
[ 10.020000] usbcore: registered new interface driver usb-storage
[ 10.100000] block: attempting to load /tmp/jffs_cfg/upper/etc/config/fstab
[ 10.120000] block: extroot: not configured
[ 10.130000] mount_root: switching to jffs2 overlay
[ 10.180000] procd: - early -
[ 11.020000] scsi 0:0:0:0: Direct-Access SanDisk Cruzer Blade 1.27 PQ: 0 ANSI: 6
[ 11.030000] sd 0:0:0:0: no of_node; not parsing pinctrl DT
[ 11.050000] sd 0:0:0:0: [sda] 30529536 512-byte logical blocks: (15.6 GB/14.5 GiB)
[ 11.070000] sd 0:0:0:0: [sda] Write Protect is off
[ 11.070000] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[ 11.090000] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 11.120000] sda: sda1
[ 11.130000] sd 0:0:0:0: [sda] Attached SCSI removable disk
[ 11.550000] EXT4-fs (sda1): Cannot load crc32c driver
oh no, this seems to be a bug
Bug#819725: ext4 missing softdep on crc32c module
https://lists.debian.org/debian-kernel/2016/04/msg00013.html
the following workaround is not applicable because initramfs is a native file system at startup time (https://en.wikipedia.org/wiki/Initramfs) and has no influence when the system is fully up (rootfs is mounted):
Until this is fixed in the kernel package, you can work around it by
either:
Setting base-installer/initramfs-tools/driver-policy to "most" instead of "dep"
Setting base-config/late_command to a script that adds crc32c to /etc/initramfs-tools/modules
post the stack trace anyway, maybe there is another workaround
this is overcomplicated stuff...
here is maybe a solution https://forum.openwrt.org/viewtopic.php?id=69175
download kmod-lib-crc32c and kmod-crypto-crc32c
if this is not working maybe the easiest solution is to format the USB stack as VFAT and to wait for a new kernel...
this is not a permissions error. a permission error would return EPERM -> error code 1 Operation not permitted
it would be interesting to know what exit code the mount returns. The 'exit behavior is very different in the several mount version' i.e. mount(2) and mount(8)
for getting the return value, type in a shell the command
mount /dev/sda1 /mnt
then
echo $?
the number is the returned exit code of the mount (the 255 means 'exit status out of range' in this case '-1', http://www.tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF)
a listing of the mount(8) exit codes is i.e. in http://www.stackoverflow.com/questions/33167585/what-are-the-return-codes-values-of-linux-umount
http://www.becane.com/2014/09/02/understanding-exit-codes-and-how-to-use-them-in-a-bash-script
beside the return value mount(2) also sets an error code in errno (http://man7.org/linux/man-pages/man3/errno.3.html). printing errno in shell is a bit difficult it is easier to get a reference like http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html and search for the error string, in this case No such file or directory
the string No such file or directory is system error ENOENT
As a system error ENOENT means A pathname was empty or had a nonexistent component. (http://man7.org/linux/man-pages/man2/mount.2.html)
try sudo mount -t ext4 /dev/sda1 /mnt because the stick is formatted in ext4
if this is not working dmesg output would be interesting
detach usb device, reattach usb device, type dmesg and see the output. in the output of dmesg you also see which drivers are loaded for the device
https://wiki.openwrt.org/doc/howto/usb.storage says that you need several more drivers (block-mount, kmod-scsi-core,...) because a usb stick (USB Mass Storage class) is also a SCSI and a block device...
(linux system error codes are in http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html)
print a stack trace sudo strace -f mount -t ext4 -o default /dev/sda1 /mnt and post it

Very low performance of g_mass_storage virtual usb device

Hello I am using Linux usb gadget facility to emulate a USB flash drive. It is working fine except for very low performance.
I use a 4Gb file, created by dd and created a ext2 or vfat (tried both) partition on it. Than I mount it using the following command sequence:
# modprobe dummy_hcd is_super_speed=1 # I tried is_high_speed=1, and no parameter too
# modprobe g_mass_storage file=/home/del/img/flash stall=0 # tried w/o stall=0 too
# mount /dev/sdc1 /mnt/tmp
After that I get /dev/sdc and /dev/sdc1 devices created without any errors in dmesg:
[1256700.986581] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256701.022551] gadget: high-speed config #1: Linux File-Backed Storage
[1256701.242481] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256701.278422] gadget: high-speed config #1: Linux File-Backed Storage
[1256701.422339] gadget: high-speed config #1: Linux File-Backed Storage
[1256934.915697] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256934.951628] gadget: high-speed config #1: Linux File-Backed Storage
[1256935.915155] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256935.951090] gadget: high-speed config #1: Linux File-Backed Storage
[1256936.095018] gadget: high-speed config #1: Linux File-Backed Storage
[1317073.396892] usb-storage 3-1:1.0: Quirks match for vid 0525 pid a4a5: 10000
[1317073.396995] scsi53 : usb-storage 3-1:1.0
[1317074.411883] scsi 53:0:0:0: Direct-Access Linux File-CD Gadget 0302 PQ: 0 ANSI: 2
[1317074.412669] sd 53:0:0:0: Attached scsi generic sg3 type 0
[1317074.431910] sd 53:0:0:0: [sdc] 8388608 512-byte logical blocks: (4.29 GB/4.00 GiB)
[1317074.443816] sd 53:0:0:0: [sdc] Write Protect is off
[1317074.443821] sd 53:0:0:0: [sdc] Mode Sense: 0f 00 00 00
[1317074.455839] sd 53:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[1317074.551757] sdc: sdc1
[1317074.683704] sd 53:0:0:0: [sdc] Attached SCSI removable disk
The problem is that IO performance is very poor. Writing 200Mb file takes quite a while:
$ ls -lh file
-rw-rw-r-- 1 root del 206M Sep 4 09:34 file
$ time sudo cp file /mnt/tmp/
real 11m59.618s
user 0m0.000s
sys 0m0.260s
Which is about 300K/sec. However the same file on the same system is copied to a real USB flash in less than a minute.
Iotop shows something like this:
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
9986 be/4 root 0.00 B/s 262.05 K/s 0.00 % 99.86 % cp file /mnt/tmp/
20651 be/4 root 51.77 K/s 238.95 K/s 0.00 % 93.23 % [file-storage]
Can anything be done to improve the performance of g_mass_storage-emulated USB drive?
PS: I am using kernel
$ uname -rm
3.2.0-4-686-pae i686
Same here.
After one night at 6:00 i had a solution for me.
modprobe g_mass_storage file=/home/del/img/flash stall=0 buflen=65536
This made up to 5MByte/sec
modprobe g_mass_storage file=/home/del/img/flash stall=0 nofua=1
This made up to 11MByte/sec
A combination of "buflen" and "nofua" did not really helped.
About "nufua" read here: http://lxr.free-electrons.com/source/drivers/usb/gadget/file_storage.c?v=3.5
Ultrasoft /

usb_modeswitch is hangs on manual switch

I have 3.2.27 Linux kernel with Busybox. I am using Raspberry PI. When I pluging my Huawei E303c dmesg showing
[ 4.569781] usb 1-1.2: new high-speed USB device number 5 using dwc_otg
[ 4.681078] usb 1-1.2: New USB device found, idVendor=12d1, idProduct=14fe
[ 4.690885] usb 1-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[ 4.701143] usb 1-1.2: Product: HUAWEI Mobile
[ 4.708326] usb 1-1.2: Manufacturer: HUAWEI
[ 4.718185] scsi0 : usb-storage 1-1.2:1.0
[ 4.726518] scsi1 : usb-storage 1-1.2:1.1
[ 5.720951] scsi 0:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
[ 5.738561] scsi 1:0:0:0: Direct-Access HUAWEI SD Storage 2.31 PQ: 0 ANSI: 2
[ 5.755514] sd 1:0:0:0: [sda] Attached SCSI removable disk
The option kernel module is already running but usb-storage module not running. But when I enter usb_modeswitch -v 0x12d1 -p 0x14fe -H it's hangs like
Looking for default devices ...
Found default devices (1)
Accessing device 002 on bus 002 ...
Using endpoints 0x04 (out) and 0x83 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
OK, driver found ("usb-storage")
OK, driver "usb-storage" detached
Can anyone give me a solution,
This has solve my issue
usb_modeswitch -c /etc/usb_modeswitch.conf -W -I
modprobe option
modprobe ppp_generic
My /etc/usb_modeswitch.conf looks like
# Huawei E303c
DefaultVendor= 0x12d1
DefaultProduct=0x14fe
TargetVendor= 0x12d1
TargetProductList="1001,1406,140b,140c,1412,141b,14ac,1506"
CheckSuccess=20
MessageEndpoint= 0x01
MessageContent="55534243123456780000000000000011062000000100000000000000000000"

Resources