Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
harvald
Posts: 3
Joined: 07 Feb 2023, 12:46

another device with 0bda:1a2b not switching to c811

Post by harvald » 17 Feb 2023, 14:00

I have device with the ID 0bda:1a2b. On Ubuntu 20.04 and usb_modeswitch 2.5.2 worked okay. Now on Ubuntu 22.04 and usb_modeswitch 2.6.1 it's something wrong. Not switching while booting or manually with command:

Code: Select all

sudo usb_modeswitch -v 0bda -p 1a2b -P c811 -K
Switching works only when re-plugged.
I know that there are other post about similar problems, but not offers solution for my case.


From dmesg from booting.

Code: Select all

[   44.052757] usb 2-1.2: new high-speed USB device number 5 using ehci-pci
[   44.161591] usb 2-1.2: New USB device found, idVendor=0bda, idProduct=1a2b, bcdDevice= 2.00
[   44.163033] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[   44.164401] usb 2-1.2: Product: DISK
[   44.167222] usb 2-1.2: Manufacturer: Realtek
[   44.171144] usb-storage 2-1.2:1.0: USB Mass Storage device detected
[   44.173943] scsi host2: usb-storage 2-1.2:1.0
Replugging

Code: Select all

[   47.922192] usb 2-1.2: USB disconnect, device number 5
[   48.144766] usb 2-1.2: new high-speed USB device number 6 using ehci-pci
[   48.253556] usb 2-1.2: New USB device found, idVendor=0bda, idProduct=c811, bcdDevice= 2.00
[   48.253565] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   48.253568] usb 2-1.2: Product: 802.11ac NIC
[   48.253570] usb 2-1.2: Manufacturer: Realtek
[   48.253572] usb 2-1.2: SerialNumber: 123456
usb_modeswitch log from boot

Code: Select all

Use top device dir /sys/bus/usb/devices/2-1.2
Check class of first interface ...
 Interface class is 08.

----------------
USB values from sysfs:
  manufacturer	Realtek
  product	DISK
  serial	
----------------
bNumConfigurations is 1 - don't check for active configuration
Found packed config collection /usr/share/usb_modeswitch/configPack.tar.gz
ConfigList: /etc/usb_modeswitch.d/0bda:1a2b pack/0bda:1a2b pack/
SCSI attributes not needed, move on
Check config: /etc/usb_modeswitch.d/0bda:1a2b
! matched. Read config data
Use config file from override folder /etc/usb_modeswitch.d
Logger is /usr/bin/logger
Use top device dir /sys/bus/usb/devices/2-1.2
Check class of first interface ...
 Interface class is 08.

----------------
USB values from sysfs:
  manufacturer	Realtek
  product	DISK
  serial	
----------------
bNumConfigurations is 1 - don't check for active configuration
Found packed config collection /usr/share/usb_modeswitch/configPack.tar.gz
ConfigList: /etc/usb_modeswitch.d/0bda:1a2b pack/0bda:1a2b pack/
SCSI attributes not needed, move on
Check config: /etc/usb_modeswitch.d/0bda:1a2b
! matched. Read config data
Use config file from override folder /etc/usb_modeswitch.d
Logger is /usr/bin/logger
Command line:
usb_modeswitch -W -D -u -1 -b 2 -g 5 -v 0bda -p 1a2b -f $flags(config)
Use top device dir /sys/bus/usb/devices/2-1.2
Check class of first interface ...
 Interface class is 08.

----------------
USB values from sysfs:
  manufacturer	Realtek
  product	DISK
  serial	
----------------
bNumConfigurations is 1 - don't check for active configuration
Found packed config collection /usr/share/usb_modeswitch/configPack.tar.gz
ConfigList: /etc/usb_modeswitch.d/0bda:1a2b pack/0bda:1a2b pack/
SCSI attributes not needed, move on
Check config: /etc/usb_modeswitch.d/0bda:1a2b
! matched. Read config data
Use config file from override folder /etc/usb_modeswitch.d
Logger is /usr/bin/logger
Command line:
usb_modeswitch -W -D -u -1 -b 2 -g 5 -v 0bda -p 1a2b -f $flags(config)

Verbose debug output of usb_modeswitch and libusb follows
(Note that some USB errors are to be expected in the process)
--------------------------------

Read long config from command line

 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.6.1 (C) Josua Dietze 2017
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x0bda
DefaultProduct= 0x1a2b
TargetVendor=   0x0bda
TargetProduct=  0xc811

StandardEject=1
System integration mode enabled

Use given bus/device number: 002/005 ...
Look for default devices ...
 bus/device number matched
  found USB ID 0bda:1a2b
   vendor ID matched
   product ID matched
 Found devices in default mode (1)
Get the current device configuration ...
Use interface number 0
 with class 8
Use endpoints 0x0b (out) and 0x8a (in)

USB description data (for identification)
-------------------------
Manufacturer: Realtek
     Product: DISK
  Serial No.: not provided
-------------------------
Sending standard EJECT sequence
Looking for active drivers ...
Set up interface 0
Use endpoint 0x0b for message sending ...
Trying to send message 1 to endpoint 0x0b ...
 Sending the message returned error -7. Try to continue
Read the response to message 1 (CSW) ...
 Response reading failed (error -8)
 Device is gone, skip any further commands
ok:busdev
--------------------------------
(end of usb_modeswitch output)

Check success of mode switch for max. 20 seconds ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...

