espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.75k stars 7.3k forks source link

new SIM800L example is not working (wont receive IP address) (IDFGH-2478) #4590

Closed Arthedian closed 3 years ago

Arthedian commented 4 years ago

Environment

Problem Description

I am using some old PPPOS_client example (some v4.0, but not the latest), where if I have GSM signal, it will connect to the network and I can connect to the internet without problem. I had some other issues with it, so I updated esp idf to the newest version, and now pppos_client is not working. ESP32 wont receive IP address from the GSM network.

Expected Behavior

work corectly and download things from the internet.

Actual Behavior

THE ESP32 wont receive IP address from the GSM network and it will fail to connect through the PPP network.

Steps to reproduce

  1. use standard pppos_client example from esp idf.
  2. I just add code to the beggining, which is restarting the SIM800L via RST pin. It will switch off for 5 seconds, and than start it on and waits for 60 seconds (just to be sure).

Debug Logs

I (809) cpu_start: Starting scheduler on PRO CPU.
D (0) intr_alloc: Connected src 25 to int 2 (cpu 1)
I (0) cpu_start: Starting scheduler on APP CPU.
D (825) heap_init: New heap initialised at 0x3ffe0440
D (835) heap_init: New heap initialised at 0x3ffe4350
D (845) intr_alloc: Connected src 16 to int 12 (cpu 0)
I (845) gpio: GPIO[5]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
D (855) pppos_example: Resseting
D (5855) pppos_example: DOne resseting
D (65855) esp_netif_lwip: LwIP stack has been initialized
D (65855) esp_netif_lwip: esp-netif has been successfully initialized
D (65855) event: running task for loop 0x3ffb8b8c
D (65855) event: created task for loop 0x3ffb8b8c
D (65865) event: created event loop 0x3ffb8b8c
D (65865) esp_netif_objects: esp_netif_add_to_list 0x3ffb9b38
D (65875) esp_netif_objects: esp_netif_add_to_list netif added successfully (total netifs: 1)
D (65885) esp-netif_lwip-ppp: esp_netif_new_ppp: PPP connection created: 0x3ffb9e24
D (65885) esp-netif_lwip-ppp: Phase Dead
I (65895) uart: queue free spaces: 30
D (65895) intr_alloc: Connected src 35 to int 13 (cpu 0)
D (65905) event: created event loop 0x3ffbb608
D (65955) dce_service: sync ok
D (66055) dce_service: disable echo ok
D (66255) sim800: get module name ok
D (66455) sim800: get imei number ok
D (66655) sim800: get imsi number ok
D (66855) sim800: get network operator ok
D (66955) dce_service: set flow control ok
D (67055) dce_service: save settings ok
I (67055) pppos_example: Module: SIMCOM_SIM800L
I (67055) pppos_example: Operator: "EUROTEL PRAHA"
I (67055) pppos_example: IMEI: 865674032096113
I (67055) pppos_example: IMSI: 234500021973833
D (67255) sim800: inquire signal quality ok
I (67255) pppos_example: rssi: 18, ber: 0
D (67455) sim800: inquire battery status ok
I (67455) pppos_example: Battery voltage: 4158 mV
D (67555) dce_service: define pdp context ok
D (67655) sim800: enter ppp mode ok
D (67655) event: running post ESP_MODEM_EVENT:0 with handler 0x400d6358 on loop 0x3ffbb608
I (67655) pppos_example: Modem PPP Started
D (67655) event: running post ESP_MODEM_EVENT:0 with handler 0x400dadbc on loop 0x3ffbb608
D (67665) esp_netif_handlers: esp_netif action has started with netif0x3ffb9b38 from event_id=0
D (67675) esp-netif_lwip-ppp: esp_netif_start_ppp: Starting PPP connection: 0x3ffb9e24
D (67685) esp-netif_lwip-ppp: Phase Start
D (67685) esp-netif_lwip-ppp: Phase Establish
D (67795) esp-netif_lwip-ppp: Phase Authenticate
D (67845) esp-netif_lwip-ppp: Phase Network
D (68545) esp-netif_lwip-ppp: Phase Establish
D (74545) esp-netif_lwip-ppp: Phase Disconnect
D (74545) esp-netif_lwip-ppp: Phase Dead
I (74545) esp-netif_lwip-ppp: Connection lost
D (74545) event: running post IP_EVENT:6 with handler 0x400d63b4 on loop 0x3ffb8b8c
I (74555) pppos_example: IP event! 6
I (74555) pppos_example: Modem Disconnect from PPP Server
suda-morris commented 4 years ago

