Skip to content

Commit bebd47d

Browse files
author
Liu Jinhong
committed
bugfix(esp_board_manager): Fixed sdmmc sdcard host slot configuration
1. Fixed the configuration of the sdmmc sdcard host slot, ensuring the configuration for the host slot in the yml file takes effect correctly 2. Using slot 0 to drive the sdcard for p4 function board, avoiding conflict with wifi hosted
1 parent 36a823d commit bebd47d

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

packages/esp_board_manager/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Bug Fixes
6+
- Fixed the configuration of the sdmmc sdcard host slot, ensuring the configuration for the host slot in the yml file takes effect correctly
7+
- Using slot 0 to drive the sdcard for p4_function board, avoiding conflict with wifi hosted
8+
39
## v0.4.0
410

511
### Features

packages/esp_board_manager/boards/esp32_p4_function_ev/board_devices.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ devices:
2525
- name: i2c_master
2626
address: 0x30
2727
frequency: 400000
28-
28+
2929
- name: audio_adc
3030
chip: es8311 # Codec chip (ES8311)
3131
type: audio_codec
@@ -46,18 +46,27 @@ devices:
4646
- name: i2c_master
4747
address: 0x30
4848
frequency: 400000
49-
49+
5050
- name: fs_sdcard
5151
type: fatfs_sdcard
5252
version: default
5353
config:
54+
# Use SDMMC slot 0
55+
slot: SDMMC_HOST_SLOT_0
56+
frequency: SDMMC_FREQ_HIGHSPEED
5457
bus_width: 4
58+
# If using slot 0, the pin must be configured as 0, the IO pins actually used are configured by the SDMMC driver
59+
# For more details, please check https://github.com/espressif/esp-idf/blob/v5.5.1/components/esp_driver_sdmmc/src/sdmmc_host.c#L668
5560
pins:
56-
clk: 43
57-
cmd: 44
58-
d0: 39
59-
d1: 40
60-
d2: 41
61-
d3: 42
62-
61+
clk: 0
62+
cmd: 0
63+
d0: 0
64+
d1: 0
65+
d2: 0
66+
d3: 0
67+
d4: 0
68+
d5: 0
69+
d6: 0
70+
d7: 0
71+
6372
ldo_chan_id: 4 # Use LDO_VO4 to power SDMMC IO

packages/esp_board_manager/devices/dev_fatfs_sdcard/dev_fatfs_sdcard.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int dev_fatfs_sdcard_init(void *cfg, int cfg_size, void **device_handle)
4343
// Use SDMMC host
4444
handle->host = (sdmmc_host_t)SDMMC_HOST_DEFAULT();
4545
handle->host.max_freq_khz = config->frequency;
46-
handle->host.flags = config->slot;
46+
handle->host.slot = config->slot;
4747

4848
#ifdef SOC_GP_LDO_SUPPORTED
4949
if (config->ldo_chan_id != -1) {
@@ -57,6 +57,7 @@ int dev_fatfs_sdcard_init(void *cfg, int cfg_size, void **device_handle)
5757
goto cleanup;
5858
}
5959
handle->host.pwr_ctrl_handle = pwr_ctrl_handle;
60+
ESP_LOGI(TAG, "LDO power control is initialized");
6061
} else {
6162
ESP_LOGI(TAG, "LDO power control is not used");
6263
}

packages/esp_board_manager/devices/dev_fatfs_sdcard/dev_fatfs_sdcard.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# Define valid enum values for SDMMC configuration
1010
VALID_SDMMC_ENUMS = {
1111
'slot': [
12+
'SDMMC_HOST_SLOT_0',
1213
'SDMMC_HOST_SLOT_1',
13-
'SDMMC_HOST_SLOT_2'
1414
],
1515
'frequency': [
1616
'SDMMC_FREQ_DEFAULT', # 20000
@@ -115,14 +115,14 @@ def parse(name: str, full_config: dict, peripherals_dict=None) -> dict:
115115
frequency_raw = config.get('frequency', 'SDMMC_FREQ_HIGHSPEED')
116116
frequency = get_enum_value(frequency_raw, 'SDMMC_FREQ_HIGHSPEED', 'frequency')
117117
bus_width = config.get('bus_width', 1) # Default to 1-bit mode
118-
slot_flags = config.get('slot_flags', 'SDMMC_SLOT_FLAG_INTERNAL_PULLUP') # Default slot flags
118+
slot_flags = config.get('slot_flags', 0) # Default slot flags
119119

120120
# Get GPIO pins with default values from board_devices.yaml
121121
pins = config.get('pins', {})
122122
pin_config = {
123-
'clk': pins.get('clk', 15), # GPIO_NUM_15
124-
'cmd': pins.get('cmd', 7), # GPIO_NUM_7
125-
'd0': pins.get('d0', 4), # GPIO_NUM_4
123+
'clk': pins.get('clk', -1), # Not used
124+
'cmd': pins.get('cmd', -1), # Not used
125+
'd0': pins.get('d0', -1), # Not used
126126
'd1': pins.get('d1', -1), # Not used
127127
'd2': pins.get('d2', -1), # Not used
128128
'd3': pins.get('d3', -1), # Not used

0 commit comments

Comments
 (0)