pycom / pycom-micropython-sigfox

A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
MIT License
196 stars 167 forks source link

"Cannot determine modem state" after firmware upgrade #599

Open JolonB opened 2 years ago

JolonB commented 2 years ago

This issue occurred when I attempted to update the LTE modem firmware using the SD card method. I was attempting to change the firmware to NB-IoT and then realised that I actually needed Cat-M1 and tried to change back.

The exact steps I performed are as follows. Note that all firmware versions were downloaded from the official pycom download page. I used NB1-41019 and CATM1-5.2-48829 for the following commands.

Changing to NB-IoT firmware

>>> import sqnsupgrade
>>> sqnsupgrade.info()
[...]
UE5.0.0.0d                                                               
LR5.1.1.0-46470 
[...]
>>> from machine import SD; import os
>>> sd = SD()
>>> os.mount(sd, '/sd')
>>> sqnsupgrade.run('/sd/NB1-41019.dup')
<<< Welcome to the SQN3330 firmware updater [1.2.6] >>>
>>> FiPy with firmware version 1.20.1.r2
Firmware file is too big to load via FFF method. Using ON_THE_FLY
Attempting AT wakeup...
Session opened: version 1, max transfer 8192 bytes
Sending 5835531 bytes: [########################################] 100%
Waiting for modem to finish the update...
<<<=== DO NOT DISCONNECT POWER ===>>>
Resetting................................
Your modem has been successfully updated.
Here is the current firmware version:

UE6.0.0.0
LR6.0.0.0-41019

IMEI: [...]
True

This upgrade appeared to work. I only tried running lte.send_at_cmd("AT+SQNCTM=?") and got a valid output.

After this, I realised that I actually did need Cat-M1, so went to switch back:


>>> from machine import SD; import os
>>> sd = SD()
>>> os.mount(sd, '/sd')
>>> sqnsupgrade.run('/sd/CATM1-5.2-48829-1.dup', load_fff=False) # as instructed to do so here: https://docs.pycom.io/updatefirmware/ltemodem/
<<< Welcome to the SQN3330 firmware updater [1.2.6] >>>
>>> FiPy with firmware version 1.20.1.r2
Attempting AT wakeup...
Session opened: version 1, max transfer 8192 bytes
Sending 416448 bytes: [########################################] 100%
Waiting for modem to finish the update...
<<<=== DO NOT DISCONNECT POWER ===>>>
Resetting.........................................................................................
..................................................................................................
..................................................................................................
...............................................................................................Tra
ceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sqnsupgrade.py", line 1018, in run
  File "sqnsupgrade.py", line 905, in upgrade
  File "sqnsupgrade.py", line 725, in __run
  File "sqnsupgrade.py", line 150, in wait_for_modem
OSError: Timeout waiting for modem to respond!

At no point did the FiPy lose power. I didn't even touch the FiPy during this process. After this, it is no longer possible to communicate with the modem:

>>> import sqnsupgrade
>>> sqnsupgrade.info(debug=True)
<<< Welcome to the SQN3330 firmware updater [1.2.6] >>>
>>> FiPy with firmware version 1.20.1.r2
The current delay is 1000
Response (+++ #1): b'\x00\x00'
Response (AT #1) None
Response (AT #3) b'\x80\x00'
Response (AT #4) None
Response (AT #1 @ 115200) b'\xc1'
Response (AT #2 @ 115200) None
The current delay is 2000
Response (+++ #1): b'\xc0\x00'
Response (AT #1) None
Response (AT #3) b'\x00\x00'
Response (AT #4) b'\x00\x00'
Response (AT #1 @ 115200) b'\xf0'
Response (AT #2 @ 115200) b'\xc1'
The current delay is 3000
Response (+++ #1): None
Response (AT #1) b'\xfe\x00'
Response (AT #2) None
Response (+++ #2): None
Response (AT #3) b'\x00\x00\xf0\x00'
Response (AT #4) b'\x80\x00'
Response (AT #1 @ 115200) b'\xe1\xe0'
Response (AT #2 @ 115200) b'\xe0'
The current delay is 4000
Response (+++ #1): b'\x00'
Response (AT #1) None
Response (AT #3) b'\x00\x00\x00'
Response (AT #4) b'\x00\x00\x00\x00'
Response (AT #1 @ 115200) b'\xe0\xc1'
Response (AT #2 @ 115200) b'\xc5\xc1'
The current delay is 5000
Response (+++ #1): None
Response (AT #1) b'\x00\x00'
Response (AT #2) None
Response (+++ #2): None
Response (AT #3) b'\x80\x00\x00\x00\x00'
Response (AT #4) b'\x00\x00\x00'
Response (AT #1 @ 115200) b'\xc1\xe1\xc1'
Response (AT #2 @ 115200) b'\xf0\xc1'
Modem state: None
Cannot determine modem state!
>>> from network import LTE
>>> lte = LTE
>>> lte = LTE()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: Couldn't connect to Modem!

>>> # Attempting to do a USB upgrade instead
>>> sqnsupgrade.uart(True)
<<< Welcome to the SQN3330 firmware updater [1.2.6] >>>
>>> FiPy with firmware version 1.20.1.r2
Could not detect your modem!
Please try to power off your device and restart in safeboot mode.
Preparing modem for upgrade...
FFH mode is not necessary... ignoring!
Do not specify updater.elf when updating!
Attempting AT wakeup...

What went wrong here? Is it possible to recover my modem?

Thank you!