There might be some regression in the uart driver, since 4.1 has introduced a HAL layer for drivers. A regular way to locate the issue is using git bisect, could you tell the commit id that works for you?

Arthedian commented 4 years ago

Sadly I have no way how to find it, but probably I have some older version. I have tried example from v3.3.1, and it has the same problem. In my example, esp_modem doesnt write any DEBUG info about PPP phases. I have SIM800L connected to GPIO1 and GPIO3, and outwards logging through UART on GPIO32 and GPIO35.

Arthedian commented 4 years ago

I created a repo with working example (for me). https://github.com/Arthedian/esp32_gsm

EDIT:with the repo above, I have only problem If I deinit PPP, and want to init it again, than it will give loadprohibited error. But this is another problem, and thats why I wanted to use newer version.

D (106030) sim800: enter ppp mode ok
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x400ec216  PS      : 0x00060f30  A0      : 0x800d6a25  A1      : 0x3ffcd270  
A2      : 0x00000000  A3      : 0x3ffbd46c  A4      : 0x0000002b  A5      : 0x3ffcf784  
A6      : 0x3ffb4934  A7      : 0x0000002b  A8      : 0x800ec213  A9      : 0x3ffcd250  
A10     : 0x00000000  A11     : 0x3ffbd46c  A12     : 0x400ec434  A13     : 0x0000002b  
A14     : 0x0000002b  A15     : 0x0000002b  SAR     : 0x00000018  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000028  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0x00000000  

ELF file SHA256: 413f1209914d7fb5a1dd1bdb6780d631cc5c9b8b535683fd653db7b7867942e4

Backtrace: 0x400ec213:0x3ffcd270 0x400d6a22:0x3ffcd290 0x400d6b7b:0x3ffcd2c0 0x400888b9:0x3ffcd2f0

EDIT2: This output has backtrace from monitor:

D (107455) sim800: enter ppp mode ok
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x400efa8e  PS      : 0x00060e30  A0      : 0x800d6855  A1      : 0x3ffbfc20  
0x400efa8e: pppos_input_tcpip at /home/arthedian/esp/esp-idf/components/lwip/lwip/src/netif/ppp/pppos.c:440

A2      : 0x00000000  A3      : 0x3ffd0c5c  A4      : 0x0000002b  A5      : 0x3ffdf674  
A6      : 0x3ffb5bc0  A7      : 0x0000002b  A8      : 0x800efa8b  A9      : 0x3ffbfc00  
A10     : 0x00000000  A11     : 0x3ffd0c5c  A12     : 0x400efcac  A13     : 0x0000002b  
0x400efcac: pppos_input_sys at /home/arthedian/esp/esp-idf/components/lwip/lwip/src/netif/ppp/pppos.c:448

A14     : 0x0000002b  A15     : 0x0000002b  SAR     : 0x00000018  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000028  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0x00000000  

ELF file SHA256: d633b17e84f95b1a314dca37b46ec5f19cdc7e7d1940d83c8fd06c7272a42cc8

Backtrace: 0x400efa8b:0x3ffbfc20 0x400d6852:0x3ffbfc40 0x400d69ab:0x3ffbfc70 0x400885a5:0x3ffbfca0
0x400efa8b: pppos_input_tcpip at /home/arthedian/esp/esp-idf/components/lwip/lwip/src/netif/ppp/pppos.c:440

