feat(usb_device_example): Create per-target sdkconfig.defaults

This commit is contained in:
peter.marcisovsky
2026-07-16 10:19:44 +02:00
parent 63c49d432d
commit 28dee52563
5 changed files with 26 additions and 17 deletions
@@ -59,7 +59,8 @@ GPIOs and SD bus settings can be configured in two ways:
- Select "SDMMC CARD" for "Storage Media Used"
- Select "SD/MMC bus width" — "4 lines (D0 - D3)" or "1 line (D0)" (see `CONFIG_EXAMPLE_SDMMC_BUS_WIDTH_1`)
- On ESP32-S3 and ESP32-P4: set the GPIO numbers for the SD card interface
2. In the source code: See the initialization of ``sdmmc_slot_config_t slot_config`` structure in the example code.
2. Using target-specific defaults: Pin and LDO defaults for each chip are in ``sdkconfig.defaults.esp32s3``, ``sdkconfig.defaults.esp32p4``, and ``sdkconfig.defaults.esp32s31``. These are applied automatically when you set the target with ``idf.py set-target``.
3. In the source code: See the initialization of ``sdmmc_slot_config_t slot_config`` structure in the example code.
By default, this example uses 4-line SD mode, utilizing 6 pins: CLK, CMD, D0 - D3.
@@ -13,7 +13,7 @@ menu "TinyUSB MSC Example Configuration"
config EXAMPLE_STORAGE_MEDIA_SDMMC
bool "SDMMC CARD"
depends on IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32S31
depends on SOC_SDMMC_HOST_SUPPORTED
endchoice
if EXAMPLE_STORAGE_MEDIA_SDMMC
@@ -39,40 +39,34 @@ menu "TinyUSB MSC Example Configuration"
config EXAMPLE_PIN_CMD
int "CMD GPIO number"
range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX
default 35 if IDF_TARGET_ESP32S3
default 44 if IDF_TARGET_ESP32P4
default 35
config EXAMPLE_PIN_CLK
int "CLK GPIO number"
range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX
default 36 if IDF_TARGET_ESP32S3
default 43 if IDF_TARGET_ESP32P4
default 36
config EXAMPLE_PIN_D0
int "D0 GPIO number"
range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX
default 37 if IDF_TARGET_ESP32S3
default 39 if IDF_TARGET_ESP32P4
default 37
if EXAMPLE_SDMMC_BUS_WIDTH_4
config EXAMPLE_PIN_D1
int "D1 GPIO number"
range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX
default 38 if IDF_TARGET_ESP32S3
default 40 if IDF_TARGET_ESP32P4
default 38
config EXAMPLE_PIN_D2
int "D2 GPIO number"
range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX
default 33 if IDF_TARGET_ESP32S3
default 41 if IDF_TARGET_ESP32P4
default 33
config EXAMPLE_PIN_D3
int "D3 GPIO number"
range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX
default 34 if IDF_TARGET_ESP32S3
default 42 if IDF_TARGET_ESP32P4
default 34
endif # EXAMPLE_SDMMC_BUS_WIDTH_4
@@ -81,7 +75,6 @@ menu "TinyUSB MSC Example Configuration"
config EXAMPLE_SD_PWR_CTRL_LDO_INTERNAL_IO
depends on SOC_SDMMC_IO_POWER_EXTERNAL || SOC_SDMMC_IO_UHS_POWER_EXTERNAL
bool "SDMMC powered by internal LDO"
default y
help
Enable when internal LDO of an ESP32 is used as a power supply for SD card. Specify the LDO IO.
Disable when external power supply is used as a power supply for SD card.
@@ -90,8 +83,7 @@ menu "TinyUSB MSC Example Configuration"
depends on SOC_SDMMC_IO_POWER_EXTERNAL || SOC_SDMMC_IO_UHS_POWER_EXTERNAL
depends on EXAMPLE_SD_PWR_CTRL_LDO_INTERNAL_IO
int "LDO IO"
default 4 if IDF_TARGET_ESP32P4
default 1 if IDF_TARGET_ESP32S31
default 1
help
There are several IOs in ESP32 SD card capable targets which are in "SD card IO" power domain.
Power has to be supplied to this power domain externally (from outside the chip) via one of the pins.
@@ -0,0 +1,8 @@
CONFIG_EXAMPLE_PIN_CMD=44
CONFIG_EXAMPLE_PIN_CLK=43
CONFIG_EXAMPLE_PIN_D0=39
CONFIG_EXAMPLE_PIN_D1=40
CONFIG_EXAMPLE_PIN_D2=41
CONFIG_EXAMPLE_PIN_D3=42
CONFIG_EXAMPLE_SD_PWR_CTRL_LDO_INTERNAL_IO=y
CONFIG_EXAMPLE_SD_PWR_CTRL_LDO_IO_ID=4
@@ -0,0 +1,6 @@
CONFIG_EXAMPLE_PIN_CMD=35
CONFIG_EXAMPLE_PIN_CLK=36
CONFIG_EXAMPLE_PIN_D0=37
CONFIG_EXAMPLE_PIN_D1=38
CONFIG_EXAMPLE_PIN_D2=33
CONFIG_EXAMPLE_PIN_D3=34
@@ -0,0 +1,2 @@
CONFIG_EXAMPLE_SD_PWR_CTRL_LDO_INTERNAL_IO=y
CONFIG_EXAMPLE_SD_PWR_CTRL_LDO_IO_ID=1