Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
emkah
Posts: 3
Joined: Fri Jun 12, 2020 6:26 pm

Huawei E5576-320 setup

Post by emkah » Fri Jun 12, 2020 6:33 pm

Hello there,

I'm trying to get my Huawei E5576-320 modem router to work via the USB link on Alpine Linux 3.12. I made some progress with manual switching the device into wwan or Hilink mode. However, on either end, I have no clue how to tell the modem to bring me online.

So, this is the situation so far:

- I want to use the modem as wwan device on a headless Alpine system
- For now, I've disabled WIFI in the modem's web interface (don't know if this matters for the wwan use of the USB connection)
- When I connect the modem with a MacBook Pro running macOS, the device switches to 12d1:14db and automatically connects me to the internal web interface and also succesfully enables internet access via the USB link. So the device itself basically works.

Now, to the alpine machine.
- When I connect the modem to the machine, it presents itself as expected with 12d1:1f01
- There is no udev installed yet and I hope I don't need it when setting up the /etc/network/interfaces file correctly with pre-up rules
- I use the following usb_modeswitch config file, stored under /etc/usb-modeswitch.d/12d1:1f01:

Code: Select all

# Huawei E353 (3.se) and others
# Switch from default mass storage device mode 12d1:1f01 to ...
TargetVendor=0x12d1

# WWAN mode 12d1:155e
TargetProduct=0x155e
MessageContent="55534243123456780000000000000011063000000100010000000000000000"

# Broadband modem mode 12d1:1442
#TargetProduct=0x1442
#MessageContent="55534243000000000000000000000011060000000000000000000000000000"

# "ethernet" mode
#TargetProductList="14db,14dc"
#HuaweiNewMode=1
- I've tried both the WWAN mode and the "ethernet" mode. (EDIT: I know that what is called "Broadband modem mode" doesn't work and I didn't try it out either. I just left it there for now as I obviously "stole" this instruction from the E353 initialization) Both modes are somehow working when enabling them manually with the following usb-modeswitch output:

Code: Select all

# usb_modeswitch -v 12d1 -p 1f01 -c /etc/usb_modeswitch.d/12d1:1f01 
Look for target devices ...
 No devices in target mode or class found
Look for default devices ...
 Found devices in default mode (1)
Access device 003 on bus 001
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
 with class 8
Use endpoints 0x01 (out) and 0x81 (in)
Looking for active drivers ...
 OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
 OK, message successfully sent
Read the response to message 1 (CSW) ...
 Response successfully read (13 bytes), status 0
Reset response endpoint 0x81
 Could not reset endpoint (probably harmless): -99
Reset message endpoint 0x01
 Could not reset endpoint (probably harmless): -4
 Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!
After this, the device ID was properly changed, either to 155e or 14db respectively.

In WWAN mode (I will omit the ethernet mode from here, as I do not intend to use it if I don't have to), there is a new wwan0 network interface:

Code: Select all

# ip a
7: wwan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff

There is also a new serial device:

Code: Select all

# ls -l /dev/ttyUSB* 
crw-rw----    1 root     dialout   188,   0 Jun 12 17:59 /dev/ttyUSB0
dmesg output:

Code: Select all

[  184.209207] usb 1-2: USB disconnect, device number 3
[  189.497604] usb 1-2: new high-speed USB device number 5 using xhci_hcd
[  189.639752] usb 1-2: New USB device found, idVendor=12d1, idProduct=155e, bcdDevice= 1.02
[  189.639768] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  189.639784] usb 1-2: Product: HUAWEI_MOBILE
[  189.639792] usb 1-2: Manufacturer: HUAWEI_MOBILE
[  189.693978] usbcore: registered new interface driver usbserial_generic
[  189.694043] usbserial: USB Serial support registered for generic
[  189.702886] usbcore: registered new interface driver option
[  189.702955] usbserial: USB Serial support registered for GSM modem (1-port)
[  189.722762] cdc_ncm 1-2:1.1: MAC-Address: xx:xx:xx:xx:xx:xx
[  189.722778] cdc_ncm 1-2:1.1: setting rx_max = 16384
[  189.724330] cdc_ncm 1-2:1.1 wwan0: register 'cdc_ncm' at usb-0000:00:14.0-2, Mobile Broadband Network Device, xx:xx:xx:xx:xx:xx
[  189.724436] usbcore: registered new interface driver cdc_ncm
[  189.724477] option 1-2:1.0: GSM modem (1-port) converter detected
[  189.725244] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB0
[  189.732600] usbcore: registered new interface driver cdc_wdm
[  189.737610] usbcore: registered new interface driver cdc_mbim
From there, I don't have a clue how to continue. I've read several pages here in the forum and on other sites, but obviously, I'm missing some important information. As far as I understand, I need to "enable" the modem somehow, but I have no idea how to achieve this.

I tried issuing the following command with the appropriate apn with no visual result:

Code: Select all

# echo -ne '\r\nAT^NDISUP=1,1,"xxxxxx"\r\n' > /dev/ttyUSB0
ip link set wwan0 up fails, the interface keeps down

EDIT: I've also tried to configure the wwan port via /etc/network/interfaces:

Code: Select all

allow-hotplug wwan0
iface wwan0 inet dhcp
       wwan_apn "xxxxx"
       pre-up /usr/sbin/usb_modeswitch -v 12d1 -p 1f01 -c /etc/usb_modeswitch.d/12d1:1f01
However, the interface didn't came up automatically. With

Code: Select all

#ifup wwan0
, I got the same output as when manually calling usb-modeswitch like above. The wwan0 interface also stays down.

I would like to use as less additional tools/packages as possible to keep my installation lean and clean. However, from that point, the knowledge I gathered is simply not enough to continue without help.

Thanks in advance!
Last edited by emkah on Sat Jun 13, 2020 10:58 am, edited 1 time in total.

LOM
Posts: 1308
Joined: Wed Jul 11, 2012 3:14 pm
Location: Koh Samui, TH

Re: Huawei E5576-320 setup

Post by LOM » Sat Jun 13, 2020 3:02 am

You will not be able to use the dongle in ncm mode (12d1:155e) under linux 3.12 without the huawei_cdc_ncm driver which was introduced in the end of linux 3 or in the beginning of linux 4. linux 3.12 just doesn't have it, it is too old.
It is a small helper driver taking care of Huawei special ncm quirks and it depends on the standard cdc_ncm driver.

What you call "Broadband modem mode" isn't, it is a factory test mode unusable for you and the reason you end up there is because you use the wrong switch message.
The Huawei linux switch message is 55534243123456780000000000000011062000000101000100000000000000 and it will switch the dongle into 12d1:14db which you already is familiar with from the Macbook.

emkah
Posts: 3
Joined: Fri Jun 12, 2020 6:26 pm

Re: Huawei E5576-320 setup

Post by emkah » Sat Jun 13, 2020 10:49 am

Obviously, there are a few misunderstandings:
LOM wrote:
Sat Jun 13, 2020 3:02 am
linux 3.12 just doesn't have it, it is too old.
3.12 was the distro's version, not the kernel's.

Code: Select all

# uname -r
Linux xxxxx 5.4.43-1-lts #2-Alpine SMP Thu, 28 May 2020 20:13:48 UTC x86_64 Linux
LOM wrote:
Sat Jun 13, 2020 3:02 am
What you call "Broadband modem mode" isn't, it is a factory test mode unusable for you and the reason you end up there is because you use the wrong switch message. The Huawei linux switch message is 55534243123456780000000000000011062000000101000100000000000000 and it will switch the dongle into 12d1:14db which you already is familiar with from the Macbook.
I didn't use the "Broadband modem mode" and I also didn't end there accidentally. I either used the first two switching parameters (labeled as "WWAN mode") or the last two (labeled as "ethernet mode"). Switching to both modes gave me the correct product id (15533 or 14db respectively). When switching to "ethernet mode" (12d1:14db), the device also assigned me an IP address upon firing up udhcpc, but there was no route to the internet (guess I have to add it manually in iptables). Is using "HuaweiNewMode=1" equivalent to the switching message you just gave me (55534243123456780000000000000011062000000101000100000000000000)?

I still would prefer wwan mode over the other. As the kernel is new enough, I expect that I just have too little knowledge about configuring the modem correctly as usb-modeswitch seems to work correctly.

LOM
Posts: 1308
Joined: Wed Jul 11, 2012 3:14 pm
Location: Koh Samui, TH

Re: Huawei E5576-320 setup

Post by LOM » Sat Jun 13, 2020 11:36 am

Yes the switch message I gave you is what usb_modeswitch uses for HuaweiNewMode.

Looking at my interface listing for 12d1:155e I see now that neither huawei_cdc_ncm nor cdc_ncm will handle that dongle, the ncm interface has standard ncm class/subclass/proto attributes instead of Huawei proprietary attributes and that is why the std cdc_ncm driver binds instead of huawei_cdc_ncm.
The cdc_ncm driver can not handle Huaweis quirky ncm and the huawei_cdc_ncm driver can only bind to interfaces with Huawei proprietary attributes..

The switch message you use for getting to 12d1:155e is what usb_modeswitch calls HuaweiAltMode and it is intended for Android which doesn't use linux drivers, instead it has a Huawei supplied proprietary ncm driver which can handle Huawei ncm quirks.

So your only choice is 12d1:14db ie cdc_ether mode.

emkah
Posts: 3
Joined: Fri Jun 12, 2020 6:26 pm

Re: Huawei E5576-320 setup

Post by emkah » Sat Jun 13, 2020 11:54 am

Ok, thank you very much! Then I'll go with 14db.

Post Reply