I am a newbie to ESP32. Can you please suggest a solution...
Hardware: ESP32 KitC V4 ESP32-WROOM-32
IDE: Platform IO for VSCode
Framework: ESP IDF
Board: az-delivery-devkit-v4
For my project, i want to run inference of neural network model on my esp32. The inference code consists the following variables:
- static constexpr signed char layer_2_weight[3][3][1][32] = <constant values>;
- static constexpr signed char layer_2_bias[32] = <constant values>;
- static constexpr float layer_3_threshold[32] = <constant values>;
- static constexpr unsigned int layer_5_weight[3][3][32][1] = <constant values>;
- static constexpr signed char layer_5_bias[32] = <constant values>;
- static constexpr signed char layer_6_threshold[32] = <constant values>;
- static constexpr unsigned int layer_9_weight[32][25] = <constant values>;
- static constexpr signed char layer_9_bias[32] = <constant values>;
- static constexpr signed char layer_10_threshold[32] = {<constant values>;
- static constexpr unsigned int layer_11_weight[10][1] = <constant values>;
- static constexpr signed char layer_11_bias[10] = <constant values>;
- static double layer_2_output[26][26][32];
- static unsigned int layer_3_output[26][26][1];
- static unsigned int layer_4_output[13][13][1];
- static signed int layer_5_output[11][11][32];
- static unsigned int layer_6_output[11][11][1];
- static unsigned int layer_7_output[5][5][1];
- static signed int layer_9_output[32];
- static unsigned int layer_10_output[1];
- static signed int layer_11_output[10];
- void predict_model(double const * const x, double * pred)
- {
- //for loop for layers.
- }
- ---- Code end -------
For image buffers and uart buffers, 10kB is used is allocated using malloc().
I am transferring the image via UART and that aspect of the code runs perfectly when this predict_model function is not called.
Problem:
When predict_model is called, linker error comes that the data is overflown by certain amount of bytes.
- Linking .pio/build/az-delivery-devkit-v4/firmware.elf
- /home/divya/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/az-delivery-devkit-v4/firmware.elf section `.dram0.bss' will not fit in region `dram0_0_seg'
- /home/divya/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: DRAM segment data does not fit.
- /home/divya/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: DRAM segment data does not fit.
- /home/divya/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: region `dram0_0_seg' overflowed by 24848 bytes
- collect2: error: ld returned 1 exit status
- *** [.pio/build/az-delivery-devkit-v4/firmware.elf] Error 1
- /* Shared data RAM, excluding memory reserved for ROM bss/data/stack.
- Enabling Bluetooth & Trace Memory features in menuconfig will decrease
- the amount of RAM available.
- Note: Length of this section *should* be 0x50000, and this extra DRAM is available
- in heap at runtime. However due to static ROM memory usage at this 176KB mark, the
- additional static memory temporarily cannot be used.
- */
- dram0_0_seg (RW) : org = 0x3FFB0000 + CONFIG_BT_RESERVE_DRAM,
- // len = DRAM0_0_SEG_LEN
- len = 0x50000 // changed value
Question 2 - After these modifications, the ESP32 getting automatically resets after flashing with above changes on power on(hard reset).
Error code:
- Rebooting...
- ets Jun 8 2016 00:22:57
- rst:0xc (SW_CPU_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:0x3fff0030,len:7560
- load:0x40078000,len:14912
- load:0x40080400,len:3688
- entry 0x4008067c
- ␛[0;32mI (27) boot: ESP-IDF 4.3.2 2nd stage bootloader␛[0m
- ␛[0;32mI (27) boot: compile time 23:17:23␛[0m
- ␛[0;32mI (27) boot: chip revision: 1␛[0m
- ␛[0;32mI (30) boot_comm: chip revision: 1, min. bootloader chip revision: 0␛[0m
- ␛[0;32mI (37) boot.esp32: SPI Speed : 40MHz␛[0m
- ␛[0;32mI (42) boot.esp32: SPI Mode : DIO␛[0m
- ␛[0;32mI (46) boot.esp32: SPI Flash Size : 4MB␛[0m
- ␛[0;32mI (51) boot: Enabling RNG early entropy source...␛[0m
- ␛[0;32mI (56) boot: Partition Table:␛[0m
- ␛[0;32mI (60) boot: ## Label Usage Type ST Offset Length␛[0m
- ␛[0;32mI (67) boot: 0 nvs WiFi data 01 02 00009000 00006000␛[0m
- ␛[0;32mI (74) boot: 1 phy_init RF data 01 01 0000f000 00001000␛[0m
- ␛[0;32mI (82) boot: 2 factory factory app 00 00 00010000 00100000␛[0m
- ␛[0;32mI (89) boot: End of partition table␛[0m
- ␛[0;32mI (93) boot_comm: chip revision: 1, min. application chip revision: 0␛[0m
- ␛[0;32mI (101) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=09f30h ( 40752) map␛[0m
- ␛[0;32mI (124) esp_image: segment 1: paddr=00019f58 vaddr=3ffb0000 size=02988h ( 10632) load␛[0m
- ␛[0;32mI (128) esp_image: segment 2: paddr=0001c8e8 vaddr=40080000 size=03730h ( 14128) load␛[0m
- ␛[0;32mI (136) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=16bb0h ( 93104) map␛[0m
- ␛[0;32mI (172) esp_image: segment 4: paddr=00036bd8 vaddr=40083730 size=08aa4h ( 35492) load␛[0m
- ␛[0;32mI (187) esp_image: segment 5: paddr=0003f684 vaddr=50000000 size=00010h ( 16) load␛[0m
- ␛[0;32mI (193) boot: Loaded app from partition at offset 0x10000␛[0m
- ␛[0;32mI (193) boot: Disabling RNG early entropy source...␛[0m
- Re-enable cpu cache.
- Guru Meditation Error: Core 0 panic'ed (IntegerDivideByZero). Exception was unhandled.
- Core 0 register dump:
- PC : 0x4008afb1 PS : 0x00060730 A0 : 0x8008b00c A1 : 0x3ffe3c00
- A2 : 0x00fdffb3 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00001000
- A6 : 0x3ffe3ba2 A7 : 0x00000002 A8 : 0x00000000 A9 : 0x00000000
- A10 : 0x20000000 A11 : 0x00000000 A12 : 0x00000014 A13 : 0x3ffe3bf4
- A14 : 0x00000007 A15 : 0x00000006 SAR : 0x00000010 EXCCAUSE: 0x00000006
- EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
- Backtrace:0x4008afae:0x3ffe3c00 0x4008b009:0x3ffe3c20 0x4008170b:0x3ffe3c40 0x40079508:0x3ffe3c80 |<-CORRUPTED
- ELF file SHA256: d0070a14dd27e9ef