How to disable USB device on Linux Mint? - linux

I have consecutive log messages:
usb-storage 2-1.5:1.0: USB Mass Storage device detected
usb-storage 2-1.5:1.0: Quirks match for vid 05e3 pid 0723: 8000
scsi host25: usb-storage 2-1.5:1.0
usb 2-1.5: USB disconnect, device number 49
usb 2-1.5: new high-speed USB device number 50 using ehci-pci
usb 2-1.5: new high-speed USB device number 53 using ehci-pci
usb 2-1.5: new high-speed USB device number 54 using ehci-pci
usb 2-1.5: new high-speed USB device number 57 using ehci-pci
usb 2-1.5: New USB device found, idVendor=05e3, idProduct=0723
usb 2-1.5: New USB device strings: Mfr=3, Product=4, SerialNumber=2
usb 2-1.5: Product: USB Storage
usb 2-1.5: Manufacturer: Generic
usb 2-1.5: SerialNumber: 000000009451
usb-storage 2-1.5:1.0: USB Mass Storage device detected
usb-storage 2-1.5:1.0: Quirks match for vid 05e3 pid 0723: 8000
scsi host26: usb-storage 2-1.5:1.0
scsi 26:0:0:0: Direct-Access Generic STORAGE DEVICE 9451 PQ: 0 ANSI: 0
sd 26:0:0:0: Attached scsi generic sg2 type 0
sd 26:0:0:0: [sdc] Attached SCSI removable disk
usb 2-1.5: USB disconnect, device number 57
usb 2-1.5: new high-speed USB device number 58 using ehci-pci
usb 2-1.5: New USB device found, idVendor=05e3, idProduct=0723
usb 2-1.5: New USB device strings: Mfr=3, Product=4, SerialNumber=2
usb 2-1.5: Product: USB Storage
usb 2-1.5: Manufacturer: Generic
usb 2-1.5: SerialNumber: 000000009451
usb-storage 2-1.5:1.0: USB Mass Storage device detected
usb-storage 2-1.5:1.0: Quirks match for vid 05e3 pid 0723: 8000
scsi host27: usb-storage 2-1.5:1.0
scsi 27:0:0:0: Direct-Access Generic STORAGE DEVICE 9451 PQ: 0 ANSI: 0
sd 27:0:0:0: Attached scsi generic sg2 type 0
sd 27:0:0:0: [sdc] Attached SCSI removable disk
This disturb me because of sound of plugged/unplugged device, even when sound is muted (I setup 0% volume, and the sound icon in taskbar is grayed)
How to prevent this?

This command seems helps me:
echo "2-1.5:1.0" > /sys/bus/usb/drivers/usb-storage/2-1.5:1.0/driver/unbind

Related

Linux does not create /dev/ file for USB modem

