geerlingguy / pi-router

Raspberry Pi-based OpenWRT router config for 4G/5G Waveshare Dual Ethernet board.
101 stars 8 forks source link

Work on initial LuCI and hardware configs #1

Closed geerlingguy closed 10 months ago

geerlingguy commented 1 year ago

I need to get the following set up and working:

geerlingguy commented 1 year ago

Testing this config: config.patch.txt

geerlingguy commented 1 year ago

Working on WWAN Dongle setup:

root@OpenWrt:~# cat /sys/kernel/debug/usb/devices
...
T:  Bus=01 Lev=02 Prnt=02 Port=02 Cnt=01 Dev#=  4 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1199 ProdID=90c3 Rev= 0.06
S:  Manufacturer=Sierra Wireless, Incorporated
S:  Product=Sierra Wireless EM7565 with Qualcomm Snapdragon X16 LTE
S:  SerialNumber=2af40a0a
C:* #Ifs= 3 Cfg#= 1 Atr=a0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
E:  Ad=82(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
E:  Ad=84(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

root@OpenWrt:~# dmesg | grep usb
[    0.086024] usbcore: registered new interface driver usbfs
[    0.086070] usbcore: registered new interface driver hub
[    0.086110] usbcore: registered new device driver usb
[    0.086233] usb_phy_generic phy: supply vcc not found, using dummy regulator
[    0.086344] usb_phy_generic phy: dummy supplies not allowed for exclusive requests
[    0.359673] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.15
[    0.359698] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.359716] usb usb1: Product: xHCI Host Controller
[    0.359730] usb usb1: Manufacturer: Linux 5.15.60 xhci-hcd
[    0.359744] usb usb1: SerialNumber: 0000:01:00.0
[    0.360504] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 5.15
[    0.360530] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.360548] usb usb2: Product: xHCI Host Controller
[    0.360561] usb usb2: Manufacturer: Linux 5.15.60 xhci-hcd
[    0.360575] usb usb2: SerialNumber: 0000:01:00.0
[    0.361978] usbcore: registered new interface driver uas
[    0.362053] usbcore: registered new interface driver usb-storage
[    0.667391] usb 1-1: new high-speed USB device number 2 using xhci_hcd
[    0.923624] usb 1-1: New USB device found, idVendor=2109, idProduct=3431, bcdDevice= 4.20
[    0.939086] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[    0.952639] usb 1-1: Product: USB2.0 Hub
[    1.502342] usb 2-4: new SuperSpeed USB device number 2 using xhci_hcd
[    1.538359] usb 2-4: New USB device found, idVendor=0bda, idProduct=8153, bcdDevice=31.00
[    1.546546] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=6
[    1.553691] usb 2-4: Product: USB 10/100/1000 LAN
[    1.558398] usb 2-4: Manufacturer: Realtek
[    1.562490] usb 2-4: SerialNumber: 001000001
[    1.827403] usb 1-1.3: new high-speed USB device number 3 using xhci_hcd
[    1.962738] usb 1-1.3: New USB device found, idVendor=1199, idProduct=90c2, bcdDevice= 0.00
[    1.971119] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    1.978447] usb 1-1.3: Product: QUSB_Fast_Enum.
[    1.982980] usb 1-1.3: Manufacturer: Sierra Wireless, Incorporated
[    1.989168] usb 1-1.3: SerialNumber: XK73468776020606
[    2.241111] usb 1-1.3: USB disconnect, device number 3
[    7.474072] usbcore: registered new interface driver cdc_wdm
[    7.495790] usbcore: registered new interface driver lan78xx
[    7.505008] usbcore: registered new interface driver r8152
[    7.512122] usbcore: registered new interface driver usbhid
[    7.517724] usbhid: USB HID core driver
[    7.523626] usbcore: registered new interface driver usbserial_generic
[    7.530252] usbserial: USB Serial support registered for generic
[    7.536785] usbcore: registered new interface driver cdc_ether
[    7.543539] usbcore: registered new interface driver cdc_ncm
[    7.589020] usbcore: registered new interface driver qmi_wwan
[    7.595384] usbcore: registered new interface driver sierra
[    7.601056] usbserial: USB Serial support registered for Sierra USB modem
[    7.608623] usbcore: registered new interface driver sierra_net
[    7.624049] usbcore: registered new interface driver brcmfmac
[    7.631876] usbcore: registered new interface driver option
[    7.637525] usbserial: USB Serial support registered for GSM modem (1-port)
[    7.646110] usbcore: registered new interface driver qcserial
[    7.651975] usbserial: USB Serial support registered for Qualcomm USB modem
[    7.687900] usb 2-4: reset SuperSpeed USB device number 2 using xhci_hcd
[   14.087426] usb 1-1.3: new high-speed USB device number 4 using xhci_hcd
[   14.218631] usb 1-1.3: New USB device found, idVendor=1199, idProduct=90c3, bcdDevice= 0.06
[   14.227000] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   14.234339] usb 1-1.3: Product: Sierra Wireless EM7565 with Qualcomm Snapdragon X16 LTE
[   14.242365] usb 1-1.3: Manufacturer: Sierra Wireless, Incorporated
[   14.248560] usb 1-1.3: SerialNumber: 2af40a0a
geerlingguy commented 1 year ago

Posted on the Sierra Wireless forums: EM7565 on Raspberry Pi with OpenWRT - USB device listed but not usable

geerlingguy commented 1 year ago

Maybe try ModemManager instead?

geerlingguy commented 1 year ago

Device might be stuck in MBIM-only mode if someone used it on Windows: https://forum.sierrawireless.com/t/my-mc7710-cant-work-on-linux-after-plug-in-it-to-windows8/7986/12?u=geerlingguy

geerlingguy commented 1 year ago

User rspmn on the Sierra Wireless forum mentioned:

Your EM7565 has been set to a different USB id 1199:90c3 which is not known by the mainline Linux kernel drivers (qcserial.c, qmi_wwan.c).

You would have to use AT!UDPID=9091 to make the EM7565 usable with OpenWRT. To be able to send AT commands to the EM7565 with minicom, screen etc. on USB id 1199:90c3 you can use:

modprobe option
echo 1199 90c3 > /sys/bus/usb-serial/drivers/option1/new_id

And indeed, if I run those two commands, I see:

root@OpenWrt:~# ls /dev/ttyUSB*
/dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2

Then I ran cat /dev/ttyUSB0 in one terminal to capture output from ttyUSB0, and in another, ran echo -ne 'AT!UDPID=9091\r\n' > /dev/ttyUSB0. This gave me the output:

