ESP32 PPP disconnection re-connection issue

el_kadenaz
Posts: 9
Joined: Fri May 15, 2020 7:03 am

Re: ESP32 PPP disconnection re-connection issue

Postby el_kadenaz » Thu Oct 14, 2021 1:51 pm

Hi David,
seems that I've found the issue:
I was calling the esp_netif_new and esp_modem_netif_setup

Code: Select all

   
   esp_netif_config_t cfg = ESP_NETIF_DEFAULT_PPP();
   esp_netif = esp_netif_new(&cfg);
   assert(esp_netif);
   modem_netif_adapter = esp_modem_netif_setup(dte);
   esp_modem_netif_set_default_handlers(modem_netif_adapter, esp_netif);
   
Into the esp_modem_setup_ppp() each time I starting a reconnection and the

Code: Select all

   
   esp_event_handler_unregister(IP_EVENT, ESP_EVENT_ANY_ID, &on_ip_event);
   esp_modem_netif_clear_default_handlers(modem_netif_adapter);
   esp_modem_netif_teardown(modem_netif_adapter);
   esp_netif_destroy(esp_netif);
at the disconnection.
Moving the first at the device init calling it only once and never calling the destroy functions the device seems to work properly. Actually I'm at the 7th disconnectio/reconnection without issue.

Thanks for the support

AdiXPS
Posts: 10
Joined: Sat Aug 17, 2019 7:41 am

Re: ESP32 PPP disconnection re-connection issue

Postby AdiXPS » Sat Oct 23, 2021 9:02 am

