4G usb modem

Hello,

I bought a Huawei E3372 modem and flashed its firmware to "stick mode", so it acts as a modem, not as a router.
This way, I have access to NCM connection instead of PPP.
I also modified the multi-mode so I do not need to use usb_modeswitch(8).

Manually, I :
  • launch an AT^ command to /dev/cuaU0 to initialize the modem
  • run dhclient on ue0 (the ncm interface)
That's it, the connection does work flawlessly.

What I would like to achieve is doing this automatically on boot (the USB key will remain connected).
So far, I :
  • set ifconfig_ue0="DHCP" (or SYNCDHCP) in /etc/rc.conf
  • created a devd entry to launch the AT^ command
But /etc/rc.d/devd is run after /etc/rc.d/netif.
So on boot, FreeBSD tries to get an IP address on ue0 (which fails because the modem is down at this very moment).
Then devd is started, the modem is initialized and ue0 is ready to get an IP address. But it is too late.

Does anyone know how it would be possible to launch the initialization command before the start of the network ?
 
It seems that I misinterpreted my tests.
I might misunderstand it, but I do not think that netwait is the solution, because the interface (ue0) is present early.
What I could have to wait for is /dev/cuaU0, but it is present early too.

My problem is maybe relative to the order of devd rules, where netif would start before my rule is fired.
Thanks for the information.
 
Do you have a thread open on this subject ? I think that a dedicated one would be a better place for an answer; it could be more technical and useful for anyone looking for this.
In the meantime, here are some explanations, but I have been owning it for a few days only.

By default, there are two consecutive modes. In the first one, the key acts as a cdrom containing drivers for Windows.
Once those drivers are installed, the key switches to the second mode, where it acts like a modem or router.
This depends on its firmware :
  • router <-> hilink
  • modem <-> stick
What you want is your key to be in this second mode. The purpose of usb_modeswitch is to allow you force this switch, for both types of firmwares.

If you own a stick version , It is possible to change the behavior of each mode ( you can choose what will be present or not - rndis card, ncm ,modem etc - ), even disabling the first one. in this case usb_modeswitch is not needed.

if you own a hilink, the only solution is usb_modeswitch. This is the simpler solution because there is a dhcp server in it, but it is more limited; you can not send sms etc.
You can flash a stick firmware on it, but the way depends on the model.
 
Snail , coming to your question.

The dirty solution is:
-] use a @reboot line in cron and run your configurations in a custom script
where you decide the order of services and config you want to launch.

The clean solution probably is:
-] make your own rc.script called e.g. "at-conf" then change dhclient rc.script
in such a way that it runs after "at-conf".
CAVEAT. I never tried to do this so far, it is a guess.
 
Phishfry : yes, it seems you did. I might still create an how-to, that would help people feeling as lost as I was when I began to try to use this key on FreeBSD.

Nicola Mingotti : that is near what I did .
I created an rc script to lauch my command, and I specified "# BEFORE: netif" in the header.

It does work, but I am not totally satisfied.
I might be wrong but I think that the cleanest way would be to able to launch a command prior the configuration of an interface. Something like pre-up, post-up found in Debian.
 
Do you have a thread open on this subject ? I think that a dedicated one would be a better place for an answer; it could be more technical and useful for anyone looking for this.

I very much agree and keep looking to see if you have starteed an E3372 thread in the Howto section :)
 
Hello,
I will write it, but I need to solve remaining problems (disconnections, FIB routing tables, firewall behavior...) first as the machine is my router.
 
Did you need to do anything with sysutils/usb_modeswitch ? I spent months trying to get my Huawei E3372 working.
How did you go about flashing the device

I've looked briefly at this device, as I'm thinking about a 4G failover setup. I don't own the E3372, since I've been looking at more recent stuff that has better LTE band coverage, etc. Anyway, in looking at various posts about the E3372, I came across an item that speaks to putting the E3372 into modem mode without flashing it, by using the web admin pages of the router when it's in HiLink mode, and switching the device mode by going to http://192.168.8.1, and then subsequently to http://192.168.8.1/html/SwitchProjectMode.html .

I guess that's stating the obvious for people on this thread :). I see that OpenBSD has a driver for MBIM, which seems to be a better choice - maybe. Perhaps FreeBSD can have an MBIM driver, patterned after the OpenBSD one. Many of the recent/new modems are supporting AT, MBIM, and QMI protocols because Microsoft is pushing MBIM and also for MBIM's better performance. I'm just starting with 4G modems, so for me there are way too many choices to make ...
 
I've looked briefly at this device, as I'm thinking about a 4G failover setup. I don't own the E3372, since I've been looking at more recent stuff that has better LTE band coverage, etc.

I'd be interested in knowing how you identify 'better LTE band coverage, etc'....

Anyway, in looking at various posts about the E3372, I came across an item that speaks to putting the E3372 into modem mode without flashing it, by using the web admin pages of the router when it's in HiLink mode, and switching the device mode by going to http://192.168.8.1, and then subsequently to http://192.168.8.1/html/SwitchProjectMode.html .

I read that somewhere but could never get it to work.
 