ERROR

Trying just AT\r\n for the echo returned OK, so I was definitely interacting with the modem.

geerlingguy commented 1 year ago

Looking at this Initial settings doc, I tried a few more commands:

ATI
Manufacturer: Sierra Wireless, Incorporated
Model: EM7565-9
Revision: SWI9X50C_00.06.02.00 f50f0a jenkins 2017/08/25 05:33:58
MEID: [redacted]
IMEI: [redacted]
IMEI SV:  1
FSN: [redacted]
+GCAP: +CGSM

AT!IMPREF?
!IMPREF: 
 preferred fw version:    00.06.02.00
 preferred carrier name:  GENERIC
 preferred config name:   GENERIC_001.004_000
 current fw version:      00.06.02.00
 current carrier name:    GENERIC
 current config name:     GENERIC_001.004_000

AT!USBVID?
ERROR

AT!PRIID?
PRI Part Number: 9907220
Revision: 001.004
Customer: Lenovo-Laptop

Carrier PRI: 9999999_9907259_SWI9X50C_00.06.02.00_00_GENERIC_001.004_000
geerlingguy commented 1 year ago

Possibly related, since it looks like this module was pulled from a Lenovo laptop: Upgrade Firmware EM7565 Failed

geerlingguy commented 1 year ago

It looks like that was the main issue, and a thread linked from the thread linked above had a solution (maybe, testing now): basically:

// Unlock password-protected commands (A710 is the default pw).
AT!ENTERCND="A710"
OK

// Restore the modem to factory defaults.
AT!NVRESTORE=0
!NVRESTORE:

Items Restored:  906
Items Deleted:   272
Items Skipped:   4

OK

// Reset the modem.
AT!RESET
OK
geerlingguy commented 1 year ago

After resetting the modem, it came up with a different ID:

root@OpenWrt:~# dmesg
...
[    7.329244] usb 2-3: New USB device found, idVendor=1199, idProduct=90b1, bcdDevice= 0.06

So I set that instead:

root@OpenWrt:~# modprobe option
root@OpenWrt:~# echo 1199 90b1 > /sys/bus/usb-serial/drivers/option1/new_id

And now it appears at /dev/ttyUSB2, and I'm trying to set it correctly:

root@OpenWrt:~# echo -ne 'AT!UDPID=9091\r\n' > /dev/ttyUSB2
ERROR

root@OpenWrt:~# echo -ne 'AT!PRIID?\r\n' > /dev/ttyUSB2
PRI Part Number: Unknown
Revision: Unknown
Customer: Unknown

Carrier PRI: None
geerlingguy commented 1 year ago

Trying:

root@OpenWrt:~# echo -ne 'AT!ENTERCND="A710"?\r\n' > /dev/ttyUSB2
OK

root@OpenWrt:~# echo -ne 'AT!USBPID?\r\n' > /dev/ttyUSB2
!USBPID: 
APP : 90B1
BOOT: 90B0

root@OpenWrt:~# echo -ne 'AT!UDPID=9091\r\n' > /dev/ttyUSB2
ERROR
geerlingguy commented 1 year ago

Ah, user jyijyi pointed out the command is USBPID:

AT!USBPID?
!USBPID: 
APP : 90B1
BOOT: 90B0

AT!USBPID=9091
OK

AT!USBPID?
!USBPID: 
APP : 9091
BOOT: 9090
geerlingguy commented 1 year ago

And after a power reset (could've also rebooted and RESET modem, but oh well):

root@OpenWrt:~# ls /dev/ttyUSB*
/dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2

root@OpenWrt:~# dmesg
...
[    7.557902] usb 2-3: new SuperSpeed USB device number 3 using xhci_hcd
[    7.588647] usb 2-3: config 1 has an invalid interface number: 12 but max is 4
[    7.595894] usb 2-3: config 1 has an invalid interface number: 13 but max is 4
[    7.603198] usb 2-3: config 1 has an invalid interface number: 13 but max is 4
[    7.610435] usb 2-3: config 1 has no interface number 1
[    7.615668] usb 2-3: config 1 has no interface number 4
[    7.621586] usb 2-3: New USB device found, idVendor=1199, idProduct=9091, bcdDevice= 0.06
[    7.629801] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    7.636939] usb 2-3: Product: EM7565-9
[    7.640704] usb 2-3: Manufacturer: Sierra Wireless, Incorporated
[    7.646708] usb 2-3: SerialNumber: 2af40a0a
[    7.655521] usb 2-3: Enable of device-initiated U1 failed.
[    7.661706] usb 2-3: Enable of device-initiated U2 failed.
[    7.668709] usb 2-3: Enable of device-initiated U1 failed.
[    7.674911] usb 2-3: Enable of device-initiated U2 failed.
[    7.680579] qcserial 2-3:1.0: Qualcomm USB modem converter detected
[    7.687028] usb 2-3: Qualcomm USB modem converter now attached to ttyUSB0
[    7.695408] usb 2-3: Enable of device-initiated U1 failed.
[    7.701568] usb 2-3: Enable of device-initiated U2 failed.
[    7.707229] qcserial 2-3:1.2: Qualcomm USB modem converter detected
[    7.713697] usb 2-3: Qualcomm USB modem converter now attached to ttyUSB1
[    7.721972] usb 2-3: Enable of device-initiated U1 failed.
[    7.728207] usb 2-3: Enable of device-initiated U2 failed.
[    7.733903] qcserial 2-3:1.3: Qualcomm USB modem converter detected
[    7.740353] usb 2-3: Qualcomm USB modem converter now attached to ttyUSB2