0x400d6852: esp_handle_uart_data at /home/arthedian/prace/BeiT/test/gsm_ota_test/build/../components/gsm/lib/esp_modem.c:151

0x400d69ab: uart_event_task_entry at /home/arthedian/prace/BeiT/test/gsm_ota_test/build/../components/gsm/lib/esp_modem.c:168

0x400885a5: vPortTaskWrapper at /home/arthedian/esp/esp-idf/components/freertos/port.c:143
amitcv commented 4 years ago

I have the exact same problem with same backtrace as above EDIT2. I am using bg96 module with esp-idf version v4.0 @Arthedian did you have any new ideas?

edwin-oetelaar commented 4 years ago

Same issues here. Latest idf. Verbose logging shows valid PPP connection. It seems callbacks are not fired. Will investigate further.

D (11810) event: running post ESP_MODEM_EVENT:0 with handler 0x400db5f8 and context 0x3ffc6fd8 on loop 0x3ffc4c8c
0x400db5f8: modem_event_handler at /home/oetelaar/esp/intercom_minimal/main/app_ppp.c:127

I (11813) pppos_example: Modem PPP Started
D (11817) event: running post ESP_MODEM_EVENT:0 with handler 0x400e16b0 and context 0x3ffc8a00 on loop 0x3ffc4c8c
0x400e16b0: esp_netif_action_start at /home/oetelaar/esp/esp-idf/components/esp_netif/esp_netif_handlers.c:32

D (11828) esp_netif_handlers: esp_netif action has started with netif0x3ffc7010 from event_id=0
D (11836) esp-netif_lwip-ppp: esp_netif_start_ppp: Starting PPP connection: 0x3ffc73d8
ppp_connect[1]: holdoff=0
ppp phase changed[1]: phase=3
D (11849) esp-netif_lwip-ppp: Phase Start
pppos_connect: unit 1: connecting
ppp_start[1]
ppp phase changed[1]: phase=6
D (11860) esp-netif_lwip-ppp: Phase Establish
pppos_send_config[1]: out_accm=FF FF FF FF
ppp_send_config[1]
pppos_recv_config[1]: in_accm=FF FF FF FF
ppp_recv_config[1]
ppp: auth protocols: PAP=1 CHAP=0 CHAP_MD5=0 CHAP_MS=0 CHAP_MS2=0
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x9dcc9c59> <pcomp> <accomp>]
pppos_write[1]: len=24
ppp_start[1]: finished
D (11892) esp_netif_lwip: check: remote, if=0x3ffc7010 fn=0x400e2e30
0x400e2e30: esp_netif_update_default_netif_lwip at /home/oetelaar/esp/esp-idf/components/esp_netif/lwip/esp_netif_lwip.c:163