My USB modem called Anydata W150. My goal is to send AT commands to the modem via USB and get some information from it.
When I'm connecting the USB modem, first of all it connects for a few seconds as /dev/ttyACM0,
then changes it's mode to flash drive mode and then becomes an internet interface with address like enp0s...
Here is my lsusb output.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 059: ID 0e8d:2004 MediaTek Inc. uf906_lowram_adr_20211118
Bus 001 Device 004: ID 04d9:fa51 Holtek Semiconductor, Inc. USB Optical gaming mouse
Bus 001 Device 030: ID 0416:c345 Winbond Electronics Corp. Gaming Keyboard
Bus 001 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The device with address 0e8d:2004 is my USB modem.
Here is my dmesg output:
[275592.103620] usb 1-9: new high-speed USB device number 60 using xhci_hcd
[275592.244562] usb 1-9: New USB device found, idVendor=0e8d, idProduct=2000, bcdDevice= 1.00
[275592.244576] usb 1-9: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[275592.244581] usb 1-9: Product: MT65xx Preloader
[275592.244585] usb 1-9: Manufacturer: MediaTek
[275592.267780] cdc_acm 1-9:1.0: Zero length descriptor references
[275592.267790] cdc_acm: probe of 1-9:1.0 failed with error -22
[275592.348134] cdc_acm 1-9:1.1: ttyACM0: USB ACM device
[275601.426952] usb 1-9: new high-speed USB device number 61 using xhci_hcd
[275601.571247] usb 1-9: New USB device found, idVendor=0e8d, idProduct=2008, bcdDevice=ff.ff
[275601.571261] usb 1-9: New USB device strings: Mfr=2, Product=3, SerialNumber=4
[275601.571267] usb 1-9: Product: uf906_lowram_adr_20211118
[275601.571271] usb 1-9: Manufacturer: MediaTek
[275601.571276] usb 1-9: SerialNumber: W1502022081454
[275641.660198] usb 1-9: new high-speed USB device number 62 using xhci_hcd
[275641.801278] usb 1-9: New USB device found, idVendor=0e8d, idProduct=201d, bcdDevice=ff.ff
[275641.801290] usb 1-9: New USB device strings: Mfr=2, Product=3, SerialNumber=4
[275641.801296] usb 1-9: Product: uf906_lowram_adr_20211118
[275641.801301] usb 1-9: Manufacturer: MediaTek
[275641.801305] usb 1-9: SerialNumber: W1502022081454
[275642.564116] usb 1-9: USB disconnect, device number 62
[275642.893553] usb 1-9: new high-speed USB device number 63 using xhci_hcd
[275643.035170] usb 1-9: New USB device found, idVendor=0e8d, idProduct=2008, bcdDevice=ff.ff
[275643.035183] usb 1-9: New USB device strings: Mfr=2, Product=3, SerialNumber=4
[275643.035189] usb 1-9: Product: uf906_lowram_adr_20211118
[275643.035194] usb 1-9: Manufacturer: MediaTek
[275643.035198] usb 1-9: SerialNumber: W1502022081454
[275643.629773] usb 1-9: USB disconnect, device number 63
[275643.990292] usb 1-9: new high-speed USB device number 64 using xhci_hcd
[275644.137932] usb 1-9: New USB device found, idVendor=0e8d, idProduct=2004, bcdDevice=ff.ff
[275644.137940] usb 1-9: New USB device strings: Mfr=2, Product=3, SerialNumber=4
[275644.137943] usb 1-9: Product: uf906_lowram_adr_20211118
[275644.137945] usb 1-9: Manufacturer: MediaTek
[275644.137947] usb 1-9: SerialNumber: W1502022081454
[275644.142808] rndis_host 1-9:1.0 usb0: register 'rndis_host' at usb-0000:00:14.0-9, RNDIS device, 16:50:ad:07:74:9c
[275644.143294] usb-storage 1-9:1.2: USB Mass Storage device detected
[275644.144374] scsi host4: usb-storage 1-9:1.2
[275644.255327] rndis_host 1-9:1.0 enp0s20f0u9: renamed from usb0
[275645.164442] scsi 4:0:0:0: CD-ROM Linux File-CD Gadget 0318 PQ: 0 ANSI: 2
[275645.165306] sr 4:0:0:0: Power-on or device reset occurred
[275645.166137] sr 4:0:0:0: [sr0] scsi-1 drive
[275645.167227] sr 4:0:0:0: Attached scsi CD-ROM sr0
[275645.167541] sr 4:0:0:0: Attached scsi generic sg2 type 5
I googled a lot and found out, that I need to create udev rules. I created rules file with path /etc/udev/rules.d/99-usb-modem.rules
Contents of the file:
ACTION=="add", KERNEL=="enp0s*", SUBSYSTEM=="net", ATTRS{idVendor}=="0e8d", ATTRS{idProduct}=="2004", SYMLINK+="/dev/ttyUSB10"
So, I'm trying to create a symlink, but it does nothing. I tried a lot of variations of this file and it's contents but nothing is working.
Also, I tried to load drivers via modprobe command. Command syntax was like this:
# modprobe rndis_host
And also tried this with defining the ID from lsusb.

USB_OTG_FS for stm device not working on linux