root@OpenWrt:~# cat /sys/kernel/debug/usb/devices
...
T:  Bus=02 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  3 Spd=5000 MxCh= 0
D:  Ver= 3.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
P:  Vendor=1199 ProdID=9091 Rev= 0.06
S:  Manufacturer=Sierra Wireless, Incorporated
S:  Product=EM7565-9
S:  SerialNumber=2af40a0a
C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=896mA
A:  FirstIf#=12 IfCount= 2 Cls=02(comm.) Sub=0e Prot=00
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=qcserial
E:  Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=qcserial
E:  Ad=83(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=qcserial
E:  Ad=85(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=84(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I:* If#=12 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=(none)
E:  Ad=86(I) Atr=03(Int.) MxPS=  64 Ivl=32ms
I:* If#=13 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=02 Driver=(none)
I:  If#=13 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=(none)
E:  Ad=8e(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=0f(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
geerlingguy commented 1 year ago

Now trying to figure out how to put it in QMI mode ~(not sure what it's in right now)~:

root@OpenWrt:~# echo -ne 'AT!USBCOMP=?\r\n' > /dev/ttyUSB2
!USBCOMP: 
AT!USBCOMP=<Config Index>,<Config Type>,<Interface bitmask>
  <Config Index>      - configuration index to which the composition applies, should be 1

  <Config Type>       - 1:MBIM USBIF, 2:PCIE USBIF, 3:Legacy-Generic, 4:RNDIS

  <Interface bitmask> - DIAG     - 0x00000001,
                        NMEA     - 0x00000004,
                        MODEM    - 0x00000008,
                        RMNET0   - 0x00000100,
                        RMNET1   - 0x00000400,
                        MBIM     - 0x00001000,
  e.g.
  10D  - diag, nmea, modem, rmnet interfaces enabled
  1009 - diag, modem, mbim interfaces enabled

  The default configuration is:
  at!usbcomp=1,3,10F

OK

root@OpenWrt:~# echo -ne 'AT!USBCOMP?\r\n' > /dev/ttyUSB2
Config Index: 1
Config Type:  3 (Generic)
Interface bitmask: 0000100D (diag,nmea,modem,mbim)
geerlingguy commented 1 year ago

Yay, can see it with ModemManager!

root@OpenWrt:~# mmcli -m 0
  -----------------------------
  General  |              path: /org/freedesktop/ModemManager1/Modem/0
           |         device id: [redacted]
  -----------------------------
  Hardware |      manufacturer: Sierra Wireless, Incorporated
           |             model: EM7565-9
           | firmware revision: SWI9X50C_00.06.02.00 f50f0a jenkins 2017/08/25 05:33:58
           |         supported: gsm-umts, lte
           |           current: gsm-umts, lte
  -----------------------------
  System   |            device: /sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb2/2-3
           |           drivers: qcserial
           |            plugin: generic
           |      primary port: ttyUSB2
           |             ports: ttyUSB0 (qcdm), ttyUSB1 (gps), ttyUSB2 (at)
  -----------------------------
  Status   |             state: disabled
           |       power state: on
           |    signal quality: 0% (cached)
  -----------------------------
  Modes    |         supported: allowed: 2g, 3g, 4g; preferred: none
           |           current: allowed: 2g, 3g, 4g; preferred: none
  -----------------------------
  IP       |         supported: ipv4, ipv6, ipv4v6
  -----------------------------
  SIM      |  primary sim path: /org/freedesktop/ModemManager1/SIM/0
geerlingguy commented 1 year ago

I added the ` driver, and now I'm seeing thecdc_mbim` driver loaded for the card:

# cat /sys/kernel/debug/usb/devices
...
T:  Bus=02 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  3 Spd=5000 MxCh= 0
D:  Ver= 3.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
P:  Vendor=1199 ProdID=9091 Rev= 0.06
S:  Manufacturer=Sierra Wireless, Incorporated
S:  Product=EM7565-9
S:  SerialNumber=2af40a0a
C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=896mA
A:  FirstIf#=12 IfCount= 2 Cls=02(comm.) Sub=0e Prot=00
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=qcserial
E:  Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=qcserial
E:  Ad=83(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=qcserial
E:  Ad=85(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=84(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I:* If#=12 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=cdc_mbim
E:  Ad=86(I) Atr=03(Int.) MxPS=  64 Ivl=32ms
I:  If#=13 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
I:* If#=13 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
E:  Ad=8e(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=0f(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
geerlingguy commented 1 year ago

Hooray! Added wwan port in the UI and that seems to be working:

Screen Shot 2022-08-23 at 7 53 14 PM

Next step is to export network interfaces and base configs, and automate all the package installs to be correct (I think I can pull out the qmi stuff).

root@OpenWrt:~# mmcli -m 0
  --------------------------------
  General  |                 path: /org/freedesktop/ModemManager1/Modem/0
           |            device id: 37556a1b7193b9a461be92ba7e5e293b2ed4ae3d
  --------------------------------
  Hardware |         manufacturer: Sierra Wireless, Incorporated
           |                model: EM7565-9
           |    firmware revision: SWI9X50C_00.06.02.00
           |       carrier config: default
           |         h/w revision: EM7565-9
           |            supported: gsm-umts, lte
           |              current: gsm-umts, lte
           |         equipment id: [redacted]
  --------------------------------
  System   |               device: /sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb2/2-3
           |              drivers: qcserial, cdc_mbim
           |               plugin: sierra
           |         primary port: cdc-wdm0
           |                ports: cdc-wdm0 (mbim), ttyUSB0 (qcdm), ttyUSB1 (gps), 
           |                       ttyUSB2 (at), wwan0 (net)
  --------------------------------
  Status   |       unlock retries: sim-pin2 (10)
           |                state: registered
           |          power state: on
           |          access tech: lte
           |       signal quality: 25% (recent)
  --------------------------------
  Modes    |            supported: allowed: 3g; preferred: none
           |                       allowed: 4g; preferred: none
           |                       allowed: 3g, 4g; preferred: 4g
           |                       allowed: 3g, 4g; preferred: 3g
           |              current: allowed: 2g, 3g, 4g; preferred: 2g
  --------------------------------
  Bands    |            supported: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8, 
           |                       utran-9, utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, 
           |                       eutran-7, eutran-8, eutran-9, eutran-12, eutran-13, eutran-17, 
           |                       eutran-18, eutran-19, eutran-20, eutran-26, eutran-28, eutran-29, 
           |                       eutran-30, eutran-32, eutran-41, eutran-66
           |              current: utran-1, utran-3, utran-4, utran-6, utran-5, utran-8, 
           |                       utran-9, utran-2, eutran-1, eutran-2, eutran-3, eutran-4, eutran-5, 
           |                       eutran-7, eutran-8, eutran-9, eutran-12, eutran-13, eutran-17, 
           |                       eutran-18, eutran-19, eutran-20, eutran-26, eutran-28, eutran-29, 
           |                       eutran-30, eutran-32, eutran-41, eutran-66
  --------------------------------
  IP       |            supported: ipv4, ipv6, ipv4v6
  --------------------------------
  3GPP     |                 imei: [redacted]
           |        enabled locks: fixed-dialing
           |          operator id: 310260
           |        operator name: Twilio
           |         registration: roaming
  --------------------------------
  3GPP EPS | ue mode of operation: csps-2
           |  initial bearer path: /org/freedesktop/ModemManager1/Bearer/0
  --------------------------------
  SIM      |     primary sim path: /org/freedesktop/ModemManager1/SIM/0
  --------------------------------
  Bearer   |                paths: /org/freedesktop/ModemManager1/Bearer/1
geerlingguy commented 1 year ago

Hmm... after a few seconds it seems to disconnect:

  Status   |       unlock retries: sim-pin2 (10)
           |                state: registered
           |          power state: on
           |          access tech: lte
           |       signal quality: 16% (recent)
Screen Shot 2022-08-23 at 7 59 23 PM

And I can't ping Google or anything. Maybe WAN configuration is a bit off...

Here's the system log entries from OpenWRT: https://gist.github.com/geerlingguy/f78b785dc15bf7349250c6a830f14814

geerlingguy commented 1 year ago

And if I click Restart in LuCI for the wwan interface, it seems to reconnect and get an IP, but only temporarily. There are packets sent (TX), but no packets received (RX). Here's the log from the moment I clicked Restart:

Sat Aug 20 22:35:38 2022 daemon.notice netifd: wwan (7347): stopping network
Sat Aug 20 22:35:38 2022 daemon.notice netifd: wwan (7347): running disconnection (common)
Sat Aug 20 22:35:38 2022 daemon.notice netifd: wwan (7347): Command failed: ubus call network.interface notify_proto { "action": 0, "link-up": false, "keep": false, "interface": "wwan" } (Permission denied)
Sat Aug 20 22:35:38 2022 daemon.notice netifd: wwan (7347): successfully disconnected all bearers in the modem
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] state changed (registered -> disabling)
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] 3GPP registration state changed (roaming -> unknown)
Sat Aug 20 22:35:38 2022 daemon.notice netifd: wwan (7347): successfully disabled the modem
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] state changed (disabling -> disabled)
Sat Aug 20 22:35:38 2022 daemon.notice netifd: Interface 'wwan' is now down
Sat Aug 20 22:35:38 2022 daemon.notice netifd: Interface 'wwan' is setting up now
Sat Aug 20 22:35:38 2022 daemon.notice netifd: wwan (7391): modem available at /org/freedesktop/ModemManager1/Modem/0
Sat Aug 20 22:35:38 2022 daemon.notice netifd: wwan (7391): starting connection with apn 'super'...
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] simple connect started...
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] simple connect state (3/8): enable
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] state changed (disabled -> enabling)
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] power state updated: on
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] simple connect state (4/8): wait to get fully enabled
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] state changed (enabling -> enabled)
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] simple connect state (5/8): register
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] 3GPP registration state changed (unknown -> registering)
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] 3GPP registration state changed (registering -> roaming)
Sat Aug 20 22:35:38 2022 daemon.info [3589]: <info>  [modem0] state changed (enabled -> registered)
Sat Aug 20 22:35:39 2022 daemon.info [3589]: <info>  [modem0] simple connect state (6/8): bearer
Sat Aug 20 22:35:39 2022 daemon.info [3589]: <info>  [modem0] simple connect state (7/8): connect
Sat Aug 20 22:35:39 2022 daemon.info [3589]: <info>  [modem0] state changed (registered -> connecting)
Sat Aug 20 22:35:39 2022 daemon.info [3589]: <info>  [modem0] state changed (connecting -> connected)
Sat Aug 20 22:35:39 2022 daemon.info [3589]: <info>  [modem0] simple connect state (8/8): all done
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): successfully connected the modem
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): signal refresh rate is not set
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): network operator name: Twilio
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): network operator MCCMNC: 310410
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): registration type: roaming
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): access technology: lte
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): signal quality: 16%
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): IPv4 connection setup required in interface wwan: static
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): adding IPv4 address 100.68.68.54, netmask 255.255.255.252
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): adding default IPv4 route via 100.68.68.53
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): adding primary DNS at 8.8.4.4
Sat Aug 20 22:35:39 2022 daemon.notice netifd: wwan (7391): adding secondary DNS at 8.8.8.8
Sat Aug 20 22:35:39 2022 daemon.notice netifd: Interface 'wwan' is now up
Sat Aug 20 22:35:39 2022 daemon.info dnsmasq[1]: reading /tmp/resolv.conf.d/resolv.conf.auto
Sat Aug 20 22:35:39 2022 daemon.info dnsmasq[1]: using nameserver 8.8.4.4#53
Sat Aug 20 22:35:39 2022 daemon.notice netifd: Network device 'wwan0' link is up
Sat Aug 20 22:35:39 2022 daemon.info dnsmasq[1]: using nameserver 8.8.8.8#53
Sat Aug 20 22:35:39 2022 daemon.info dnsmasq[1]: using only locally-known addresses for test
Sat Aug 20 22:35:39 2022 daemon.info dnsmasq[1]: using only locally-known addresses for onion
Sat Aug 20 22:35:39 2022 daemon.info dnsmasq[1]: using only locally-known addresses for localhost
Sat Aug 20 22:35:39 2022 daemon.info dnsmasq[1]: using only locally-known addresses for local
Sat Aug 20 22:35:39 2022 daemon.info dnsmasq[1]: using only locally-known addresses for invalid
Sat Aug 20 22:35:39 2022 daemon.info dnsmasq[1]: using only locally-known addresses for bind
Sat Aug 20 22:35:39 2022 daemon.info dnsmasq[1]: using only locally-known addresses for lan
Sat Aug 20 22:35:39 2022 kern.info kernel: [ 1554.316204] 8021q: adding VLAN 0 to HW filter on device wwan0
Sat Aug 20 22:35:39 2022 user.notice firewall: Reloading firewall due to ifup of wwan (wwan0)
Sat Aug 20 22:36:24 2022 daemon.info [3589]: <info>  [modem0] state changed (connected -> registered)
Sat Aug 20 22:36:24 2022 daemon.info [3589]: <info>  [modem0/bearer5] connection #1 finished: duration 45s, tx: 0 bytes, rx: 0 bytes
Sat Aug 20 22:36:25 2022 user.notice modemmanager: interface wwan (network device wwan0) disconnected
Sat Aug 20 22:36:25 2022 daemon.notice netifd: Interface 'wwan' has lost the connection
Sat Aug 20 22:36:25 2022 daemon.notice netifd: Network device 'wwan0' link is down
Sat Aug 20 22:36:25 2022 daemon.warn dnsmasq[1]: no servers found in /tmp/resolv.conf.d/resolv.conf.auto, will retry
Sat Aug 20 22:36:25 2022 daemon.info [3589]: <info>  [modem0] 3GPP registration state changed (roaming -> idle)
Sat Aug 20 22:36:25 2022 daemon.info [3589]: <info>  [modem0] state changed (registered -> enabled)
Sat Aug 20 22:36:25 2022 daemon.warn [3589]: <warn>  [modem0] couldn't load operator code: Current operator MCC/MNC is still unknown
Sat Aug 20 22:36:25 2022 daemon.warn [3589]: <warn>  [modem0] couldn't load operator name: Current operator name is still unknown
Sat Aug 20 22:36:25 2022 daemon.info [3589]: <info>  [modem0] 3GPP registration state changed (idle -> searching)
Sat Aug 20 22:36:25 2022 daemon.info [3589]: <info>  [modem0] state changed (enabled -> searching)
Sat Aug 20 22:36:41 2022 daemon.info [3589]: <info>  [modem0] 3GPP registration state changed (searching -> registering)
Sat Aug 20 22:36:41 2022 daemon.info [3589]: <info>  [modem0] 3GPP registration state changed (registering -> roaming)
Sat Aug 20 22:36:41 2022 daemon.info [3589]: <info>  [modem0] state changed (searching -> registered)
geerlingguy commented 1 year ago

