Page 1 of 1

Problems when using modeswitch on an embedded ARM board

Posted: 17 Oct 2012, 09:12
by Stampede
Hi,

I am trying to use modeswitch on a ARM board with a iMX53 processor with Linux-2.6.35. The stick i use is the Huawei E303.

On insertion of the stick, I get:
usb 1-1.2: new high speed USB device using fsl-ehci and address 5
scsi1 : usb-storage 1-1.2:1.0
scsi 1:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
Obvioulsly, no sr0 or sg0 or whatever device is created. I only can see it as usbdevices1.xx in /dev.

In order to modeswitch, I used the precompiled usb_modeswitch-1.1.9-arm-static with the command line option:

Code: Select all

./usb_modeswitch-1.1.9-arm-static -W -v 12d1 -p 1f01 -M 55534243123456780000000000000011062000000100000000000000000000
Now, the result of the operation is:
* usb_modeswitch: handle USB devices with multiple modes
* Version 1.1.9 (C) Josua Dietze 2011
* Based on libusb0 (0.1.12 and above)

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x12d1
DefaultProduct= 0x1f01
TargetVendor= not set
TargetProduct= not set
TargetClass= not set
TargetProductList=""

DetachStorageOnly=0
HuaweiMode=0
SierraMode=0
SonyMode=0
GCTMode=0
KobilMode=0
SequansMode=0
MobileActionMode=0
CiscoMode=0
MessageEndpoint= not set
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
NeedResponse=0
ResponseEndpoint= not set
Interface=0x00

InquireDevice enabled (default)
Success check disabled
System integration mode disabled

usb_set_debug: Setting debugging level to 15 (on)
usb_os_find_busses: Found 001
usb_os_find_busses: Found 002
usb_os_find_devices: Found 001 on 001
usb_os_find_devices: Found 002 on 001
usb_os_find_devices: Found 003 on 001
skipped 1 class/vendor specific interface descriptors
error obtaining child information: Inappropriate ioctl for device
usb_os_find_devices: Couldn't open /dev/bus/usb/002/001

Looking for default devices ...
searching devices, found USB ID 1d6b:0002
searching devices, found USB ID 0424:2514
searching devices, found USB ID 046d:c050
No devices in default mode found. Nothing to do. Bye.
I think the problem is related the USB detection / hotplugging. If i use lsusb, I cannot see the stick (like usb_modeswitch):

Code: Select all

# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 003: ID 046d:c050 Logitech, Inc. RX 250 Optical Mouse
However, if I use usb-devices, the device is visible:

Code: Select all

# usb-devices

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 1
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=02.06
S:  Manufacturer=Linux 2.6.35.3-744-g27fdf7b-svn2671 ehci_hcd
S:  Product=Freescale On-Chip EHCI Host Controller
S:  SerialNumber=fsl-ehci.1
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480 MxCh= 4
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=02 MxPS=64 #Cfgs=  1
P:  Vendor=0424 ProdID=2514 Rev=0b.b3
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=2mA
I:  If#= 0 Alt= 1 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=02 Driver=hub

T:  Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#=  4 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=12d1 ProdID=1f01 Rev=01.02
S:  Manufacturer=HUAWEI
S:  Product=HUAWEI HiLink
C:  #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

[...]
As I use an embedded board, not all features are enabled. I found out, that mdev is used instead of udev for detecting hotplug events. May this be a problem?
Does the newer 1.2.4 version has a better detection method to find the device? I somehow stuck here...
Any help is appreciated.

Regards,
Stampede

Re: Problems when using modeswitch on an embedded ARM board

Posted: 18 Oct 2012, 08:52
by Stampede
Anybody???

Re: Problems when using modeswitch on an embedded ARM board

Posted: 28 Oct 2012, 21:57
by Josh
"lsusb" is likely using libusb, just like usb_modeswitch.

If there is trouble seeing a device, there is nothing I can do. But I've never heard about such problems with libusb. If I were you, I'd look for a hardware or host driver problem.
BTW, does the modem get enough power? Can the port provide 500 mA?

Re: Problems when using modeswitch on an embedded ARM board