Target config not matching - current values are
    2-1.2:1.0/bInterfaceClass: 08
    bConfigurationValue:       1
    bNumConfigurations:        1
    busnum:                    2
    devnum:                    5
    idProduct:                 1a2b
    idVendor:                  0bda
    manufacturer:              Realtek
    product:                   DISK
    serial:                    

Mode switching may have failed. Exit
And from replugging

Code: Select all

Use top device dir /sys/bus/usb/devices/2-1.2
Check class of first interface ...
 Interface class is 08.

----------------
USB values from sysfs:
  manufacturer	Realtek
  product	DISK
  serial	
----------------
bNumConfigurations is 1 - don't check for active configuration
Found packed config collection /usr/share/usb_modeswitch/configPack.tar.gz
ConfigList: /etc/usb_modeswitch.d/0bda:1a2b pack/0bda:1a2b pack/
SCSI attributes not needed, move on
Check config: /etc/usb_modeswitch.d/0bda:1a2b
! matched. Read config data
Use config file from override folder /etc/usb_modeswitch.d
Logger is /usr/bin/logger
Use top device dir /sys/bus/usb/devices/2-1.2
Check class of first interface ...
 Interface class is 08.

----------------
USB values from sysfs:
  manufacturer	Realtek
  product	DISK
  serial	
----------------
bNumConfigurations is 1 - don't check for active configuration
Found packed config collection /usr/share/usb_modeswitch/configPack.tar.gz
ConfigList: /etc/usb_modeswitch.d/0bda:1a2b pack/0bda:1a2b pack/
SCSI attributes not needed, move on
Check config: /etc/usb_modeswitch.d/0bda:1a2b
! matched. Read config data
Use config file from override folder /etc/usb_modeswitch.d
Logger is /usr/bin/logger
Command line:
usb_modeswitch -W -D -u -1 -b 2 -g 6 -v 0bda -p 1a2b -f $flags(config)

Verbose debug output of usb_modeswitch and libusb follows
(Note that some USB errors are to be expected in the process)
--------------------------------

Read long config from command line

 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.6.1 (C) Josua Dietze 2017
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x0bda
DefaultProduct= 0x1a2b
TargetVendor=   0x0bda
TargetProduct=  0xc811

StandardEject=1
System integration mode enabled

Use given bus/device number: 002/006 ...
Look for default devices ...
 bus/device number matched
  found USB ID 0bda:1a2b
   vendor ID matched
   product ID matched
 Found devices in default mode (1)
Get the current device configuration ...
Use interface number 0
 with class 8
Use endpoints 0x0b (out) and 0x8a (in)

USB description data (for identification)
-------------------------
Manufacturer: Realtek
     Product: DISK
  Serial No.: not provided
-------------------------
Sending standard EJECT sequence
Looking for active drivers ...
 OK, driver detached
Set up interface 0
Use endpoint 0x0b for message sending ...
Trying to send message 1 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 1 (CSW) ...
 Response successfully read (13 bytes), status 1
Trying to send message 2 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 2 (CSW) ...
 Response successfully read (13 bytes), status 0
Trying to send message 3 to endpoint 0x0b ...
 Sending the message returned error -1. Try to continue
Read the response to message 3 (CSW) ...
 Device seems to have vanished after reading. Good.
 Device is gone, skip any further commands
ok:busdev
--------------------------------
(end of usb_modeswitch output)

Check success of mode switch for max. 20 seconds ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...

Target config not matching - current values are
    2-1.2:1.0/bInterfaceClass: ff
    bConfigurationValue:       1
    bNumConfigurations:        1
    busnum:                    2
    devnum:                    7
    idProduct:                 c811
    idVendor:                  0bda
    manufacturer:              Realtek
    product:                   802.11ac NIC
    serial:                    123456

Mode switching may have failed. Exit
Please help.

harvald
Posts: 3
Joined: 07 Feb 2023, 12:46

Re: another device with 0bda:1a2b not switching to c811

Post by harvald » 09 Apr 2023, 10:52

Okay, I have a breakthrough! :)

Instead of trying to change mode of the device after booting, I've focused on cause why kernel throw a couple of times messages:

Code: Select all

kernel: [    8.696426] usb 2-1.2: reset high-speed USB device number 4 using ehci-pci
and stopping for 30 seconds every time.

After that I've noticed that command:

Code: Select all

lshw -class usb
is hanging when scanning scsi. This gave me an idea, that maybe something in new kernels 5.x changed in communications with mass storage devices. Maybe there is a bug in firmware of device, and kernel could no longer co-op with that. But, of course I don't care about communication with storage, because I only want to switch it to NIC mode. So after digging I've found info about tricks with kernel parameters: https://www.kernel.org/doc/html/v5.0/ad ... eters.html
There specially interesting was

Code: Select all

usb-storage.quirks= 
i = IGNORE_DEVICE (don't bind to this device);

So in file /etc/default/grub , I've added:

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="usb-storage.quirks=0bda:1a2b:i"
And updated grub config with command:

Code: Select all

update-grub2
And voila! No errors on booting, no delays, and after boot I can switch mode with manual command:

Code: Select all

sudo usb_modeswitch -v 0bda -p 1a2b -P c811 -K
or by udev rules. :D :D :D

I guess that something that kernel was doing was causing device to hang-up and not respond normally to other communications.

Jacobjsdhfg
Posts: 1
Joined: 15 Jan 2024, 05:37

Re: another device with 0bda:1a2b not switching to c811

Post by Jacobjsdhfg » 15 Jan 2024, 05:39

thanks for sharing!!! Drive Mad 2

Post Reply