Description
Problem Description
Default max_buffer_len is 1024 in the example. Increasing it to 4096 causes a crash and reboot of the ESP32-S3:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:1
load:0x3fce3818,len:0x438
load:0x403c9700,len:0x4
load:0x403c9704,len:0x9ac
load:0x403cc700,len:0x2758
entry 0x403c9868
[ 136][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42006aa8
[ 147][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x42006a74
[ 158][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42006a40
[ 170][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42006a0c
[ 181][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42006aa8
[ 192][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x42006a74
[ 204][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42006a40
[ 215][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42006a0c
[ 226][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42006aa8
[ 238][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x42006a74
[ 249][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42006a40
[ 260][V][esp32-hal-periman.c:229] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42006a0c
[ 281][V][esp32-hal-periman.c:154] perimanSetPinBus(): Pin 44 successfully set to type UART_RX (2) with bus 0x3fc94000
[ 292][V][esp32-hal-periman.c:154] perimanSetPinBus(): Pin 43 successfully set to type UART_TX (3) with bus 0x3fc94000
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
Model : ESP32-S3
Package : 0
Revision : 1
Cores : 2
Frequency : 240 MHz
Embedded Flash : No
Embedded PSRAM : No
2.4GHz WiFi : Yes
Classic BT : No
BT Low Energy : Yes
IEEE 802.15.4 : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
Total Size : 393404 B ( 384.2 KB)
Free Bytes : 361756 B ( 353.3 KB)
Allocated Bytes : 26664 B ( 26.0 KB)
Minimum Free Bytes: 356568 B ( 348.2 KB)
Largest Free Block: 327668 B ( 320.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
Chip Size : 33554432 B (32 MB)
Block Size : 65536 B ( 64.0 KB)
Sector Size : 4096 B ( 4.0 KB)
Page Size : 256 B ( 0.2 KB)
Bus Speed : 80 MHz
Bus Mode : OPI
------------------------------------------
Partitions Info:
------------------------------------------
nvs : addr: 0x00009000, size: 20.0 KB, type: DATA, subtype: NVS
otadata : addr: 0x0000E000, size: 8.0 KB, type: DATA, subtype: OTA
app0 : addr: 0x00010000, size: 3264.0 KB, type: APP, subtype: OTA_0
app1 : addr: 0x00340000, size: 3264.0 KB, type: APP, subtype: OTA_1
spiffs : addr: 0x00670000, size: 1536.0 KB, type: DATA, subtype: SPIFFS
coredump : addr: 0x007F0000, size: 64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
Compile Date/Time : Jan 22 2024 22:35:06
ESP-IDF Version : v5.1.2-622-g47b44dfa71-dirty
Arduino Version : 3.0.0
------------------------------------------
Board Info:
------------------------------------------
Arduino Board : Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM)
Arduino Variant : esp32s3
Core Debug Level : 5
Arduino Runs Core : 1
Arduino Events on : 1
Arduino USB Mode : 1
CDC On Boot : 0
============ Before Setup End ============
[ 1604][V][esp32-hal-uart.c:396] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(44) txPin(43)
[ 1613][V][esp32-hal-uart.c:482] uartBegin(): UART0 not installed. Starting installation
[ 1621][V][esp32-hal-uart.c:527] uartBegin(): UART0 initialization done.
starting ADC...
[ 1628][V][esp32-hal-periman.c:154] perimanSetPinBus(): Pin 5 successfully set to type ADC_CONT (8) with bus 0x1
[ 1639][V][esp32-hal-periman.c:154] perimanSetPinBus(): Pin 6 successfully set to type ADC_CONT (8) with bus 0x1
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
Total Size : 393404 B ( 384.2 KB)
Free Bytes : 336604 B ( 328.7 KB)
Allocated Bytes : 51336 B ( 50.1 KB)
Minimum Free Bytes: 331600 B ( 323.8 KB)
Largest Free Block: 303092 B ( 296.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
GPIO : BUS_TYPE[bus/unit][chan]
--------------------------------------
5 : ADC_CONT[0][4]
6 : ADC_CONT[0][5]
43 : UART_TX[0]
44 : UART_RX[0]
============ After Setup End =============
Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (loopTask)
Core 1 register dump:
PC : 0x400570e8 PS : 0x00060836 A0 : 0x820027c3 A1 : 0x3fce9f40
A2 : 0x3fce9f50 A3 : 0x00000000 A4 : 0x00002000 A5 : 0x3fcea180
A6 : 0x00000005 A7 : 0x00000200 A8 : 0x3fcf15f4 A9 : 0x00060023
A10 : 0xb33fffff A11 : 0xb33fffff A12 : 0x00000000 A13 : 0x3fc958d0
A14 : 0x00060023 A15 : 0x00000001 SAR : 0x00000010 EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0x000001dc
Backtrace: 0x400570e5:0x3fce9f40 0x420027c0:0x3fce9f50 0x420029d6:0x3fcebf�x���x����������x���������x����xxxxx�x�x���x�������������x�����x����xxxxx�x�x���x��������������xx���x����xxxxx�x��x�xx�xx�xx�xx�xxx�xx���x��x�xxx���x�xx��x����������x������x������x�x��������x���xx��xx�x��xx�xx�x�x�x��x�x�xx�x�xx�xESP-ROM:esp32s3-20210327
Note that I also had to lower the sample_rate down to 22050 since the default 44100 caused this issue:
starting ADC... [E] AnalogAudioESP32V1.h : 470 - sample rate eff: 88200 can not be set, range: 611 to 83333
Device Description
ESP32-S3-DevKitC-1-N32R8V
Sketch
/**
* @file adc-serial.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/adc-serial/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
* #TODO retest is outstanding
*/
#include "Arduino.h"
#include "AudioTools.h"
AnalogAudioStream adc;
const int32_t max_buffer_len = 4096;
uint8_t buffer[max_buffer_len];
// Arduino Setup
void setup(void) {
delay(1000); // wait for serial to become available
Serial.begin(115200);
// Include logging to serial
AudioLogger::instance().begin(Serial, AudioLogger::Warning); //Warning, Info, Error, Debug
auto adcConfig = adc.defaultConfig(RX_MODE);
// For ESP32 by Espressif Systems version 3.0.0 and later:
// see examples/README_ESP32.md
adcConfig.sample_rate = 22050;
adcConfig.adc_bit_width = 12;
adcConfig.adc_calibration_active = true;
adcConfig.is_auto_center_read = false;
adcConfig.adc_attenuation = ADC_ATTEN_DB_6;
adcConfig.channels = 2;
adcConfig.adc_channels[0] = ADC_CHANNEL_4;
adcConfig.adc_channels[1] = ADC_CHANNEL_5;
Serial.println("starting ADC...");
adc.begin(adcConfig);
}
// Arduino loop - repeated processing
void loop() {
size_t len = adc.readBytes(buffer, max_buffer_len);
int16_t *sample = (int16_t*) buffer;
int size = len / 4;
for (int j=0; j<size; j++){
Serial.print(*sample++);
Serial.print(", ");
Serial.println(*sample++);
}
}
Other Steps to Reproduce
The Arduino framework that comes by default in platformIO is based on esp-idf 4.4.6.
I may have bodged the install of the latest Arduino framework to get it to work, that may explain the errors I'm getting.
If there is a better way to getting this to work please let me know :)
Here is the content of platform.ini for reference:
[platformio]
description = Audio Example
default_envs = esp32dev
[env:esp32dev]
platform = https://github.com/sgryphon/platform-espressif32.git#sgryphon/add-esp32-arduino-libs
platform_packages =
platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#master
platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
board = esp32-s3-devkitc-1
framework = arduino
board_build.arduino.memory_type = opi_opi
lib_deps = https://github.com/pschatzmann/arduino-audio-tools
build_flags = -DCORE_DEBUG_LEVEL=5 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-format-extra-args
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
What is your development environment
PlatformIO with Arduino ESP32 alpha v3.0.0 based on ESP-IDF v5.1 for ESP32-S3 support in platformIO.
see platformio/platform-espressif32#1281
I have checked existing issues, discussions and online documentation
- I confirm I have checked existing issues, discussions and online documentation