I am using a adafruit STM32F405 feather, and have written a program for it in the stm32cubeide. I have enabled USB_OTG_FS and also selected VCP under USB_DEVICE under middleware. I sent a simple message using CDC_Transmit_FS() within my main.c file. I wanted to then display the message using minicom but the stm32f405 is not recognized as a virtual com port when i plug it in. Please can anyone help with this problem?
This what i get from dmesg
[13875.812682] CPU4: Package temperature/speed normal
[13875.812714] CPU7: Package temperature/speed normal
[13875.812714] CPU3: Package temperature/speed normal
[13991.385412] usb 1-1: new full-speed USB device number 7 using xhci_hcd
[13991.535289] usb 1-1: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[13991.535296] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[13991.535299] usb 1-1: Product: STM32 Virtual ComPort
[13991.535302] usb 1-1: Manufacturer: STMicroelectronics
[13991.535305] usb 1-1: SerialNumber: 2052368B424D
[13991.537315] cdc_acm 1-1:1.0: ttyACM1: USB ACM device
[14011.512953] usb 1-1: USB disconnect, device number 7
[14011.965421] usb 1-1: new full-speed USB device number 8 using xhci_hcd
[14012.115098] usb 1-1: New USB device found, idVendor=0483, idProduct=df11, bcdDevice=22.00
[14012.115101] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[14012.115103] usb 1-1: Product: STM32 BOOTLOADER
[14012.115105] usb 1-1: Manufacturer: STMicroelectronics
[14012.115106] usb 1-1: SerialNumber: 2052368B424D
[14062.597167] usb 1-1: USB disconnect, device number 8
[14062.905188] usb 1-1: new full-speed USB device number 9 using xhci_hcd
[14078.380920] usb 1-1: device descriptor read/64, error -110
[14093.996841] usb 1-1: device descriptor read/64, error -110
[14094.232811] usb 1-1: new full-speed USB device number 10 using xhci_hcd
[14109.616762] usb 1-1: device descriptor read/64, error -110
[14125.228684] usb 1-1: device descriptor read/64, error -110
[14125.336733] usb usb1-port1: attempt power cycle
[14125.752659] usb 1-1: new full-speed USB device number 11 using xhci_hcd
[14130.988679] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[14132.495127] usb 1-1: Device not responding to setup address.
[14132.700624] usb 1-1: device not accepting address 11, error -71
[14142.916583] usb 1-1: new full-speed USB device number 13 using xhci_hcd
[14158.508419] usb 1-1: device descriptor read/64, error -110
It appears that there is an error when reading the usb device descripter, any ideas how i can solve this?
HAL_PWREx_EnableUSBVoltageDetector() at end of MX_USB_DEVICE_Init for older Firmware it appears.
I updated from Jan to July release of IDE, MX and STM32CubeF4 releases and my USB_OTG_FS started working (the call above is not present in the latest).

OpenOCD cannot open connection to STM32L4 board (STEVAL STWINCSV1)