D (11899) esp_netif_lwip: esp_netif_update_default_netif_lwip 0x3ffc7010
D (11908) esp_netif_lwip: call api in lwip: ret=0x0, give sem
pppos_input[1]: got 99 bytes
rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0xd1320fb0> <pcomp> <accomp>]
sent [LCP ConfNak id=0x0 <auth pap>]
pppos_write[1]: len=12
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x9dcc9c59> <pcomp> <accomp>]
pppos_input[1]: got 52 bytes
rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <auth pap> <magic 0xd1320fb0> <pcomp> <accomp>]
sent [LCP ConfAck id=0x1 <asyncmap 0x0> <auth pap> <magic 0xd1320fb0> <pcomp> <accomp>]
pppos_write[1]: len=28
netif_set_mtu[1]: mtu=1500
pppos_send_config[1]: out_accm=0 0 0 0
ppp_send_config[1]
pppos_recv_config[1]: in_accm=0 0 0 0
ppp_recv_config[1]
ppp phase changed[1]: phase=7
D (11989) esp-netif_lwip-ppp: Phase Authenticate
sent [PAP AuthReq id=0x1 user="KPN" password="GPRS"]
pppos_write[1]: len=17
pppos_input[1]: got 33 bytes
rcvd [LCP DiscReq id=0x2 magic=0xd1320fb0]
rcvd [PAP AuthAck id=0x1 ""]
PAP authentication succeeded
ppp phase changed[1]: phase=9
D (12018) esp-netif_lwip-ppp: Phase Network
ccp_set[1]: is_open=1, is_up=0, receive_method=0, transmit_method=0
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
pppos_write[1]: len=32
sent [IPV6CP ConfReq id=0x1 <addr fe80::e4a6:9094:0c1e:6149>]
pppos_write[1]: len=18
pppos_input[1]: got 34 bytes
rcvd [IPCP ConfNak id=0x1 <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14> < 82 06 0a 0b 0c 0d> < 84 06 0a 0b 0c 0e>]
sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14>]
pppos_write[1]: len=32
sent [IPV6CP ConfReq id=0x1 <addr fe80::e4a6:9094:0c1e:6149>]
pppos_write[1]: len=18
sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14>]
pppos_write[1]: len=32
sent [IPV6CP ConfReq id=0x1 <addr fe80::e4a6:9094:0c1e:6149>]
pppos_write[1]: len=18
sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14>]
pppos_write[1]: len=32
sent [IPV6CP ConfReq id=0x1 <addr fe80::e4a6:9094:0c1e:6149>]
pppos_write[1]: len=18
sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14>]
pppos_write[1]: len=32
sent [IPV6CP ConfReq id=0x1 <addr fe80::e4a6:9094:0c1e:6149>]
pppos_write[1]: len=18
sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14>]
pppos_write[1]: len=32
sent [IPV6CP ConfReq id=0x1 <addr fe80::e4a6:9094:0c1e:6149>]
pppos_write[1]: len=18
sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14>]
pppos_write[1]: len=32
sent [IPV6CP ConfReq id=0x1 <addr fe80::e4a6:9094:0c1e:6149>]
pppos_write[1]: len=18
sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14>]
pppos_write[1]: len=32
sent [IPV6CP ConfReq id=0x1 <addr fe80::e4a6:9094:0c1e:6149>]
pppos_write[1]: len=18
sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14>]
pppos_write[1]: len=32
sent [IPV6CP ConfReq id=0x1 <addr fe80::e4a6:9094:0c1e:6149>]
pppos_write[1]: len=18
sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14>]
pppos_write[1]: len=32
sent [IPV6CP ConfReq id=0x1 <addr fe80::e4a6:9094:0c1e:6149>]
pppos_write[1]: len=18
sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns2 10.11.12.14>]
pppos_write[1]: len=32
IPV6CP: timeout sending Config-Requests
IPCP: timeout sending Config-Requests
ppp phase changed[1]: phase=11
D (73052) esp-netif_lwip-ppp: Phase Terminate
ccp_set[1]: is_open=0, is_up=0, receive_method=0, transmit_method=0
ppp phase changed[1]: phase=6
D (73060) esp-netif_lwip-ppp: Phase Establish
pppos_send_config[1]: out_accm=FF FF FF FF
ppp_send_config[1]
pppos_recv_config[1]: in_accm=0 0 0 0
ppp_recv_config[1]
sent [LCP TermReq id=0x2 "No network protocols running"]
pppos_write[1]: len=36
sent [LCP TermReq id=0x3 "No network protocols running"]
pppos_write[1]: len=36
ppp phase changed[1]: phase=12
D (85082) esp-netif_lwip-ppp: Phase Disconnect
Connection terminated.
ppp_link_terminated[1]
ppp_link_end[1]
ppp phase changed[1]: phase=0
D (85086) esp-netif_lwip-ppp: Phase Dead
I (85090) esp-netif_lwip-ppp: Connection lost
D (85095) event: running post IP_EVENT:6 with handler 0x400db1cc and context 0x3ffb0ec4 on loop 0x3ffbc184
0x400db1cc: on_ip_event at /home/oetelaar/esp/intercom_minimal/main/app_ppp.c:200

