Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pppos restart failed (IDFGH-5761) #7469

Closed
achao1104 opened this issue Aug 25, 2021 · 6 comments
Closed

pppos restart failed (IDFGH-5761) #7469

achao1104 opened this issue Aug 25, 2021 · 6 comments
Labels
Resolution: Won't Do This will not be worked on Status: Done Issue is done internally

Comments

@achao1104
Copy link

Hello,

I referred the pppos sample, it works fine. but if I deinit and then start again, it reports the following exception, I have used the deinit codes in the sample.

I (59650) ppposutil: PPP state changed event 259
I (59650) ppposutil: PPP state changed event 262
I (59650) ppposutil: PPP state changed event 263
I (59650) ppposutil: PPP state changed event 265
I (59670) esp-netif_lwip-ppp: Connected
I (59670) esp-netif_lwip-ppp: Name Server1: 218.4.4.4
I (59670) esp-netif_lwip-ppp: Name Server2: 218.2.2.2
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump:
PC : 0x400a3ede PS : 0x00060230 A0 : 0x800a402c A1 : 0x3ffdd620
0x400a3ede: netif_do_set_ipaddr at D:/project/esp32/es-idf-v4.3-release/components/lwip/lwip/src/core/netif.c:473 (discriminator 2)

A2 : 0x00000000 A3 : 0x3f01383c A4 : 0x3ffdd660 A5 : 0x3ffdd704
A6 : 0x3ffde210 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x3ffe760c A11 : 0x00000000 A12 : 0x3ff9ffa8 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000003 SAR : 0x0000001c EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004 LBEG : 0x3ff9ffa8 LEND : 0x00000000 LCOUNT : 0x4002771d
0x4002771d: _xt_user_exc at D:/project/esp32/es-idf-v4.3-release/components/freertos/port/xtensa/xtensa_vectors.S:627

Backtrace:0x400a3edb:0x3ffdd620 0x400a4029:0x3ffdd660 0x4009e42b:0x3ffdd6a0 0x4009e06f:0x3ffdd6c0 0x40038049:0x3ffdd6e0 0x40038028:0x3ffdd700 0x400322d9:0x3ffdd730
0x400a3edb: netif_do_set_ipaddr at D:/project/esp32/es-idf-v4.3-release/components/lwip/lwip/src/core/netif.c:470 (discriminator 1)

0x400a4029: netif_set_addr at D:/project/esp32/es-idf-v4.3-release/components/lwip/lwip/src/core/netif.c:702

0x4009e42b: esp_netif_up_api at D:/project/esp32/es-idf-v4.3-release/components/esp_netif/lwip/esp_netif_lwip.c:1215

0x4009e06f: esp_netif_api_cb at D:/project/esp32/es-idf-v4.3-release/components/esp_netif/lwip/esp_netif_lwip.c:107

0x40038049: tcpip_thread_handle_msg at D:/project/esp32/es-idf-v4.3-release/components/lwip/lwip/src/api/tcpip.c:168

0x40038028: tcpip_thread at D:/project/esp32/es-idf-v4.3-release/components/lwip/lwip/src/api/tcpip.c:154

0x400322d9: vPortTaskWrapper at D:/project/esp32/es-idf-v4.3-release/components/freertos/port/xtensa/port.c:168

Thanks,
Peter

@espressif-bot espressif-bot added the Status: Opened Issue is new label Aug 25, 2021
@github-actions github-actions bot changed the title pppos restart failed pppos restart failed (IDFGH-5761) Aug 25, 2021
@david-cermak
Copy link
Collaborator

Hi Peter,

How do you deinitialize the client? Assuming these 3 lines should work provided you correctly reinitialize the ppp glue and netif itself. Could you please share your init and deinit code?

Please, share also the exact commit in ESP-IDF, you're using. We had an issue with deinitialization, but that was fixed in 6f1b8fe (should be included in v4.3 though)

@achao1104
Copy link
Author

Thanks for your reply.
deinit is like below, however, if I esp_event_loop_delete_default() then esp_event_loop_create_default after deinit, there would not be any problem.
esp_event_handler_unregister(IP_EVENT, ESP_EVENT_ANY_ID, &on_ip_event);
esp_event_handler_unregister(NETIF_PPP_STATUS, ESP_EVENT_ANY_ID, &on_ppp_changed);