I have a STEVAL STWINCSV1 board with an STM32L4R9 chip connected to my computer via USB. I am trying to use OpenOCD to flash a new image. I am using the command openocd -d -f board/stm32l4discovery.cfg to try to open a connection to the board. Here are the contents of the cfg file
# Explicitly for the STM32L476 discovery board:
# http://www.st.com/web/en/catalog/tools/PF261635
# but perfectly functional for any other STM32L4 board connected via
# an stlink-v2-1 interface.
# This is for STM32L4 boards that are connected via stlink-v2-1.
source [find interface/stlink.cfg]
transport select hla_swd
source [find target/stm32l4x.cfg]
reset_config srst_only
When I plug in the board via USB and check the output of dmesg | grep usb, here is what I get (I plugged the board in multiple times):
[15316.981696] usb 1-1.3: new full-speed USB device number 7 using xhci_hcd
[15317.119120] usb 1-1.3: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[15317.119121] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[15317.119122] usb 1-1.3: Product: STM32 Virtual ComPort in FS Mode
[15317.119123] usb 1-1.3: Manufacturer: STMicroelectronics
[15317.119123] usb 1-1.3: SerialNumber: FFFFFFFEFFFF
[15317.169176] usbcore: registered new interface driver cdc_acm
[15726.366247] usb 1-1.3: USB disconnect, device number 7
[15733.238286] usb 1-1.3: new full-speed USB device number 8 using xhci_hcd
[15733.363181] usb 1-1.3: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[15733.363182] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[15733.363183] usb 1-1.3: Product: STM32 Virtual ComPort in FS Mode
[15733.363184] usb 1-1.3: Manufacturer: STMicroelectronics
[15733.363184] usb 1-1.3: SerialNumber: FFFFFFFEFFFF
[15822.875489] usb 1-1.3: USB disconnect, device number 8
[15861.278256] usb 1-3.4: new full-speed USB device number 9 using xhci_hcd
[15861.400511] usb 1-3.4: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[15861.400512] usb 1-3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[15861.400513] usb 1-3.4: Product: STM32 Virtual ComPort in FS Mode
[15861.400514] usb 1-3.4: Manufacturer: STMicroelectronics
[15861.400514] usb 1-3.4: SerialNumber: FFFFFFFEFFFF
[16196.113834] usb 1-3.4: USB disconnect, device number 9
[16251.868195] usb 1-1.3: new full-speed USB device number 10 using xhci_hcd
[16252.006377] usb 1-1.3: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[16252.006378] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[16252.006379] usb 1-1.3: Product: STM32 Virtual ComPort in FS Mode
[16252.006380] usb 1-1.3: Manufacturer: STMicroelectronics
[16252.006380] usb 1-1.3: SerialNumber: FFFFFFFEFFFF
When I run openocd -d -f board/stm32l4discovery.cfg, here is the output (pastebinned since it was a bit long): https://pastebin.com/biVLuf7U
Does anyone know what might be going wrong here?
I figured out the issue. First of all, the eval board I was using does not support stlink over its usb port, so I had to use a stlink/v3 mini external programmer instead. Also, the latest OpenOCD release on my distro did not support stlink/v3, so I had to compile OpenOCD from source. That fixed my issue.

Cross compiling drivers for USB modem

