Closed crispmfc closed 1 month ago
I have found that SDIO is better. I am going to try to connect my SD Card that way. I was probably trying to use SPI unnecessarily, I see that the examples must have good reasons for choosing SDIO.
I have tried using the example with a sdcard connected in SDIO 1-line mode and no success. I have already manually set the pins and also connected the pins as they are by default in the audio board file. The serial monitor reports:
E (1931) I2C_BUS: C:/Users/chris/esp-adf-v2.6/components/esp_peripherals/driver/i2c_bus/i2c_bus.c:170 (i2c_bus_read_bytes):I2C Bus ReadReg Error
E (1945) I2C_BUS: C:/Users/chris/esp-adf-v2.6/components/esp_peripherals/driver/i2c_bus/i2c_bus.c:115 (i2c_bus_write_bytes):I2C Bus WriteReg Error
E (1958) AUDIO_HAL: audio_hal.c:66 (audio_hal_init): audio_hal_init failed
E (1966) AUDIO_BOARD: board.c:55 (audio_board_adc_init): Got NULL Pointer
E (1973) AUDIO_HAL: audio_hal handle is null
I (1978) DOWNMIX_PIPELINE_EXAMPLE: [2.0] Start and wait for SDCARD to mount
E (1987) PERIPH_SDCARD: no sdcard detect
E (4491) AUDIO_BOARD: Sdcard mount failed
I (4491) DOWNMIX_PIPELINE_EXAMPLE: [3.0] Create pipeline_mix pipeline
I (4491) DOWNMIX_PIPELINE_EXAMPLE: [3.1] Create down-mixer element
I (4498) DOWNMIX_PIPELINE_EXAMPLE: [3.2] Create i2s stream to read audio data from codec chip
I (4510) DOWNMIX_PIPELINE_EXAMPLE: [3.3] Link elements together downmixer-->i2s_writer
I (4516) DOWNMIX_PIPELINE_EXAMPLE: [3.4] Link elements together downmixer-->i2s_stream-->[codec_chip]
I (4526) DOWNMIX_PIPELINE_EXAMPLE: [4.0] Create Fatfs stream to read input data
I (4534) DOWNMIX_PIPELINE_EXAMPLE: [4.1] Create mp3 decoder to decode mp3 file
I (4542) DOWNMIX_PIPELINE_EXAMPLE: [4.1] Create resample element
I (4549) DOWNMIX_PIPELINE_EXAMPLE: [4.2] Create raw stream of base mp3 to write data
I (4557) DOWNMIX_PIPELINE_EXAMPLE: [5.0] Set up event listener
I (4564) DOWNMIX_PIPELINE_EXAMPLE: [5.1] Listening event from peripherals
W (4572) AUDIO_THREAD: Make sure selected the CONFIG_SPIRAM_BOOT_INIT
and CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
by make menuconfig
W (4584) AUDIO_THREAD: Make sure selected the CONFIG_SPIRAM_BOOT_INIT
and CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
by make menuconfig
E (4598) FATFS_STREAM: Failed to open. File name: /sdcard/music.mp3, error message: No such file or directory, line: 134
E (4609) AUDIO_ELEMENT: [base_file] AEL_STATUS_ERROR_OPEN,-1
W (4615) AUDIO_ELEMENT: [base_file] audio_element_on_cmd_error,7
W (4622) AUDIO_ELEMENT: IN-[base_mp3] AEL_IO_ABORT
E (4628) MP3_DECODER: failed to read audio data (line 122)
W (4634) AUDIO_ELEMENT: [base_mp3] AEL_IO_ABORT, -3
W (4729) AUDIO_ELEMENT: IN-[base_filter] AEL_IO_ABORT
W (4729) AUDIO_THREAD: Make sure selected the CONFIG_SPIRAM_BOOT_INIT
and CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
by make menuconfig
I (4795) DOWNMIX_PIPELINE_EXAMPLE: [6.0] Base stream pipeline running
@crispmfc There is some errors, please enable the sdmmc debug log and check why mount sdcard failed.
I (1978) DOWNMIX_PIPELINE_EXAMPLE: [2.0] Start and wait for SDCARD to mount
E (1987) PERIPH_SDCARD: no sdcard detect
E (4491) AUDIO_BOARD: Sdcard mount failed
This topic has become inactive so I'm going to close the issue. Please reopen this if you have any questions or need any further assistance.
Environment
Audio development kit: |none]
Module or chip used: ESP32-S3-DevKitM-1
IDF version: v5.1.1
ADF version: v2.6
Build system: idf.py
Running log: E (2046) I2C_BUS: C:/Users/chris/esp-adf-v2.6/components/esp_peripherals/driver/i2c_bus/i2c_bus.c:170 (i2c_bus_read_bytes):I2C Bus ReadReg Error E (2066) I2C_BUS: C:/Users/chris/esp-adf-v2.6/components/esp_peripherals/driver/i2c_bus/i2c_bus.c:115 (i2c_bus_write_bytes):I2C Bus WriteReg Error E (2076) AUDIO_HAL: audio_hal.c:66 (audio_hal_init): audio_hal_init failed E (2086) AUDIO_BOARD: board.c:55 (audio_board_adc_init): Got NULL Pointer E (2086) AUDIO_HAL: audio_hal handle is null I (2096) PLAY_SDCARD_MUSIC: [3.0] Create audio pipeline for playback I (2106) PLAY_SDCARD_MUSIC: [3.1] Create fatfs stream to read data from sdcard I (2106) PLAY_SDCARD_MUSIC: [3.2] Create i2s stream to write data to codec chip I (2126) PLAY_SDCARD_MUSIC: [3.3] Create mp3 decoder I (2126) PLAY_SDCARD_MUSIC: [3.4] Register all elements to audio pipeline I (2136) PLAY_SDCARD_MUSIC: [3.5] Link it together [sdcard]-->fatfs_stream-->music_decoder-->i2s_stream-->[codec_chip] I (2146) PLAY_SDCARD_MUSIC: [3.6] Set up uri: /sdcard/test.mp3 I (2146) PLAY_SDCARD_MUSIC: [ 4 ] Set up event listener I (2156) PLAY_SDCARD_MUSIC: [4.1] Listening event from all elements of pipeline I (2166) PLAY_SDCARD_MUSIC: [4.2] Listening event from peripherals I (2166) PLAY_SDCARD_MUSIC: [ 5 ] Start audio_pipeline W (2176) AUDIO_THREAD: Make sure selected the
CONFIG_SPIRAM_BOOT_INIT
andCONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
bymake menuconfig
E (2186) FATFS_STREAM: Failed to open. File name: /sdcard/test.mp3, error message: No such file or directory, line: 134 E (2206) AUDIO_ELEMENT: [file] AEL_STATUS_ERROR_OPEN,-1 W (2206) AUDIO_ELEMENT: [file] audio_element_on_cmd_error,7 W (2216) AUDIO_ELEMENT: IN-[dec] AEL_IO_ABORT E (2216) MP3_DECODER: failed to read audio data (line 122) W (2226) AUDIO_ELEMENT: [dec] AEL_IO_ABORT, -3 W (2226) AUDIO_ELEMENT: IN-[i2s] AEL_IO_ABORT I (2236) PLAY_SDCARD_MUSIC: [ 6 ] Listen for all pipeline events W (2266) PLAY_SDCARD_MUSIC: [ * ] Stop event received I (2266) PLAY_SDCARD_MUSIC: [ 7 ] Stop audio_pipeline W (2266) AUDIO_ELEMENT: [file] Element already stopped W (2266) AUDIO_ELEMENT: [dec] Element already stopped W (2276) AUDIO_ELEMENT: [i2s] Element already stopped W (2276) AUDIO_PIPELINE: There are no listener registered W (2286) AUDIO_ELEMENT: [file] Element has not create when AUDIO_ELEMENT_TERMINATE W (2296) AUDIO_ELEMENT: [i2s] Element has not create when AUDIO_ELEMENT_TERMINATE W (2306) AUDIO_ELEMENT: [dec] Element has not create when AUDIO_ELEMENT_TERMINATECompiler version: xtensa-esp32-elf-gcc (crosstool-NG esp-12.2.0_20230208) 12.2.0
Operating system: Windows 11
Environment type: ESP Command Prompt
Using an IDE?: Yes, Espressif IDE v2.9.1
Power supply: USB
Problem Description
ESP32 S3 Mini cannot find test.mp3 file on SPI SD card using example pipeline_play_sdcard_music and pipeline_sdcard_mp3_control. It seems to be trying to use I2C instead of SPI for my sd card reader module.
I know that my sd card works correctly with my ESP32-S3-Mini, since with another code in IDF v5.1.1 it does recognize the sd card, it is able to create a text file and read it, but I did that with other libraries that they are not fatfs_stream.h, among others. It also works fine on arduino framework.
I have managed to use the examples to play .mp3 from spiffs and from http, the dac is MAX98357A, but I have not been able to read .mp3 files from the sd card.
I have defined in main SD_MODE_SPI instead of SD_MODE_1_LINE. This helped me get around errors like "error mounting sd card" and now I only get the error that it could not find the test.mp3 file - I suspect it is still a pin configuration problem, or maybe I need to configure something to use the SD card in SPI mode.
I've tried defining the pins in both main and board_def.h and commenting out pins that are assigned to something else. This didn't solve anything, although it seemed to be my solution.
I have also tried many kinds of solutions like reading documentation, trying other examples, looking for all kinds of errors or similar codes, lots of chatgpt codes and tips, using parts of my code that do read sd card and mixing them with the example, etc. I've been trying to fix it for days. On github and esp32 forums I have found some people with the same or similar problem, but it was from 1-3 years ago and no possible solution worked for me. I also tried to create my custom board or modify existing ones, but that didn't improve anything.
I don't think this is relevant: The ESP32-S3-MINI-1 does not have PSRAM and in the serial monitor it mentions "AUDIO_THREAD: Make sure selected the
CONFIG_SPIRAM_BOOT_INIT
andCONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
bymake menuconfig
but I cannot activate PSRAM, because when I do that the ESP32-S3-Mini goes into a bootloop and asks to disable PSRAM support.Expected Behavior
Find /sdcard/test.mp3 from my SPI SD Card and play it on I2S
Actual Behavior
The ESP32-S3-Mini reports 'FATFS_STREAM: Failed to open. File name: /sdcard/test.mp3, error message: No such file or directory, line: 134' and test.mp3 file does not play
Steps to Reproduce
audio_board_sdcard_init(set, SD_MODE_1_LINE);
byaudio_board_sdcard_init(set, SD_MODE_SPI);
Set the I2S pins for MAX98357A:
define ESP_SD_PIN_CLK GPIO_NUM_40
define ESP_SD_PIN_CMD GPIO_NUM_41
define ESP_SD_PIN_D0 GPIO_NUM_19
define ESP_SD_PIN_D1 GPIO_NUM_46
Debug Logs
Other Items If Possible
None