Hi,
I have the same issue. While I've managed to make the re-connection work, I've let it to cycle through disconnection and re-connection for hours just to make sure that there is no sudden crashes.. But I'm getting random crash:
[0;33mW (2115847) event: handler already registered, overwriting[0m
[0;33mW (2115857) event: handler already registered, overwriting[0m
[0;33mW (2115857) event: handler already registered, overwriting[0m
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump:
PC : 0x40140f35 PS : 0x00060930 A0 : 0x80140a06 A1 : 0x3ffb7ab0
A2 : 0x3ffb6e04 A3 : 0x3ffbf6e8 A4 : 0x00000001 A5 : 0x3f40afb8
A6 : 0x00000006 A7 : 0x3ffbf990 A8 : 0x00000005 A9 : 0x3ffb7a80
A10 : 0x3ffb34a8 A11 : 0x3f40afb8 A12 : 0x00000006 A13 : 0x3ffbf990
A14 : 0x00000000 A15 : 0x3ffbd470 SAR : 0x0000001c EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000005 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000

Backtrace:0x40140f32:0x3ffb7ab0 0x40140a03:0x3ffb7ae0 0x40140abd:0x3ffb7b20 0x4008a5c1:0x3ffb7b40


ELF file SHA256: 34dbaccc87a47901

Rebooting...
Seems it crashes when calling esp_netif_attach(). My method is diffrent, I have disconnect fuction that will wait for the disconnect event and will try to reconnect:

Code: Select all

        xEventGroupWaitBits(event_group, DISCONNECT_BIT, pdFALSE, pdTRUE, portMAX_DELAY);
        ESP_LOGI(TAG, "on_disconnect event is Triggered");

        typedef struct mobility_objects_t_struct
        {
            modem_dte_t *dte;
            void *modem_netif_adapter;
            esp_netif_t *esp_netif;

        } mobility_objects_t;


        mobility_objects_t *mobility_objects = (mobility_objects_t *)event_data;
        
        ESP_ERROR_CHECK(esp_modem_stop_ppp(mobility_objects->dte));
        xEventGroupWaitBits(event_group, STOP_BIT, pdTRUE, pdTRUE, portMAX_DELAY);

        esp_modem_netif_clear_default_handlers(mobility_objects->modem_netif_adapter);
        esp_modem_netif_teardown(mobility_objects->modem_netif_adapter);
        esp_netif_destroy(mobility_objects->esp_netif);
        ESP_LOGI(TAG, "cleared. Alhamdullah");

        // Init netif object
        esp_netif_config_t cfg = ESP_NETIF_DEFAULT_PPP();
        mobility_objects->esp_netif = esp_netif_new(&cfg);
        assert(mobility_objects->esp_netif);

        mobility_objects->modem_netif_adapter = esp_modem_netif_setup(mobility_objects->dte);
        esp_modem_netif_set_default_handlers(mobility_objects->modem_netif_adapter, mobility_objects->esp_netif);

        /* attach the modem to the network interface */
        esp_netif_attach(mobility_objects->esp_netif, mobility_objects->modem_netif_adapter);

        xEventGroupClearBits(event_group, DISCONNECT_BIT);
        xEventGroupClearBits(event_group, STOP_BIT);
not sure though. I've spend couple of weeks now to debug it.. appreciate any comment or direction here?

AdiXPS
Posts: 10
Joined: Sat Aug 17, 2019 7:41 am

Re: ESP32 PPP disconnection re-connection issue

Postby AdiXPS » Tue Oct 26, 2021 5:16 pm

I've tried ESP_cermak example, I've let it running for hours but after awhile, I'am getting the famous "GGuru Mediation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled." One more thing here, I notice that its showing Core 1 while I dont have any task running on it..?

Code: Select all

[0;32mI (334856) esp-netif_lwip-ppp: Connected[0m
[0;32mI (334856) esp-netif_lwip-ppp: Name Server1: [0m
[0;32mI (334856) esp-netif_lwip-ppp: Name Server2: [0m
[0;32mI (334866) pppos_example: Modem Connect to PPP Server[0m
[0;32mI (334866) pppos_example: ~~~~~~~~~~~~~~[0m
[0;32mI (334876) pppos_example: IP          :  [0m
[0;32mI (334886) pppos_example: Netmask     : [0m
[0;32mI (334886) pppos_example: Gateway     : [0m
[0;32mI (334896) pppos_example: Name Server1: [0m
[0;32mI (334896) pppos_example: Name Server2: [0m
[0;32mI (334906) pppos_example: ~~~~~~~~~~~~~~[0m
[0;32mI (334906) pppos_example: GOT ip event!!![0m
[0;32mI (334906) pppos_example: CONNECTED![0m
[0;32mI (334916) pppos_example: PPP state changed event 266[0m
[0;32mI (334916) pppos_example: STOPPING[0m
GGuru Mediation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x4000c2af  PS      : 0x00060e30  A0      : 0x800d6c30  A1      : 0x3ffb70c0  
A2      : 0x3ffb7796  A3      : 0xaba66fb1  A4      : 0x1aaa34d1  A5      : 0x3ffb7796  
A6      : 0x00000025  A7      : 0x0000007e  A8      : 0x8008a79d  A9      : 0x3ffb70a0  
A10     : 0x00000003  A11     : 0x00060e23  A12     : 0x00060e20  A13     : 0x00060e23  
A14     : 0x00000001  A15     : 0x0000835a  SAR     : 0x00000008  EXCCAUSE: 0x0000001c  
EXCVADDR: 0xaba66fb1  LBEG    : 0x4000c349  LEND    : 0x4000c36b  LCOUNT  : 0x00000000  

Backtrace:0x4000c2ac:0x3ffb70c0 0x400d6c2d:0x3ffb70d0 0x400e1d32:0x3ffb7120 0x400e1dff:0x3ffb7150 0x4008a525:0x3ffb7180


ELF file SHA256: 286b2651d396ce8c

AdiXPS
Posts: 10
Joined: Sat Aug 17, 2019 7:41 am

Re: ESP32 PPP disconnection re-connection issue

Postby AdiXPS » Thu Oct 28, 2021 4:45 pm

Can I get any feedback here????

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 PPP disconnection re-connection issue

Postby ESP_Sprite » Fri Oct 29, 2021 4:51 am

Can you decode that backtrace?

AdiXPS
Posts: 10
Joined: Sat Aug 17, 2019 7:41 am

Re: ESP32 PPP disconnection re-connection issue

Postby AdiXPS » Fri Oct 29, 2021 11:13 am

ESP_Sprite wrote:
Fri Oct 29, 2021 4:51 am
Can you decode that backtrace?
Hi,
Thanks. Sure please find below:

Code: Select all

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400d52e5  PS      : 0x00050031  A0      : 0x400826f8  A1      : 0x3ffb0dc0
0x400d52e5: uart_ll_get_intsts_mask at C:/esp4/esp-idf/components/hal/esp32/include/hal/uart_ll.h:170
 (inlined by) uart_rx_intr_handler_default at C:/esp4/esp-idf/components/driver/uart.c:746

0x400826f8: _xt_lowint1 at C:/esp4/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1105

A2      : 0x3ffb7760  A3      : 0x3ffb0aa0  A4      : 0x00000091  A5      : 0x8ca96391  
A6      : 0x00000910  A7      : 0x00000000  A8      : 0x00000001  A9      : 0x3ffb0d50
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x80103e4e  A13     : 0x3ffb86c0  
A14     : 0x3ffb2f6c  A15     : 0x3ffb86e0  SAR     : 0x0000001a  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000008  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  

Backtrace:0x400d52e2:0x3ffb0dc0 0x400826f5:0x3ffb0e10 0x40118563:0x3ffb8710 0x400d845b:0x3ffb8730 0x40088505:0x3ffb8750 0x4008a525:0x3ffb8770
0x400d52e2: uart_ll_get_intsts_mask at C:/esp4/esp-idf/components/hal/esp32/include/hal/uart_ll.h:170
 (inlined by) uart_rx_intr_handler_default at C:/esp4/esp-idf/components/driver/uart.c:746

0x400826f5: _xt_lowint1 at C:/esp4/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1105

0x40118563: cpu_ll_waiti at C:/esp4/esp-idf/components/hal/esp32/include/hal/cpu_ll.h:183
 (inlined by) esp_pm_impl_waiti at C:/esp4/esp-idf/components/esp_pm/pm_impl.c:827

0x400d845b: esp_vApplicationIdleHook at C:/esp4/esp-idf/components/esp_common/src/freertos_hooks.c:63

0x40088505: prvIdleTask at C:/esp4/esp-idf/components/freertos/tasks.c:3839 (discriminator 1)

0x4008a525: vPortTaskWrapper at C:/esp4/esp-idf/components/freertos/port/xtensa/port.c:168



ELF file SHA256: d843f1542d225f73

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 PPP disconnection re-connection issue

Postby ESP_Sprite » Sat Oct 30, 2021 2:01 am

Hm, that's interesting; seems like some internal UART variable got overwritten with NULL. My guess is that you have memory corruption somewhere, but I know too little about the ppp examples to help you further...

AdiXPS
Posts: 10
Joined: Sat Aug 17, 2019 7:41 am

Re: ESP32 PPP disconnection re-connection issue

Postby AdiXPS » Sat Oct 30, 2021 2:05 pm

Ohh ok,might @ESP_cermak will help us here.. I notice also one more thing, its always crashing when exiting from PPP

Code: Select all

[0;32mI (511128) esp-modem: entering esp_modem_stop_ppp...[0m
[0;31mE (512058) esp-modem: esp_dte_handle_line(124): handle line failed[0m
[0;33mW (512058) pppos_example: Unknow line received: ~!E[0m
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Always getting Unknow line received: ~!E.

When I monitor the modem I am getting this transmitted:

Code: Select all

"10/30/2021 3:50:38 PM",CONNECT 150000000
"10/30/2021 3:50:38 PM",~ÿ}#À!}!¦} }9}"}&} } } } }#}%Â#}%}%}&Öcº÷}'}"}(}"£~~ÿ}#À!}"}!} }4}"}&} } } } }%}&M§T}$}'}"}(}"³ø~~ÿ}#À!}!§} }8}"}&} } } } }#}$À#}%}&Öcº÷}'}"}(}"í×~~ÿ}#À!}+¨} }(Öcº÷CC~~À#  ý0~~€!< jà~~€! 
"10/30/2021 3:50:39 PM", -ø0~~€!= ¶º~~€! 
"10/30/2021 3:50:39 PM",™ mTë7ƒTë9æÄG~~€! 
"10/30/2021 3:50:39 PM",™ mTë7ƒTë9æõÙ~~!E  ;å@ U­Ä
"10/30/2021 3:50:43 PM",E
"10/30/2021 3:50:43 PM",™ m»b`µÇª€ }]y  
"10/30/2021 3:50:43 PM",¼}^€bV_9  x(~
"10/30/2021 3:50:43 PM",OK

"10/30/2021 3:50:47 PM",OK
"10/30/2021 3:50:59 PM",~!E  (®²@ 3Ú¶13‚.
"10/30/2021 3:50:59 PM",™ m»âpK.hì¶ÑP s‘`  “~~!E  ;æ@ U­Ã
"10/30/2021 3:51:23 PM",E
"10/30/2021 3:51:23 PM",™ m»b`µÇª€ áw  
"10/30/2021 3:51:23 PM",¼cV_9  µ~~!E  0  @ sIa13‚.
seems the esp sending +++ and ath but the modem keep sending garbage? or it didnt actually exit data mode?

here is sample from modem when there is no issues..:

Code: Select all

"10/30/2021 5:05:32 PM",CONNECT 150000000
"10/30/2021 5:05:32 PM",~ÿ}#À!}!}1} }9}"}&} } } } }#}%Â#}%}%}&Ö¨N½}'}"}(}"°}#~~ÿ}#À!}"}!} }4}"}&} } } } }%}&×É£Õ}'}"}(}"_D~~ÿ}#À!}!}2} }8}"}&} } } } }#}$À#}%}&Ö¨N½}'}"}(}"¡¿~~ÿ}#À!}+}3} }(Ö¨N½œ°~~À#  ý0~~€!Ø ªŠ~~€! 
"10/30/2021 5:05:34 PM", -ø0~~€!Ù vÐ~~€! 
"10/30/2021 5:05:34 PM",ANTë7ƒTë9毥~~€! 
"10/30/2021 5:05:34 PM",ANTë7ƒTë9æž;~
"10/30/2021 5:05:38 PM",OK

"10/30/2021 5:05:41 PM",OK

"10/30/2021 5:05:52 PM",OK

AdiXPS
Posts: 10
Joined: Sat Aug 17, 2019 7:41 am

Re: ESP32 PPP disconnection re-connection issue

Postby AdiXPS » Sun Oct 31, 2021 3:03 pm

I've created git issue:

https://github.com/espressif/esp-idf/issues/7803

I appreciate any valuable feedback on the issue

AdiXPS
Posts: 10
Joined: Sat Aug 17, 2019 7:41 am

Re: ESP32 PPP disconnection re-connection issue

Postby AdiXPS » Sat Nov 06, 2021 3:32 pm

The issue is still being investigated. But just out of curiosity, I am using UART1, there is no resistor 470 Ohm between the esp TXD and modem RXD.. is it mandatory?

Who is online

Users browsing this forum: No registered users and 115 guests