I have a physical card with an IMX6 CPU that runs Linux (a kernel I compiled from source, from the manufacturer's website). I also have a USB Cellular modem dongle that I want to use with the card. However, when I plug the dongle in the card, I get this in dmesg:
[ 29.825491] usb 1-1: new high-speed USB device number 2 using ci_hdrc
[ 29.983396] usb-storage 1-1:1.0: USB Mass Storage device detected
[ 29.991796] scsi0 : usb-storage 1-1:1.0
[ 30.987573] scsi 0:0:0:0: Direct-Access ALCATEL Mass Storage 2.31 PQ: 0 ANSI: 2
[ 30.996027] scsi 0:0:0:1: CD-ROM ALCATEL Mass Storage 2.31 PQ: 0 ANSI: 2
[ 31.008487] sd 0:0:0:0: [sda] Attached SCSI removable disk
It looks like Linux is recognizing the device as a mass storage device (it doubles as a storage device), but not as a modem. When I insert the same dongle into a regular Ubuntu machine, I get this:
[264822.947101] usb 1-5: new high-speed USB device number 12 using ehci-pci
[264823.086874] usb 1-5: New USB device found, idVendor=1bbb, idProduct=0017
[264823.086880] usb 1-5: New USB device strings: Mfr=3, Product=2, SerialNumber=[REDACTED]
[264823.086883] usb 1-5: Product: HSPA Data Card
[264823.086886] usb 1-5: Manufacturer: USBModem
[264823.086888] usb 1-5: SerialNumber: [REDACTED]
[264823.089483] option 1-5:1.0: GSM modem (1-port) converter detected
[264823.089685] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB1
[264823.089816] option 1-5:1.1: GSM modem (1-port) converter detected
[264823.090019] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB2
[264823.090150] option 1-5:1.2: GSM modem (1-port) converter detected
[264823.090311] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB3
[264823.090433] option 1-5:1.3: GSM modem (1-port) converter detected
[264823.090574] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB4
[264823.090666] usb-storage 1-5:1.4: USB Mass Storage device detected
[264823.090916] scsi host16: usb-storage 1-5:1.4
[264823.091067] option 1-5:1.5: GSM modem (1-port) converter detected
[264823.091133] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB5
[264824.089843] scsi 16:0:0:0: Direct-Access ALCATEL Mass Storage 2.31 PQ: 0 ANSI: 2
[264824.090238] sd 16:0:0:0: Attached scsi generic sg2 type 0
[264824.093552] sd 16:0:0:0: [sdb] Attached SCSI removable disk
I know how to compile modules externally and into the kernel, by choosing them in menuconfig. However, I don't know which modules I should compile for this device, if they are even included in the kernel source. How can I find which modules / drivers to compile?
USB modems often start up as Mass storage devices to allow for driver installation.
You can use software such as USB_ModeSwitch to force it to change modes. (this is likely already installed and working on your Ubuntu system)
Failing that, many will switch modes when their storage is ejected (as by eject).
you can check the sysfs attributes in Ubuntu for the associated driver
in /sys/bus/usb/devices/ and enable that driver in your board kernel configuration.

how to access usb Mass Storage Device in uclinux...?

I have got the kernel log it says about usb but how can access it . there is no device registration in /dev ..? how access this..?
and configured and anabledin kernel
Under "Device Drivers"
Under "USB Support"
Enable "USB Mass Storage Support"
(Optionally) Enable "USB Mass Storage verbose debug"
Under "SCSI device support -->"
Enable "SCSI disk support"
usb 1-2: new full speed USB device using lpc178x-ohci and address 2
usb 1-2: New USB device found, idVendor=8564, idProduct=1000
usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-2: Product: Mass Storage Device
usb 1-2: Manufacturer: JetFlash
usb 1-2: SerialNumber: 74O2LC2HD514SCME
#Amar, in the kernel log, will find the information regarding where the plugged in USB mass storage device is attached to in the filesystem for ex: it can be either sda or sdb or sdc. Check and use mount command to mount USB mass storage sudo mount /dev/sd* <Path where you want to mount USB device> and after you can access USB mass storage. Below is the kernel log information on where the USB mass storage is attached to
[85508.500115] usb 1-1: new high speed USB device using ehci_hcd and address 3
[85509.110370] usb 1-1: configuration #1 chosen from 1 choice
[85509.112895] scsi4 : SCSI emulation for USB Mass Storage devices
[85509.113486] usb-storage: device found at 3
[85509.113487] usb-storage: waiting for device to settle before scanning
[85514.128615] usb-storage: device scan complete
[85514.137855] scsi 4:0:0:0: Direct-Access Generic- Compact Flash 1.01 PQ: 0 ANSI: 0
[85514.146766] scsi 4:0:0:1: Direct-Access Multiple Flash Reader 1.05 PQ: 0 ANSI: 0
[85514.148945] sd 4:0:0:0: Attached scsi generic sg2 type 0
[85514.149018] sd 4:0:0:1: Attached scsi generic sg3 type 0
[85514.549761] sd 4:0:0:0: [sdb] Attached SCSI removable disk
[85514.558770] sd 4:0:0:1: [sdc] 31116288 512-byte logical blocks: (15.9 GB/14.8 GiB)
[85514.586964] sd 4:0:0:1: [sdc] Write Protect is off
[85514.586966] sd 4:0:0:1: [sdc] Mode Sense: 03 00 00 00
[85514.586968] sd 4:0:0:1: [sdc] Assuming drive cache: write through
[85514.711875] sd 4:0:0:1: [sdc] Assuming drive cache: write through
[85514.711880] sdc: sdc1 sdc2 sdc3 sdc4
[85514.808220] sd 4:0:0:1: [sdc] Assuming drive cache: write through
[85514.808224] sd 4:0:0:1: [sdc] Attached SCSI removable disk
In this case mount either /dev/sdc1 or /dev/sdc2 or /dev/sdc3 or /dev/sdc4 partition
depending on which partition you are interested in.

Resources