Reset the modem using gpio pins if it doesn't respond to the AT reset sequence

If the modem firmware crashes and stops responding to at commands, it won't get properly reset. This adds logic to attempt to reboot the modem by sending the shutdown gpio sequence, and then by sending the force reset gpio sequence. Hopefully this can significantly reduce the cases where the modem gets it's self stuck in a bad state.

It also appears that the foss firmware doesn't handle the AT+CFUN=1,1 command, when I tried that I got +CME ERROR: 3. I suspect the at reset sequence won't work on the foss firmware. Adding AT+REBOOTDO to the reset commands list could fix this.

Given that the reset commands don't always work, and this attempts to gracefully shutdown the modem using the gpio powerkey sequence, it might make sense to drop the at sequence. This would also make the recovery significantly faster because we wouldn't need to wait for the at command to fail before initiating a restart using gpio. Feedback on this would be greatly appreciated!

Fixes #47 (closed)

Cases to test

crash / reset

  • usb stops working, fix by unbind/rebind
  • usb stops working, reboot modem (by at command)
  • AT+CFUN is only supported on the stock firmware
  • modem crashes but responds to shutdown pin sequence, reboot by power gpio pin
  • If at_send_command is called with no command (so it clears the command queue), it will reset the state and gpio reboot won't be attempted. I expect this should be rare, I ran into this because responses from a attempted gnss upload weren't received until the soft-wake sequence to send the reboot command was run. I think there's a bug lurking in the handling of the DTR pin somewhere.
  • modem stuck in bootloader when eg25-manager starts: eg25-manager should toggle the reset pin causing the modem to (re)boot. In this condition the modem will set the status pin to indicate that the modem is off, and won't respond to PWRKEY, so I don't think this can be detected except perhaps by looking for the presence of the fastboot usb device. This can be simulated with the foss firmware (might work on stock too, untested) by running fastboot oem stay while the modem is booting.

startup

Test Foss firmware Stock Firmware
Boot from modem off (where reset will not cause the modem to boot)
Boot from modem on (where reset will cause the modem to boot). Simulate by modifying modem_start to always call gpio_sequence_poweron, boot modem by running then sigkilling eg25-manager.
Edited by ArenM

Merge request reports

Loading