Theory: the SIM is disabled in SixFab CONNECT.

I checked the ICCID of the SIM card using the AT command:

root@OpenWrt:~# echo -ne 'AT+CCID\r\n' > /dev/ttyUSB2
OK

+CCID: 89[redacted...]

I checked the SixFab CONNECT dashboard, and that SIM is currently active:

Screen Shot 2022-08-23 at 8 21 40 PM

Sooo... maybe this is the issue?

Sat Aug 20 22:36:25 2022 daemon.warn [3589]: <warn>  [modem0] couldn't load operator code: Current operator MCC/MNC is still unknown
Sat Aug 20 22:36:25 2022 daemon.warn [3589]: <warn>  [modem0] couldn't load operator name: Current operator name is still unknown
NeilHanlon commented 1 year ago

Some vague google searching suggests openwrt's modem support may be iffy, and points towards http://ofmodemsandmen.com/ for openwrt packages... but my knowledge here is lacking

geerlingguy commented 1 year ago

A few things I'm thinking about:

  1. From the Wiki: "If you want to disable the 4G/5G module, you can set the GPIO6 to High and enable it again by setting the GPIO6 to Low." — this doesn't seem to be an issue, that GPIO should be low at boot.
  2. Maybe it's being blocked by the network (Twilio)? I found this: "If your network interface in netifd was "up" but the modem is "registered", it's because at some point it was connected, but then it disconnected; e.g. a network-initiated disconnection."
  3. Maybe it's blocked in FCC Mode? This issue about enabling the radio may be helpful, as well as this FCC locking section on the Arch wiki?