/* Exit PPP mode */
ESP_ERROR_CHECK(esp_modem_stop_ppp(dte));
/* Unregister events, destroy the netif adapter and destroy its esp-netif instance */
esp_modem_netif_clear_default_handlers(modem_netif_adapter);
esp_modem_netif_teardown(modem_netif_adapter);
//esp_modem_dte_deinit(dte);
esp_netif_destroy(esp_netif_pppos);
xEventGroupWaitBits(event_group, STOP_BIT, pdTRUE, pdTRUE, portMAX_DELAY);
/* Power down module */
//ESP_ERROR_CHECK(dce->power_down(dce));
//ESP_LOGI(TAG, "Power down");
ESP_ERROR_CHECK(dce->deinit(dce));
ESP_ERROR_CHECK(dte->deinit(dte));
vEventGroupDelete(event_group);
event_group=NULL;

@david-cermak
Copy link
Collaborator

if I esp_event_loop_delete_default() then esp_event_loop_create_default after deinit, there would not be any problem.

Maybe some forgotten event is fired during your re-initialization? (looks like a network connection event, but which interface? -- doesn't seem to be ppp netif). If you disable the default loop, the event won't be triggered.

Is it only the pppos netif you're using in your example? This looks weird, as your deinitialization routine looks okay and as said, the netif-up event from your backtrace log doesn't make sense to me. Do you use any other interface? Is the issue reproducible also without the other one?

I've been testing the scenario, see my test code here (using PPP server, so I can disconnect/reconnect faster), but didn't find any issue. The only trouble was missing unregistration of some handlers, this could only appear as a warning in the log.
This should be fixed, too, of course, but it's unrelated to your issues.

diff --git a/examples/protocols/pppos_client/components/modem/src/esp_modem_netif.c b/examples/protocols/pppos_client/components/modem/src/esp_modem_netif.c
index 1c6f4bcf191..46e88c743fe 100644
--- a/examples/protocols/pppos_client/components/modem/src/esp_modem_netif.c
+++ b/examples/protocols/pppos_client/components/modem/src/esp_modem_netif.c
@@ -144,6 +144,18 @@ esp_err_t esp_modem_netif_clear_default_handlers(void *h)
     if (ret != ESP_OK) {
         goto clear_event_failed;
     }
+    ret = esp_event_handler_unregister(IP_EVENT, IP_EVENT_PPP_GOT_IP, esp_netif_action_connected);
+    if (ret != ESP_OK) {
+        goto clear_event_failed;
+    }
+    ret = esp_event_handler_unregister(IP_EVENT, IP_EVENT_PPP_LOST_IP, esp_netif_action_disconnected);
+    if (ret != ESP_OK) {
+        goto clear_event_failed;
+    }
+    ret = esp_event_handler_unregister(NETIF_PPP_STATUS, ESP_EVENT_ANY_ID, on_ppp_changed);
+    if (ret != ESP_OK) {
+        goto clear_event_failed;
+    }
     return ESP_OK;
 
 clear_event_failed:

@achao1104
Copy link
Author

thanks for your reply, and I will try to use a pure sample to test again. BTW, where is the USB-4G sample, it looks the previous link is not accessable.

@david-cermak
Copy link
Collaborator

BTW, where is the USB-4G sample, it looks the previous link is not accessable.

You mean a component manager's link to the esp_modem component, or which link? No (official) USB example for the PPP/modem component has been made public yet.

@espressif-bot espressif-bot added Resolution: Won't Do This will not be worked on Status: Done Issue is done internally and removed Status: Opened Issue is new labels Aug 31, 2021
@leeebo
Copy link

leeebo commented Sep 6, 2021

@achao1104 @david-cermak We implemented a preliminary usb_4g_module example based on esp-modem (replace UART with the USB I/O interface), You can find it here usb_cdc_4g_module. P.S. please checkout IDF to b63ec47 as the master branch has changed some USB header files.

espressif-bot pushed a commit that referenced this issue Oct 28, 2021
NETIF_PPP_STATUS is registerd while modem gets attached to the related netif.
we don't have any network detach functionality in the modem component, so we
unregister the event during esp_modem_netif_clear_default_handlers().

Related https://esp32.com/viewtopic.php?f=13&t=23632
Related #7469
espressif-bot pushed a commit that referenced this issue Dec 1, 2021
NETIF_PPP_STATUS is registerd while modem gets attached to the related netif.
we don't have any network detach functionality in the modem component, so we
unregister the event during esp_modem_netif_clear_default_handlers().

Related https://esp32.com/viewtopic.php?f=13&t=23632
Related #7469
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Won't Do This will not be worked on Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

4 participants