3

I am attempting to use an esp8266 to play an .mp3 audio file through a connected speaker using the 'ESP8266Audio' library.

I have tested that the hardware setup is correct (e.g. I have been able to play sounds from the speaker using a simple tone() function). I have also tested that the filesystem image is correctly built and uploaded because I have been able to list the files in the directory and read from simple text files that I have placed there.

Why is my code unable to process/play the audio file?

Here is my code:

 #include <Arduino.h>
 #include <LittleFS.h>
 #include <AudioFileSourceLittleFS.h>
 #include <AudioGeneratorMP3.h>
 #include <AudioOutputI2SNoDAC.h>
 
 AudioGeneratorMP3 *mp3;
 AudioFileSourceLittleFS *file;
 AudioOutputI2SNoDAC *out;
 
 void setup() {
 Serial.begin(9600);
 
 if (!LittleFS.begin()) {
 Serial.println("LittleFS initialization failed!");
 return;
 } else {
 Serial.println("LittleFS initialisation successful");
 }
 
 file = new AudioFileSourceLittleFS("/feet.mp3");
 if (!file->isOpen()) {
 Serial.println("Failed to open file.");
 return;
 } else {
 Serial.println("File opened successfully.");
 }
 
 out = new AudioOutputI2SNoDAC();
 out->SetOversampling(200);
 out->SetGain(2.0);
 
 mp3 = new AudioGeneratorMP3();
 if (mp3->begin(file, out)) {
 Serial.println("MP3 begin successful");
 } else {
 Serial.println("MP3 begin failed");
 }
 }
 
 void loop() {
 
 if (mp3->isRunning()) {
 if (!mp3->loop()) {
 Serial.println("MP3 loop failed");
 mp3->stop();
 } else {
 Serial.print("Free heap during loop: ");
 Serial.println(ESP.getFreeHeap());
 }
 } else {
 Serial.println("MP3 done");
 delay(1000);
 }
 }

