espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.32k stars 7.2k forks source link

ESP32C2 tjpgd example run will crash (IDFGH-7549) #9109

Closed dreamcmi closed 2 years ago

dreamcmi commented 2 years ago

I try to run the example of tjpgd on the ESP8684-DevKitM-1 development board, but it will crash, the following is the error log, how can I solve this problem?

ESP-ROM:esp8684-api2-20220127
Build:Jan 27 2022
rst:0xc (RTC_SW_CPU_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x403805be
0x403805be: esp_restart_noos at /home/darren/esp/esp-idf/components/esp_system/port/soc/esp32c2/system_internal.c:112 (discriminator 1)

SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6108,len:0x18b4
load:0x403ae000,len:0x864
load:0x403b0000,len:0x2598
entry 0x403ae000
I (23) boot: ESP-IDF v5.0-dev-3290-g01d014c42d 2nd stage bootloader
I (23) boot: compile time 22:51:47
I (23) boot: chip revision: 0
I (26) boot.esp32c2: MMU Page Size  : 64K
I (31) boot.esp32c2: SPI Speed      : 60MHz
I (36) boot.esp32c2: SPI Mode       : DIO
I (40) boot.esp32c2: SPI Flash Size : 2MB
I (45) boot: Enabling RNG early entropy source...
I (51) boot: Partition Table:
I (54) boot: ## Label            Usage          Type ST Offset   Length
I (61) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (69) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (76) boot:  2 factory          factory app      00 00 00010000 00100000
I (84) boot: End of partition table
I (88) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=18f38h (102200) map
I (128) esp_image: segment 1: paddr=00028f60 vaddr=3fca9d70 size=00ce8h (  3304) load
I (130) esp_image: segment 2: paddr=00029c50 vaddr=40380000 size=063c8h ( 25544) load
I (143) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=10c90h ( 68752) map
I (165) esp_image: segment 4: paddr=00040cb8 vaddr=403863c8 size=0399ch ( 14748) load
I (176) boot: Loaded app from partition at offset 0x10000
I (177) boot: Disabling RNG early entropy source...
I (188) cpu_start: Pro cpu up.
I (197) cpu_start: Pro cpu start user code
I (197) cpu_start: cpu freq: 120000000 Hz
I (197) cpu_start: Application information:
I (200) cpu_start: Project name:     lcd_tjpgd
I (205) cpu_start: App version:      1
I (210) cpu_start: Compile time:     Jun  6 2022 22:51:42
I (216) cpu_start: ELF file SHA256:  d14307d530b58591...
I (222) cpu_start: ESP-IDF:          v5.0-dev-3290-g01d014c42d
I (228) heap_init: Initializing. RAM available for dynamic allocation:
I (236) heap_init: At 3FCABCF0 len 0002C310 (176 KiB): D/IRAM
I (242) heap_init: At 3FCD8000 len 000074BC (29 KiB): STACK/DRAM
I (249) spi_flash: detected chip: generic
I (253) spi_flash: flash io: dio
W (257) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (271) sleep: Configure to isolate all GPIO pins in sleep state
I (277) sleep: Enable automatic switching of GPIO sleep configuration
I (284) cpu_start: Starting scheduler.
I (289) gpio: GPIO[4]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (299) gpio: GPIO[1]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (299) gpio: GPIO[0]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
total size:210892
free size:21588
minimum free size:18488
Heap summary for capabilities 0x00000800:
  At 0x3fcabcf0 len 181008 free 21044 allocated 158340 min_free 17944
    largest_free_block 19968 alloc_blocks 242 free_blocks 2 total_blocks 244
  At 0x3fcd8000 len 29884 free 544 allocated 27716 min_free 544
    largest_free_block 296 alloc_blocks 59 free_blocks 1 total_blocks 60
  Totals:
    free 21588 allocated 186056 min_free 18488 largest_free_block 19968
1free size:21588
Heap summary for capabilities 0x00000008:
  At 0x3fcabcf0 len 181008 free 21044 allocated 158340 min_free 17944
    largest_free_block 19968 alloc_blocks 242 free_blocks 2 total_blocks 244
  At 0x3fcd8000 len 29884 free 544 allocated 27716 min_free 544
    largest_free_block 296 alloc_blocks 59 free_blocks 1 total_blocks 60
  Totals:
    free 21588 allocated 186056 min_free 18488 largest_free_block 19968
1free size:11348
Heap summary for capabilities 0x00000008:
  At 0x3fcabcf0 len 181008 free 10804 allocated 168580 min_free 10804
    largest_free_block 9728 alloc_blocks 243 free_blocks 2 total_blocks 245
  At 0x3fcd8000 len 29884 free 544 allocated 27716 min_free 544
    largest_free_block 296 alloc_blocks 59 free_blocks 1 total_blocks 60
  Totals:
    free 11348 allocated 196296 min_free 11348 largest_free_block 9728

assert failed: app_main lcd_tjpgd_example_main.c:173 (s_lines[i] != NULL)
Stack dump detected
Core  0 register dump:
MEPC    : 0x403805d2  RA      : 0x4038431e  SP      : 0x3fcae320  GP      : 0x3fcaa570  
0x403805d2: panic_abort at /home/darren/esp/esp-idf/components/esp_system/panic.c:409

0x4038431e: __ubsan_include at /home/darren/esp/esp-idf/components/esp_system/ubsan.c:313

TP      : 0x3fc95808  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x0000007e  S1      : 0x00000001  A0      : 0x3fcae35c  A1      : 0x3fcaa351  
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x00000001  A5      : 0x3fcac000  
A6      : 0x0000000c  A7      : 0x76757473  S2      : 0x00000009  S3      : 0x3fcae479  
S4      : 0x3fcaa350  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
0x40380001: _vector_table at ??:?

MHARTID : 0x00000000  

Failed to run gdb_panic_server.py script: Command '['riscv32-esp-elf-gdb', '--batch', '-n', '/home/darren/esp/examples-master/peripherals/lcd/tjpgd/build/lcd_tjpgd.elf', '-ex', 'target remote | "/home/darren/.espressif/python_env/idf5.0_py3.8_env/bin/python" "/home/darren/esp/esp-idf/tools/idf_monitor_base/../gdb_panic_server.py" --target esp32c2 "/tmp/tmp6w_uraoe"', '-ex', 'bt']' returned non-zero exit status 1.
b"usage: gdb_panic_server.py [-h] [--target {esp32c3,esp32h2}] [--gdb-log GDB_LOG] input_file\ngdb_panic_server.py: error: argument --target: invalid choice: 'esp32c2' (choose from 'esp32c3', 'esp32h2')\nRemote communication error.  Target disconnected.: Connection reset by peer.\nNo stack.\n"

Core  0 register dump:
MEPC    : 0x403805d2  RA      : 0x4038431e  SP      : 0x3fcae320  GP      : 0x3fcaa570  
TP      : 0x3fc95808  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x0000007e  S1      : 0x00000001  A0      : 0x3fcae35c  A1      : 0x3fcaa351  
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x00000001  A5      : 0x3fcac000  
A6      : 0x0000000c  A7      : 0x76757473  S2      : 0x00000009  S3      : 0x3fcae479  
S4      : 0x3fcaa350  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00000000  

Stack memory:
3fcae320: 0x3c020d42 0x3c020d43 0x3c022844 0x40388824 0x3fcaa424 0x3c022844 0x3fcaa408 0x3c022b0d
3fcae340: 0x3fcaa434 0x3fcae354 0x3fcaa438 0x3c022af0 0x3fcaa350 0x00333731 0x00302064 0x65737361
3fcae360: 0x66207472 0x656c6961 0x61203a64 0x6d5f7070 0x206e6961 0x5f64636c 0x67706a74 0x78655f64
3fcae380: 0x6c706d61 0x616d5f65 0x632e6e69 0x3337313a 0x5f732820 0x656e696c 0x5d695b73 0x203d2120
3fcae3a0: 0x4c4c554e 0x00000029 0x3fcd33a7 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcae3c0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x3c020d08 0x3fcae6a4 0x4038855c
3fcae3e0: 0x00000000 0x00000000 0x00000000 0x400586f4 0x3fce0000 0x00000000 0x3fcd8000 0x400587c2
3fcae400: 0x00000220 0x00002c54 0x0002fec8 0x00002800 0x00000001 0x00000008 0x3fcac370 0x403807ba
3fcae420: 0x00000002 0x00000000 0x00000000 0x00000000 0x00000008 0x00002800 0x00000000 0x00000000
3fcae440: 0x00000000 0x00001000 0x00000001 0x4200525c 0x00000000 0x00000000 0x00000001 0x00000010
3fcae460: 0x00000000 0x00000000 0x3fcd8d90 0x0000000a 0x00000001 0x00000000 0x00989680 0x0000000a
3fcae480: 0x00000000 0x00000000 0x00000008 0x00000008 0x00000000 0x3fcd8850 0x00000003 0xffffffff
3fcae4a0: 0x00000002 0xffffffff 0xffffffff 0x00000000 0x00000000 0x00000000 0x00000000 0x00002808
3fcae4c0: 0x00000000 0x00000000 0x00000010 0x00000000 0x00000002 0x00000000 0x00000000 0x00000000
3fcae4e0: 0x00000000 0x00000000 0x00000000 0x42010a56 0x00000000 0x00001388 0x00000001 0x00000000
3fcae500: 0x00000000 0x00000000 0x00000000 0x40386c28 0x00000000 0x00000000 0x00000000 0x00000000
3fcae520: 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x27146414 0x01010107 0x00000001 0x00000000
3fcae540: 0x8800759c 0x7e37e43c 0x54400000 0x3ff921fb 0x1a626331 0x3dd0b461 0x1a600000 0x3dd0b461
3fcae560: 0x2e037073 0x3ba3198a 0x6dc9c883 0x3fe45f30 0x00000000 0x3fe00000 0x2e000000 0x3ba3198a
3fcae580: 0x252049c1 0x397b839a 0x00000000 0x41700000 0x00000000 0x3fd20000 0x00000000 0x3ff00000
3fcae5a0: 0xbe8838d4 0xbda8fae9 0xbdb4b1c4 0x3e21ee9e 0x809c52ad 0x3e927e4f 0x19cb1590 0x3efa01a0
3fcae5c0: 0x16c15177 0x3f56c16c 0x5555554c 0x3fa55555 0x00000000 0x3e700000 0x00000000 0x3fc00000
3fcae5e0: 0x00000000 0x40200000 0x5acfd57c 0x3de5d93a 0x8a2b9ceb 0x3e5ae5e6 0x57b1fe7d 0x3ec71de3
3fcae600: 0x19c161d5 0x3f2a01a0 0x1110f8a6 0x3f811111 0x55555549 0x3fc55555 0x00000000 0x43500000
3fcae620: 0xc2f8f359 0x01a56e1f 0x8800759c 0xfe37e43c 0xc2f8f359 0x81a56e1f 0x00000000 0x3c900000
3fcae640: 0xa5a5a5a5 0x00000154 0x3fcae130 0x0000000e 0x3fcab1ac 0x3fcab1ac 0x3fcae648 0x3fcab1a4
3fcae660: 0x00000018 0xae7bb29e 0xb329028f 0x3fcae648 0x00000000 0x00000001 0x3fcad844 0x6e69616d
3fcae680: 0x15476400 0xc9616d2f 0x00621f38 0x00000000 0x3fcae640 0x00000001 0x00000000 0x00000000
3fcae6a0: 0x00000000 0x00000000 0x3fcac53c 0x3fcac5a4 0x3fcac60c 0x00000000 0x00000000 0x00000001
3fcae6c0: 0x00000000 0x00000000 0x00000000 0x4200f57c 0x00000000 0x00000000 0x00000000 0x00000000
3fcae6e0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcae700: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000

ELF file SHA256: d14307d530b58591
ELF file SHA256: d14307d530b58591

Rebooting...

I tried adding the following code, but didn't find the reason.

//
    printf("total size:%d\n",heap_caps_get_total_size(MALLOC_CAP_INTERNAL));
    printf("free size:%d\n",heap_caps_get_free_size(MALLOC_CAP_INTERNAL));
    printf("minimum free size:%d\n",heap_caps_get_minimum_free_size (MALLOC_CAP_INTERNAL));
    heap_caps_print_heap_info ( MALLOC_CAP_INTERNAL ) ;
    // Allocate memory for the pixel buffers
    for (int i = 0; i < 2; i++) {
        printf("1free size:%d\n",heap_caps_get_free_size(MALLOC_CAP_DMA));
        heap_caps_print_heap_info (MALLOC_CAP_DMA) ;
        s_lines[i] = heap_caps_malloc(EXAMPLE_LCD_H_RES * PARALLEL_LINES * sizeof(uint16_t), MALLOC_CAP_DMA);
        assert(s_lines[i] != NULL);
    }
dreamcmi commented 2 years ago

It looks like it's running out of memory?

suda-morris commented 2 years ago

@dreamcmi yes, OOM issue. If you change the PARALLEL_LINES from 16 to 10, I think this example will be runnable again on C2

dreamcmi commented 2 years ago

@dreamcmi yes, OOM issue. If you change the PARALLEL_LINES from 16 to 10, I think this example will be runnable again on C2

Oh thanks, after I tried changing PARALLEL_LINES to 10 or 12, the ESP32C2 doesn't crash at runtime anymore. I created a pull requests to fix this and hopefully can be merged https://github.com/espressif/esp-idf/pull/9119