Author Message

<  Everything Coding  ~  "Error -1" switching Huawei E3272s-153 on FreeBSD

PostPosted: Thu Jul 24, 2014 9:42 pm Reply with quote
Posts: 6 Joined: Thu Jul 24, 2014 8:34 pm
Hello,

I have two different Huawei E3272s-153 LTE USB sticks with different Firmware editions, and I cannot switch one of them on FreeBSD 8.3/pfsense Firewall platform.

A short explanation of the different firmware editions (see also here: http://unlock4modem.in/download-huawei- ... date-free/):

    The first one has "dashboard" type firmware (version 22.x), by which I mean that after plugging in and installing the driver in Windows, a browser window opens up to http://192.168.1.1 one can go and configure the device and click on the "Connect" button. This kind of stick does not allow public IP passthrough, and will only expose an ethernet device to the OS.
    I am able to successfully switch this kind of stick using the instructions found here: http://pethson.blogspot.co.at/2014/01/h ... se-21.html (Google Translate will help)
    But since I will be using it on a firewall, I prefer having the public IP directly available to the firewall, so I bought a the same stick, which had the "normal" type firmware (version 21.x) installed. After being switched, this firmware presents a serial modem port and a broadband device port to the OS.
    This is the version I am having problems with. It does not accept the same command as in the above post (because it has a different initial device ID).

I have followed the instructions on the main page under "Contribute" and the linked blog article using Windows XP and the SniffUSB tool, and was able to capture the last command sent to the stick before it switches the mode (see attached file UsbSnoop.log)

Based on the information I have built together the following command:
Code:
usb_modeswitch -v 12d1 -p 14fe -V 012d1 -P 01506 -M "55534243000000000000000000000011060000000100000000000000000000" -W


But when issuing this command, I get the following output:
Quote:
[2.1.3-RELEASE][root@gw.home.local]/root(8): usb_modeswitch -v 12d1 -p 14fe -V 012d1 -P 01506 -M "55534243000000000000000000000011060000000100000000000000000000" -W
Taking all parameters from the command line


* usb_modeswitch: handle USB devices with multiple modes
* Version 1.2.1 (C) Josua Dietze 2011
* Based on libusb0 (0.1.12 and above)

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x12d1
DefaultProduct= 0x14fe
TargetVendor= 0x12d1
TargetProduct= 0x1506
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="55534243000000000000000000000011060000000100000000000000000000"
NeedResponse=0
ResponseEndpoint= not set

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


Looking for target devices ...
searching devices, found USB ID 12d1:14fe
found matching vendor ID
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
No devices in target mode or class found
Looking for default devices ...
searching devices, found USB ID 12d1:14fe
found matching vendor ID
found matching product ID
adding device
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
Found device in default mode, class or configuration (1)
Accessing device 004 on bus 000 ...
Getting the current device configuration ...
OK, got current device configuration (1)
Using first interface: 0x00
Using endpoints 0x01 (out) and 0x81 (in)
Inquiring device details; driver will be detached ...
Cant't do driver detection and detaching on this platform.
Could not send INQUIRY message (error -1)[/b]

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
Product: HUAWEI Mobile
Serial No.: FFFFFFFFFFFFFFFF
-------------------------
Cant't do driver detection and detaching on this platform.
Setting up communication with interface 0
Using endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
Sending the message returned error -1. Trying to continue
Resetting response endpoint 0x81
Could not reset endpoint (probably harmless): -1
Resetting message endpoint 0x01
Could not reset endpoint (probably harmless): -1
-> Run lsusb to note any changes. Bye.


After that I searched the net for this vendor and device IDs and usb_modeswitch and found two additional messages I could try:
Code:
usb_modeswitch -v 12d1 -p 14fe -V 012d1 -P 01506 -M "55534243123456780000000000000011062000000100000000000000000000" -W
usb_modeswitch -v 12d1 -p 14fe -V 012d1 -P 01506 -M "55534243123456780000000000000011062000000101000100000000000000" -W

but both fail with the error code "-1".

The last thing I have tried was setting up Ubuntu 14.04 and trying the stick there - it switched the mode successfully with the already integrated version of usb_modeswitch without me having to do anything.

Now, is there anything I can do to find out the reason for error "-1"?
Or maybe I did miss something when trying to read UsbSnoop.log?

I have also attached the output of "usbconfig dump_device_desc show_ifdrv" (file usbconfig.log").

Regards,
Marc
Attachments:
usbconfig.log [2.1 KiB]
Downloaded 298 times

UsbSnoop.log [10.13 KiB]
Downloaded 301 times

Offline
PostPosted: Fri Jul 25, 2014 2:59 am Reply with quote
Posts: 1175 Joined: Wed Jul 11, 2012 3:14 pm Location: Koh Samui, TH
Start with upgrading usb_modeswitch, it should fix your usb communication errors.


Offline
PostPosted: Fri Jul 25, 2014 10:53 am Reply with quote
Posts: 6 Joined: Thu Jul 24, 2014 8:34 pm
Hi,

Thanks for the reply, I will try to figure out how to do that!

Marc


Offline
PostPosted: Sat Aug 23, 2014 11:40 pm Reply with quote
Posts: 6 Joined: Thu Jul 24, 2014 8:34 pm
Hi,

I have finally managed to get myself a FreeBSD 8.3 VM in which I could compile usb_smodewitch 2.2.0.
Unfortunately my efforts seem to have come to an end soon:

Quote:
freebsd# make static
cc -o usb_modeswitch usb_modeswitch.c -O2 -pipe -Wall `pkg-config --libs --cflags libusb-1.0`
gnome-config: not found
Package libusb-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libusb-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libusb-1.0' found
/var/tmp//ccizp0O5.o(.text+0xe56): In function `get_current_configuration':
: undefined reference to `libusb_free_config_descriptor'
/var/tmp//ccizp0O5.o(.text+0xea8): In function `get_current_configuration':
: undefined reference to `libusb_get_active_config_descriptor'
/var/tmp//ccizp0O5.o(.text+0xedc): In function `findMBIMConfig':
: undefined reference to `libusb_get_device_list'

...



So I tried to get libusb-1.0.19 and compile it:

Quote:
freebsd# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking build system type... i386-unknown-freebsd8.3
checking host system type... i386-unknown-freebsd8.3
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert i386-unknown-freebsd8.3 file names to i386-unknown-freebsd8.3 format... func_convert_file_noop
checking how to convert i386-unknown-freebsd8.3 file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... freebsd8.3 ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for windres... no
checking for inline... inline
checking operating system... configure: error: unsupported operating system
freebsd#


Seems like I have run out of luck...or has anybody an idea what I could try to do next?

Regards,
Marc


Offline
PostPosted: Sun Aug 24, 2014 2:38 pm Reply with quote
Posts: 6 Joined: Thu Jul 24, 2014 8:34 pm
Ok, it took me the whole night to figure out, that I do not need to build libusb on FreeBSD because there was already a compatible one. :mrgreen:

So I removed the libusb version I compiled and installed during that process and restored the original libusb libraries that were delivered together with the basic install.

I had to make the following modifications to Makefile, to get usb_modeswitch compile successfully:
Code:
CFLAGS      += -g -Wall -D_THREAD_SAFE -pthread

instead of
Code:
CFLAGS      += -Wall

(I enabled debugging because there are still errors)

Code:
LIBS        = /usr/lib/libusb.so

instead of
Code:
#LIBS        = `pkg-config --libs --cflags libusb-1.0`


and I had to modify the code around HOST_TCL as follows because make was complaining something about a missind delimiter/syntax error or something like that:
Code:
#HOST_TCL   := $(shell cd jim && ./autosetup/find-tclsh)
HOST_TCL    = /root/usb-modeswitch-2.2.0/jim/autosetup/jimsh0
#ifeq (,$(findstring jimsh0,$(HOST_TCL)))
TCL        ?= $(HOST_TCL)
#else
#TCL        ?= /usr/bin/tclsh
#endif


Then, before compiling, I needed to go into the jim folder and do a ./configure && make which built fine.
After that, a simple "make" built the executable, without any warnings or errors.

Unfortunately, as mentioned, I still get errors:

Quote:
./usb_modeswitch -v 12d1 -p 14fe -V 012d1 -P 01506 -M "55534243000000000000000000000011060000000100000000000000000000" -W
Take all parameters from the command line


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

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x12d1
DefaultProduct= 0x14fe
TargetVendor= 0x12d1
TargetProduct= 0x1506
MessageContent="55534243000000000000000000000011060000000100000000000000000000"
NeedResponse=0

Look for target devices ...
found USB ID 0000:0000
found USB ID 0000:0000
found USB ID 12d1:14fe
vendor ID matched
No devices in target mode or class found
Look for default devices ...
found USB ID 0000:0000
found USB ID 0000:0000
found USB ID 12d1:14fe
vendor ID matched
product ID matched
Found devices in default mode (1)
Access device 002 on bus 001
Segmentation fault (core dumped)


Then I read, that with the new version 2.2.0 I could try a different method:

Quote:
./usb_modeswitch -v 12d1 -p 14fe -V 012d1 -P 01506 -J -W
Take all parameters from the command line


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

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x12d1
DefaultProduct= 0x14fe
TargetVendor= 0x12d1
TargetProduct= 0x1506
HuaweiNewMode=1
NeedResponse=0

Look for target devices ...
found USB ID 0000:0000
found USB ID 0000:0000
found USB ID 12d1:14fe
vendor ID matched
No devices in target mode or class found
Look for default devices ...
found USB ID 0000:0000
found USB ID 0000:0000
found USB ID 12d1:14fe
vendor ID matched
product ID matched
Found devices in default mode (1)
Access device 002 on bus 001
Segmentation fault (core dumped)


I then wanted to exclude that maybe something with my hardware or installation was fishy, so I unplugged the stick from the original hardware and mapped it into the Virtualbox VM where I built the binary, but I get the same segmentation faults.

At the moment I am trying to do a crash course in gdb to find out what is going on just around the place where the segmentation fault is happening (it seems like it is a possible to get more info out there).

Any further help appreciated...
Marc

@Moderator: maybe because of the unintentional change of the topic, it might be useful to move the thread to the development section of this forum?


Offline
PostPosted: Sun Aug 24, 2014 2:57 pm Reply with quote
Posts: 6 Joined: Thu Jul 24, 2014 8:34 pm
Small update (crash course worked :mrgreen:):

Quote:
gdb ./usb_modeswitch usb_modeswitch.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
Core was generated by `usb_modeswitch'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libusb.so.2...done.
Loaded symbols for /usr/lib/libusb.so.2
Reading symbols from /lib/libthr.so.3...done.
Loaded symbols for /lib/libthr.so.3
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0 main (argc=11, argv=0xbfbfebd0) at usb_modeswitch.c:545
545 currentConfig = active_config->bConfigurationValue;
[New Thread 28201140 (LWP 100128/initial thread)]


I will report any further findings...
Regards,
Marc

P.S. sorry for "spamming" your board, but right now I am really excited that I get results... :D


Offline
PostPosted: Sun Aug 24, 2014 3:15 pm Reply with quote
Posts: 6 Joined: Thu Jul 24, 2014 8:34 pm
Hmm, this might be my last post for today, because right now I am lost. I don't know what to do with "error accessing memory":

Quote:
gdb ./usb_modeswitch --args ./usb_modeswitch -v 12d1 -p 14fe -V 012d1 -P 01506 -J -W
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) b 544
Breakpoint 1 at 0x804eb50: file usb_modeswitch.c, line 544.
(gdb) run
Starting program: /root/usb-modeswitch-2.2.0/usb_modeswitch -v 12d1 -p 14fe -V 012d1 -P 01506 -J -W
[New LWP 100103]
[New Thread 28201140 (LWP 100103/initial thread)]
Take all parameters from the command line


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

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x12d1
DefaultProduct= 0x14fe
TargetVendor= 0x12d1
TargetProduct= 0x1506
HuaweiNewMode=1
NeedResponse=0

Look for target devices ...
found USB ID 0000:0000
found USB ID 0000:0000
found USB ID 12d1:14fe
vendor ID matched
No devices in target mode or class found
Look for default devices ...
found USB ID 0000:0000
found USB ID 0000:0000
found USB ID 12d1:14fe
vendor ID matched
product ID matched
Found devices in default mode (1)
Access device 002 on bus 001
[Switching to Thread 28201140 (LWP 100103/initial thread)]

Breakpoint 1, main (argc=11, argv=0xbfbfeb9c) at usb_modeswitch.c:544
544 if (Configuration > -1) {
(gdb) print Configuration
$1 = 0
(gdb) step
545 currentConfig = active_config->bConfigurationValue;
(gdb) print currentConfig
$2 = 0
(gdb) print active_config
$3 = (struct libusb_config_descriptor *) 0x0
(gdb) print active_config->bConfigurationValue
Error accessing memory address 0x5: Bad address.
(gdb)


Any ideas?


Offline

Display posts from previous:  Sort by:

All times are UTC+02:00
Page 1 of 1
7 posts
Users browsing this forum: No registered users and 1 guest
Search for:
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum