However, that doesn’t mean that you can’t get this to work. I simply added all the ESP-ADFs “components” as libraries in a project, added the needed include (-I), library paths (-L) and defines (-D) and the play_mp3_dac example compiles fine.
when embedding files, they should be in the top root of the project, not in src. When you put them in src/ the name of the object will change to include the src path, and examples don’t work unless you change the filename in the asm statement
the esp_http_client libraries is inside there twice, in newer ESP-IDF and as a component in ESP-ADF. I haven’t found a pretty way to un-include it automatically except with a static build_unflags. You need to change the path to match your system. (using $PIOHOME_DIR inside the build_unflags failed )
When you want to use other ESP-ADF components, modify the platformio.ini
add the components include/ folder to the -I flags
add the lib name to lib_deps
if the library contains a static library file (*.a), add the path to it to the library search path using -L and -l
The clean way would be to add this as “framework”. Since ESP-ADF is on top of the ESP-IDF framework, this works too…
I haven’t attempted such a thing myself. But there’s documentation available on setting up a custom platform and board (here); A platform would include a range of frameworks (and toolchains). However in this case we already have the espressif32 platform and its espidf framework, so you don’t want to create a new platform from scratch. You just want to add a new framework (which is 99% based on ESP-IDF). For that, the starting point would be platform-espressif32/builder/frameworks at develop · platformio/platform-espressif32 · GitHub. Reading the espidf.py it seems for ESP-ADF you’d just need a few more components entries.
This used to work until espressif updated esp-adf a few days ago and now I can’t get your git-hub example code working anymore … I fixed all the missing include paths but now i get a ton of linker errors that I can’t solve
Any chance you could update it to work again?
Thanks!
.pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_ldfw.o: In function main': tw_ldfw.c:(.text.startup.main+0x0): multiple definition ofmain’
.pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_ldcfg.o:tw_ldcfg.c:(.text.startup.main+0x0): first defined here
.pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_ldfwcfg.o: In function main': tw_ldfwcfg.c:(.text.startup.main+0x0): multiple definition ofmain’
.pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_ldcfg.o:tw_ldcfg.c:(.text.startup.main+0x0): first defined here
.pioenvs\esp32dev\src\play_sdcard_mp3_example.o:(.literal.app_main+0x78): undefined reference to mp3_decoder_init' .pioenvs\esp32dev\src\play_sdcard_mp3_example.o: In functionapp_main’:
play_sdcard_mp3_example.c:(.text.app_main+0x198): undefined reference to mp3_decoder_init' .pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_spi_access.o:(.literal.tw_upload_dsp_firmware+0x14): undefined reference tost_twFirmware’
.pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_spi_access.o:(.literal.tw_upload_dsp_firmware+0x18): undefined reference to firmwareStreamLen' .pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_spi_access.o:(.literal.tw_upload_dsp_firmware+0x1c): undefined reference toexecutionAddress’
.pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_spi_access.o:(.literal.tw_upload_dsp_firmware+0x20): undefined reference to haveProgramBaseAddress' .pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_spi_access.o:(.literal.tw_upload_dsp_firmware+0x24): undefined reference toprogramBaseAddress’
.pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_spi_access.o:(.literal.tw_upload_dsp_firmware+0x48): undefined reference to configStreamLen' .pioenvs\esp32dev\lib82d\audio_hal\driver\zl38063\example_apps\tw_spi_access.o:(.literal.tw_upload_dsp_firmware+0x4c): undefined reference tost_twConfig’
.pioenvs\esp32dev\lib6bd\audio_stream\fatfs_stream.o:(.literal._fatfs_close+0x14): undefined reference to wav_head_init' .pioenvs\esp32dev\lib6bd\audio_stream\fatfs_stream.o:(.literal._fatfs_close+0x18): undefined reference towav_head_size’
.pioenvs\esp32dev\lib6bd\audio_stream\fatfs_stream.o: In function _fatfs_close': fatfs_stream.c:(.text._fatfs_close+0x85): undefined reference towav_head_init’
fatfs_stream.c:(.text._fatfs_close+0x8f): undefined reference to `wav_head_size’
You seem to be so knowledgeable about ESP-ADF I was wondering if you could suggest changes needed to support an audio sampling rate of 96 kHz which the ES8388 codec is capable of - but ADF limits it to 48 kHz. I need this for a non-audio application. It appears as though changes are needed in the driver section - registers need to be modified to work at double speed. Thanks
If the codec and the ESP32 I2S bus support it, it should be possible. But please file an issue at Issues · espressif/esp-adf · GitHub so that Espressif’s developers can integrate it instead of me building a quick hack.
I did report it to Espressif developers - they say that unless we have an audio sample available at that sampling rate they will not be able to verify it.
In the function “esp_err_t es8388_init(audio_hal_codec_config_t *cfg)” there is a line that sets the rate:
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL2, 0x02); //DACFsMode,SINGLE SPEED; DACFsRatio,256
I think this needs to be modified as Table 1 on page 7 of the data sheet indicates:
Did you try it? I don’t have the hardware, I only have one with a ZL38063 codec.
But the change makes sense though, see page 23. Writing 0x02 to DAC control 2 will cause single speed & 256 MCLK sampling frequency. With table table 2 you can get the needed ratio, so overall you’d need to write (1 << 5) | 0B0000) (MCLK/128) or (1 << 5) | 0B0001) (MCLK/192) depending on the MCLK frequency. You’d then also need to modify the register holding ADCFsRatio (“Master mode ADC MCLK to sampling frequency ratio”) according to table 2. Finally, you’ll have to a change the I2S setings to send the data at that new data frequency.
I could have used the ADC in the ESP32 for my project - unfortunately the linearity of the ADC is not that great as many in this forum have reported. It works well even at 1 Mbps sampling rate - I have checked this out. The other drawback is the 8-bit DAC. My application requires generating a sine wave from the DAC, drive a BLUE LED to excite a fluoroscent material. The resulting fluoroscent RED light is detected by a photodiode amplifier. This is captured by the ADC and phase shift of the sine wave modulation relative to the BLUE light is measured.
I got the LyraT 4.3 board and tried your MP3 example. Everything works perfectly but no output through my headphones. Is there a setting to direct output to headphones rather than speakers?
I even modified the location of the .mp3 file and tried. After “Receive music…” there is a 7 second pause which means something is happening! After that the pipeline is stopped.