Hi nliviu, thanks for the support so far. I have moved it to main.c but am still seeing a core dump happening at the same place
#include "mgos.h"
#include "mgos_pppos.h"
#include "math.h"
struct mgos_pppos_cmd cmds[] = {
// {.cmd = "AT$GPSP=0"},
// {.cmd = "AT$GPSP=1"},
{.cmd = "AT$GPSACP", .cb = gnsinf_cb},
{.cmd = NULL},
};
bool gnsinf_cb(void *cb_arg, bool ok, struct mg_str data)
{
LOG(LL_INFO, ("What is ok %d", ok));
if (!ok)
return false;
int fix = 0;
char ns, ew;
float time = 0, lon = 0, hdop = 0, alt = 0, speed = 0, course = 0, lat = 0;
// $GPSACP: 095903.000,0305.3127N,10137.9417E,0.6,87.0,3,292.1,0.0,0.0,230519,10,05
sscanf(data.p, "$GPSACP: %f,%f%c,%f%c,%f,%f,%d,%f,%f",
&time, &lat, &ns, &lon, &ew, &hdop, &alt, &fix, &course, &speed);
// LOG(LL_INFO, ("Scan Sentence %.*s", data.len, data.p));
LOG(LL_INFO, ("What is fix %d\n", fix));
// LOG(LL_INFO, ("What is time %f\n", time));
// LOG(LL_INFO, ("What is lat %f\n", lat));
// LOG(LL_INFO, ("What is ns %c\n", ns));
// LOG(LL_INFO, ("What is lon %f\n", lon));
if (fix > 2)
{
if (ns == 'S')
{
lat *= -1.0;
}
if (ew == 'W')
{
lon *= -1.0;
}
float degrees = trunc(lat / 100.0f);
float minutes = lat - (degrees * 100.0f);
lat = degrees + minutes / 60.0f;
degrees = trunc(lon / 100.0f);
minutes = lon - (degrees * 100.0f);
lon = degrees + minutes / 60.0f;
LOG(LL_INFO, ("lat,lon: %f,%f alt: %.3f speed: %.2f course: %.2f",
lat, lon, alt, speed, course));
}
else
{
LOG(LL_INFO, ("No GNSS fix yet"));
}
(void)cb_arg;
return true;
}
static void gps_cb (void *gps) {
LOG(LL_INFO, ("Timer test"));
mgos_pppos_run_cmds(0, gps);
}
enum mgos_app_init_result mgos_app_init(void) {
LOG(LL_INFO, ("\n\n\n\nDoes it work?"));
// Retrieve GNSS status from SimCom GPS-capable modem:
// mgos_pppos_run_cmds(0, cmds);
LOG(LL_INFO, ("Yes it does\n\n\n\n"));
mgos_set_timer(5000, true, gps_cb, cmds);
return MGOS_APP_INIT_SUCCESS;
}
The core dump happens when connection to the network is lost. I have simulated this by changing AT+COPS=2 to deregister from the network and the system core dumps as soon as that happens. After it reboots, it outputs the “not connected to mobile network” printout until connection is re-established. The code runs fine until another
[May 24 16:47:44.644] mgos_pppos.c:215 Error 6 (phase 0), reconnect
[May 24 16:47:44.644] mgos_net.c:85 PPP: connecting
happens again. I am quite stumped to why this is happening right now. Is there any other sample code that we can refer to or any proposed solutions to this problem?
Below is the console output
[May 24 16:47:43.565] main.c:82 Timer test
[May 24 16:47:44.644] mgos_pppos.c:215 Error 6 (phase 0), reconnect
[May 24 16:47:44.644] mgos_net.c:85 PPP: connecting
[May 24 16:47:47.170] main.c:31 What is ok 1
[May 24 16:47:47.170] main.c:41 What is fix 3
[May 24 16:47:47.175]
[May 24 16:47:47.175] main.c:66 lat,lon: 3.088380,101.632370 alt: 68.100 speed: 0.00 course: 189.40
[May 24 16:47:47.194] Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
[May 24 16:47:47.199] Core 0 register dump:
[May 24 16:47:47.199] PC : 0x40144585 PS : 0x00060e30 A0 : 0x80100179 A1 : 0x3ffb4f60
[May 24 16:47:47.212] A2 : 0x00000000 A3 : 0x3ffc8f6c A4 : 0x0000000e A5 : 0x3ffbae40
[May 24 16:47:47.217] A6 : 0x00000a0d A7 : 0x52414320 A8 : 0x80144585 A9 : 0x3ffb4f40
[May 24 16:47:47.221] A10 : 0x00000000 A11 : 0x3ffc8f6c A12 : 0x0000000e A13 : 0x00000000
[May 24 16:47:47.233] A14 : 0x0000000e A15 : 0x0000000e SAR : 0x00000015 EXCCAUSE: 0x0000001c
[May 24 16:47:47.238] EXCVADDR: 0x00000028 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
[May 24 16:47:47.249]
[May 24 16:47:47.249] Backtrace: 0x40144585 0x40100176 0x40100189 0x40100227 0x400e38b8 0x4017e269 0x4008398a 0x40083b25
[May 24 16:47:47.256]
[May 24 16:47:47.256] --- BEGIN CORE DUMP ---
[May 24 16:47:47.262] mos: catching core dump
[May 24 16:47:50.116] .............
[May 24 16:48:27.145] ---- END CORE DUMP ----
[May 24 16:48:27.152] mos: wrote to c:\mos\orion-test-firmware\PPPOS_GNSS\core-PPPOS_GNSS-esp32-20190524-164827.617415983 (459473 bytes)
[May 24 16:48:27.163] mos: analyzing core dump
Core dump by PPPOS_GNSS/esp32 1.0 20190524-041338/g93f3b6a-master-dirty
Using ELF file at: c:\mos\orion-test-firmware\PPPOS_GNSS\build\objs\PPPOS_GNSS.elf
Using Docker image: docker.io/mgos/esp32-build:3.2-r6
Running docker run --rm -v /c/mos/orion-test-firmware/PPPOS_GNSS/build/objs/PPPOS_GNSS.elf:/fw.elf -v /c/mos/orion-test-firmware/PPPOS_GNSS/core-PPPOS_GNSS-esp32-20190524-164827.617415983:/core -v c:\mos\orion-test-firmware\PPPOS_GNSS:/c/mos/orion-test-firmware/PPPOS_GNSS docker.io/mgos/esp32-build:3.2-r6 bash -c /usr/local/bin/serve_core.py --rom=/opt/Espressif/rom/rom.bin --rom_addr=0x40000000 --xtensa_addr_fixup=true /fw.elf /core & $MGOS_TARGET_GDB /fw.elf -ex 'target remote 127.0.0.1:1234' -ex 'set confirm off' -ex bt -ex quit
GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /fw.elf...done.
Remote debugging using 127.0.0.1:1234
pppos_input_tcpip (ppp=0x0,
s=0x3ffc8f6c "\r\nNO CARRIER\r\n747.000,0305.3028N,10137.9424E,0.7,68.1,3,189.4,0.0,0.0,240519,08,03\r\n\r\nOK\r\n\374?\325\217\374?\004\230\374?",
l=<optimized out>)
at /opt/Espressif/esp-idf/components/lwip/lwip/src/netif/ppp/pppos.c:421
421 err = tcpip_inpkt(p, ppp_netif(ppp), pppos_input_sys);
#0 pppos_input_tcpip (ppp=0x0,
s=0x3ffc8f6c "\r\nNO CARRIER\r\n747.000,0305.3028N,10137.9424E,0.7,68.1,3,189.4,0.0,0.0,240519,08,03\r\n\r\nOK\r\n\374?\325\217\374?\004\230\374?",
l=<optimized out>)
at /opt/Espressif/esp-idf/components/lwip/lwip/src/netif/ppp/pppos.c:421
#1 0x40100179 in mgos_pppos_dispatch_once (pd=0x3ffc233c)
at /c/mos/orion-test-firmware/PPPOS_GNSS/deps/pppos/src/mgos_pppos.c:926
#2 0x4010018c in mgos_pppos_dispatch (pd=0x3ffc233c)
at /c/mos/orion-test-firmware/PPPOS_GNSS/deps/pppos/src/mgos_pppos.c:938
#3 0x4010022a in mgos_pppos_uart_dispatcher (uart_no=<optimized out>,
arg=0x3ffc233c)
at /c/mos/orion-test-firmware/PPPOS_GNSS/deps/pppos/src/mgos_pppos.c:971
#4 0x400e38bb in mgos_uart_dispatcher (arg=0x2)
at /c/mos/orion-test-firmware/PPPOS_GNSS/deps/modules/mongoose-os/src/mgos_uart.c:69
#5 0x4017e26c in mongoose_poll (ms=0)
at /data/tmp/mos_prebuild/tmp/cesanta/mos-libs/mongoose/src/mgos_mongoose.c:55
#6 0x4008398d in mgos_mg_poll_cb (arg=<optimized out>)
at /c/mos/orion-test-firmware/PPPOS_GNSS/deps/freertos/src/mgos_freertos.c:101
#7 0x40083b28 in mgos_task (arg=<optimized out>)
at /c/mos/orion-test-firmware/PPPOS_GNSS/deps/freertos/src/mgos_freertos.c:220
Detaching from program: /fw.elf, Remote target
Found core at 23 - 459424
Mapping DRAM: 335872 @ 0x3ffae000
Mapping /opt/Espressif/rom/rom.bin at 0x40000000
Mapping /fw.elf .rtc.text: 52 @ 0x400c0000
Mapping /fw.elf .rtc.dummy: 52 @ 0x3ff80000
Mapping /fw.elf .iram0.vectors: 1024 @ 0x40080000
Mapping /fw.elf .iram0.text: 70333 @ 0x40080400
Mapping /fw.elf .dram0.data: 10156 @ 0x3ffb0000
Mapping /fw.elf .dram0.bss: 32832 @ 0x3ffb27b0
Mapping /fw.elf .flash.rodata: 164812 @ 0x3f400020
Mapping /fw.elf .flash.text: 793218 @ 0x400d0018
Loaded core dump from last snippet in /core
GDB closed the connection
Waiting for gdb on 1234
Dump contains FreeRTOS task info
Ending remote debugging.
[May 24 16:48:33.816] Rebooting...
[May 24 16:48:33.816] ets Jun 8 2016 00:22:57
[May 24 16:48:33.816]
[May 24 16:48:33.816] rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[May 24 16:48:33.816] configsip: 0, SPIWP:0xee
[May 24 16:48:33.816] clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[May 24 16:48:33.816] mode:DIO, clock div:1
[May 24 16:48:33.816] load:0x3fff0018,len:4
[May 24 16:48:33.816] load:0x3fff001c,len:6188
[May 24 16:48:33.816] load:0x40078000,len:9588
[May 24 16:48:33.816] load:0x40080400,len:6968
[May 24 16:48:33.816] entry 0x40080740
[May 24 16:48:33.816] e[0;32mI (29) boot: ESP-IDF v3.2-r6 2nd stage bootloadere[0m
[May 24 16:48:33.816] e[0;32mI (29) boot: compile time 06:38:46e[0m
[May 24 16:48:33.816] e[0;32mI (29) boot: Enabling RNG early entropy source...e[0m
[May 24 16:48:33.816] e[0;32mI (34) qio_mode: Enabling default flash chip QIOe[0m
[May 24 16:48:33.816] e[0;32mI (39) boot: SPI Speed : 80MHze[0m
[May 24 16:48:33.816] e[0;32mI (43) boot: SPI Mode : QIOe[0m
[May 24 16:48:33.816] e[0;32mI (47) boot: SPI Flash Size : 4MBe[0m
[May 24 16:48:33.816] e[0;32mI (51) boot: Partition Table:e[0m
[May 24 16:48:33.816] e[0;32mI (55) boot: ## Label Usage Type ST Offset Length Flagse[0m
[May 24 16:48:33.816] e[0;32mI (63) boot: 0 nvs WiFi data 01 02 00009000 00004000 00000000e[0m
[May 24 16:48:33.816] e[0;32mI (71) boot: 1 otadata OTA data 01 00 0000d000 00002000 00000000e[0m
[May 24 16:48:33.816] e[0;32mI (79) boot: 2 app_0 OTA app 00 10 00010000 00180000 00000000e[0m
[May 24 16:48:33.816] e[0;32mI (87) boot: 3 fs_0 SPIFFS 01 82 00190000 00040000 00000000e[0m
[May 24 16:48:33.816] e[0;32mI (96) boot: 4 app_1 OTA app 00 11 001d0000 00180000 00000000e[0m
[May 24 16:48:33.816] e[0;32mI (104) boot: 5 fs_1 SPIFFS 01 82 00350000 00040000 00000000e[0m
[May 24 16:48:33.816] e[0;32mI (112) boot: End of partition tablee[0m
[May 24 16:48:33.816] e[0;32mI (117) boot: OTA data 0: seq 0x00000001, st 0x10, CRC 0x157a2b85, valid? 1e[0m
[May 24 16:48:33.816] e[0;32mI (124) boot: OTA data 1: seq 0x00000000, st 0x00, CRC 0x00000000, valid? 0e[0m
[May 24 16:48:33.816] e[0;32mI (132) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x283cc (164812) mape[0m
[May 24 16:48:33.816] e[0;32mI (184) esp_image: segment 1: paddr=0x000383f4 vaddr=0x3ffb0000 size=0x027ac ( 10156) loade[0m
[May 24 16:48:33.816] e[0;32mI (187) esp_image: segment 2: paddr=0x0003aba8 vaddr=0x40080000 size=0x00400 ( 1024) loade[0m
[May 24 16:48:33.816] e[0;32mI (191) esp_image: segment 3: paddr=0x0003afb0 vaddr=0x40080400 size=0x05060 ( 20576) loade[0m
[May 24 16:48:33.816] e[0;32mI (206) esp_image: segment 4: paddr=0x00040018 vaddr=0x400d0018 size=0xc1a84 (793220) mape[0m
[May 24 16:48:33.816] e[0;32mI (415) esp_image: segment 5: paddr=0x00101aa4 vaddr=0x40085460 size=0x0c260 ( 49760) loade[0m
[May 24 16:48:33.816] e[0;32mI (430) esp_image: segment 6: paddr=0x0010dd0c vaddr=0x400c0000 size=0x00034 ( 52) loade[0m
[May 24 16:48:33.816] e[0;32mI (441) boot: Loaded app from partition at offset 0x10000e[0m
[May 24 16:48:33.816] e[0;32mI (441) boot: Disabling RNG early entropy source...e[0m
[May 24 16:48:33.816] e[0;32mI (442) cpu_start: Pro cpu up.e[0m
[May 24 16:48:33.816] e[0;32mI (446) cpu_start: Single core modee[0m
[May 24 16:48:33.816] e[0;32mI (450) heap_init: Initializing. RAM available for dynamic allocation:e[0m
[May 24 16:48:33.816] e[0;32mI (457) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAMe[0m
[May 24 16:48:33.816] e[0;32mI (463) heap_init: At 3FFBA7F0 len 00025810 (150 KiB): DRAMe[0m
[May 24 16:48:33.816] e[0;32mI (469) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAMe[0m
[May 24 16:48:33.816] e[0;32mI (476) heap_init: At 40078000 len 00008000 (32 KiB): IRAMe[0m
[May 24 16:48:33.816] e[0;32mI (482) heap_init: At 400916C0 len 0000E940 (58 KiB): IRAMe[0m
[May 24 16:48:33.816] e[0;32mI (488) cpu_start: Pro cpu start user codee[0m
[May 24 16:48:33.816] e[0;32mI (170) cpu_start: Starting scheduler on PRO CPU.e[0m
[May 24 16:48:33.816]
[May 24 16:48:33.816]
[May 24 16:48:33.816] mgos_freertos.c:175 PPPOS_GNSS 1.0 (20190524-041338/g93f3b6a-master-dirty)
[May 24 16:48:33.816] mgos_freertos.c:177 Mongoose OS 201905221818 (20190523-065926/2.14.0-1-gaee6b1d-master)
[May 24 16:48:33.816] mgos_freertos.c:181 CPU: 160 MHz, FreeRTOS 8.2.0, heap: 289560 total, 257584 free
[May 24 16:48:33.816] mgos_freertos.c:183 Newlib 2.2.0
[May 24 16:48:33.816] esp32_main.c:116 ESP-IDF v3.2-r6
[May 24 16:48:33.816] esp32_main.c:119 Boot partition: app_0; flash: 4M
[May 24 16:48:33.816] mg_lwip_ev_mgr.c:93 Mongoose 6.14, LwIP 2.0.3
[May 24 16:48:33.816] mg_ssl_if_mbedtls.c:57 mbed TLS 2.16.0-cesanta4
[May 24 16:48:33.816] mgos_vfs_dev.c:73 fs_0: esp32part ({"label": "fs_0"}), size 262144
[May 24 16:48:33.816] mgos_vfs_dev.c:73 fs_1: esp32part ({"label": "fs_1"}), size 262144
[May 24 16:48:33.816] mgos_vfs.c:147 /: SPIFFS @ fs_0, opts {"bs": 4096, "ps": 256, "es": 4096}
[May 24 16:48:33.816] mgos_vfs.c:320 /: size 233681, used: 96133, free: 137548
[May 24 16:48:33.816] mgos_sys_config.c:368 MAC: 24:0a:c4:1c:a8:48
[May 24 16:48:33.816] mgos_sys_config.c:376 WDT: 30 seconds
[May 24 16:48:33.816] mgos_pppos.c:1136 PPPoS UART2 (RX:16 TX:17 CTS:14 RTS:15), 115200, fc off, APN 'diginet'
[May 24 16:48:33.816] mgos_rpc_channel_ua:313 0x3ffc2808 UART0
[May 24 16:48:33.816] mgos_wifi.c:458 WiFi mode: AP
[May 24 16:48:33.816] esp32_wifi.c:196 WiFi mode: AP
[May 24 16:48:33.816] I (691) wifi: wifi driver task: 3ffc3ec4, prio:23, stack:3584, core=0
[May 24 16:48:33.816] I (691) wifi: wifi firmware version: 2af77cc
[May 24 16:48:33.816] I (701) wifi: config NVS flash: enabled
[May 24 16:48:33.816] I (701) wifi: config nano formating: disabled
[May 24 16:48:33.816] I (711) wifi: Init dynamic tx buffer num: 32
[May 24 16:48:33.816] I (711) wifi: Init data frame dynamic rx buffer num: 64
[May 24 16:48:33.818] I (721) wifi: Init management frame dynamic rx buffer num: 64
[May 24 16:48:33.818] I (721) wifi: Init management short buffer num: 32
[May 24 16:48:33.818] I (731) wifi: Init static rx buffer size: 1600
[May 24 16:48:33.818] I (731) wifi: Init static rx buffer num: 10
[May 24 16:48:33.818] I (741) wifi: Init dynamic rx buffer num: 0
[May 24 16:48:33.818] e[0;32mI (801) phy: phy_version: 4008, 544f89f, Jan 24 2019, 14:54:06, 0, 0e[0m
[May 24 16:48:33.818] I (801) wifi: mode : softAP (24:0a:c4:1c:a8:49)
[May 24 16:48:33.818] I (811) wifi: Total power save buffer number: 16
[May 24 16:48:33.818] I (821) wifi: Init max length of beacon: 752/752
[May 24 16:48:33.818] I (821) wifi: Init max length of beacon: 752/752
[May 24 16:48:33.818] I (831) wifi: Set ps type: 0
[May 24 16:48:33.818]
[May 24 16:48:33.818] esp32_wifi.c:442 WiFi AP: SSID Mongoose_1CA848, channel 6
[May 24 16:48:33.818] I (1671) wifi: Total power save buffer number: 16
[May 24 16:48:33.818] esp32_wifi.c:492 WiFi AP IP: 192.168.4.1/255.255.255.0 gw 192.168.4.1, DHCP range 192.168.4.2 - 192.168.4.100
[May 24 16:48:33.818] esp32_wifi.c:497 WiFi AP: SSID Mongoose_1CA848, channel 6
[May 24 16:48:33.818] main.c:88
[May 24 16:48:33.818]
[May 24 16:48:33.818]
[May 24 16:48:33.818]
[May 24 16:48:33.818] Does it work?
[May 24 16:48:33.818] main.c:95 Yes it does
[May 24 16:48:33.818]
[May 24 16:48:33.818]
[May 24 16:48:33.818]
[May 24 16:48:33.818]
[May 24 16:48:33.818] mgos_init.c:36 Init done, RAM: 288892 total, 221736 free, 221508 min free
[May 24 16:48:33.818] mgos_mongoose.c:66 New heap free LWM: 217212
[May 24 16:48:33.818] mgos_net.c:85 PPP: connecting
[May 24 16:48:33.818] mgos_net.c:85 PPP: connecting
[May 24 16:48:33.818] mgos_pppos.c:727 Connecting (UART2, APN 'diginet')...
[May 24 16:48:33.818] mgos_pppos.c:301 332, IMEI:
[May 24 16:48:33.818] mgos_pppos.c:388 SIM is ready, IMSI: , ICCID:
[May 24 16:48:33.818] mgos_pppos.c:454 Not connected to mobile network, status 0 (idle)
[May 24 16:48:33.818] mgos_pppos.c:454 Not connected to mobile network, status 0 (idle)
[May 24 16:48:33.936] main.c:82 Timer test
[May 24 16:48:34.556] mgos_pppos.c:454 Not connected to mobile network, status 0 (idle)
[May 24 16:48:35.657] mgos_pppos.c:454 Not connected to mobile network, status 0 (idle)