feat: init repo and scripts and readme

This commit is contained in:
Hugo Poissonnet 2022-07-17 15:14:52 +02:00
commit 9012a54ae5
3 changed files with 86 additions and 0 deletions

62
README.md Normal file
View File

@ -0,0 +1,62 @@
# How to use Huawei 3372s under linux
https://www.0xf8.org/2017/01/flashing-a-huawei-e3372h-4g-lte-stick-from-hilink-to-stick-mode/
## How to flash
1. `sudo ./balong-usbdload -p /dev/ttyUSB0 usblsafe-3372h.bin` DO NOT
TOUCH the usb key, you should see 3 new tty poping
2. `sudo ./balong_flash -p /dev/ttyUSB2 Huawei_E3372h-153_21.180.01.00.00_Firmware_general_3Ginfo.ru/E3372h-153_UPDATE_21.180.01.00.00.BIN`
* [See the fuck here with linux drivers](https://askubuntu.com/questions/816974/huawei-usb-modem-proper-drivermodule-is-not-loading/818374#818374)
https://wiki.dd-wrt.com/wiki/index.php/Cellular_Phone/USB_Modem_as_WAN_connection
https://openwrt.org/docs/guide-user/network/wan/wwan/ethernetoverusb_ncm
1. Delete old /dev/ttyUSBx can save your life
1. Doing a `rmmod option` can solve a lot
1. You should have `usb-devices`
```
T: Bus=01 Lev=01 Prnt=01 Port=06 Cnt=03 Dev#= 68 Spd=480 MxCh= 0
D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=12d1 ProdID=1506 Rev=01.02
S: Manufacturer=HUAWEI_MOBILE
S: Product=HUAWEI_MOBILE
C: #Ifs= 5 Cfg#= 1 Atr=80 MxPwr=2mA
I: If#=0x0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=02 Prot=12 Driver=option
I: If#=0x1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
I: If#=0x2 Alt= 1 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=16 Driver=huawei_cdc_ncm
I: If#=0x3 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
I: If#=0x4 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
```
1. `ip link` must show a device like `wwx00XXXXXXXXX`
1. To enable connection
1. `socat - /dev/ttyUSB0,crnl`
1. `ATI` show basic informations
1. `AT+CPIN=1234` if you have a pin code
1. `AT+CGDCONT=1,"IP","m2m.tele2.com"` for setup a APN
1. `AT^NDISDUP=1,1,` to enable APN should show => `^NDISSTAT:1,,,"IPV4"`
1. Then you enable wwx iface with `ip link set up wwx00XXXXXXXXX`
1. Then send shcp request `dhclient -v wwx00XXXXXXXXX`
## On DDWRT
1. Usb drivers debug helpful command `cat /sys/kernel/debug/usb/devices`
1. You need to load kernel module first `insmod cdc-ncm.ko cdc_wdm.ko huawei_cdc_ncm.ko usb_wwan.ko option.ko` TODO finish this
1. Switch the Huawei in modem mode `usb_modeswitch -v 0x12d1 -p 0x14fe -J`
1. You should see a change in `lsusb`
1. You should see `wwan0: register 'huawei_cdc_ncm' at usb-0000:00:0b.1-2, Huawei CDC NCM device, 00:1e` in `dmesg` command output
1. Enable connection `echo -ne "AT^NDISDUP=1,1,\"sl2sfr\"\r\n" > /dev/ttyUSB0`
1. `ifconfig wwan0 up` see this documentation here
1. `udhcpc -i wwan0`
1. `iptables -t nat -A POSTROUTING -o wwan0 -j MASQUERADE`
1. `iptables -A FORWARD -i br0 -j ACCEPT`
1. `iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu`

10
connect-huawei-e3372.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/sh
# Load linux kernel modules
# For gsm serial console on /dev/ttyUSBx
modprobe -v option
# For Huawei CDC NCM ether card
modprobe -v huawei_cdc_ncm
usb_modeswitch -v 0x12d1 -p 0x14fe -J
sleep 2
echo -ne "AT^NDISDUP=1,1,\"sl2sfr\"\r\n" > /dev/ttyUSB0

View File

@ -0,0 +1,14 @@
#!/bin/sh
if ping -c 4 9.9.9.9;
then
echo "4G seems good"
else
echo -ne "AT^NDISDUP=1,0\r\n" > /dev/ttyUSB0
sleep 1
echo -ne "AT^NDISDUP=1,1,\"sl2sfr\"\r\n" > /dev/ttyUSB0
sleep 1
udhcpc -i wwan0
iptables -t nat -A POSTROUTING -o wwan0 -j MASQUERADE
iptables -A FORWARD -i br0 -j ACCEPT
iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
fi