The results of the exception decoder is:

 Exception (3):
 epc1=0x402046ae epc2=0x00000000 epc3=0x00000000 excvaddr=0x40249b36 depc=0x00000000
 
 LoadStoreError: Processor internal physical address or data error during load or store 
 epc1=0x402046ae in mad_layer_III at ??:?
 excvaddr=0x40249b36 in system_get_sdk_version at ??:?
 
 >>>stack>>>
 
 ctx: cont
 sp: 3ffffb40 end: 3fffffd0 offset: 0150
 3ffffc90: 00000000 00000000 00000000 006f0000
 3ffffca0: 00000000 00000000 0000f884 00000000
 3ffffcb0: 00000000 00000000 00000000 00000000
 3ffffcc0: 00000000 00000030 00000008 3ffe8368
 3ffffcd0: 4025dd3f 3ffe8368 40219f3c 00000004
 3ffffce0: 00000000 0000000a 3ffffd53 00000000
 3ffffcf0: 000000b0 00000000 3ffffd53 4025e128 
 3ffffd00: 4025e129 3ffe8368 3ffffdc0 02b2a450 
 3ffffd10: 009200c0 01000000 00ff050f 24070000 
 3ffffd20: 00000004 00000039 fe302064 3ffef64c
 3ffffd30: 00100408 3ffef9c0 00100408 00000000 
 3ffffd40: 00000000 00000000 0000001f 341002a8 
 3ffffd50: 00353930 400042db 3fffc228 40105af5 
 3ffffd60: 40004b31 3ffefa14 00000000 003435c0 
 3ffffd70: 3ffffe90 3ffffe80 00000014 4000050c
 3ffffd80: 3ffffe90 ffffff9d ffffff9d ffffff9d
 3ffffd90: ffffff9d ffffff9d ffffff9d ffffff9d 
 3ffffda0: ffffff9d ffffff9d ffffff9d ffffff9d 
 3ffffdb0: ffffff9d ffffff9d ffffff9d ffffff9d 
 3ffffdc0: ffffff9d ffffff9d ffffff9d ffffff9d
 3ffffdd0: ffffff9d ffffff9d ffffff9d 3ffe85e0 
 3ffffde0: 00000080 0000270f 00000000 00000030 
 3ffffdf0: 402079a8 00000030 00000008 ffffffff 
 3ffffe00: 402079a8 3fff12eb 3ffefa30 00000001 
 3ffffe10: 40100175 00000096 3ffefa30 00000001
 3ffffe20: 4000050c 40100138 3fffc270 4000050c 
 3ffffe30: 40100175 00000080 3fff0374 402174cd 
 3ffffe40: 3ffffe90 3ffffe80 0000000c 4000050c 
 3ffffe50: 4020b8f8 00000030 00000008 ffffffff 
 3ffffe60: 3fff0d04 00080010 40252660 40217540
 3ffffe70: 3fff536c 3fff5c6c 3fff0d01 00080010
 3ffffe80: ffffffe8 14000000 04000000 3ffffc90 
 3ffffe90: 40252664 3ffffd88 00000000 00000001 
 3ffffea0: 00000000 3fff1d3c 00000002 3ffffc90
 3ffffeb0: 00000000 00000000 3ffffe68 3fff536c
 3ffffec0: 00000000 00000000 000002b2 3fff12f4
 3ffffed0: 3fff1cf4 74612027 00000001 40251be4 
 3ffffee0: 74657366 3ffffc90 00000054 00000000 
 3ffffef0: 000000ab 3fff1324 00000057 00000057 
 3fffff00: 00000054 000000ab 00000004 3fff5c6c 
 3fffff10: 3fff1d3c 00000002 3fffff6c 3fff12f4
 3fffff20: 00000001 3fff1d3c 3fff1310 4020158f 
 3fffff30: 3fff12ec 00000000 6f726863 617a696e 
 3fffff40: 3fff12ec 00000001 3fff0374 00000000 
 3fffff50: 3fff1cf4 3fff12f4 3fff1d3c 402016b8 
 3fffff60: 0000270f 3fff0374 00000000 4020db7c
 3fffff70: 0000270f 3fff0384 3fff0374 4020d004 
 3fffff80: 0000270f 3fff0384 3fff0374 4020d161 
 3fffff90: 4020f19c 3ffe8b88 3ffee8fc 3ffeea6c 
 3fffffa0: 3fffdad0 3ffee8bc 3ffee8fc 4020c34f 
 3fffffb0: 3fffdad0 00000000 3ffeea40 402107bc
 3fffffc0: feefeffe feefeffe 3fffdab0 40100f11 
 <<<stack<<<
 
 0x4025dd3f in etharp_output at ??:?
 0x40219f3c in __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:179 
 0x4025e128 in etharp_output at ??:?
 0x4025e129 in etharp_output at ??:?
 0x40105af5 in ets_timer_disarm at ??:?
 0x402079a8 in lfs_bd_read at lfs.c:?
 0x402079a8 in lfs_bd_read at lfs.c:?
 0x40100175 in i2s_slc_isr at core_esp8266_i2s.cpp:?
 0x40100138 in i2s_slc_isr at core_esp8266_i2s.cpp:?
 0x40100175 in i2s_slc_isr at core_esp8266_i2s.cpp:?
 0x402174cd in vsnprintf at /workdir/repo/newlib/newlib/libc/stdio/vsnprintf.c:41
 0x4020b8f8 in lfs_file_read at ??:?
 0x40252660 in system_get_sdk_version at ??:?
 0x40217540 in snprintf_P at /workdir/repo/newlib/newlib/libc/sys/xtensa/stdio_pgmspace.c:33 
 0x40252664 in system_get_sdk_version at ??:?
 0x40251be4 in system_get_sdk_version at ??:?
 0x4020158f in mad_header_decode at ??:?
 0x402016b8 in mad_frame_decode at ??:?
 0x4020db7c in littlefs_impl::LittleFSFileImpl::read(unsigned char*, unsigned int) at ??:? 
 0x4020d004 in AudioGeneratorMP3::DecodeNextFrame() at ??:?
 0x4020d161 in AudioGeneratorMP3::loop() at ??:?
 0x4020f19c in HardwareSerial::write(unsigned char const*, unsigned int) at ??:?
 0x4020c34f in loop at ??:?
 0x402107bc in loop_wrapper() at core_esp8266_main.cpp:?
 0x40100f11 in cont_wrapper at ??:?

As an newbie to this world, any help would be greatly appreciated!

Rohit Gupta
6122 gold badges5 silver badges18 bronze badges
asked Oct 20, 2024 at 10:41
1
  • 1
    What messages appeared on the console before the stack trace ? Commented Oct 20, 2024 at 22:22

1 Answer 1

0

I found the source of my problems was that the most up to date version of the ESP8266Audio library (1.9.9) does not seem to be compatible with my setup. Reverting back to a previous revision of the library (1.9.7)

answered Oct 22, 2024 at 20:20

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.