| |
Automatic Activation, Hotplug and UDEV, Configuration
-
rifo
- Posts: 6
- Joined: 11 Jan 2013, 17:06
Post
by rifo » 11 Jan 2013, 17:30
Hello all,
I have a Vodafone K3770 dongle which I am trying to integrate to an embedded linux system running an ARM. I have taken the usb_switchmode from buildroot
Code: Select all
* usb_modeswitch: handle USB devices with multiple modes
* Version 1.2.5 (C) Josua Dietze 2012
* Based on libusb0 (0.1.12 and above)
! PLEASE REPORT NEW CONFIGURATIONS !
I have prepared a conf file as below
Code: Select all
#####################################
# Huawei, newer modems
DisableSwitching=0
EnableLoggin=1
#HuaweiMode=1
#DetachStorageOnly=1
DefaultVendor=0x12d1
DefaultProduct=0x14d1
TargetVendor=0x12d1
TargetProduct=0x1c05
CheckSuccess=20
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
Currently I implement everything manually.
Code: Select all
# mount usbfs -t usbfs /proc/bus/usb/
# insmod ./usbserial.ko vendor=0x12d1 product=0x1c05
# ./usb_modeswitch -W -c ./usb_modeswitch.conf
Once I run usb_modeswitch, here is the log output that I get
Code: Select all
Reading config file: ./usb_modeswitch.conf
* usb_modeswitch: handle USB devices with multiple modes
* Version 1.2.5 (C) Josua Dietze 2012
* Based on libusb0 (0.1.12 and above)
! PLEASE REPORT NEW CONFIGURATIONS !
DefaultVendor= 0x12d1
DefaultProduct= 0x14d1
TargetVendor= 0x12d1
TargetProduct= 0x1c05
TargetClass= not set
TargetProductList=""
DetachStorageOnly=0
HuaweiMode=0
SierraMode=0
SonyMode=0
QisdaMode=0
GCTMode=0
KobilMode=0
SequansMode=0
MobileActionMode=0
CiscoMode=0
MessageEndpoint= not set
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
NeedResponse=0
ResponseEndpoint= not set
InquireDevice enabled (default)
Success check enabled, max. wait time 20 seconds
System integration mode disabled
Looking for target devices ...
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 12d1:14d1
found matching vendor ID
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2517
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 0bda:8176
No devices in target mode or class found
Looking for default devices ...
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 12d1:14d1
found matching vendor ID
found matching product ID
adding device
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2517
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 0bda:8176
Found device in default mode, class or configuration (1)
Accessing device 002 on bus 001 ...
Getting the current device configuration ...
OK, got current device configuration (1)
Using interface number 0
Using endpoints 0x0f (out) and 0x8f (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
OK, driver found; name unknown, limitation of libusb1
OK, driver "unkown" detached
SCSI inquiry data (for identification)
-------------------------
Vendor String: Vodafone
Model String: CD ROM (Huawei)
Revision String: 2.31
-------------------------
USB description data (for identification)
-------------------------
Manufacturer: HUAWEI
Product: Vodafone Mobile Broadband (Huawei)
Serial No.: not provided
-------------------------
Setting up communication with interface 0
Using endpoint 0x0f for message sending ...
Trying to send message 1 to endpoint 0x0f ...
OK, message successfully sent
Resetting response endpoint 0x8f
libusb:error [op_clear_halt] clear_halt failed error -1 errno 71
Could not reset endpoint (probably harmless): -34
Resetting message endpoint 0x0f
Could not reset endpoint (probably harmless): -6
Device is gone, skipping any further commands
Checking for mode switch (max. 20 times, once per second) ...
Searching for target devices ...
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2517
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 0bda:8176
Searching for target devices ...
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2517
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 0bda:8176
Searching for target devices ...
searching devices, found USB ID 12d1:1c05
found matching vendor ID
found matching product ID
adding device
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2517
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 0bda:8176
Found target device, now opening
Found target device 003 on bus 001
Target device description data
-------------------------
Manufacturer: HUAWEI
Product: Vodafone Mobile Broadband (Huawei)
Serial No.: not provided
-------------------------
Found correct target device
Mode switch succeeded. Bye.
I can see that the switching operation is successful
Code: Select all # lsusb
Bus 001 Device 003: ID 12d1:1c05
However no ttyUSB* files are generated under /dev folder.
Can you please guide me about this problem?
Thanks a lot in advance for your help.
Rifat
-
Josh
- Site Admin
- Posts: 6593
- Joined: 03 Nov 2007, 00:30
Post
by Josh » 12 Jan 2013, 09:55
You need to bind the modem port driver ("option") to the device after the mode switch:
Code: Select all # modprobe -v option
# echo "12d1 1c05" > /sys/bus/usb-serial/drivers/option1/new_id
The full usb_modeswitch package does this automatically; if you have "udev" running on your system, consider using it.
-
rifo
- Posts: 6
- Joined: 11 Jan 2013, 17:06
Post
by rifo » 14 Jan 2013, 17:35
Hello,
Thanks a lot for your answer. I have tried implementing your suggestions but came across a couple of problems. Here is what I did
Code: Select all # mount usbfs -t usbfs /proc/bus/usb
# ./usb_modeswitch -W -c ./usb_modeswitch.conf
* usb_modeswitch: handle USB devices with multiple modes
* Version 1.2.5 (C) Josua Dietze 2012
* Based on libusb0 (0.1.12 and above)
! PLEASE REPORT NEW CONFIGURATIONS !
DefaultVendor= 0x12d1
DefaultProduct= 0x14d1
TargetVendor= 0x12d1
TargetProduct= 0x1c05
TargetClass= not set
TargetProductList=""
DetachStorageOnly=0
HuaweiMode=0
SierraMode=0
SonyMode=0
QisdaMode=0
GCTMode=0
KobilMode=0
SequansMode=0
MobileActionMode=0
CiscoMode=0
MessageEndpoint= not set
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
NeedResponse=0
ResponseEndpoint= not set
InquireDevice enabled (default)
Success check enabled, max. wait time 20 seconds
System integration mode disabled
Looking for target devices ...
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 12d1:14d1
found matching vendor ID
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2517
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
No devices in target mode or class found
Looking for default devices ...
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 12d1:14d1
found matching vendor ID
found matching product ID
adding device
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2517
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
Found device in default mode, class or configuration (1)
Accessing device 002 on bus 001 ...
Getting the current device configuration ...
OK, got current device configuration (1)
Using interface number 0
Using endpoints 0x0f (out) and 0x8f (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
OK, driver found; name unknown, limitation of libusb1
OK, driver "unkown" detached
SCSI inquiry data (for identification)
-------------------------
Vendor String: Vodafone
Model String: CD ROM (Huawei)
Revision String: 2.31
-------------------------
USB description data (for identification)
-------------------------
Manufacturer: HUAWEI
Product: Vodafone Mobile Broadband (Huawei)
Serial No.: not provided
-------------------------
Setting up communication with interface 0
Using endpoint 0x0f for message sending ...
Trying to send message 1 to endpoint 0x0f ...
OK, message successfully sent
Resetting response endpoint 0x8f
libusb:error [op_clear_halt] clear_halt failed error -1 errno 71
Could not reset endpoint (probably harmless): -99
Resetting message endpoint 0x0f
Could not reset endpoint (probably harmless): -4
Device is gone, skipping any further commands
Checking for mode switch (max. 20 times, once per second) ...
Searching for target devices ...
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2517
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
Searching for target devices ...
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2517
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
Searching for target devices ...
searching devices, found USB ID 12d1:1c05
found matching vendor ID
found matching product ID
adding device
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2517
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
searching devices, found USB ID 1199:68a3
Found target device, now opening
Found target device 003 on bus 001
Target device description data
-------------------------
Manufacturer: HUAWEI
Product: Vodafone Mobile Broadband (Huawei)
Serial No.: not provided
-------------------------
Found correct target device
Mode switch succeeded. Bye.
Code: Select all # lsusb
...
Bus 001 Device 003: ID 12d1:1c05
...
Later on, I have tried making use of modprobe but got the following problem so I kept relying on insmod
Code: Select all Could not load /lib/modules/2.6.32_V3_HDMI/modules.deb
I also had some problems making use of the "new_id" mechansim in /sys/bus/... so I tried passing parameters to option.ko to no avail
Code: Select all insmod ./usbserial.ko
# insmod ./option.ko vendor=0x12d1 product=0x1c05
insmod: can't insert './option.ko': unknown symbol in module, or unknown parameter
# insmod ./option.ko
At this point, I guess that option.ko cannot know that 0x1c05 is its target. Below is the reason that I believe new_id is not available on my kernel
Code: Select all # cat /sys/bus/usb-serial/drivers/option1/new_id
cat: can't open '/sys/bus/usb-serial/drivers/option1/new_id': Permission denied
ls /dev/ttyUSB* doesn't show any output
Code: Select all
# ls /dev/ttyUSB*
ls: /dev/ttyUSB*: No such file or directory
My kernel version is
I have searched through the forum and came across a post where you suggested modifying the option.c source code when "new_id" mechanism doesn't work. I updated option.c such that there is an
++ #define HUAWEI_PRODUCT_E1C05 0x1C05
++ { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1C05) },
Note that I have also tried adding the second line like below to no avail
++ { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1C05, 0xff, 0xff, 0xff) },
I have then compiled this module and loaded that to the embedded linux system of mine but the driver didn't get the modem. Below is the last lines of my dmesg output
Code: Select all [ 4577.249053] usb 1-1: USB disconnect, address 2
[ 4579.653900] usb 1-1: new high speed USB device using musb_hdrc and address 3
[ 4579.803375] usb 1-1: New USB device found, idVendor=12d1, idProduct=1c05
[ 4579.803405] usb 1-1: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[ 4579.803405] usb 1-1: Product: Vodafone Mobile Broadband (Huawei)
[ 4579.803436] usb 1-1: Manufacturer: HUAWEI
[ 4579.806030] usb 1-1: no configuration chosen from 1 choice
[ 5137.920776] option: Unknown symbol usb_serial_port_softint
[ 5137.923583] option: Unknown symbol usb_serial_disconnect
[ 5137.925140] option: Unknown symbol usb_serial_suspend
[ 5137.931365] option: Unknown symbol usb_serial_probe
[ 5137.931915] option: Unknown symbol usb_serial_register
[ 5137.932312] option: Unknown symbol usb_serial_deregister
[ 5137.932708] option: Unknown symbol usb_serial_resume
[ 5156.630401] usbcore: registered new interface driver usbserial
[ 5156.631744] USB Serial support registered for generic
[ 5156.648040] usbcore: registered new interface driver usbserial_generic
[ 5156.648071] usbserial: USB Serial Driver core
[ 5159.798706] option: Unknown parameter `vendor'
7238.276824] USB Serial support registered for GSM modem (1-port)
[ 7238.285369] usbcore: registered new interface driver option
[ 7238.285400] option: v0.7.2:USB Driver for GSM modems
I am kind of stuck at this point. Any help would be appreciated
Thanks a lot
rifat
-
Josh
- Site Admin
- Posts: 6593
- Joined: 03 Nov 2007, 00:30
Post
by Josh » 14 Jan 2013, 19:59
rifo wrote:At this point, I guess that option.ko cannot know that 0x1c05 is its target. Below is the reason that I believe new_id is not available on my kernel
Code: Select all # cat /sys/bus/usb-serial/drivers/option1/new_id
cat: can't open '/sys/bus/usb-serial/drivers/option1/new_id': Permission denied
Did you try to change the permissions of the attribute? Do you have sufficient superuser rights?
rifo wrote:I also had some problems making use of the "new_id" mechansim in /sys/bus/... so I tried passing parameters to option.ko to no avail
Code: Select all insmod ./usbserial.ko
# insmod ./option.ko vendor=0x12d1 product=0x1c05
insmod: can't insert './option.ko': unknown symbol in module, or unknown parameter
This will never work. These parameters are not implemented.
-
rifo
- Posts: 6
- Joined: 11 Jan 2013, 17:06
Post
by rifo » 15 Jan 2013, 15:01
Hello again,
I have tried running the modem on a PC with success and noticed that the usb_switchmode system assigned a product id of 14c9 . I have then did the same thing on the embedded device to no avail. While searching for the
problem, it turned out that aside from the product id, one needs to change the message content too. With the below config, things work fine after loading the usbserial driver with
Code: Select all ./insmod ./usbserial.ko vendor=0x12d1 product=0x14c9
Code: Select all # cat usb_modeswitch.conf
#####################################
# Huawei, newer modems
DisableSwitching=0
EnableLoggin=1
#HuaweiMode=1
#DetachStorageOnly=1
DefaultVendor=0x12d1
DefaultProduct=0x14d1
TargetVendor=0x12d1
TargetProduct=0x14c9
#TargetProductList="1001,1406,140b,140c,1412,141b,1433,14ac,1506,1436,14ac"
CheckSuccess=20
#MessageContent="55534243123456780000000000000011060000000000000000000000000000"
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
I'll try to make use of the udev system right now but I don't have support for modprobe and new_id mechanisms in my system. Hopefully I'll come with a workaround.
thanks for your help
rifat
-
LOM
- Posts: 1404
- Joined: 11 Jul 2012, 15:14
- Location: Koh Samui, TH
Post
by LOM » 15 Jan 2013, 17:15
You should have consulted the usb_modeswitch datapackage, you have just reinvented the wheel..
The file 12d1_14d1 contains:
# Vodafone / Huawei K3770
TargetVendor= 0x12d1
TargetProduct= 0x14c9
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
-
Josh
- Site Admin
- Posts: 6593
- Joined: 03 Nov 2007, 00:30
Post
by Josh » 15 Jan 2013, 20:21
rifo wrote:I'll try to make use of the udev system right now but I don't have support for modprobe and new_id mechanisms in my system.
You can work with "insmod" of course. It just needs the full path to the module file as opposed to "modprobe".
The "new_id" attribute should be an integrated feature of the "option" driver since kernel 2.6.27. Did you load the module successfully? Just don't load it with any parameters.
-
rifo
- Posts: 6
- Joined: 11 Jan 2013, 17:06
Post
by rifo » 21 Jan 2013, 11:16
Hello again,
I have modifed the udev scripts so that insmod is used and setup the rest of the udev environment. I have plugged my Vodafone / Huawei K3770 (12d1, 14d1) and it was successfully binded to the device node /dev/gsmmodem. Later on I called a pppd script and connected to the internet. Thanks for sharing such great software
I have then tried another modem from ZTE (19d2, 2000) but this time the dispatcher software was not able to call the usb_modeswitch binary. Below is the output I got from /var/log/messages
Code: Select all Jan 1 00:01:21 modeo user.info kernel: [ 96.049682] usb 1-1: New USB device found, idVendor=19d2, idProduct=2000
Jan 1 00:01:21 modeo user.info kernel: [ 96.049682] usb 1-1: New USB device strings: Mfr=3, Product=2, SerialNumber=4
Jan 1 00:01:21 modeo user.info kernel: [ 96.049713] usb 1-1: Product: ZTE WCDMA Technologies MSM
Jan 1 00:01:21 modeo user.info kernel: [ 96.049713] usb 1-1: Manufacturer: ZTE,Incorporated
Jan 1 00:01:21 modeo user.info kernel: [ 96.049743] usb 1-1: SerialNumber: MF1900AVED010000
Jan 1 00:01:21 modeo user.warn kernel: [ 96.052581] usb 1-1: new config #1 exceeds power limit by 400mA
Jan 1 00:01:22 modeo user.info kernel: [ 96.061706] scsi0 : usb-storage 1-1:1.0
Jan 1 00:01:22 modeo user.warn kernel: [ 96.065429] usb 1-1: 500mA is over 100mA budget for port 1!
Jan 1 00:01:22 modeo user.warn kernel: [ 96.065460] hub 1-0:1.0: 400mA over power budget!
Jan 1 00:01:23 modeo user.err usb_modeswitch_dispatcher: *** glibc detected *** usb_modeswitch_dispatcher: double free or corruption (!prev): 0x000c1088 ***
I have searched for the error message and saw that there was a patch issued for it (which I guess is alreay included in my version)
Code: Select all * usb_modeswitch: handle USB devices with multiple modes
* Version 1.2.5 (C) Josua Dietze 2012
* Based on libusb0 (0.1.12 and above)
I would be happy if you can guide me about this problem.
Thank you very much again for your time
rifat
-
rifo
- Posts: 6
- Joined: 11 Jan 2013, 17:06
Post
by rifo » 23 Jan 2013, 12:52
Hello again,
Just wanted to inform you guys that, I have modified the script (added a couple of echo messages) to understand where the process was stuck. It turns out that the below command
Code: Select all usb_modeswitch_dispatcher --switch-mode 1-1/1-1 /lib/udev/usb_modeswitch
sometimes isn't able to switch the dongle to 3G modem mode when it is run via the udev mechanism.
After getting stuck, if I issue the above command manually then everything works fine and the rest of the process is handled again via the udev mechanism.
Note that 1 out of 10 tries, the udev mechanism works without problems after the dongle is plugged but usually it is stuck at the switching process.
Thanks a lot for your help
Rifat
-
rifo
- Posts: 6
- Joined: 11 Jan 2013, 17:06
Post
by rifo » 23 Jan 2013, 13:01
Also, in case it may be helpful, I have run the usd_switchmode_dispatcher with Valgrind and got the below output
Code: Select all cat valgrind_log.txt
==2605== Memcheck, a memory error detector
==2605== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==2605== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==2605== Command: usb_modeswitch_dispatcher --switch-mode 1-1/1-1 /lib/udev/usb_modeswitch
==2605== Parent PID: 1343
==2605==
==2605== Invalid read of size 4
==2605== at 0x190E8: Jim_EvalObj (in /usr/sbin/usb_modeswitch_dispatcher)
==2605== Address 0x49febf4 is 4 bytes inside a block of size 56 free'd
==2605== at 0x4831CE0: free (vg_replace_malloc.c:366)
==2605== by 0xCAFF: Jim_DeleteHashEntry (in /usr/sbin/usb_modeswitch_dispatcher)
==2605==
==2605==
==2605== HEAP SUMMARY:
==2605== in use at exit: 0 bytes in 0 blocks
==2605== total heap usage: 12,727 allocs, 12,727 frees, 683,985 bytes allocated
==2605==
==2605== All heap blocks were freed -- no leaks are possible
==2605==
==2605== For counts of detected and suppressed errors, rerun with: -v
==2605== ERROR SUMMARY: 9 errors from 1 contexts (suppressed: 13 from 6)
-
Josh
- Site Admin
- Posts: 6593
- Joined: 03 Nov 2007, 00:30
Post
by Josh » 24 Jan 2013, 21:21
Did you notice this error in your log?
Jan 1 00:01:21 modeo user.warn kernel: [ 96.052581] usb 1-1: new config #1 exceeds power limit by 400mA
Jan 1 00:01:22 modeo user.warn kernel: [ 96.065429] usb 1-1: 500mA is over 100mA budget for port 1!
Jan 1 00:01:22 modeo user.warn kernel:[ 96.065460] hub 1-0:1.0: 400mA over power budget!
3G modems need the full 500 mA specified as the maximum power that a standard USB port has to provide. You might need to power your hub.
|
|