Do you have a thread open on this subject ? I think that a dedicated one would be a better place for an answer; it could be more technical and useful for anyone looking for this.
In the meantime, here are some explanations, but I have been owning it for a few days only.

By default, there are two consecutive modes. In the first one, the key acts as a cdrom containing drivers for Windows.
Once those drivers are installed, the key switches to the second mode, where it acts like a modem or router.
This depends on its firmware :
  • router <-> hilink
  • modem <-> stick
What you want is your key to be in this second mode. The purpose of usb_modeswitch is to allow you force this switch, for both types of firmwares.

If you own a stick version , It is possible to change the behavior of each mode ( you can choose what will be present or not - rndis card, ncm ,modem etc - ), even disabling the first one. in this case usb_modeswitch is not needed.

if you own a hilink, the only solution is usb_modeswitch. This is the simpler solution because there is a dhcp server in it, but it is more limited; you can not send sms etc.
You can flash a stick firmware on it, but the way depends on the model.

I have both a hilink and a stick version and did have my hilink version working at one point using usb_modeswitch, but the modem was locked until a few days ago and I hadn't used it for a while. Unfortunately I'm away from home at the moment and the system I have with me is not configured to use it and I can't remember what I did to get it working.

I look forward to your post in the Howto section :)
 
Hello,

I bought a Huawei E3372 modem and flashed its firmware to "stick mode", so it acts as a modem, not as a router.
This way, I have access to NCM connection instead of PPP.
I also modified the multi-mode so I do not need to use usb_modeswitch(8).

Manually, I :
  • launch an AT^ command to /dev/cuaU0 to initialize the modem
  • run dhclient on ue0 (the ncm interface)
That's it, the connection does work flawlessly.

I'm trying to figure out exactly what you did since I have 'stick mode' Huawei E3372. When I insert it, it presents itself as a
Modem (Mass Storage Mode). As such a /dev/cuaU0 does not get created and no ue0 interface appears.
 
Hello ,

balanga : I just saw your posts.
As I say, There are two consecutives modes, the first mode being, by default, a virtual cdrom.
The second mode is the one you are interested in; it brings the modem mode among other things. You can switch to this mode by using the well named usb_modeswitch.
I think that usb_modeswitch should recognize your stick and switch it on its own. If that is not the case, I created a file named /etc/usb_modeswitch.d/12d1:14fe reading
Code:
TargetVendor=0x12d1
TargetProductList="1506,150f,151d,1c1e"
HuaweiNewMode=1

I tried a lot of things at the beginning, so I can not ensure you that this will work.

Once there, you should modify those 2 modes by using codes, which are:
  • FF : disable first mode
  • 1 : 3G modem
  • 10 : 4G modem
  • 12 : port COM "PC UI Interface"
  • 16 : NCM network card
  • A1 : virtual CD-ROM
  • A2 : microSD
  • A3 : RNDIS network card
Those codes are sent to the modem though the AT command AT^SETPORT.
The first mode can only accept FF, A2 and A1.
A mode can accept several codes separated by "," , while the modes are separated by ";".

/!\ /!\/!\/!\ Do never remove the code 12, or your modem would be bricked /!\ /!\/!\/!\

I just needed the NCM network card so I :
Code:
1) connected to the port com
cu -s 115200 -l cuaU0

2) sent the codes
AT^SETPORT="FF;12,16"

# explanations
FF-> disable first mode
; -> codes are now dedicated to the second mode
12 -> com port ( cuaU0 )
16 -> ncm ( ue0 interface)
Note that if you activate 3G or 4G modem, you will get cuaU1 etc...

3) reset the modem
AT^RESET

The modem will reboot and you won't need usb_modeswitch anymore.
 
Hello ,

balanga : I just saw your posts.
As I say, There are two consecutives modes, the first mode being, by default, a virtual cdrom.
The second mode is the one you are interested in; it brings the modem mode among other things. You can switch to this mode by using the well named usb_modeswitch.
I think that usb_modeswitch should recognize your stick and switch it on its own. If that is not the case, I created a file named I h reading
Code:
TargetVendor=0x12d1
TargetProductList="1506,150f,151d,1c1e"
HuaweiNewMode=1

Thanks for the help but I don't seem to be able to activate this usb_modeswitch command...

I have created a /etc/usb_modeswitch.d/12d1:14fe with the contents you suggest but can't figure out how to run it.

I tried simply rebooting hoping usb_modeswitch would run on boot, but that didn't work. I also tried usb_modeswitch -W -c /etc/usb_modeswitch.d/12d1:14fe but got
Read config file: /etc/usb_modeswitch.d/12d1:14fe

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

! PLEASE REPORT NEW CONFIGURATIONS !

TargetVendor= 0x12d1
TargetProductList="1506,150f,151d,1c1e"
HuaweiNewMode=1

No default vendor/product ID given. Abort