geerlingguy commented 1 year ago

Ah...

root@OpenWrt:~# echo -ne 'At!entercnd="A710"\r\n' > /dev/ttyUSB2
root@OpenWrt:~# echo -ne 'At!impref?\r\n' > /dev/ttyUSB2
!IMPREF: 
 preferred image setting does not exist
 current fw version:      00.06.02.00
 current carrier name:    
 current config name:     

 fw version mismatch
 carrier name mismatch
 config name mismatch

So I tried setting it to AUTO-SIM:

root@OpenWrt:~# echo -ne 'AT!IMPREF="AUTO-SIM"\r\n' > /dev/ttyUSB2
OK

root@OpenWrt:~# echo -ne 'At!impref?\r\n' > /dev/ttyUSB2
!IMPREF: 
 preferred fw version:    00.00.00.00
 preferred carrier name:  AUTO-SIM
 preferred config name:   AUTO-SIM_000.000_000
 current fw version:      00.06.02.00
 current carrier name:    
 current config name:     

 fw version mismatch
 carrier name mismatch
 config name mismatch

root@OpenWrt:~# echo -ne 'At!reset\r\n' > /dev/ttyUSB2

I can see in the logs it connects to Twilio:

Sat Aug 20 22:25:28 2022 daemon.notice netifd: wwan (7924): successfully connected the modem
Sat Aug 20 22:25:28 2022 daemon.notice netifd: wwan (7924): signal refresh rate is not set
Sat Aug 20 22:25:28 2022 daemon.notice netifd: wwan (7924): network operator name: Twilio
Sat Aug 20 22:25:28 2022 daemon.notice netifd: wwan (7924): network operator MCCMNC: 310410
Sat Aug 20 22:25:28 2022 daemon.notice netifd: wwan (7924): registration type: roaming
Sat Aug 20 22:25:28 2022 daemon.notice netifd: wwan (7924): access technology: lte
Sat Aug 20 22:25:28 2022 daemon.notice netifd: wwan (7924): signal quality: 16%
Sat Aug 20 22:25:28 2022 daemon.notice netifd: wwan (7924): IPv4 connection setup required in interface wwan: static
Sat Aug 20 22:25:29 2022 daemon.notice netifd: wwan (7924): adding IPv4 address 100.68.137.27, netmask 255.255.255.248
Sat Aug 20 22:25:29 2022 daemon.notice netifd: wwan (7924): adding default IPv4 route via 100.68.137.28
Sat Aug 20 22:25:29 2022 daemon.notice netifd: wwan (7924): adding primary DNS at 8.8.8.8
Sat Aug 20 22:25:29 2022 daemon.notice netifd: wwan (7924): adding secondary DNS at 8.8.4.4
Sat Aug 20 22:25:29 2022 daemon.notice netifd: Interface 'wwan' is now up

But no packets are sent, and 45 seconds later it disconnects:

Sat Aug 20 22:25:29 2022 user.notice firewall: Reloading firewall due to ifup of wwan (wwan0)
Sat Aug 20 22:26:14 2022 daemon.info [2904]: <info>  [modem1] state changed (connected -> registered)
Sat Aug 20 22:26:14 2022 daemon.info [2904]: <info>  [modem1/bearer3] connection #1 finished: duration 45s, tx: 0 bytes, rx: 0 bytes
Sat Aug 20 22:26:14 2022 user.notice modemmanager: interface wwan (network device wwan0) disconnected
Sat Aug 20 22:26:14 2022 daemon.notice netifd: Interface 'wwan' has lost the connection
Sat Aug 20 22:26:14 2022 daemon.warn dnsmasq[1]: no servers found in /tmp/resolv.conf.d/resolv.conf.auto, will retry
Sat Aug 20 22:26:14 2022 daemon.notice netifd: Network device 'wwan0' link is down
rjocoleman commented 1 year ago

