Espressif skainet demo - Data cache error when trying to run with arduinoesp32

Hello,

I am trying to re-create a demo (esp-skainet/examples/cn_speech_commands_recognition at master · espressif/esp-skainet · GitHub) from esp idf 4.4 in the framework-arduinoespressif32(current version). The board I am using is a esp32s3-devkit-c with 8gb psram and 8 gb flash. The code is compiling and I am able to flash board, but almost as soon as the application starts I get errors on console and esp32 resets again and again. Here is message.

,
load:0x403cc700,len:0x2a3c
entry 0x403c98d8
[ 165][I][esp32-hal-psrPSRAM initialized successfully
E (4) SR_SYS: Data cache should be 64KB
E (4) SR_SYS: Data cache line should be 64B
␛[0;31mE (4) AFE_SR: sample_rate only support 16000, please modify it!
␛[0m
␛[0;31mE (9) AFE_SR: AFE config error!
␛[0m
␛[0;31mE (13) AFE_SR: afe_get_fetch_chunksz: afe data is NULL!
␛[0m
-␛[0;31mE (203) AFE_SR: afe_get_feed_chunksz: afe data is NULL!
␛[0m
␛[0;31mE (209) AFE_SR: afe_get_channel_num: afe data is NULL!
␛[0m

assert failed: void feed_Task(void*) main.cpp:27 (i2s_buff)

In the application a buffer for i2s data is created and evidentially designed to be stored in the data cache of the ram. This makes sense due to the performance needed to detect speech. I believe this error is due to these two items not being set, as it would be in skdconfig. I tried putting them into platformio.ini file, but didn’t see to help.

CONFIG_ESP32S3_DATA_CACHE_64KB=y
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y

Also, I am not sure if this setting affects the linker files memory.ld and section.ld dynamically during the build? If someone could help me out, I would appreciate it. If you don’t know answer maybe you could point me in the right direction.

I know that I could run if I wasn’t using arduinoesp32, but I want to use existing arduino libraries with the demo code from espressif.

Thanks

When using framework = arduino, the ESP-IDF base is precompiled and unchangable. You cannot change ESP-IDF settings afterward.

Use framework = espidf as the original project intends it. Or, framework = arduino, espidf as a combined framework, as seen e.g. here.

Mhm. The project https://github.com/maxgerhardt/pio-esp-skainet should be what it needs, but there’s a linking error at the end, ld.exe: group ended before it began. This might be a bug in the PlatformIO integration for ESP-IDF / CMake…

1 Like

I’ve written an ugly workaround against that and now it compiles.

Of course, make sure to select the right board type for it to fully work, the I2S pins etc. But the Data cache should be 64KB errors should be gone. And also, the example is for a partition table expecting 16MB of flash, not 8MB. And certainly not “Gigabytes”. So change the partition tables and flash size at your own risk.

Thanks for your help Max, that worked out well.

I have an ESP32S3 Devkit C as well (8mb of psram and 16 mb of flash), but I cannot seem to find where to alter the I2S pins. However, it is also possible I just have the wrong board selected and do not know it. This issue seems to be causing the following errors:
␛[0;31mE (882) I2C_If: Fail to write to dev 80␛[0m
␛[0;31mE (891) ES7210: Write register fail␛[0m
␛[0;31mE (895) ES7210: Open fail␛[0m
␛[0;32mI (899) Adev_Codec: Open codec device OK␛[0m
␛[0;31mE (904) I2C_If: Fail to write to dev 30␛[0m
␛[0;31mE (953) I2C_If: Fail to read from dev 30␛[0m
␛[0;32mI (958) ES8311: Work in Slave mode␛[0m
␛[0;31mE (962) I2C_If: Fail to write to dev 30␛[0m
␛[0;31mE (998) ES8311: Open fail␛[0m
␛[0;32mI (1001) Adev_Codec: Open codec device OK␛[0m
␛[0;32mI (1006) AFE_SR: afe interface for speech recognition
␛[0m
␛[0;32mI (1012) AFE_SR: AFE version: SR_V220727
␛[0m
␛[0;32mI (1017) AFE_SR: Initial auido front-end, total channel: 2, mic num: 1, ref num: 1
␛[0m
␛[0;32mI (1025) AFE_SR: aec_init: 1, se_init: 1, vad_init: 1
␛[0m
␛[0;32mI (1031) AFE_SR: wakenet_init: 1
␛[0m
␛[0;31mE (1079) AFE_SR: ERROR: Please select wake words!
␛[0m

Any help would be great.
Thanks

You see that based on the activated macros in the sdkconfig, the hardware_driver components selects different .c files to be built, which in turn contain the expected pins.

See

https://github.com/maxgerhardt/pio-esp-skainet/blob/main/components/hardware_driver/CMakeLists.txt

and with the current settings

it’s gonna expect a ES7210 codec and I2S pins for microphone etc as listed here.

1 Like

Thanks again Max, you helped out greatly.

I’m sorry Max, your solution worked and I successfully had my project going until I needed to clear a previous flash from another program (On Arduino IDE) and proceeded to do: esptool.py --chip esp32s3 --port (my port) erase_flash.
When I went back to flash the project onto my device it seemed to stop working and I was getting this:
␛[0;32mI (757) spiram: Adding pool of 8192K of external SPI memory to heap allocator␛[0m
␛[0;32mI (765) spi_flash: detected chip: boya␛[0m
␛[0;32mI (769) spi_flash: flash io: qio␛[0m
␛[0;32mI (774) sleep: Configure to isolate all GPIO pins in sleep state␛[0m
␛[0;32mI (780) sleep: Enable automatic switching of GPIO sleep configuration␛[0m
␛[0;32mI (787) cpu_start: Starting scheduler on PRO CPU.␛[0m
␛[0;32mI (0) cpu_start: Starting scheduler on APP CPU.␛[0m
␛[0;32mI (803) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations␛[0m
[ 807][E][esp32-hal-misc.c:264] initArduino(): Failed to initialize NVS! Error: 261
␛[0;32mI (830) MODEL_LOADER: The storage free size is 23424 KB␛[0m
␛[0;32mI (831) MODEL_LOADER: The partition size is 5168 KB␛[0m
␛[0;32mI (832) MODEL_LOADER: Successfully map model partition␛[0m
␛[0;32mI (837) I2S: DMA Malloc info, datalen=blocksize=640, dma_buf_count=6␛[0m
␛[0;32mI (844) AFE_SR: afe interface for speech recognition
␛[0m
␛[0;32mI (850) AFE_SR: AFE version: SR_V220727
␛[0m
␛[0;32mI (854) AFE_SR: Initial auido front-end, total channel: 2, mic num: 1, ref num: 1
␛[0m
␛[0;32mI (863) AFE_SR: aec_init: 1, se_init: 1, vad_init: 1
␛[0m
␛[0;32mI (868) AFE_SR: wakenet_init: 1
␛[0m
␛[0;31mE (916) AFE_SR: ERROR: Please select wake words!
␛[0m
Guru Meditation Error: Core 1 panic’ed (LoadProhibited). Exception was unhandled.

I tried using another unopened, identical ESP32-S3 that I had on hand, but I encountered the same error. I’m not sure what I might have done, but any assistance you can provide would be greatly appreciated.

Thank you.