HOWTO: Initializing an CDC ECM LTE modem using raw USB messages

Started by wrobelda, March 12, 2025, 03:16:43 PM

Previous topic - Next topic
I was struggling with getting Huawei E3131 modem initialize under FreeBSD/OPNSense in CDC ECM mode, even though it worked out-of-the-box with Linux and NetworkManager. What NetworkManager actually does is and equivalent of a simple:

echo -e 'AT^NDISDUP=1,1\r' > /dev/cdc-wdm0
sent to the WDM device CDC WDM control interface. Sending this to any of the serial diagnostic or PPP serial ports would *not* work, it has to be sent to WDM interface explicitly.

Unfortunately, FreeBSD/OPNSense does not have module for WDM and as such doesn't expose the cdc-wdm character device like Linux. The workaround here was using usbcontrol to send the USB control message directly to the device, like so:

usbconfig -d 8.2 -i 0 do_request 0x21 0 0 2 16 0x41 0x54 0x5e 0x4e 0x44 0x49 0x53 0x44 0x55 0x50 0x3d 0x31 0x2c 0x31 0x0d 0x0a
REQUEST = <OK>

Where, -d 8.2 -i 0 do_request 0x21 0 0 2 16 instructs usbconfig to send a control message of length 0x16 to device at bus 8.2, while the
0x41 0x54 0x5e 0x4e 0x44 0x49 0x53 0x44 0x55 0x50 0x3d 0x31 0x2c 0x31 0x0d 0x0a is the byte-encoded "AT^NDISDUP=1,1\r\n" message.

I explained my findings in details in an article here, hopefully this will help others having similar issue:
https://dawidwrobel.com/journal/initializing-lte-modem-using-raw-usb-communication/

This is pretty nice work. I have no use for it but thanks for sharing @wrobelda.

Quote from: cookiemonster on March 12, 2025, 04:27:58 PMThis is pretty nice work. I have no use for it but thanks for sharing @wrobelda.

Thanks, hopefully this will be of help for someone, given how many people appear to have struggled with a similar issue.