I just unbricked one of these EM7565 modems on Monday evening and got it up and running with OpenWRT via QMI and started with ModemManager but didn't complete that (as QMI was working fine).

Did you check your power mode? AT!PCINFO?

You have a super old firmware on this. Might want to upgrade it?

Also, you can change what interfaces are showing with AT!USBCOMP

rjocoleman commented 1 year ago

So I tried setting it to AUTO-SIM:

You probably want this to be GENERIC. Which images do you have? AT!IMAGE?

geerlingguy commented 1 year ago

So strange... it always connects and gets an IP, and starts sending TX packets:

  Status   |       unlock retries: sim-pin2 (10)
           |                state: connected
           |          power state: on
           |          access tech: lte
           |       signal quality: 32% (recent)
Screen Shot 2022-08-23 at 11 24 13 PM

...but it never receives any packets, and after almost exactly 45 seconds, it always switches to 'registered' state, and won't connect again until I restart the modem :/

Sat Aug 20 22:23:39 2022 daemon.notice netifd: Network device 'wwan0' link is up
Sat Aug 20 22:23:39 2022 kern.info kernel: [  225.859251] 8021q: adding VLAN 0 to HW filter on device wwan0
Sat Aug 20 22:23:39 2022 user.notice firewall: Reloading firewall due to ifup of wwan (wwan0)
Sat Aug 20 22:23:46 2022 daemon.warn [3069]: <warn>  [modem0] couldn't load network timezone from the current network
Sat Aug 20 22:23:46 2022 daemon.warn [3069]: <warn>  [modem0] port ttyUSB2 timed out 8 consecutive times
Sat Aug 20 22:24:23 2022 daemon.info [3069]: <info>  [modem0] state changed (connected -> registered)
Sat Aug 20 22:24:23 2022 daemon.info [3069]: <info>  [modem0/bearer3] connection #1 finished: duration 44s, tx: 0 bytes, rx: 0 bytes
Sat Aug 20 22:24:23 2022 user.notice modemmanager: interface wwan (network device wwan0) disconnected
Sat Aug 20 22:24:23 2022 daemon.notice netifd: Interface 'wwan' has lost the connection
Sat Aug 20 22:24:23 2022 daemon.warn dnsmasq[1]: no servers found in /tmp/resolv.conf.d/resolv.conf.auto, will retry
Sat Aug 20 22:24:23 2022 daemon.notice netifd: Network device 'wwan0' link is down
  Status   |       unlock retries: sim-pin2 (10)
           |                state: registered
           |          power state: on
           |          access tech: lte
           |       signal quality: 16% (recent)
Screen Shot 2022-08-23 at 11 26 06 PM
geerlingguy commented 1 year ago

@rjocoleman - Thanks for the assistance! Here are a few answers:

root@OpenWrt:~# echo -ne 'AT!PCINFO?\r\n' > /dev/ttyUSB2
State: Online
LPM voters - Temp:0, Volt:0, User:0, W_DISABLE:0, IMSWITCH:0, BIOS:0, LWM2M:0, OMADM:0, FOTA:0, RFCAL:0
LPM persistence - None

root@OpenWrt:~# echo -ne 'AT!IMAGE?\r\n' > /dev/ttyUSB2
TYPE SLOT STATUS LRU FAILURES UNIQUE_ID   BUILD_ID
FW   1    GOOD   127 0 0      ?_?         00.05.03.00_?
FW   2    EMPTY  0   0 0                  
FW   3    EMPTY  0   0 0                  
FW   4    EMPTY  0   0 0                  
Max FW images: 4
Active FW image is at slot 255

TYPE SLOT STATUS LRU FAILURES UNIQUE_ID   BUILD_ID
Max PRI images: 50

You have a super old firmware on this. Might want to upgrade it?

Yeah... was hoping I wouldn't have to because it looks like it will require more work than just "download this thing easily and click an upload button," heh. But I should probably do that.

Current firmware is:

root@OpenWrt:~# echo -ne 'AT+CGMR\r\n' > /dev/ttyUSB2
SWI9X50C_00.06.02.00 f50f0a jenkins 2017/08/25 05:33:58

[re AUTO-SIM] You probably want this to be GENERIC

I tried setting that but got ERROR, I guess it's not present. I bought this card used, so I think most of my work so far has been untangling whatever stuff it was originally set up with!

Is there a good guide for updating the firmware on the card through OpenWRT's cli, or will I have to do it on another machine?

geerlingguy commented 1 year ago

Oh uh... maybe this is the issue?

Screen Shot 2022-08-23 at 11 35 12 PM
geerlingguy commented 1 year ago

Bought a new data package, and power cycled the entire unit. Seems to be going into the same pattern, though it spent some time going idle/searching/idle/searching before it got stuck on registered :/

Restarting the interface does the same thing—it goes to connected, but only TX's and doesn't RX, then after 45s it goes back to registered as all previous attempts. Ping sits and waits... then when the modem disconnects I get Network unreachable.

Maybe I should wait till tomorrow and see if it works then. Maybe the data plan change has to propagate through Twilio/T-Mobile/AT&T's backend?

rjocoleman commented 1 year ago

Awesome - low power mode is off 😀 Nothing to see here, unless it gets triggered on with a firmware update (easy fix)

Yeah... was hoping I wouldn't have to because it looks like it will require more work than just "download this thing easily and click an upload button," heh. But I should probably do that.

There are two ways to update (that I know of)

  1. danielewood's repo is super handy. https://github.com/danielewood/sierra-wireless-modems/blob/master/Sierra-Linux-QMI-SDK.md#em7565-from-version-01050100-release-9-to-latest-release-9 Due to the version of your firmware this is exactly what you need to do. All steps however the latest firmware is newer than written up in that repo - I note it below and there is a link to it. I flashed on x86_64 so I was able to use fwdwl-litehostx86_64, I put the modem in a USB m.2 wwan adapter I had laying around.

  2. qmi-firmware-update from libqmi which may work on the Pi more easily. I used this tool to recover from my brick.

The most recent generic firmware is SWI9X50C_01.14.13.00 to contrast your SWI9X50C_00.06.02.00 https://source.sierrawireless.com/resources/airprime/minicard/75xx/em_mc75xx-approved-fw-packages/

To un-mess up the card and restore it to a set of useful and sane defaults on the latest version, I would:

rjocoleman commented 1 year ago

I just realised after typing you're on an even older firmware than I thought. Both my cards on 00.05.x were super funky and straight up refused to work until upgraded to a newer version - does it look like an engineering sample card?

