esp32-s3使用sdmmc时报错108

zhaoanguo222
Posts: 7
Joined: Wed Aug 30, 2023 3:25 am

esp32-s3使用sdmmc时报错108

Postby zhaoanguo222 » Thu Feb 13, 2025 12:53 am

我自己画的板子,直接通过代码挂载sdcard时,可以正常读取内容,测试wav文件可以正常播放,但是转到pipeline来播放时,会报错:sdmmc_read_sectors_dma: sdmmc_send_cmd returned 0x108;分析应该不是线路问题,因为直接读取sd卡和写入sd卡都是正常的。切换到pipeline就会报错
以下是播放代码:
#include "playsoundtool.h"
#define TAG "PLAYSOUND"



esp_err_t init_playSound(char * playName)
{

// 2. 初始化流水线
audio_pipeline_handle_t pipeline;
audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
pipeline = audio_pipeline_init(&pipeline_cfg);

esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG();
esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg);
// Initialize SD Card peripheral
audio_board_sdcard_init(set, SD_MODE_1_LINE);

// 3. 创建并注册组件
fatfs_stream_cfg_t fs_cfg = FATFS_STREAM_CFG_DEFAULT();
fs_cfg.type = AUDIO_STREAM_READER;
audio_element_handle_t fs_stream = fatfs_stream_init(&fs_cfg);

wav_decoder_cfg_t wav_cfg = DEFAULT_WAV_DECODER_CONFIG();
audio_element_handle_t wav_decoder = wav_decoder_init(&wav_cfg);

i2s_stream_cfg_t i2s_cfg = I2S_STREAM_CFG_DEFAULT();
i2s_cfg.stack_in_ext = true;
i2s_cfg.std_cfg.gpio_cfg.bclk = I2S_STD_BCLK_IO1;
i2s_cfg.std_cfg.gpio_cfg.dout = I2S_STD_DOUT_IO1;
i2s_cfg.std_cfg.gpio_cfg.ws = I2S_STD_WS_IO1;
audio_element_handle_t i2s_stream = i2s_stream_init(&i2s_cfg);

audio_pipeline_register(pipeline, fs_stream, "file");
audio_pipeline_register(pipeline, wav_decoder, "wav");
audio_pipeline_register(pipeline, i2s_stream, "i2s");

// 4. 连接组件
const char *link_tag[3] = {"file", "wav", "i2s"};
audio_pipeline_link(pipeline, &link_tag[0], 3);

// 5. 设置URI并启动
audio_element_set_uri(fs_stream, playName);
audio_event_iface_cfg_t evt_cfg = AUDIO_EVENT_IFACE_DEFAULT_CFG();
audio_event_iface_handle_t evt = audio_event_iface_init(&evt_cfg);

ESP_LOGI(TAG, "[4.1] Listening event from all elements of pipeline");
audio_pipeline_set_listener(pipeline, evt);

ESP_LOGI(TAG, "[4.2] Listening event from peripherals");
audio_event_iface_set_listener(esp_periph_set_get_event_iface(set), evt);

ESP_LOGI(TAG, "[ 5 ] Start audio_pipeline");
audio_pipeline_run(pipeline);
// Example of linking elements into an audio pipeline -- END

ESP_LOGI(TAG, "[ 6 ] Listen for all pipeline events");
while (1)
{
audio_event_iface_msg_t msg;
esp_err_t ret = audio_event_iface_listen(evt, &msg, portMAX_DELAY);
if (ret != ESP_OK)
{
ESP_LOGE(TAG, "[ * ] Event interface error : %d", ret);
continue;
}

if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *)wav_decoder && msg.cmd == AEL_MSG_CMD_REPORT_MUSIC_INFO)
{
audio_element_info_t music_info = {0};
audio_element_getinfo(wav_decoder, &music_info);

ESP_LOGI(TAG, "[ * ] Receive music info from music decoder, sample_rates=%d, bits=%d, ch=%d",
music_info.sample_rates, music_info.bits, music_info.channels);

audio_element_setinfo(i2s_stream, &music_info);
i2s_stream_set_clk(i2s_stream, music_info.sample_rates, music_info.bits, music_info.channels);
continue;
}

/* Stop when the last pipeline element (i2s_stream_writer in this case) receives stop event */
if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *)i2s_stream && msg.cmd == AEL_MSG_CMD_REPORT_STATUS && (((int)msg.data == AEL_STATUS_STATE_STOPPED) || ((int)msg.data == AEL_STATUS_STATE_FINISHED)))
{
ESP_LOGW(TAG, "[ * ] Stop event received");
break;
}
}

ESP_LOGI(TAG, "[ 7 ] Stop audio_pipeline");
audio_pipeline_stop(pipeline);
audio_pipeline_wait_for_stop(pipeline);
audio_pipeline_terminate(pipeline);

audio_pipeline_unregister(pipeline, fs_stream);
audio_pipeline_unregister(pipeline, i2s_stream);
audio_pipeline_unregister(pipeline, wav_decoder);

/* Terminal the pipeline before removing the listener */
audio_pipeline_remove_listener(pipeline);

/* Stop all periph before removing the listener */
esp_periph_set_stop_all(set);
audio_event_iface_remove_listener(esp_periph_set_get_event_iface(set), evt);

/* Make sure audio_pipeline_remove_listener & audio_event_iface_remove_listener are called before destroying event_iface */
audio_event_iface_destroy(evt);

/* Release all resources */
audio_pipeline_deinit(pipeline);
audio_element_deinit(fs_stream);
audio_element_deinit(i2s_stream);
audio_element_deinit(wav_decoder);
esp_periph_set_destroy(set);

return ESP_OK;
}

zhaoanguo222
Posts: 7
Joined: Wed Aug 30, 2023 3:25 am

Re: esp32-s3使用sdmmc时报错108

Postby zhaoanguo222 » Thu Feb 13, 2025 2:19 am

我使用的是idf5.3版本,adf最新,板子的gpio定义已经修改过来了。

Who is online

Users browsing this forum: No registered users and 70 guests