ppp_link_terminated[1]: finished.
D (85105) pppos_example: IP event! 6
I (85111) pppos_example: Modem Disconnect from PPP Server
D (85117) event: running post IP_EVENT:6 with handler 0x400e1898 and context 0x3ffc8b08 on loop 0x3ffbc184
0x400e1898: esp_netif_action_disconnected at /home/oetelaar/esp/esp-idf/components/esp_netif/esp_netif_handlers.c:91

D (85127) esp_netif_handlers: esp_netif action disconnected with netif0x3ffc7010 from event_id=6
D (85136) esp_netif_lwip: check: remote, if=0x3ffc7010 fn=0x400e2154
0x400e2154: esp_netif_down_api at /home/oetelaar/esp/esp-idf/components/esp_netif/lwip/esp_netif_lwip.c:1125

D (85142) esp_netif_lwip: esp_netif_down_api esp_netif:0x3ffc7010
D (85149) esp_netif_lwip: check: local, if=0x3ffc7010 fn=0x400e2e30
0x400e2e30: esp_netif_update_default_netif_lwip at /home/oetelaar/esp/esp-idf/components/esp_netif/lwip/esp_netif_lwip.c:163

D (85155) esp_netif_lwip: esp_netif_update_default_netif_lwip 0x3ffc7010
D (85162) esp_netif_lwip: call api in lwip: ret=0x0, give sem
pppos_input[1]: got 14 bytes

The crux might be here : IPCP: timeout sending Config-Requests

I investigate further.

JonathanJol commented 4 years ago

I had a similar problem using Nimbelink's BG96 modem, it would start the PPP connection, but I was never able to get IP data.

After quite some time reading and trying other things like just sending UART AT commands, I realized that the modem had flow control enabled by default, so I just turned on HW flow control in the example code and everything worked as intended after that, I hope this information can help anybody with similar problems.

devUsama commented 3 years ago

Issue still exists with the espidf-v4.2 example

david-cermak commented 3 years ago

I'm sorry, i've been neglecting this issue, as it's a bit difficult to say whether the connection issue is or is not on IDF side (SIM800L is largely obsolete and won't work in many countries, getting the IP address depends on the mobile operator, setting the APN, etc). We're going to introduce a new modem/console example in IDF which would just propagate the AT commands from the esp-console to the device. This should help us to tell apart the operator connection issues from PPPoS problems (if the connection succeeds via command line mode but fails in PPP mode is a clear indication of pppos/esp-modem issue).

As for the current status of the PPPoS example, the only outstanding issue is in clean exit of the data mode (https://github.com/espressif/esp-idf/issues/6024, also mentioned above I think) -- master.

I will revisit this issue when we have the console app ready.

svenehlers commented 3 years ago

I have the same issue. Does anybody have a workaround for this?

david-cermak commented 3 years ago

@svenehlers Please make sure you've correctly configured the APN (in the project configuration menu)

(Top) → Component config → ESP-MODEM
    Set Access Point Name (APN)

Also, please check with your operator that G2 connectivity is supported and enabled.

All issues mentioned above have been fixed and the pppos-client should work as expected. We'd still keep this open, until the console application mentioned above is ready.

For troubleshooting I'd suggest enabling PPP debug messages in lwip menu, enabling phase events and sharing your debug log. Although it might be hard to tell the connectivity and cellular issues apart, it might give us some pointers, at least.

david-cermak commented 3 years ago

We're going to close this issue as noted previously. There's no update from reporters on setting APN or checking for G2/GSM connectivity. Also the modem console application is now available as an example to the esp_modem component. Users can play with the device using the console app to check for connectivity issues and settings runtime.

Please feel free to reopen this if the console app could connect but pppos example won't get an IP.

Arthedian commented 2 years ago

@david-cermak I just resolved the problem I had at the beginning. Not sure if the problem is with the chip or the library. At the begging I am hardware resetting the chip (5s down, 5s up), then I cannot get the ip address. But if instead of 5 seconds waiting before connecting I will wait 15 seconds, than everything is working.