Closed steve6375 closed 1 year ago
Finding a trade-off between storage usage and features is difficult. Without PSRAM with I2S DAC only mp3 and aac will work properly. 1) The InBuffer, which temporarily stores the raw audio data, is about 16000 bytes large without PSRAM and about 640000 bytes with PSRAM. So FLAC with a block size of 8KB, only 2 frames fit into the buffer, which is very little. 2) Some WLAN functions are swapped out to the PSRAM, if available 3) mbetTLS (https://...) needs more than 20KB and should therefore be written to PSRAM. 4) VS1053 is a HW decoder, the SW decoders need additional memory, PSRAM is used where possible 5) I reduced the stack in the audio task by 2000 DWORDs (8000bytes), that might help. If you click on the question mark, the 'highest water level' is displayed in the log. There should still be some space at the top, if you reach zero there is a risk of a crash. If you want to use all functions, PSRAM is advisable. Especially OPUS, VORBIS and FLAC are very memory hungry.
Thanks for reply. Changing CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC didn't help. The memory stats when using the test ? button in the web ui station screen dont show much difference (but playing some radio stations cause buffer errors as soon as they are played on the DAC still). I guess an esp32 with PSRAM is needed. Do you have a recommendation for a suitable esp32, audio board and TFT that will work the best? Is any model of esp32+PSRAM OK?
An ESP32 with 4MB PSRAM is sufficient. PSRAM is faster with ESP32-S3, even faster with octal PSRAM. AAC with SBR is then also activated for the S3 (only ext. DAC). An external DAC would also be good, like PCM5102 instead of the old VS1053B
FreeNove WROVER + PSRAM + camera board with PCM5102 solves the problem.
I get warnings
08:21:06 AUDIO_info: slow stream, dropouts are possible 08:21:07 AUDIO_info: slow stream, dropouts are possible 08:21:08 AUDIO_info: slow stream, dropouts are possible
but seems OK.
I have both a VS1053B and PCM5102A DAC connected to an esp32. The only problem the VS1053 has is that m4a files don't seem to play and sometimes flac files dont fully play. SD card works OK and esp32 doesn't crash.
I used 'Release' build (not debug) and -DCORE_DEBUG_LEVEL=5
So I tried the DAC and just changed DECODER to 1 and recompiled. With DAC it does play m4a (not FLAC files as no PSRAM) and some radio stations but on other stations it will give memory errors and also reads and writes to SD card often fail and leaves blank stations.csv or settings.csv. Also crashes on occasion even from fresh boot. I tried several clean rebuilds but still a problem. I am using the small buttons previous build still (not latest main) release.
Is it using too much memory and is there anything I can do to make DAC work reliably?
This is DECODER = 0 which is basically stable and OK:
This is DECODER = 1
various runs...
[164433][V][ssl_client.cpp:321] stop_ssl_socket(): Cleaning SSL connection. 17:18:44 AUDIO_info: buffers freed, free Heap: 67152 bytes 17:18:44 AUDIO_info: Connection has been established in 14 ms, free Heap: 66244 bytes [164494][E][Audio.cpp:2399] readPlayListData(): m3u8 playlists requires PSRAM enabled! 17:18:44 AUDIO_info: new request: "http://as-hls-uk-live.akamaized.net/pool_904/live/uk/bbc_radio_fourfm/bbc_radio_fourfm.isml/bbc_radio_fourfm-audio=96000-263691176.ts" 17:18:44 AUDIO_info: AACDecoder has been initialized, free Heap: 20272 bytes , free stack 2600 DWORDs 17:18:44 AUDIO_info: syncword found at pos 0 17:18:44 AUDIO_info: Channels: 2 17:18:44 AUDIO_info: SampleRate: 24000 17:18:44 AUDIO_info: BitsPerSample: 16 17:18:44 AUDIO_info: BitRate: 90374 17:18:44 AUDIO_info: AAC HeaderFormat: ADTS 17:18:44 AUDIO_info: AAC Codec: MPEG-4 LowComplexity 17:18:44 AUDIO_info: VBR recognized, audioFileDuration is estimated 17:18:45 file "/logo/s/BBC Radio 4 hls LOW rate.jpg" not found 17:18:45 HTML_info: SD/logo/BBC Radio 4 hls LOW rate .jpg 17:18:45 WS_onCmd: cmd="SD/logo/BBC Radio 4 hls LOW rate .jpg", params="t=1687623525741", arg="" 17:18:45 HTML_info: Length of file /common/s/unknown.jpg is 3187 [165367][E][WiFiClient.cpp:422] write(): fail on fd 54, errno: 11, "No more processes" 17:18:45 Audiocodec: AAC 17:18:46 HTML_info: SD/common/M3U8.jpg 17:18:46 WS_onCmd: cmd="SD/common/M3U8.jpg", params="t=1687623526281", arg="" 17:18:46 HTML_info: Length of file /common/s/M3U8.jpg is 8861 [165816][E][WiFiClient.cpp:422] write(): fail on fd 54, errno: 11, "No more processes" [166106][E][WiFiClient.cpp:422] write(): fail on fd 54, errno: 11, "No more processes" 17:18:50 AUDIO_info: new request: "http://as-hls-uk-live.akamaized.net/pool_904/live/uk/bbc_radio_fourfm/bbc_radio_fourfm.isml/bbc_radio_fourfm-audio=96000-263691177.ts"
17:22:53 HTML_info: next_station 17:22:53 WS_onCmd: cmd="next_station", params="", arg="" 17:22:53 in setStation 2 17:22:53 action: ... switch to station 2 17:22:54 IN connecttohost https://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_radio_fourfm.m3u8 17:22:54 AUDIO_info: Connect to new host: "https://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_radio_fourfm.m3u8" [413908][V][ssl_client.cpp:321] stop_ssl_socket(): Cleaning SSL connection. 17:22:54 AUDIO_info: buffers freed, free Heap: 69348 bytes [413936][V][ssl_client.cpp:62] start_ssl_client(): Free internal heap before TLS 69348 [413937][V][ssl_client.cpp:68] start_ssl_client(): Starting socket [413952][V][ssl_client.cpp:146] start_ssl_client(): Seeding the random number generator [413953][V][ssl_client.cpp:155] start_ssl_client(): Setting up the SSL/TLS structure... [413959][D][ssl_client.cpp:176] start_ssl_client(): WARNING: Skipping SSL Verification. INSECURE! [413968][V][ssl_client.cpp:254] start_ssl_client(): Setting hostname for TLS session... [413977][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():264]: (-32512) SSL - Memory allocation failed [413988][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -32512 [413997][V][ssl_client.cpp:321] stop_ssl_socket(): Cleaning SSL connection. 17:22:54 AUDIO_info: Request https://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_radio_fourfm.m3u8 failed! 17:22:54 StreamTitle: 17:22:54 HTML_info: SD/logo/BBC Radio 4.jpg 17:22:54 WS_onCmd: cmd="SD/logo/BBC Radio 4.jpg", params="t=1687623774793", arg="" 17:22:54 HTML_info: Length of file /logo/s/BBC Radio 4.jpg is 2980
------- RESET EXAMPLE ....
17:58:00 bitRate: 56Kbit/s 17:58:00 bitRate: 56Kbit/s 17:58:00 AUDIO_info: icy-name: BBC Radio 17:58:00 StationName: BBC Radio 17:58:00 icy-descr: BBC Radio [ 11618][E][mp3_decoder.cpp:1555] MP3Decoder_AllocateBuffers(): not enough memory to allocate mp3decoder buffers 17:58:00 AUDIO_info: The MP3Decoder could not be initialized [ 11628][D][SoapESP32.cpp:253] soapSSDPquery(): received SSDP packet within 34 ms: packet size: 364 [ 11644][V][SoapESP32.cpp:259] soapSSDPquery(): SSDP packet content: HTTP/1.1 200 OK CACHE-CONTROL: max-age=1800 DATE: Sat, 24 Jun 2023 16:57:59 GMT ST: urn:schemas-upnp-org:device:MediaServer:1 USN: uuid:4d696e69-444c-164e-9d41-caabf0f3bf33::urn:schemas-upnp-org:device:MediaServer:1 EXT: SERVER: 2.6.35.6-45.fc14.i686 DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.1.0 LOCATION: http://192.168.1.1:8200/rootDesc.xml Content-Length: 0
[ 11683][D][SoapESP32.cpp:276] soapSSDPquery(): scanned ip=192.168.1.1, port=8200, location="rootDesc.xml" [ 11718][D][SoapESP32.cpp:253] soapSSDPquery(): received SSDP packet within 124 ms: packet size: 364 [ 11718][V][SoapESP32.cpp:259] soapSSDPquery(): SSDP packet content: HTTP/1.1 200 OK CACHE-CONTROL: max-age=1800 DATE: Sat, 24 Jun 2023 16:57:59 GMT ST: urn:schemas-upnp-org:device:MediaServer:1 USN: uuid:4d696e69-444c-164e-9d41-caabf0f3bf33::urn:schemas-upnp-org:device:MediaServer:1 EXT: SERVER: 2.6.35.6-45.fc14.i686 DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.1.0 LOCATION: http://192.168.1.1:8200/rootDesc.xml Content-Length: 0
[ 11756][D][SoapESP32.cpp:276] soapSSDPquery(): scanned ip=192.168.1.1, port=8200, location="rootDesc.xml" 17:58:04 DLNA_info: SSDP query discovered 1 media servers [ 15624][D][SoapESP32.cpp:1182] soapGet(): 192.168.1.1:8200 GET /rootDesc.xml HTTP/1.1 17:58:04 DLNA_info: connected successfully to 192.168.1.1:8200 [ 15638][E][WiFiClient.cpp:67] fillBuffer(): Not enough memory to allocate buffer [ 15638][E][WiFiClient.cpp:467] read(): fail on fd 53, errno: 119, "Connection already in progress" [ 16638][E][SoapESP32.cpp:317] soapReadHttpHeader(): header line: 17:58:05 DLNA_info: this Server does not deliver media content [ 16649][I][WiFiClient.cpp:549] connected(): Unexpected: RES: 0, ERR: 119 [ 16649][E][WiFiClient.cpp:67] fillBuffer(): Not enough memory to allocate buffer [ 16655][E][WiFiClient.cpp:467] read(): fail on fd 53, errno: 119, "Connection already in progress" [ 17649][E][websrv.cpp:361] handlehttp(): Command client schould be available but is not! 17:58:06 Audiocodec: MP3 17:58:06 ftpServer: Ftp server waiting for connection on port 21 [ 17994][E][WiFiClient.cpp:67] fillBuffer(): Not enough memory to allocate buffer [ 17994][E][WiFiClient.cpp:467] read(): fail on fd 53, errno: 11, "No more processes" [ 18994][E][websrv.cpp:361] handlehttp(): Command client schould be available but is not!
abort() was called at PC 0x4019682b on core 1
Backtrace: 0x400836f1:0x3ffd1c10 0x4008e5a9:0x3ffd1c30 0x4009861d:0x3ffd1c50 0x4019682b:0x3ffd1cd0 0x40196872:0x3ffd1cf0 0x40196b5d:0x3ffd1d10 0x40196c1c:0x3ffd1d30 0x40120752:0x3ffd1d50 0x401208f9:0x3ffd1d80 0x40117341:0x3ffd1e10 0x400d9535:0x3ffd1e40 0x400dc7af:0x3ffd1ea0 0x400dc8aa:0x3ffd1f00 0x40116075:0x3ffd1f20
0 0x400836f1:0x3ffd1c10 in panic_abort at C:\Users\Steve.platformio\packages\framework-espidf\components\esp_system/panic.c:408
1 0x4008e5a9:0x3ffd1c30 in esp_system_abort at C:\Users\Steve.platformio\packages\framework-espidf\components\esp_system/esp_system.c:137
2 0x4009861d:0x3ffd1c50 in abort at C:\Users\Steve.platformio\packages\framework-espidf\components\newlib/abort.c:46
3 0x4019682b:0x3ffd1cd0 in cxxabiv1::terminate(void (*)()) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
4 0x40196872:0x3ffd1cf0 in std::terminate() at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
5 0x40196b5d:0x3ffd1d10 in __cxa_allocate_exception at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_alloc.cc:300
6 0x40196c1c:0x3ffd1d30 in operator new(unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/new_op.cc:54
7 0x40120752:0x3ffd1d50 in gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<VFSFileImpl, std::allocator, ( gnu_cxx::_Lock_policy)2> >::allocate(unsigned int, void const*) at c:\users\steve.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\ext/new_allocator.h:111
char const&, char const&) at c:\users\steve.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\bits/shared_ptr.h:359 (inlined by) std::shared_ptr std::allocate_shared<VFSFileImpl, std::allocator, VFSImpl, char const&, char const&>(std::allocator const&, VFSImpl &&, char const&, char const&) at c:\users\steve.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\bits/shared_ptr.h:706
(inlined by) std::shared_ptr std::make_shared<VFSFileImpl, VFSImpl, char const&, char const&>(VFSImpl&&, char const&, char const&) at c:\users\steve.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\bits/shared_ptr.h:722
8 0x401208f9:0x3ffd1d80 in VFSImpl::open(char const, char const, bool) at C:/Users/Steve/.platformio/packages/framework-arduinoespressif32-src-52b8cdec3e60619426e51a1d18d1c3fa/libraries/FS/src/vfs_api.cpp:47
9 0x40117341:0x3ffd1e10 in fs::FS::open(char const, char const, bool) at C:/Users/Steve/.platformio/packages/framework-arduinoespressif32-src-52b8cdec3e60619426e51a1d18d1c3fa/libraries/FS/src/FS.cpp:234
10 0x400d9535:0x3ffd1e40 in updateSettings() at src/main.cpp:417
11 0x400dc7af:0x3ffd1ea0 in check_1sec() at src/main.cpp:2243
12 0x400dc8aa:0x3ffd1f00 in loop() at src/main.cpp:2269 (discriminator 1)
13 0x40116075:0x3ffd1f20 in loopTask(void*) at C:/Users/Steve/.platformio/packages/framework-arduinoespressif32-src-52b8cdec3e60619426e51a1d18d1c3fa/cores/esp32/main.cpp:50
ELF file SHA256: b3d397abfc4fb8c7
E (12025) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0 Rebooting... ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)