-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
PPP re-initialization fails (IDFGH-4140) #6005
Comments
@kannannair084 Thanks for reporting. Would you please help provide more details as suggested in the issue template? Information like elf, sdk configuration, backtrace, log outputs, commit ID, hardware and etc. would help us debug further. Thanks. |
esp_err_t esp_modem_setup_ppp(modem_dte_t *dte) esp_err_t esp_modem_exit_ppp(modem_dte_t *dte) |
i think this issue is very similar to another thread just that, not clear what needs to be done to resolve the issue. I am currently using IDF v4.0.1, do i need to update IDF? |
Also, tried to change IDF to version 4.2 and i am not able to get the IP address entry 0x40080688 I (159) esp_image: segment 3: paddr=0x0002b444 vaddr=0x40080404 size=0x04bd4 ( 19412) load I (331) esp_image: segment 5: paddr=0x000931c8 vaddr=0x40084fd8 size=0x0676c ( 26476) load I (349) boot: Loaded app from partition at offset 0x10000 I (0) cpu_start: App cpu up. This is based on the example ppos_client |
Rebooting... rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) entry 0x40080688 I (159) esp_image: segment 3: paddr=0x0002c828 vaddr=0x40080404 size=0x037f0 ( 14320) load I (333) esp_image: segment 5: paddr=0x00094594 vaddr=0x40083bf4 size=0x07dd8 ( 32216) load I (354) boot: Loaded app from partition at offset 0x10000 I (384) cpu_start: App cpu up. file: "../main/pppos_client_main.c" line 296 abort() was called at PC 0x40083ec3 on core 0 Backtrace:0x40085013:0x3ffb71f0 0x40085701:0x3ffb7210 0x4008959a:0x3ffb7230 0x40083ec3:0x3ffb72a0 0x400d6ca2:0x3ffb72c0 0x400d5282:0x3ffb73f0 0x40085709:0x3ffb7420 0x40085701: esp_system_abort at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp_system/system_api.c:106 0x4008959a: abort at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/newlib/abort.c:46 0x40083ec3: _esp_error_check_failed at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp_common/src/esp_err.c:46 0x400d6ca2: app_main at c:\olf\development\firmware\ppos\pppos_client\build/../main/pppos_client_main.c:296 (discriminator 1) 0x400d5282: main_task at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp32/cpu_start.c:600 (discriminator 2) 0x40085709: vPortTaskWrapper at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/port.c:143 ELF file SHA256: 8b358d93eb67733f Initiating core dump!
|
Narrowed down the issue to be that BG96 doesn't enter Command mode in the esp_modem_stop_ppp. is there a way to fix this? |
@Alvin1Zhang could you help, our project has entered a critical juncture and this issue is impeding the progress. |
Thanks for the report and your investigation, is this a random issue or does the happen consistently, all the time?
The current PPPoS example doesn't correctly address points 1) and 2), unfortunately. Could you please add this debugging line to
So that we understand the issue better.
The above shows the issue where the device already exited data mode, sending commands, but the |
Could you please test with the below patch? 0001-esp_modem-Fixed-stop_ppp-to-fist-exit-the-data-mode-.patch.txt It works around the problem to first switch back to the command mode and then exit the networking mode of the PPP client. I've also added some debug prints and retries to better understand the issue. |
It failed but not showing the set mode change error any more: I (38953) pppos_example: GOT ip event!!! Core 0 register dump: A2 : 0x3ffb6278 A3 : 0x3ffbfae0 A4 : 0x0000001d A5 : 0x3ffbad90 Backtrace:0x40132816:0x3ffbb1d0 0x40132bfb:0x3ffbb1f0 0x400de225:0x3ffbb210 0x400f0570:0x3ffbb230 0x400f0759:0x3ffbb250 0x400efc1a:0x3ffbb280 0x400fadd7:0x3ffbb2a0 0x400fae2f:0x3ffbb2d0 0x400e71a5:0x3ffbb2f0 0x400deeda:0x3ffbb310 0x400def8c:0x3ffbb330 0x40085709:0x3ffbb360 0x40132bfb: esp_netif_transmit at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp_netif/lwip/esp_netif_lwip.c:756 0x400de225: pppos_low_level_output at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp_netif/lwip/esp_netif_lwip_ppp.c:233 0x400f0570: pppos_output_last at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/netif/ppp/pppos.c:878 0x400f0759: pppos_write at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/netif/ppp/pppos.c:244 0x400efc1a: ppp_write at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/netif/ppp/ppp.c:993 0x400fadd7: fsm_sdata at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/netif/ppp/fsm.c:796 0x400fae2f: fsm_timeout at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/netif/ppp/fsm.c:282 0x400e71a5: sys_check_timeouts at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/core/timeouts.c:400 0x400deeda: tcpip_timeouts_mbox_fetch at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/api/tcpip.c:115 0x400def8c: tcpip_thread at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/api/tcpip.c:148 0x40085709: vPortTaskWrapper at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/port.c:143 |
Not sure why, i couldnt post it correctly, so attaching as text file: |
These are the modified functions as per patch , please double check if i have missed any or mis-placed it /* esp modem netif */
static esp_err_t esp_modem_dte_transmit(void *h, void *buffer, size_t len)
{
modem_dte_t *dte = h;
if (dte->dce->mode == MODEM_COMMAND_MODE)
{
return ESP_OK;
}
if (dte->send_data(dte, (const char *)buffer, len) > 0)
{
return ESP_OK;
}
return ESP_FAIL;
}
//esp_modem.c
esp_err_t esp_modem_stop_ppp(modem_dte_t *dte)
{
modem_dce_t *dce = dte->dce;
MODEM_CHECK(dce, "DTE has not yet bind with DCE", err);
esp_modem_dte_t *esp_dte = __containerof(dte, esp_modem_dte_t, parent);
/* Fist enter the command mode */
MODEM_CHECK(dte->change_mode(dte, MODEM_COMMAND_MODE) == ESP_OK, "enter command mode failed", err);
/* Hang up */
MODEM_CHECK(dce->hang_up(dce) == ESP_OK, "hang up failed", err);
/* Next exit PPP network interface */
/* post PPP mode stopped event */
esp_event_post_to(esp_dte->event_loop_hdl, ESP_MODEM_EVENT, ESP_MODEM_EVENT_PPP_STOP, NULL, 0, 0);
return ESP_OK;
err:
return ESP_FAIL;
}
static esp_err_t esp_modem_dte_change_mode(modem_dte_t *dte, modem_mode_t new_mode)
{
modem_dce_t *dce = dte->dce;
MODEM_CHECK(dce, "DTE has not yet bind with DCE", err);
esp_modem_dte_t *esp_dte = __containerof(dte, esp_modem_dte_t, parent);
MODEM_CHECK(dce->mode != new_mode, "already in mode: %d", err, new_mode);
switch (new_mode) {
case MODEM_PPP_MODE:
MODEM_CHECK(dce->set_working_mode(dce, new_mode) == ESP_OK, "set new working mode:%d failed", err, new_mode);
uart_disable_pattern_det_intr(esp_dte->uart_port);
uart_enable_rx_intr(esp_dte->uart_port);
break;
case MODEM_COMMAND_MODE:
uart_flush(esp_dte->uart_port);
uart_enable_pattern_det_baud_intr(esp_dte->uart_port, '\n', 1, MIN_PATTERN_INTERVAL, MIN_POST_IDLE, MIN_PRE_IDLE);
uart_disable_rx_intr(esp_dte->uart_port);
uart_pattern_queue_reset(esp_dte->uart_port, esp_dte->pattern_queue_size);
dce->mode = MODEM_COMMAND_MODE;
vTaskDelay(pdMS_TO_TICKS(1000));
MODEM_CHECK(dce->set_working_mode(dce, new_mode) == ESP_OK, "set new working mode:%d failed", err, new_mode);
vTaskDelay(pdMS_TO_TICKS(1000));
break;
default:
break;
}
return ESP_OK;
err:
return ESP_FAIL;
}
static void esp_handle_uart_data(esp_modem_dte_t *esp_dte)
{
if (esp_dte->parent.dce->mode != MODEM_PPP_MODE) {
// ESP_LOGE(MODEM_TAG, "Error: Got data event in PPP mode");
/* pattern detection mode -> ignore date event on uart
* (should never happen, but if it does, we could still
* read the valid data once pattern detect event fired) */
return;
}
size_t length = 0;
uart_get_buffered_data_len(esp_dte->uart_port, &length);
length = MIN(esp_dte->line_buffer_size, length);
length = uart_read_bytes(esp_dte->uart_port, esp_dte->buffer, length, portMAX_DELAY);
/* pass the input data to configured callback */
if (length) {
ESP_LOG_BUFFER_HEXDUMP(MODEM_TAG, esp_dte->buffer, length, ESP_LOG_INFO);
esp_dte->receive_cb(esp_dte->buffer, length, esp_dte->receive_cb_ctx);
}
}
/**
* @brief Returns true if the supplied string contains only CR or LF
*
* @param str string to check
* @param len length of string
*/
static inline bool is_only_cr_lf(const char *str, uint32_t len)
{
for (int i=0; i<len; ++i) {
if (str[i] != '\r' && str[i] != '\n') {
return false;
}
}
return true;
}
static esp_err_t esp_dte_handle_line(esp_modem_dte_t *esp_dte)
{
modem_dce_t *dce = esp_dte->parent.dce;
MODEM_CHECK(dce, "DTE has not yet bind with DCE", err);
const char *line = (const char *)(esp_dte->buffer);
size_t len = strlen(line);
/* Skip pure "\r\n" lines */
if (len > 2 && !is_only_cr_lf(line, len)) {
ESP_LOGD(MODEM_TAG, "LINE=\"%s\"", line);
MODEM_CHECK(dce->handle_line, "no handler for line", err_handle);
MODEM_CHECK(dce->handle_line(dce, line) == ESP_OK, "handle line failed", err_handle);
}
return ESP_OK;
err_handle:
/* Send ESP_MODEM_EVENT_UNKNOWN signal to event loop */
esp_event_post_to(esp_dte->event_loop_hdl, ESP_MODEM_EVENT, ESP_MODEM_EVENT_UNKNOWN,
(void *)line, strlen(line) + 1, pdMS_TO_TICKS(100));
err:
return ESP_FAIL;
}
/// modified code in bg96.c
static esp_err_t bg96_handle_exit_data_mode(modem_dce_t *dce, const char *line)
{
esp_err_t err = ESP_OK;
if (strstr(line, MODEM_RESULT_CODE_SUCCESS)) {
err = esp_modem_process_command_done(dce, MODEM_STATE_SUCCESS);
} else if (strstr(line, MODEM_RESULT_CODE_NO_CARRIER)) {
err = esp_modem_process_command_done(dce, MODEM_STATE_SUCCESS);
} else if (strstr(line, MODEM_RESULT_CODE_ERROR)) {
err = esp_modem_process_command_done(dce, MODEM_STATE_FAIL);
}
return err;
}
static esp_err_t bg96_set_working_mode(modem_dce_t *dce, modem_mode_t mode)
{
modem_dte_t *dte = dce->dte;
int retry = 0;
switch (mode) {
case MODEM_COMMAND_MODE:
again:
if (retry++ > 5) goto err;
if (retry > 3) {
ESP_LOGD(DCE_TAG, "Sending AT command for %d time", retry);
dce->handle_line = esp_modem_dce_handle_response_default;
DCE_CHECK(dte->send_cmd(dte, "AT\r", MODEM_COMMAND_TIMEOUT_DEFAULT) == ESP_OK, "send command failed", again);
} else {
ESP_LOGD(DCE_TAG, "Sending +++ for %d time", retry);
dce->handle_line = bg96_handle_exit_data_mode;
DCE_CHECK(dte->send_cmd(dte, "+++", 20000) == ESP_OK, "send command failed", again);
DCE_CHECK(dce->state == MODEM_STATE_SUCCESS, "enter command mode failed", err);
}
ESP_LOGD(DCE_TAG, "enter command mode ok");
dce->mode = MODEM_COMMAND_MODE;
break;
case MODEM_PPP_MODE:
dce->handle_line = bg96_handle_atd_ppp;
DCE_CHECK(dte->send_cmd(dte, "ATD*99***1#\r", MODEM_COMMAND_TIMEOUT_MODE_CHANGE) == ESP_OK, "send command failed", err);
DCE_CHECK(dce->state == MODEM_STATE_SUCCESS, "enter ppp mode failed", err);
ESP_LOGD(DCE_TAG, "enter ppp mode ok");
dce->mode = MODEM_PPP_MODE;
break;
default:
ESP_LOGW(DCE_TAG, "unsupported working mode: %d", mode);
goto err;
break;
}
return ESP_OK;
err:
return ESP_FAIL;
} |
ELF file SHA256: da60e7829b14a192 Initiating core dump!
|
After a while running like this, it gets stuck ppp_recv_config[0] Core 0 register dump: A2 : 0x3ffb6278 A3 : 0x3ffbfae0 A4 : 0x0000001d A5 : 0x3ffbad90 Backtrace:0x40132816:0x3ffbb1d0 0x40132bfb:0x3ffbb1f0 0x400de225:0x3ffbb210 0x400f0570:0x3ffbb230 0x400f0759:0x3ffbb250 0x400efc1a:0x3ffbb280 0x400fadd7:0x3ffbb2a0 0x400fae2f:0x3ffbb2d0 0x400e71a5:0x3ffbb2f0 0x400deeda:0x3ffbb310 0x400def8c:0x3ffbb330 0x40085709:0x3ffbb360 0x40132bfb: esp_netif_transmit at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp_netif/lwip/esp_netif_lwip.c:756 0x400de225: pppos_low_level_output at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp_netif/lwip/esp_netif_lwip_ppp.c:233 0x400f0570: pppos_output_last at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/netif/ppp/pppos.c:878 0x400f0759: pppos_write at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/netif/ppp/pppos.c:244 0x400efc1a: ppp_write at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/netif/ppp/ppp.c:993 0x400fadd7: fsm_sdata at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/netif/ppp/fsm.c:796 0x400fae2f: fsm_timeout at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/netif/ppp/fsm.c:282 0x400e71a5: sys_check_timeouts at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/core/timeouts.c:400 0x400deeda: tcpip_timeouts_mbox_fetch at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/api/tcpip.c:115 0x400def8c: tcpip_thread at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/lwip/lwip/src/api/tcpip.c:148 0x40085709: vPortTaskWrapper at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/port.c:143 ELF file SHA256: da60e7829b14a192 Initiating core dump! ================= CORE DUMP START ================= rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) entry 0x40080688 I (162) esp_image: segment 3: paddr=0x0002e79c vaddr=0x40080404 size=0x0187c ( 6268) load I (339) esp_image: segment 5: paddr=0x00096044 vaddr=0x40081c80 size=0x09d4c ( 40268) load I (364) boot: Loaded app from partition at offset 0x10000 I (393) cpu_start: App cpu up. I (37803) pppos_example: Module: BG96 |
Please check if making any out of sequence calls or missing something |
I made the following change and it started working , basically added a 10 sec delay before powering down and after stop. /* Exit PPP mode */
ESP_ERROR_CHECK(esp_modem_stop_ppp(dte));
xEventGroupWaitBits(event_group, STOP_BIT, pdTRUE, pdTRUE, portMAX_DELAY);
ESP_LOGI(TAG, "10 sec delay start");
vTaskDelay(pdMS_TO_TICKS(10000));
ESP_LOGI(TAG, "10 sec delay end");
/* Power down module */
ESP_ERROR_CHECK(dce->power_down(dce));
ESP_LOGI(TAG, "Power down");
ESP_ERROR_CHECK(dce->deinit(dce));
ESP_LOGI(TAG, "Restart after 60 seconds");
vTaskDelay(pdMS_TO_TICKS(60000)); |
Not really, from the coredump it looks more like the ppp mode in lwip is still active and trying to send data to dce, which as been already destroyed in line ESP_ERROR_CHECK(dce->deinit(dce)) it looks like the
Yes, it makes sense, needed to wait for the lwip PPP netif to stop Okay, thanks very much for testing this, now I understand the problem so that it could be properly fixed. |
however, after a couple of runs, i ran into this. |
it is waiting for the started bit , i think here xEventGroupWaitBits(event_group, GOT_DATA_BIT, pdTRUE, pdTRUE, portMAX_DELAY); how to avoid this from happening, as my code gets stuck there. |
Seem like a connection problem with your modem here -- no connection, so way to get an IP address. |
I (41773) pppos_example: MQTT_EVENT_SUBSCRIBED, msg_id=48260 ERROR A stack overflow in task uart_event has been detected. Backtrace:0x40085013:0x3ffbedb0 0x40085701:0x3ffbedd0 0x400859a9:0x3ffbedf0 0x4008671d:0x3ffbee70 0x40085a9c:0x3ffbee90 0x40085a52:0x00000001 |<-CORRUPTED 0x40085701: esp_system_abort at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp_system/system_api.c:106 0x400859a9: vApplicationStackOverflowHook at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/port.c:436 0x4008671d: vTaskSwitchContext at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/tasks.c:2771 0x40085a9c: _frxt_dispatch at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/portasm.S:431 0x40085a52: _frxt_int_exit at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/portasm.S:231 ELF file SHA256: f3b33259a1a38b48 Initiating core dump! |
@david-cermak could you take a look at the logs, i am just running it in a loop to see how reliable this is and i am still getting crashes. seems like miles away from destination and have a tight schedule to meet. |
It is crashing every 5th or 6th iteration... I (739323) pppos_example: GOT ip event!!! ERROR A stack overflow in task uart_event has been detected. Backtrace:0x40085013:0x3ffbedc0 0x40085701:0x3ffbede0 0x400859a9:0x3ffbee00 0x4008671d:0x3ffbee80 0x40085a9c:0x3ffbeea0 0x40085a52:0x00000001 |<-CORRUPTED 0x40085701: esp_system_abort at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp_system/system_api.c:106 0x400859a9: vApplicationStackOverflowHook at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/port.c:436 0x4008671d: vTaskSwitchContext at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/tasks.c:2771 0x40085a9c: _frxt_dispatch at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/portasm.S:431 0x40085a52: _frxt_int_exit at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/portasm.S:231 ELF file SHA256: dd787fca6e349398 |
I (130893156) pppos_example: GOT ip event!!! file: "../main/pppos_client_main.c" line 343 abort() was called at PC 0x40083ec3 on core 0 Backtrace:0x40085013:0x3ffb7200 0x40085701:0x3ffb7220 0x4008959a:0x3ffb7240 0x40083ec3:0x3ffb72b0 0x400d6fc4:0x3ffb72d0 0x400d539e:0x3ffb7400 0x40085709:0x3ffb7430 0x40085701: esp_system_abort at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp_system/system_api.c:106 0x4008959a: abort at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/newlib/abort.c:46 0x40083ec3: _esp_error_check_failed at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp_common/src/esp_err.c:46 0x400d6fc4: app_main at c:\olf\development\firmware\ppos\pppos_client\build/../main/pppos_client_main.c:343 (discriminator 1) 0x400d539e: main_task at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/esp32/cpu_start.c:600 (discriminator 2) 0x40085709: vPortTaskWrapper at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/port.c:143 ELF file SHA256: 55179065fefdb290 |
Thanks for testing this, it looks like this works for switching modes, but has multiple other issues in
Added the two fixes into the following patch Could you please test it and let us know if it works in your setup? This is the patch against f0e87c9 version (i believe that's the version of IDF you've indicated above) |
hi David, my idf was 4.0.1 and since that didnt use the netif and didn't had modem_stop.. so i upgraded the IDF to v4.2-beta1-227-gf0e87c933-dirty ( 4.2 stable release) and fix you suggested started working on 4.2 however, there are still issues as indicated in my crash report above, based on this, could you recommend what i need to change? i have added the 6d70b7c by changing timeout to 5000 and adding two lines but i don't know how to do this:
considering my idf version is IDF to v4.2-beta1-227-gf0e87c933-dirty , the 0001-esp_moded-Fix-PPP-reinit-on-v4.1.patch.txt is it still applicable? |
Thanks for explaining on the versions. Okay, so the Here's the correct one, based on this commit f0e87c9: (Note: this already includes the 6d70b7c, here's how you can apply it:
|
Thank you David for explaining, i didnt use git to get the IDF, i think i downloaded the zip and extracted it.. however, i will follow the change list as per 0001-esp_moded-Fix-PPP-reinit-on-v4.2-beta1.txt and will run it tonight and get back to you. |
It looks like the data is getting repositioned... void UARTSendCMD_PAMgr(const uint8_t* data, uint32_t len)
{
gpio_set_level(PA_RX_TX_SWITCH_PIN, 1);
memset(ui8pPADeviceReadBuffer, '\0', PA_RXBUF_SIZE);
uart_write_bytes(UART_NUM_2, (char*)data, len);
//Delay(14);
ESP_ERROR_CHECK(uart_wait_tx_done(UART_NUM_2, (100 / portTICK_PERIOD_MS))); // original was 100 ticks
gpio_set_level(PA_RX_TX_SWITCH_PIN, 0);
}
This is my data sending function, which is working fine, untill i init dte
dte = esp_modem_dte_init(&config);
where
#define ESP_MODEM_DTE_DEFAULT_CONFIG() \
{ \
.port_num = UART_NUM_1, \
.data_bits = UART_DATA_8_BITS, \
.stop_bits = UART_STOP_BITS_1, \
.parity = UART_PARITY_DISABLE, \
.baud_rate = 115200, \
.flow_control = MODEM_FLOW_CONTROL_NONE,\
.tx_io_num = 33, \
.rx_io_num = 25, \
.rts_io_num = 14, \
.cts_io_num = 26, \
.rx_buffer_size = 2048, \
.tx_buffer_size = 1024, \
.pattern_queue_size = 30, \
.event_queue_size = 35, \
.event_task_stack_size = 4096, \
.event_task_priority = 5, \
.line_buffer_size = 1024 \
}
|
Also, i noticed that, issue starts to appear after this step in esp_modem.c in the function esp_modem_dte_init(), i tried commenting out section by section to identify where it starts. /* MODEM_CHECK(uart_param_config(esp_dte->uart_port, &uart_config) == ESP_OK, "config uart parameter failed", err_uart_config);
if (config->flow_control == MODEM_FLOW_CONTROL_HW) {
res = uart_set_pin(esp_dte->uart_port, config->tx_io_num, config->rx_io_num,
config->rts_io_num, config->cts_io_num);
} else {
res = uart_set_pin(esp_dte->uart_port, config->tx_io_num, config->rx_io_num,
UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
}
MODEM_CHECK(res == ESP_OK, "config uart gpio failed", err_uart_config); */
/* Set flow control threshold */ |
@david-cermak i need to fix the issues and deliver a working solution by end of this week.. i could stay back late as i understand our time differences.. i am blocked by this issue. It would be great if you could take a look and suggest a way to fix this.. i could stick around.. please keep an eye on this thread.. |
@david-cermak could you respond when you come online and see my msg. i am here so that this issue could be resolved at the earliest. sorry for pushing this so hard, like i said, i am blocked by this issue to meet my end of the week delivery timeline. |
i got this issue, UART 2 getting corrupted, resolved by commenting this line in uart.c, esp_err_t uart_param_config(uart_port_t uart_num, const uart_config_t *uart_config)
// uart_hal_txfifo_rst(&(uart_context[uart_num].hal)); |
i am having an issue now, with this ESP_IDF change, when i connect to ble, it is crashing and after the reboot it says issue in modem.c I (6083) NewEsp: CREATE_SERVICE_EVT, status 0, service_handle 40 I (6083) NewEsp: REGISTER_APP_EVT, status 0, app_id 1 I (6093) NewEsp: REGISTER_APP_EVT, status 0, app_id 2 I (6093) NewEsp: REGISTER_APP_EVT, status 0, app_id 3 I (6103) NewEsp: BluetoothLE has been started! I (6123) NewEsp: CREATE_SERVICE_EVT, status 0, service_handle 46 I (6123) NewEsp: CREATE_SERVICE_EVT, status 0, service_handle 62 I (6133) NewEsp: CREATE_SERVICE_EVT, status 0, service_handle 78 I (6133) NewEsp: REGISTER_APP_EVT, status 0, app_id 4 I (6143) NewEsp: REGISTER_APP_EVT, status 0, app_id 5 I (6153) NewEsp: SERVICE_START_EVT, status 0, service_handle 46 I (6153) NewEsp: SERVICE_START_EVT, status 0, service_handle 62 I (6163) NewEsp: SERVICE_START_EVT, status 0, service_handle 78 I (6163) NewEsp: CREATE_SERVICE_EVT, status 0, service_handle 98 I (6173) NewEsp: CREATE_SERVICE_EVT, status 0, service_handle 102 I (6183) NewEsp: SERVICE_START_EVT, status 0, service_handle 98 I (6193) NewEsp: SERVICE_START_EVT, status 0, service_handle 102 I (6733) NewEsp: ESP_GATTS_CONNECT_EVT, conn_id 0, remote 78:59:f7:4f:cc:ab: rst:0x8 (TG1WDT_SYS_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) entry 0x40080658 W (96) boot.esp32: WDT reset info: APP CPU PC=0x4008f810 I (102) boot: Enabling RNG early entropy source... I (587) esp_image: segment 3: paddr=0x001412ec vaddr=0x3ffc14bc size=0x00e98 ( 3736) load I (595) esp_image: segment 5: paddr=0x00142598 vaddr=0x40080404 size=0x15994 ( 88468) load I (0) cpu_start: App cpu up. E (1393) NewEsp: Error (4354) reading data from NVS! E (1393) NewEsp: Error (4354) reading NVS RELAY NEW CONFIG! Core 1 register dump: A2 : 0x3ffb5fc0 A3 : 0x00000000 A4 : 0x3ffd4038 A5 : 0x00000000 Backtrace:0x400e313e:0x3ffd60d0 0x400e3317:0x3ffd6100 0x4008fc29:0x3ffd6130 0x400e3317: uart_event_task_entry at c:\olf\development\firmware\olfirmware-esp32-lte-dlc\build/../components/LteModem/src/esp_modem.c:191 0x4008fc29: vPortTaskWrapper at C:/OLF/Development/Firmware/ESP-IDF/esp-idf_4_2/components/freertos/xtensa/port.c:143 ELF file SHA256: 48f0ff3b34a46a98 Initiating core dump!
|
If I understand correctly, now the modem/ppp work okay until you get a BLE crash, consequent reboot and yet another crash from the modem then? If so, it seems like the modem is in the data mode sending packets to the ESP32 which hasn't yet initialized the data mode, thus failing. |
@kannannair084 The crash you're experiencing looks similar to one in another issue. Could you please try if applying the patch from this comment helps? |
@david-cermak thank you for getting back, sure, will try this and let you know how it goes. |
hi David, i have made the modification as suggested and no longer see issues happening... you may close this thread. |
I am handling a reconnect of PPP which esp_modem_setup_ppp(dte) and esp_modem_exit_ppp(dte)
i am getting stuck at as i found on debugging code.
esp_dte->ppp = pppapi_pppos_create(&(esp_dte->pppif), pppos_low_level_output, on_ppp_status_changed, dte);
could someone please recommend a proper init and de-init sequence for PPP.
boot: Chip Revision: 1
I (69) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot: ESP-IDF v4.0.1-dirty 2nd stage bootloader
I (39) boot: compile time 20:29:59
I (39) boot: Enabling RNG early entropy source...
I (44) boot: SPI Speed : 40MHz
I (48) boot: SPI Mode : DIO
I (52) boot: SPI Flash Size : 16MB
my reference project was pppos_client. i have to do LteModemInitialisation_LtePPPModule and LteModemDeInit_LtePPPModule in sequence and esp32 doesn't move past pppapi_pppos_create in the second iteration.
uint8_t LteModemInitialisation_LtePPPModule()
{
ESP_LOGI(TAG, "Delay 30 Seconds for Modem Readiness");
Reset_LtePPPModule();
for(int i = 0; i < 30; i++)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
ESP_LOGI(TAG, "Delay completed");
//InitFlash();
if(FirstDteInit == 0)
{
tcpip_adapter_init();
FirstDteInit = 1;
}
event_group = xEventGroupCreate();
esp_modem_dte_config_t config = ESP_MODEM_DTE_DEFAULT_CONFIG();
// create dce object
dte = esp_modem_dte_init(&config);
// Register event handler
ESP_ERROR_CHECK(esp_modem_add_event_handler(dte, modem_event_handler, NULL));
dce = bg96_init(dte);
if(dce == NULL)
{
goto skipitall;
}
ESP_ERROR_CHECK(dce->set_flow_ctrl(dce, MODEM_FLOW_CONTROL_NONE));
ESP_ERROR_CHECK(dce->store_profile(dce));
// Get signal quality
uint32_t rssi = 0, ber = 0;
ESP_ERROR_CHECK(dce->get_signal_quality(dce, &rssi, &ber));
// Setup PPP environment
esp_err_t modemstattus = esp_modem_setup_ppp(dte);
if(modemstattus != ESP_OK)
{
goto failedmodem;
}
// Wait for IP address
TRACE("Waiting for IP addres");
xEventGroupWaitBits(event_group, CONNECT_BIT, pdTRUE, pdTRUE, portMAX_DELAY);
return 0;
failedmodem:
ESP_LOGI(TAG, "PPP Init Failed");
return 3;
skipitall:
ESP_LOGI(TAG, "BG96 Init Failed");
return 2;
}
To de-initialize
void LteModemDeInit_LtePPPModule()
{
// Exit PPP mode
if(dte != NULL)
{
ESP_ERROR_CHECK(esp_modem_exit_ppp(dte));
xEventGroupWaitBits(event_group, STOP_BIT, pdTRUE, pdTRUE, portMAX_DELAY);
}
}
The text was updated successfully, but these errors were encountered: