Skip to content

Instantly share code, notes, and snippets.

@karnauskas
Forked from smarek/00README.md
Created November 27, 2021 16:36
Show Gist options
  • Save karnauskas/1a2592b0e20f5e3e10ab818d7959b1d0 to your computer and use it in GitHub Desktop.
Save karnauskas/1a2592b0e20f5e3e10ab818d7959b1d0 to your computer and use it in GitHub Desktop.
E3372s-153 from Stick mode to HiLink mode automatic installer

E3372s from STICK to HiLink mode installer

You need

  • curl, usb-modeswitch, grep, awk, sudo (not necessary, last step can fail safely)
  • balong_flash in $PATH ( https://github.com/forth32/balongflash.git )
  • atinout in $PATH ( https://github.com/beralt/atinout.git will work fine )
  • 2 files we flash (core sw update version 22.x, WebUI installer), we use these (you can probably use different balong-compatible):
    • core sw: "E3372sUpdate_22.298.03.02.965.BIN" / "E3372sUpdate_22.298.03.02.965.exe"
    • webui: "Update_WEBUI_17.100.06.00.03_Hilink_V7R2_9x25_CPIO.exe"

Scripts handle these situations:

  • Taking the device from storage/cd-rom mode to correct flashing mode (godload)
  • Taking the device from debug mode to correct flashing mode (godload)
  • Handling special state, where 12d1:1442 ttyUSB0 provides AT-mode instead of correct godload
  • Handling, when the device is hi-link but has no UI (see part with curl POST xml to /CGI)

Step-by-step

  • (Optional) put 70-huawei-e3.rules and huawei_e3.conf in correct places for UDEV usb-modeswitch and reload-rules/restart-computer
  • Put all files into one folder, together with firmware 22.x and WebUI updates
  • Plug the E3372s-153 in stick-mode to USB, and wait for it to appear in lsusb
  • Run ./auto_install.sh, observe output
  • If everything runs correctly, the modem will restart itself, script will set it up with ifconfig/dhclient, and web interface should be on address http://192.168.8.1/

WARNING, this is alpha version of scripts, everything you do is on your risk, i do not take any responsibility

# place in /etc/udev/rules.d/70-huawei-e3.rules
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1f01", RUN+="/usr/sbin/usb_modeswitch -c /etc/usb_modeswitch.d/huawei_e3.conf"
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="14fe", RUN+="/usr/sbin/usb_modeswitch -c /etc/usb_modeswitch.d/huawei_e3.conf"
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="14dc", NAME="usb0"
#!/bin/bash
echo () {
bash -c "echo [E3372s stick-to-hilink] $1"
}
IS_14FE=$(lsusb | grep 12d1\:14fe | wc -l)
if [ "$IS_14FE" == "1" ] ; then
echo "14FE (mass-storage), switching to 1506 (AT mode)"
usb_modeswitch --verbose -J -v 0x12d1 -p 0x14fe
sleep 5
else
echo "14FE not found, not switching"
fi
IS_1506=$(lsusb | grep 12d1\:1506 | wc -l)
IS_1C05=$(lsusb | grep 12d1\:1c05 | wc -l)
IS_14DC=$(lsusb | grep 12d1\:14dc | wc -l)
IS_1566=$(lsusb | grep 12d1\:1566 | wc -l)
if [ "$IS_1506" == "1" ] || [ "$IS_1566" == "1" ] ; then
echo "1506/1566 to godload"
./godload.sh
elif [ "$IS_1C05" == "1" ] ; then
echo "already in godload, not switching"
elif [ "$IS_14DC" == "1" ] ; then
echo "in hi-link mode, switching back to debug"
sudo ifconfig usb0 up
sudo dhclient usb0
sleep 3
timeout 3 curl -X POST -d @sw_debug_mode.xml http://192.168.8.1/CGI
sleep 6
./godload.sh
fi
IS_1C05=$(lsusb | grep 12d1\:1c05 | wc -l)
IS_1442=$(lsusb | grep 12d1\:1442 | wc -l)
if [ "$IS_1C05" == "1" ] ; then
balong_flash -p /dev/ttyUSB2 -gd E3372sUpdate_22.298.03.02.965.BIN
sleep 15
elif [ "$IS_1442" == "1" ] ; then
echo "skip, 1442 means 1st balong flash already passed"
else
echo "not in godload mode, exiting"
exit 1
fi
IS_1506=$(lsusb | grep 12d1\:1506 | wc -l)
IS_1442=$(lsusb | grep 12d1\:1442 | wc -l)
if [ "$IS_1506" == "1" ] && [ "$IS_1442" == "0" ] ; then
echo "1506 to godload"
./godload.sh
elif [ "$IS_1442" == "1" ] ; then
echo "skip, 1442 means we are still in godload mode"
else
echo "not 1506 after balong_flash, something went wrong"
exit 1
fi
IS_USB0_AT=$(timeout 5 bash -c "echo 'AT' | atinout - /dev/ttyUSB0 - | grep OK | wc -l")
IS_USB0_AT=$(timeout 5 bash -c "echo 'AT' | atinout - /dev/ttyUSB0 - | grep OK | wc -l")
if [ "$IS_USB0_AT" == "1" ] ; then
./godload.sh
fi
sleep 5
IS_1C05=$(lsusb | grep 12d1\:1c05 | wc -l)
IS_1442=$(lsusb | grep 12d1\:1442 | wc -l)
if [ "$IS_1C05" == "1" ] || [ "$IS_1442" == "1" ] ; then
balong_flash -p /dev/ttyUSB0 -gd Update_WEBUI_17.100.06.00.03_Hilink_V7R2_9x25_CPIO.exe
sleep 15
else
echo "not 1C05 after godload, something went wrong"
exit 1
fi
IS_1F01=$(lsusb | grep 12d1\:1f01 | wc -l)
if [ "$IS_1F01" == "1" ] ; then
usb_modeswitch --verbose -J -v 0x12d1 -p 0x1f01
sleep 5
else
echo "not 1F01 after balong_flash, maybe already automatically usb-modeswitched?"
fi
IS_14DC=$(lsusb | grep 12d1\:14dc | wc -l)
if [ "$IS_14DC" == "1" ] ; then
sudo ifconfig usb0 up
ps aux | grep -i dhclient\ usb0 | awk '{print $2}' | xargs -L1 sudo kill -9
sudo dhclient usb0
./device_info.sh
fi
exit 0
#!/bin/sh
MODEM_IP="192.168.8.1"
curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > /tmp/ses_tok.xml
COOKIE=`grep "SessionID=" /tmp/ses_tok.xml | cut -b 10-147`
TOKEN=`grep "TokInfo" /tmp/ses_tok.xml | cut -b 10-41`
curl -s -X GET "http://$MODEM_IP/api/device/information" \
-H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" \
-H "Content-Type: text/xml"
# in case of broken MTD16 (data) partition, will print out error 100002
curl -s -X GET "http://$MODEM_IP/api/dialup/profiles" \
-H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" \
-H "Content-Type: text/xml"
#!/bin/bash
at() {
timeout 1 echo "$1" | atinout - /dev/ttyUSB0 -
}
echo "[godload] startup"
at "AT"
sleep 1
at "AT"
sleep 1
at "AT^GODLOAD"
echo "[godload] waiting 10 sec"
sleep 10
# place in nano /etc/usb_modeswitch.d/huawei_e3.conf
TargetVendor=0x12d1
TargetProductList="14db,14dc"
HuaweiNewMode=1
NoDriverLoading=1
DefaultVendor=0x12d1
DefaultProduct=0x1f01
<?xml version="1.0" encoding="UTF-8" ?>
<api version="1.0">
<header>
<function>switchMode</function>
</header>
<body>
<request>
<switchType>1</switchType>
</request>
</body>
</api>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment