CPU cant start (spiffs and adc?)

newsettler_AI
Posts: 121
Joined: Wed Apr 05, 2017 12:49 pm

CPU cant start (spiffs and adc?)

Postby newsettler_AI » Mon Dec 17, 2018 7:13 pm

Hi.

I use spiffs in my project. I got error when added simple open-read function to app_main.

function:
  1.  
  2. void data_load()
  3. {
  4.     FILE *file;
  5.  
  6.     file = fopen("/spiffs/data/my_data", "rb");
  7.  
  8.     if(file == NULL)
  9.     {
  10.         printf("%s : Cant open file\n", __func__);
  11.         return;
  12.     }
  13.  
  14.     fread(&data_total.ID, sizeof(data_total.ID), 1, file); // size ID 2 bytes
  15.     fread(&data_total.data, sizeof(data_total.data), 1, file); // size data is 4 bytes
  16.  
  17.     fclose(file);
  18.  
  19.     printf("data loaded: (%d)(%d) \n", data_total.ID, data_total.data);
  20. }
I suppose its doesnt consume a lot of memory (file contains 6 bytes).

Where I should to dig?

Output:

Code: Select all

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5820
load:0x40078000,len:9020
ho 0 tail 12 room 4
load:0x40080000,len:6120
0x40080000: _WindowOverflow4 at C:/Projects/ESP32/TOOLS/esp-idf/components/freertos/xtensa_vectors.S:1685

entry 0x40080334
0x40080334: _KernelExceptionVector at ??:?

I (30) boot: ESP-IDF v3.1 2nd stage bootloader
I (30) boot: compile time 20:37:26
I (30) boot: Enabling RNG early entropy source...
I (34) boot: SPI Speed      : 40MHz
I (38) boot: SPI Mode       : DIO
I (42) boot: SPI Flash Size : 4MB
I (47) boot: Partition Table:
I (50) boot: ## Label            Usage          Type ST Offset   Length
I (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (65) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (72) boot:  2 factory          factory app      00 00 00010000 00100000
I (80) boot:  3 storage          Unknown data     01 82 00180000 00200000
I (87) boot: End of partition table
I (91) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x2b1cc (176588) map
I (162) esp_image: segment 1: paddr=0x0003b1f4 vaddr=0x3ffc0000 size=0x0346c ( 13420) load
I (168) esp_image: segment 2: paddr=0x0003e668 vaddr=0x3ffc346c size=0x00000 (     0) load
I (169) esp_image: segment 3: paddr=0x0003e670 vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _WindowOverflow4 at C:/Projects/ESP32/TOOLS/esp-idf/components/freertos/xtensa_vectors.S:1685

I (178) esp_image: segment 4: paddr=0x0003ea78 vaddr=0x40080400 size=0x01598 (  5528) load
I (189) esp_image: segment 5: paddr=0x00040018 vaddr=0x400d0018 size=0x8c500 (574720) map
0x400d0018: _flash_cache_start at ??:?

I (397) esp_image: segment 6: paddr=0x000cc520 vaddr=0x40081998 size=0x1116c ( 69996) load
0x40081998: esp_intr_set_in_iram at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/intr_alloc.c:773

I (426) esp_image: segment 7: paddr=0x000dd694 vaddr=0x400c0000 size=0x00000 (     0) load
I (427) esp_image: segment 8: paddr=0x000dd69c vaddr=0x50000000 size=0x00000 (     0) load
I (444) boot: Loaded app from partition at offset 0x10000
I (444) boot: Disabling RNG early entropy source...
I (445) cpu_start: Pro cpu up.
I (448) cpu_start: Starting app cpu, entry point is 0x400810b0
0x400810b0: call_start_cpu1 at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/cpu_start.c:225

I (0) cpu_start: App cpu up.
I (459) heap_init: Initializing. RAM available for dynamic allocation:
I (466) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (472) heap_init: At 3FFDBB30 len 000044D0 (17 KiB): DRAM
I (478) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (484) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (491) heap_init: At 40092B04 len 0000D4FC (53 KiB): IRAM
I (497) cpu_start: Pro cpu start user code
I (67) cpu_start: Starting scheduler on PRO CPU.
abort() was called at PC 0x4008106a on core 0
0x4008106a: start_cpu0_default at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/cpu_start.c:381 (discriminator 9)


Backtrace: 0x40090590:0x3ffe3bc0 0x40090733:0x3ffe3be0 0x4008106a:0x3ffe3c00 0x40081235:0x3ffe3c30 0x4007907f:0x3ffe3c50 0x400791
31:0x3ffe3c80 0x4007914f:0x3ffe3cc0 0x40079445:0x3ffe3ce0 0x40080359:0x3ffe3df0 0x40007c31:0x3ffe3eb0 0x4000073d:0x3ffe3f20
0x40090590: invoke_abort at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/panic.c:649

0x40090733: abort at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/panic.c:649

0x4008106a: start_cpu0_default at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/cpu_start.c:381 (discriminator 9)

0x40081235: call_start_cpu0 at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/cpu_start.c:213

0x40080359: _UserExceptionVector at ??:?


Also, when I commented it my app starts...

And when I added function for reading adc value, I got this cpu stop:

Code: Select all

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5820
load:0x40078000,len:9020
ho 0 tail 12 room 4
load:0x40080000,len:6120
0x40080000: _WindowOverflow4 at C:/Projects/ESP32/TOOLS/esp-idf/components/freer
tos/xtensa_vectors.S:1685

entry 0x40080334
0x40080334: _KernelExceptionVector at ??:?

I (30) boot: ESP-IDF v3.1 2nd stage bootloader
I (30) boot: compile time 21:28:59
I (30) boot: Enabling RNG early entropy source...
I (34) boot: SPI Speed      : 40MHz
I (39) boot: SPI Mode       : DIO
I (43) boot: SPI Flash Size : 4MB
I (47) boot: Partition Table:
I (50) boot: ## Label            Usage          Type ST Offset   Length
I (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (65) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (72) boot:  2 factory          factory app      00 00 00010000 00100000
I (80) boot:  3 storage          Unknown data     01 82 00180000 00200000
I (87) boot: End of partition table
I (92) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x2b634 (177
716) map
I (163) esp_image: segment 1: paddr=0x0003b65c vaddr=0x3ffc0000 size=0x0346c ( 1
3420) load
I (168) esp_image: segment 2: paddr=0x0003ead0 vaddr=0x3ffc346c size=0x00000 (
   0) load
I (169) esp_image: segment 3: paddr=0x0003ead8 vaddr=0x40080000 size=0x00400 (
1024) load
0x40080000: _WindowOverflow4 at C:/Projects/ESP32/TOOLS/esp-idf/components/freer
tos/xtensa_vectors.S:1685

I (179) esp_image: segment 4: paddr=0x0003eee0 vaddr=0x40080400 size=0x01130 (
4400) load
I (189) esp_image: segment 5: paddr=0x00040018 vaddr=0x400d0018 size=0x8dd50 (58
0944) map
0x400d0018: _flash_cache_start at ??:?

I (400) esp_image: segment 6: paddr=0x000cdd70 vaddr=0x40081530 size=0x115d4 ( 7
1124) load
0x40081530: esp_restart at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/syst
em_api.c:244

I (429) esp_image: segment 7: paddr=0x000df34c vaddr=0x400c0000 size=0x00000 (
   0) load
I (430) esp_image: segment 8: paddr=0x000df354 vaddr=0x50000000 size=0x00000 (
   0) load
I (447) boot: Loaded app from partition at offset 0x10000
I (447) boot: Disabling RNG early entropy source...
I (448) cpu_start: Pro cpu up.
I (451) cpu_start: Starting app cpu, entry point is 0x400810b0
0x400810b0: call_start_cpu1 at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/
cpu_start.c:225

I (0) cpu_start: App cpu up.
I (462) heap_init: Initializing. RAM available for dynamic allocation:
I (469) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (475) heap_init: At 3FFDBB38 len 000044C8 (17 KiB): DRAM
I (481) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (487) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (494) heap_init: At 40092B04 len 0000D4FC (53 KiB): IRAM
I (500) cpu_start: Pro cpu start user code
assertion "res == pdTRUE" failed: file "C:/Projects/ESP32/TOOLS/esp-idf/componen
ts/esp32/cpu_start.c", line 378, function: start_cpu0_default
abort() was called at PC 0x400d6de3 on core 0
0x400d6de3: __assert_func at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa
-2.2.0/xtensa-esp32-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/asse
rt.c:63 (discriminator 8)


Backtrace: 0x40090590:0x3ffe3b90 0x40090733:0x3ffe3bb0 0x400d6de3:0x3ffe3bd0 0x4
0081052:0x3ffe3c00 0x40081235:0x3ffe3c30 0x4007907f:0x3ffe3c50 0x40079131:0x3ffe
3c80 0x4007914f:0x3ffe3cc0 0x40079445:0x3ffe3ce0 0x40080359:0x3ffe3df0 0x40007c3
1:0x3ffe3eb0 0x4000073d:0x3ffe3f20
0x40090590: invoke_abort at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/pan
ic.c:649

0x40090733: abort at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/panic.c:64
9

0x400d6de3: __assert_func at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa
-2.2.0/xtensa-esp32-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/asse
rt.c:63 (discriminator 8)

0x40081052: start_cpu0_default at C:/Projects/ESP32/TOOLS/esp-idf/components/esp
32/cpu_start.c:378 (discriminator 1)

0x40081235: call_start_cpu0 at C:/Projects/ESP32/TOOLS/esp-idf/components/esp32/
cpu_start.c:213

0x40080359: _UserExceptionVector at ??:?


I have never faced such problems with cpu stops (ussually, I get into app_main at least).
So what may be the issue? What should I look for?

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

Re: CPU cant start (spiffs and adc?)

Postby ESP_Sprite » Tue Dec 18, 2018 2:42 am

It always helps if you check the backtrace to go to the source of the issue. cpu_start:213 is:

Code: Select all

        bool ext_ram_ok=esp_spiram_test();
        if (!ext_ram_ok) {
            ESP_EARLY_LOGE(TAG, "External RAM failed memory test!");
            abort();
        }
Line 378 does not resolve to an assert line in my version of esp-idf, but the closest assert checks if the main task creation fails.

Do you happen to do anything with PSRAM?

newsettler_AI
Posts: 121
Joined: Wed Apr 05, 2017 12:49 pm

Re: CPU cant start (spiffs and adc?)

Postby newsettler_AI » Thu Dec 20, 2018 7:41 pm

Issue was with stack memory allocation (other library require in some define 32KB). So sheduler cant start, my two functions causes overflow, so I thought problem is with them. Decreasing library memory to 18KB solves issue.

Not sure, but does changing of this in sdkconfig:

Code: Select all

CONFIG_MAIN_TASK_STACK_SIZE = 8192
can help to create app_main task?

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: CPU cant start (spiffs and adc?)

Postby PeterR » Thu Dec 20, 2018 11:03 pm

Yes, that option increases your main application stack. 8K is lots.
Just wondering if that is your problem though.
When I have had an overflow error I think that that was because I have exceeded my partition size. Not sure because I just increased everything. Takes so long to build on Windows so just do evevrything.
& I also believe that IDF CAN should be fixed.

newsettler_AI
Posts: 121
Joined: Wed Apr 05, 2017 12:49 pm

Re: CPU cant start (spiffs and adc?)

Postby newsettler_AI » Fri Dec 21, 2018 3:43 pm

PeterR wrote:
Thu Dec 20, 2018 11:03 pm
Yes, that option increases your main application stack. 8K is lots.
Just wondering if that is your problem though.
When I have had an overflow error I think that that was because I have exceeded my partition size. Not sure because I just increased everything. Takes so long to build on Windows so just do evevrything.
8KB was default option. Can I set it, for example 40KB? :roll:
Does this mean that I can run in app_main functions that requires 32KB stack?
And is it safe to set so high stack values?

Who is online

Users browsing this forum: Google Adsense [Bot] and 132 guests