lsusb shows:
Bus /dev/usb Device /dev/ugen1.4: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 [ThinkPad]
Bus /dev/usb Device /dev/ugen1.3: ID 17ef:1003 Lenovo Integrated Smart Card Reader
Bus /dev/usb Device /dev/ugen0.2: ID 12d1:14fe Huawei Technologies Co., Ltd. Modem (Mass Storage Mode)
Bus /dev/usb Device /dev/ugen1.2: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus /dev/usb Device /dev/ugen2.2: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus /dev/usb Device /dev/ugen1.1: ID 0000:0000
Bus /dev/usb Device /dev/ugen0.1: ID 0000:0000
Bus /dev/usb Device /dev/ugen2.1: ID 0000:0000
 
After reading some posts here I came up with
usb_modeswitch -W -v 0x12d1 -p 0x14fe -c /etc/usb_modeswitch.d/12d1:14fe

which generated:-
Read config file: /etc/usb_modeswitch.d/12d1:14fe

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

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x12d1
DefaultProduct= 0x14fe
TargetVendor= 0x12d1
TargetProductList="1506,150f,151d,1c1e"
HuaweiNewMode=1

Look for target devices ...
found USB ID 0000:0000
found USB ID 0000:0000
found USB ID 0000:0000
found USB ID 8087:0024
found USB ID 8087:0024
found USB ID 17ef:1003
found USB ID 0a5c:21e6
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 0000:0000
found USB ID 8087:0024
found USB ID 8087:0024
found USB ID 17ef:1003
found USB ID 0a5c:21e6
found USB ID 12d1:14fe
vendor ID matched
product ID matched
Found devices in default mode (1)
Access device 002 on bus 000
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
with class 8
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI_MOBILE
Product: HUAWEI_MOBILE
Serial No.: 0123456789ABCDEF
-------------------------
Using standard Huawei switching message
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) ...

Not sure what the last msg means but the command does not seem to have finished, however lsusb now shows:
Bus /dev/usb Device /dev/ugen0.2: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
 
I just re-read your upper post and got lost.
Are you trying to configure your hilink or your stick modem ?
If stick one, then you need to load the u3g kernel module BEFORE inserting the device . Read especially the BUGS part of u3g().
Or you can built the module into the kernel, which I did, as for if_cdce().
 
balanga : I am glad it worked for you.
I do not understand why, but your post beginning with "After reading some posts here I came up..." was absent when I wrote my answers.
Just curious, will you stick with the usb_modeswitch method or will you change the configuration of the modem ?
 
Hello,

This seemed to work for you in one of your topics: https://forums.freebsd.org/threads/usb_modeswitch.63677/post-369848
Isn't it the case anymore ?

The switch seems to work on your linux box, so at worst, you can send the codes with your modem connected on it.

I have now managed to get sysutils/usb_modeswitch to recognise my E3372 stick modem as Modem/Networkcard

lsusb shows:-
Bus /dev/usb Device /dev/ugen1.4: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
but I don't see a ue0 network interface appear so am obviously missing something...
 
I just re-read your upper post and got lost.
Are you trying to configure your hilink or your stick modem ?
If stick one, then you need to load the u3g kernel module BEFORE inserting the device . Read especially the BUGS part of u3g().
Or you can built the module into the kernel, which I did, as for if_cdce().


Just to clarify things.... I have two E3372 USB modems - one is a stick modem and the the other is a hilink modem.

As a result of this post of yours in which you give instructions for enabling the ue0 interface on the stick modem, I'm trying to configure my stick modem which is actually labelled a MegaFon M150-2

Connecting to /dev/cuaU0 and running ATI shows:-
Manufacturer: huawei
Model: E3372
Revision: 21.180.01.00.00
IMEI: 866119027727057
+GCAP: +CGSM,+DS,+ES

One thing I observe is that there is continuous serial activity similar to:-
^RSSI:26

^HCSQ:"LTE",60,55,186,26

^RSSI:26

^HCSQ:"LTE",60,57,196,30

^RSSI:27

^HCSQ:"LTE",62,56,191,22

^RSSI:24

^HCSQ:"LTE",57,55,191,32

^RSSI:26

^HCSQ:"LTE",61,57,186,28

^RSSI:24

^HCSQ:"LTE",57,53,181,28

^RSSI:25

^HCSQ:"LTE",58,54,191,28

^RSSI:23

^HCSQ:"LTE",55,56,186,32

What does this tell me?

The main thing is that don't know how to enable the ue0 interface.
 
I think this means that your modem is connected or receiving a signal.
In order to get the ue0 interface, you need to load the if_cdce kernel module. Read the synopsis of if_cdce().
 
I think this means that your modem is connected or receiving a signal.
In order to get the ue0 interface, you need to load the if_cdce kernel module. Read the synopsis of if_cdce().

Many thanks for this. I now have a ue0 interface but can't get an IP addressed assigned....

ifconfig ue0:-
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 2a:d7:ea:f6:7f:00
hwaddr 2a:d7:ea:f6:7f:00
inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

Is there some way I can monitor /dev/cuaU0 to see what is actually happening?

The SIM connects fine when it's in my mobile phone.
 
You need to send the NDISDUP command to your modem.

echo 'AT^NDISDUP= 1,1,"<APN>"' > /dev/cuaU0

Of course, you must replace <APN> by the APN of your ISP.
 
Back
Top