Pavel Piatruk’ tech & personal blog

Huawei E3372-325 'BROVI' and Linux (Ubuntu)

How to get to work Huawei E3372-325 ‘BROVI’ in Linux (ubuntu)

In Jan 2023 there is still no good integration of this new modem to Linux usb-modeswitch. It doesn’t include its VID:PID, which are 3566:2001.

The weird thing about this modem, when it is plugged in a Linux machine, it goes through these steps on its own:

    1. RNDIS+CDROM (netcard) , it stays here for 1..3 seconds, then switches on its own to
    1. CDROM , and stays here forever, and doesn’t react on any SCSI sequence sent by usb-modeswitch .

It only accepts a sequence when in mode RNDIS+CDROM . And when it does so , it re-attaches its ports, so its netcard appears again. In latter case we should ignore it.

    1. RNDIS+CDROM (netcard) , it stays here for 1..3 seconds,
    1. we manage to send a sequence
    1. during that sequence the RNDIS netcard appears again on the same USB port, but we ignore it (sic!)
    1. it stays in RNDIS forever

So we have to develop a script that

  • addresses a modem by USB ID (not just by Vendor+Product ID!)
  • catches a modem with 3566:2001 in RNDIS mode
  • ignores other modes : CDROM, AT-PORT, NCM card
  • ignores already switched modem

So 2 scripts are below

/usr/local/bin/brovi_switch (make it executable!)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# vim: filetype=bash

#   2023-01-28 Pavel Piatruk, piatruk.by

ID=$$

USB_ID=$(basename $DEVPATH)


{
#set|sort 

#ls -la /sys/$DEVPATH

echo bInterfaceClass on ports as follows

grep -H .  /sys$DEVPATH/1*/bInterfaceClass

IC=$( grep -h .  /sys$DEVPATH/*:1.0/bInterfaceClass )

echo "got bInterfaceClass on 1st port $IC"
    echo usb_modeswitch -b $BUSNUM -g $DEVNUM -v 3566 -p 2001

case $IC in
08) 
    echo Storage MODE
    ;;
e0)

    echo "Already RNDIS"
    LOCKFILE=/var/run/brovi.$USB_ID.lock
    if [[ -e $LOCKFILE ]]
    then    
        LOCKFILE_AGE=$(( $(date +%s ) - $(stat  $LOCKFILE -c %Y) )) 
        echo LOCKFILE_AGE=$LOCKFILE_AGE
    fi

    if [[ -n $LOCKFILE_AGE ]] && [[ $LOCKFILE_AGE -lt  10 ]]
    then    echo was switched VERY recently, noop
    else

    set > $LOCKFILE

    CMDS=(
        "usb_modeswitch -b $BUSNUM -g $DEVNUM -v $ID_VENDOR_ID -p $ID_MODEL_ID  -W -R  -w 400 "
        "usb_modeswitch -b $BUSNUM -g $DEVNUM -v $ID_VENDOR_ID -p $ID_MODEL_ID  -W -R "
    )

    i=0

    for CMD in "${CMDS[@]}"
    do
        i=$(($i+1))
        echo "=====STEP$i, run: $CMD"
        $CMD
    done
    fi

    ;;
ff)
    echo Serial Port
    ;;
*)
    echo Unknown mode
    ;;
esac

} | logger -t BROVI

exit 0

and UDEV script /etc/udev/rules.d/40-huawei.rules


ACTION!="add", GOTO="modeswitch_rules_end"
SUBSYSTEM!="usb", GOTO="modeswitch_rules_end"

# All known install partitions are on interface 0
ATTRS{bInterfaceNumber}!="00", GOTO="modeswitch_rules_end"

GOTO="modeswitch_rules_begin"

LABEL="modeswitch_rules_begin"
# Huawei E3372-325
ATTR{idVendor}=="3566", ATTR{idProduct}=="2001", RUN+="/usr/local/bin/brovi_switch %k %p"

LABEL="modeswitch_rules_end"

EDIT 2023-01-30 It seems Huawei released new firmware (below) that works fine with Linux. It switches to RNDIS -> RNDIS -> CDROM 12d1:1f01 -> usb-modeswitch switches to RNDIS.

'SoftwareVersion' => '3.0.2.62(H057SP9C983)
'WebUIVersion' => 'WEBUI 3.0.2.62(W13SP5C7702)',
'iniversion' => 'E3372-325-CUST 3.0.2.1(C778)',
'HardwareVersion' => 'CL5E3372M',

EDIT 2023-02-28

There is an alternative guide https://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=3&t=3043&p=20026#p20054 , it doesn’t properly handle the case when multiple Brovi’s are plugged in – it resets them ALL – the devices are referred by Vendor_ID and Product_ID, which are the same on identical modems. It`s fine when you have 1 BROVI on the PC.

While my solution addresses by Vendor_ID + Product_ID + Bus_ID + Deviced_ID. So the case with multiple BROVI on the PC is covered.

EDIT 2023-05-29

I got it working also in STICK mode CLICK