Posted: 29 Oct 2012, 11:08
by Stampede
Hi Josh,

thanks for your reply. I more or less found out what is going on:

Libusb only sees the deviced located in /dev/bus/usb. These entries are created usually by udev. However, my device is using mdev which recogizes the device, but does not create the entries in /dev/bus/usb. As a workaround, I created a mdev script (mdev.config) that creates a symlink when the usb stick is plugged into the USB port. The link referes to /dev/usbdevice1.x. Now, the device can be switched.
As the cdc_ether drivers still have been missing on my board, i requested the linux sources for that board from the supplier and rebuilt the kernel using udev. With udev, I got modeswitch (in command line mode) to work within seconds. As summary, I strongly encourage anybody to use udev instead of mdev.

For those who need mdev, I'd like to post my script, maybe somebody can use it on an embedded board:

mdev.conf: (which calls huawei on hotplug events)

Code: Select all

	sd[a-z]([0-9]+) 0:0 660 * /etc/automount
	usbdev[0-9].*   0:0 660 * /etc/huawei	
	mmcblk[0-9].*  0:0 660 * /etc/automount
        pcm.*          0:0 660 =snd/
        control.*      0:0 660 =snd/
        seq            0:0 660 =snd/
        sequencer.*    0:0 660 =snd/
        # some (enlightenment) require event0 in /dev/input, qt requires it in /dev/
        event.*        0:0 660 >/dev/input/
        # configures WLAN and DHCP when a WLAN card is installed. auto-wlan is provided by wpa_supplicant package
        # installed by wpa_supplicant.cfg
        "wlan0"     0:0 660 * /etc/auto-wlan
        # installed by bluez.cfg
        hci[0-9]       0:0 660 * /etc/auto-bluetooth
        .* 0:0 660
huawei (Quick n dirty workaround)

Code: Select all

#!/bin/sh
# Create device files for huawei 



	huawei_add()
	{
		# For debugging, print some parametes we can use
		echo $ACTION > /dev/console
		#echo $DEVPATH > /dev/console
		#echo $DEVNAME > /dev/console
		#echo $SUBSYSTEM > /dev/console
		#echo $SEQNUM > /dev/console
		#echo $PWD > /dev/console
		#echo $MAJOR > /dev/console
		#echo $MINOR > /dev/console
		#echo $PHYSDEVDRIVER > /dev/console
		#echo $PHYDEVBUS > /dev/console
		
		# set symlink so that usb_modswitch can access the device
		ln -s $PWD/$DEVNAME $MOUNTPOINT

		# Get the PID and VID of the device
		PID=`cat /sys$DEVPATH/device/idProduct`
		VID=`cat /sys$DEVPATH/device/idVendor`
		#echo $PID > /dev/console
		#echo $VID > /dev/console
		# check if the device as already been switched
		if [ "$PID" = "1f01" ] && [ "$VID" = "12d1" ]; then
			echo "Staring USB Modeswitch" > /dev/console
			#launch modeswitch to trigger switching
			MODESWITCH=`/Huawei/usbmodeswitch_1.2.4-arm-static -c /Huawei/E303`
			#echo $MODESWITCH > /dev/console		
		fi
		if [ "$PID" = "14db" ] && [ "$VID" = "12d1" ]; then
			echo "Device successfully switched" > /dev/console	
		fi
		

	}

	huawei_remove()
	{
		#echo "remove"
		echo $ACTION > /dev/console
		echo $DEVPATH > /dev/console
		#remove symlink which is not needed anymore
		rm -f $MOUNTPOINT
	}

	#get the busnumber by incrementing the MINOR variable by one
	declare -i InterfaceNumber
	InterfaceNumber=$MINOR
	let "InterfaceNumber += 1"
	# create a symlink to the device. This is needed for
	# usbmodeswitch to find the device
	MOUNTPOINT=/dev/bus/usb/001/00$InterfaceNumber

	case "$ACTION" in
            add)     huawei_add;;
            remove)  huawei_remove;;
        esac
If interested, I can also supply usbmodeswitch_1.2.4-arm-static.

Cheers
Stampede