You need to upgrade through SWI9X50C_01.05.01.00_00_GENERIC_001.028_000 before going newer, due to signing in the newer versions. This will probably trigger low power mode (if so flash the final a second time and it should go away).

geerlingguy commented 1 year ago

@rjocoleman - Thanks for the help—I'll get back to debugging in a bit. Still recovering post-hospital and I get spurts where I have the energy, and lulls where I have to kind of veg out right now :D

geerlingguy commented 1 year ago

@rjocoleman - Thanks so much for the details.

First, I downloaded the firmware files (download was really slow, maybe they host their download site on a 3G connection lol):

I expanded them into swi_fw0105 and swi_fwlatest, respectively. Then I downloaded SLQS04.00.27-lite.bin.tar.gz (the latest version of the QMI SDK).

I extracted the arm64 version of the firmware downloader:

tar --extract --strip-components 3 --file SLQS04.00.27-lite.bin.tar.gz SampleApps/lite-fw-download/bin/fwdwl-litearm64

Then when I tried using it, I got exec format error :(

pi@waveshare:~ $ ./fwdwl-litearm64 \
  --devmode MBIM --devpath /dev/cdc-wdm0 \
  --modelfamily 4 --logfile "fwdwl-cdc-wdm0.log" -e 1 \
  --fwpath "./swi_fw0105/"
-bash: ./fwdldarm64: cannot execute binary file: Exec format error

Trying again with fwdldarm64le, I got an error with the syntax; apparently it's changed, so I used fwpath instead of path:

pi@waveshare:~ $ ./fwdwl-litearm64le \
  --devmode MBIM --devpath /dev/cdc-wdm0 \
  --modelfamily 4 --logfile "fwdwl-cdc-wdm0.log" -e 1 \
  --fwpath "./swi_fw0105/"
Modem Manager rules Tested 
litefw version :lite-fwSLQS04.00.27 
INFO: QDL Port  : /dev/ttyUSB0
INFO: Device Path: /dev/cdc-wdm0
INFO: FW  Path  : ./swi_fw0105/
Package Info:
Carrier    :GENERIC
FW Version :01.05.01.00
Model ID   :SWI9X50C
Package ID :000
PRI Version:001.028
SKU        :9999999
Part Number:9907259
file_type : 6
verify_modem_Crash_Action_MBIM: mbim fd<0
Error in modem crash state checking!error code = 103
Exiting Application!!!

Debugging...

rjocoleman commented 1 year ago

hmmm, is it actually an ARMv8 executable? qmi-firmware-update should be able to do the same things.

rjocoleman commented 1 year ago

Trying again with fwdldarm64le, I get an error with the syntax; apparently it's changed quite a bit. So I expanded the entire QMI SDK:

fwdwl-litehost is what I've been using, not fwdld unsure if these are different but tar --extract --strip-components 3 --file SLQS04.00.27-lite.bin.tar.gz SampleApps/lite-fw-download/bin/fwdwl-litearm64le

geerlingguy commented 1 year ago

I added the --dmreset switch because of that 103 error code, and it looks like it's writing!

Switch Modem to QDL mode by DM Reset Command.
Waiting for modem to come up in BOOT and HOLD mode ...
BOOT and HOLD Mode. Downloading firmware ...
iFWImageType:6
eFW_TYPE_CWE_NVU
Tx(48):02 00 00 00 30 00 00 00 02 00 00 00 02 00 00 00 .. 00 00 00 
Tx(12):0d 00 00 00 0c 00 00 00 00 ff 00 00 
Tx(12):0f 00 00 00 0c 00 00 00 00 ff 00 00 
Write:./swi_fw0105//SWI9X50C_01.05.01.00_GENERIC_001.028_000.nvu
...

Hmm... after a couple minutes, though:

litefw_DownloadFW failed: 100
Exiting Application!!!

Going to hard restart this thing and see if I can get it to flash.

rjocoleman commented 1 year ago

FYI

/* error Codes */
enum litefw_fwdwl_error_codes
{
    eSDP_FWDWL_SUCCESS = 0,             //       Success
    eSDP_FWDWL_ERR_GENERAL = 100,       // 100 - Generic FW download error
    eSDP_FWDWL_ERR_SDK,                 // 101 - SDK specific error. Please check syslog for SDK error codes
    eSDP_FWDWL_ERR_SET_CBK,             // 102 - Error in setting SDK callbacks
    eSDP_FWDWL_ERR_PATH_TOO_LONG,       // 103 - Path is too long
    eSDP_FWDWL_ERR_PATH_NOT_SPECIFIED,  // 104 - Mandatory SDK/FW path not set
    eSDP_FWDWL_ERR_FW_UPGRADE,          // 105 - Post FW download check indicates that the FW upgrade has failed. 
                                        //       For example, PRI not updated as expected, FW version not updated etc
    eSDP_FWDWL_ERR_INVALID_DEV,         // 106 - Invalid device
    eSDP_FWDWL_ERR_INVALID_PATH,        // 107 - Invalid Path or No valid firmware or nvu file exist in the path
    eSDP_FWDWL_ERR_TIMEOUT,             // 108 - Download Process Timeout
    eSDP_FWDWL_ERR_FAIL,                // 109 - Download Process Fail
    eSDP_FWDWL_ERR_PRI_FAIL,            // 110 - Download PRI Fail
    eSDP_FWDWL_ERR_FW_VERSION_FAIL,     // 111 - Download Fail Version Not Match
    eSDP_FWDWL_ERR_SDP_TIMEOUT,         // 112 - SSDP mode timeout
    eFIREHOSE_ERR_SECBOOT_INVALID_CERT_CHAIN,// 113 - Secure boot invalid certificate chain
    eFIREHOSE_ERR_RC7611_RETRY_TEST,// 114 - RC7611 swtich to firehose mode fail
    eLITE_FWDWL_APP_ERR_RC7611_ERROR_AFTER_RETRY,// 115 RC7611 switch to firehose mode failed after retry
    eSDP_FWDWL_ERR_END
};
geerlingguy commented 1 year ago

It seems to just hang after it prints the Write: *.nvu line:

BOOT and HOLD Mode. Downloading firmware ...
iFWImageType:6
eFW_TYPE_CWE_NVU
Tx(48):02 00 00 00 30 00 00 00 02 00 00 00 02 00 00 00 .. 00 00 00 
Tx(12):0d 00 00 00 0c 00 00 00 00 ff 00 00 
Tx(12):0f 00 00 00 0c 00 00 00 00 ff 00 00 
Write:./swi_fwlatest/SWI9X50C_01.14.13.00_GENERIC_002.048_000.nvu
[hang indefinitely - waited 5 minutes first time, waited 15 minutes second time...]

I tried the same cycle with the older and latest firmware, both hang at the same point.

rjocoleman commented 1 year ago

It seems to just hang after it prints the Write: *.nvu line:

modem manager is stopped? any messages in the dmesg?

geerlingguy commented 1 year ago

ModemManager is disabled (and I confirmed stopped. dmesg shows the modem restart during the start of the flashing process (since I add the --dmreset flag), but nothing at all after that:

[  239.156030] qcserial ttyUSB0: usb_wwan_open: submit read urb 0 failed: -19
[  239.156069] qcserial ttyUSB0: usb_wwan_open: submit read urb 1 failed: -19
[  239.156088] qcserial ttyUSB0: usb_wwan_open: submit read urb 2 failed: -19
[  239.156105] qcserial ttyUSB0: usb_wwan_open: submit read urb 3 failed: -19
[  239.659870] qcserial ttyUSB0: usb_wwan_open: submit read urb 0 failed: -19
[  239.659905] qcserial ttyUSB0: usb_wwan_open: submit read urb 1 failed: -19
[  239.659923] qcserial ttyUSB0: usb_wwan_open: submit read urb 2 failed: -19
[  239.659939] qcserial ttyUSB0: usb_wwan_open: submit read urb 3 failed: -19
[  239.868477] usb 2-3: USB disconnect, device number 3
[  239.869252] qcserial ttyUSB0: Qualcomm USB modem converter now disconnected from ttyUSB0
[  239.869365] qcserial 2-3:1.0: device disconnected
[  239.870466] qcserial ttyUSB1: Qualcomm USB modem converter now disconnected from ttyUSB1
[  239.870577] qcserial 2-3:1.2: device disconnected
[  239.871362] qcserial ttyUSB2: Qualcomm USB modem converter now disconnected from ttyUSB2
[  239.871476] qcserial 2-3:1.3: device disconnected
[  239.871735] cdc_mbim 2-3:1.12 wwan0: unregister 'cdc_mbim' usb-0000:01:00.0-3, CDC MBIM
[  239.887845] cdc_mbim 2-3:1.12 wwan0: failed to kill vid 0081/0
[  243.576465] usb 2-3: new SuperSpeed USB device number 4 using xhci_hcd
[  243.599226] usb 2-3: New USB device found, idVendor=1199, idProduct=9090, bcdDevice= 0.00
[  243.599240] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  243.599246] usb 2-3: Product: QUSB__BULK
[  243.599252] usb 2-3: Manufacturer: Sierra Wireless, Incorporated
[  243.602400] qcserial 2-3:1.0: Qualcomm USB modem converter detected
[  243.603577] usb 2-3: Qualcomm USB modem converter now attached to ttyUSB0

Edit: Trying again, this time I'll be sure to grab the debug log file.

geerlingguy commented 1 year ago

Here's the debug log—it looks like it's the same. Just shows that it starts a write... then nothing more: https://gist.github.com/geerlingguy/0a78de2844861cce67b6af6297efe69d

rjocoleman commented 1 year ago

could be worth doing a factory reset AT!RMARESET=1

geerlingguy commented 1 year ago

Looking at this part (https://github.com/danielewood/sierra-wireless-modems/blob/master/Sierra-Linux-QMI-SDK.md#em7565-wont-flash-from-01000200-to-01050100), I'm going to try updating the cwe only:

./fwdwl-litearm64le --devmode MBIM -d /dev/cdc-wdm0 --modelfamily 4 --logfile "fwdwl-lite-cdc0.log" -e 1 --fwpath "./swi_fw0105/SWI9X50C_01.05.01.00.cwe" -i 1 --dmreset

Hmm... that gave a open_port: Unable to open TTY - : Permission denied — maybe I have to do as sudo?

rjocoleman commented 1 year ago

Hmm... that gave a open_port: Unable to open TTY - : Permission denied — maybe I have to do as sudo?

ah yes, all sudo all the time (for flashing) - you need root access to the port

geerlingguy commented 1 year ago

Okay, switched to root user and running:

./fwdwl-litearm64le \
  --devmode MBIM --devpath /dev/cdc-wdm0 \
  --modelfamily 4 --logfile "fwdwl-cdc-wdm0.log" -e 1 \
  --fwpath "./swi_fw0105"
...
GetDeviceMode: ERROR! Unknown modem state
Modem not in correct state
Exiting Application!!!

??? Now it's happening whether I'm root or not. I did the AT!NVRESTORE=0 — maybe that screwed something up?

rjocoleman commented 1 year ago

what's lsusb show at the moment for PID and VID?

geerlingguy commented 1 year ago

1199:90b1. Dangit! Gotta fix that again :P

rjocoleman commented 1 year ago

AT!USBCOMP=1,3,0000100D should be enough to give you the interfaces to flash 😀

geerlingguy commented 1 year ago

Switching to minicom because this two terminal setup is getting atrocious. I didn't have a way to install it on OpenWRT but I'm running Pi OS right now, so it's like driving a sports car.

minicom --device /dev/ttyUSB0 --baudrate 115200

AT!USBPID?
ERROR
AT!ENTERCND="A710"
OK
AT!USBPID?
!USBPID: 
APP : 90B1
BOOT: 90B0

OK
AT!USBPID=9091
OK
AT!USBPID?
!USBPID: 
APP : 9091
BOOT: 9090

Trying again as root...

geerlingguy commented 1 year ago

So far behaving exactly the same; waiting a minute and it's just sitting on:

./fwdwl-litearm64le \
  --devmode MBIM --devpath /dev/cdc-wdm0 \
  --modelfamily 4 --logfile "fwdwl-cdc-wdm0.log" -e 1 \
  --fwpath "./swi_fw0105" --dmreset
...
BOOT and HOLD Mode. Downloading firmware ...
iFWImageType:6
eFW_TYPE_CWE_NVU
Tx(48):02 00 00 00 30 00 00 00 02 00 00 00 02 00 00 00 .. 00 00 00 
Tx(12):0d 00 00 00 0c 00 00 00 00 ff 00 00 
Tx(12):0f 00 00 00 0c 00 00 00 00 ff 00 00 
Write:./swi_fw0105/SWI9X50C_01.05.01.00_GENERIC_001.028_000.nvu

No new output in dmesg. Maybe I have a cursed modem!