diff --git a/boards/risc-v/esp32c3/common/include/esp_board_mmcsd.h b/boards/risc-v/esp32c3/common/include/esp_board_mmcsd.h new file mode 100644 index 00000000000..5b1291dfe25 --- /dev/null +++ b/boards/risc-v/esp32c3/common/include/esp_board_mmcsd.h @@ -0,0 +1,76 @@ +/**************************************************************************** + * boards/risc-v/esp32c3/common/include/esp_board_mmcsd.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_RISCV_ESP32C3_COMMON_INCLUDE_ESP_BOARD_MMCSD_H +#define __BOARDS_RISCV_ESP32C3_COMMON_INCLUDE_ESP_BOARD_MMCSD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: esp_mmcsd_spi_initialize + * + * Description: + * Initialize SPI-based SD card. + * + * Input Parameters: + * None. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_MMCSD_SPI +int esp_mmcsd_spi_initialize(void); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_RISCV_ESP32C3_COMMON_INCLUDE_ESP_BOARD_MMCSD_H */ diff --git a/boards/risc-v/esp32c3/common/src/Make.defs b/boards/risc-v/esp32c3/common/src/Make.defs index 845649943c8..aa5947c74e2 100644 --- a/boards/risc-v/esp32c3/common/src/Make.defs +++ b/boards/risc-v/esp32c3/common/src/Make.defs @@ -70,6 +70,10 @@ ifeq ($(CONFIG_SENSORS_BMP180),y) CSRCS += esp_board_bmp180.c endif +ifeq ($(CONFIG_MMCSD_SPI),y) + CSRCS += esp_board_mmcsd.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src diff --git a/boards/risc-v/esp32c3/common/src/esp_board_mmcsd.c b/boards/risc-v/esp32c3/common/src/esp_board_mmcsd.c new file mode 100644 index 00000000000..6f356130231 --- /dev/null +++ b/boards/risc-v/esp32c3/common/src/esp_board_mmcsd.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * boards/risc-v/esp32c3/common/src/esp_board_mmcsd.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include + +#include "espressif/esp_spi.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp_mmcsd_spi_initialize + * + * Description: + * Initialize SPI-based SD card. + * + * Input Parameters: + * minor - The MMC/SD minor device number. The MMC/SD device will be + * registered as /dev/mmcsdN where N is the minor number + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +int esp_mmcsd_spi_initialize(void) +{ + struct spi_dev_s *spi; + int ret; + + syslog(LOG_INFO, "INFO: init MMC/SD slot %d on SPI%d: /dev/mmcsd%d\n", + CONFIG_NSH_MMCSDSLOTNO, CONFIG_NSH_MMCSDSPIPORTNO, + CONFIG_NSH_MMCSDMINOR); + + spi = esp_spibus_initialize(CONFIG_NSH_MMCSDSPIPORTNO); + + if (spi == NULL) + { + syslog(LOG_ERR, "ERROR: failed to initialize SPI%d.\n", + CONFIG_NSH_MMCSDSPIPORTNO); + return -ENODEV; + } + + /* Mounts to /dev/mmcsdN where N in the minor number */ + + ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, + CONFIG_NSH_MMCSDSLOTNO, spi); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: failed to bind SPI%d to SD slot %d\n", + CONFIG_NSH_MMCSDSPIPORTNO, CONFIG_NSH_MMCSDSLOTNO); + return ret; + } + + syslog(LOG_INFO, "INFO: MMCSD initialized\n"); + return OK; +} diff --git a/boards/risc-v/esp32c3/common/src/esp_board_spi.c b/boards/risc-v/esp32c3/common/src/esp_board_spi.c index 5b14eff67bf..e3cd5e2aae1 100644 --- a/boards/risc-v/esp32c3/common/src/esp_board_spi.c +++ b/boards/risc-v/esp32c3/common/src/esp_board_spi.c @@ -52,6 +52,11 @@ uint8_t esp_spi2_status(struct spi_dev_s *dev, uint32_t devid) { uint8_t status = 0; + if (devid == SPIDEV_MMCSD(0)) + { + return SPI_STATUS_PRESENT; + } + return status; } diff --git a/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_bringup.c b/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_bringup.c index 0aec1ffc155..79284f8ab39 100644 --- a/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_bringup.c +++ b/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_bringup.c @@ -122,6 +122,10 @@ # include "espressif/esp_sha.h" #endif +#ifdef CONFIG_MMCSD_SPI +# include "esp_board_mmcsd.h" +#endif + #include "esp32c3-generic.h" /**************************************************************************** @@ -261,6 +265,14 @@ int esp_bringup(void) # endif /* CONFIG_ESPRESSIF_SPI_BITBANG */ #endif /* CONFIG_ESPRESSIF_SPI */ +#if defined(CONFIG_ESPRESSIF_SPI) && defined(CONFIG_MMCSD_SPI) + ret = esp_mmcsd_spi_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: failed to init MMCSD SPI\n"); + } +#endif + #ifdef CONFIG_ESPRESSIF_SPIFLASH ret = board_spiflash_init(); if (ret) diff --git a/boards/risc-v/esp32c6/common/include/esp_board_mmcsd.h b/boards/risc-v/esp32c6/common/include/esp_board_mmcsd.h new file mode 100644 index 00000000000..9b3dda94ce6 --- /dev/null +++ b/boards/risc-v/esp32c6/common/include/esp_board_mmcsd.h @@ -0,0 +1,76 @@ +/**************************************************************************** + * boards/risc-v/esp32c6/common/include/esp_board_mmcsd.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_MMCSD_H +#define __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_MMCSD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: esp_mmcsd_spi_initialize + * + * Description: + * Initialize SPI-based SD card. + * + * Input Parameters: + * None. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_MMCSD_SPI +int esp_mmcsd_spi_initialize(void); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_MMCSD_H */ diff --git a/boards/risc-v/esp32c6/common/src/Make.defs b/boards/risc-v/esp32c6/common/src/Make.defs index f54fdb41ed4..cf3c06a7b79 100644 --- a/boards/risc-v/esp32c6/common/src/Make.defs +++ b/boards/risc-v/esp32c6/common/src/Make.defs @@ -90,6 +90,10 @@ ifeq ($(CONFIG_NCV7410),y) CSRCS += esp_board_ncv7410.c endif +ifeq ($(CONFIG_MMCSD_SPI),y) + CSRCS += esp_board_mmcsd.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src diff --git a/boards/risc-v/esp32c6/common/src/esp_board_mmcsd.c b/boards/risc-v/esp32c6/common/src/esp_board_mmcsd.c new file mode 100644 index 00000000000..688d2213136 --- /dev/null +++ b/boards/risc-v/esp32c6/common/src/esp_board_mmcsd.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * boards/risc-v/esp32c6/common/src/esp_board_mmcsd.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include + +#include "espressif/esp_spi.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp_mmcsd_spi_initialize + * + * Description: + * Initialize SPI-based SD card. + * + * Input Parameters: + * minor - The MMC/SD minor device number. The MMC/SD device will be + * registered as /dev/mmcsdN where N is the minor number + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +int esp_mmcsd_spi_initialize(void) +{ + struct spi_dev_s *spi; + int ret; + + syslog(LOG_INFO, "INFO: init MMC/SD slot %d on SPI%d: /dev/mmcsd%d\n", + CONFIG_NSH_MMCSDSLOTNO, CONFIG_NSH_MMCSDSPIPORTNO, + CONFIG_NSH_MMCSDMINOR); + + spi = esp_spibus_initialize(CONFIG_NSH_MMCSDSPIPORTNO); + + if (spi == NULL) + { + syslog(LOG_ERR, "ERROR: failed to initialize SPI%d.\n", + CONFIG_NSH_MMCSDSPIPORTNO); + return -ENODEV; + } + + /* Mounts to /dev/mmcsdN where N in the minor number */ + + ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, + CONFIG_NSH_MMCSDSLOTNO, spi); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: failed to bind SPI%d to SD slot %d\n", + CONFIG_NSH_MMCSDSPIPORTNO, CONFIG_NSH_MMCSDSLOTNO); + return ret; + } + + syslog(LOG_INFO, "INFO: MMCSD initialized\n"); + return OK; +} diff --git a/boards/risc-v/esp32c6/common/src/esp_board_spi.c b/boards/risc-v/esp32c6/common/src/esp_board_spi.c index 32f92f354ee..006738293bf 100644 --- a/boards/risc-v/esp32c6/common/src/esp_board_spi.c +++ b/boards/risc-v/esp32c6/common/src/esp_board_spi.c @@ -52,6 +52,11 @@ uint8_t esp_spi2_status(struct spi_dev_s *dev, uint32_t devid) { uint8_t status = 0; + if (devid == SPIDEV_MMCSD(0)) + { + return SPI_STATUS_PRESENT; + } + return status; } diff --git a/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c b/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c index 911de2278da..7f78882d53c 100644 --- a/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c +++ b/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c @@ -133,6 +133,10 @@ # include "esp_board_ncv7410.h" #endif +#ifdef CONFIG_MMCSD_SPI +# include "esp_board_mmcsd.h" +#endif + #include "esp32c6-devkitc.h" /**************************************************************************** @@ -296,6 +300,14 @@ int esp_bringup(void) # endif /* CONFIG_ESPRESSIF_SPI_BITBANG */ #endif /* CONFIG_ESPRESSIF_SPI */ +#if defined(CONFIG_ESPRESSIF_SPI) && defined(CONFIG_MMCSD_SPI) + ret = esp_mmcsd_spi_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: failed to init MMCSD SPI\n"); + } +#endif + #ifdef CONFIG_ESPRESSIF_SPIFLASH ret = board_spiflash_init(); if (ret) diff --git a/boards/risc-v/esp32h2/common/include/esp_board_mmcsd.h b/boards/risc-v/esp32h2/common/include/esp_board_mmcsd.h new file mode 100644 index 00000000000..d52f8a62142 --- /dev/null +++ b/boards/risc-v/esp32h2/common/include/esp_board_mmcsd.h @@ -0,0 +1,76 @@ +/**************************************************************************** + * boards/risc-v/esp32h2/common/include/esp_board_mmcsd.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_RISCV_ESP32H2_COMMON_INCLUDE_ESP_BOARD_MMCSD_H +#define __BOARDS_RISCV_ESP32H2_COMMON_INCLUDE_ESP_BOARD_MMCSD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: esp_mmcsd_spi_initialize + * + * Description: + * Initialize SPI-based SD card. + * + * Input Parameters: + * None. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_MMCSD_SPI +int esp_mmcsd_spi_initialize(void); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_RISCV_ESP32H2_COMMON_INCLUDE_ESP_BOARD_MMCSD_H */ diff --git a/boards/risc-v/esp32h2/common/src/Make.defs b/boards/risc-v/esp32h2/common/src/Make.defs index 2bbc9c67d3f..61b8b2bb3fa 100644 --- a/boards/risc-v/esp32h2/common/src/Make.defs +++ b/boards/risc-v/esp32h2/common/src/Make.defs @@ -74,6 +74,10 @@ ifeq ($(CONFIG_ESP_PCNT),y) CSRCS += esp_board_pcnt.c endif +ifeq ($(CONFIG_MMCSD_SPI),y) + CSRCS += esp_board_mmcsd.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src diff --git a/boards/risc-v/esp32h2/common/src/esp_board_mmcsd.c b/boards/risc-v/esp32h2/common/src/esp_board_mmcsd.c new file mode 100644 index 00000000000..9f21ab33ad3 --- /dev/null +++ b/boards/risc-v/esp32h2/common/src/esp_board_mmcsd.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * boards/risc-v/esp32h2/common/src/esp_board_mmcsd.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include + +#include "espressif/esp_spi.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp_mmcsd_spi_initialize + * + * Description: + * Initialize SPI-based SD card. + * + * Input Parameters: + * minor - The MMC/SD minor device number. The MMC/SD device will be + * registered as /dev/mmcsdN where N is the minor number + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +int esp_mmcsd_spi_initialize(void) +{ + struct spi_dev_s *spi; + int ret; + + syslog(LOG_INFO, "INFO: init MMC/SD slot %d on SPI%d: /dev/mmcsd%d\n", + CONFIG_NSH_MMCSDSLOTNO, CONFIG_NSH_MMCSDSPIPORTNO, + CONFIG_NSH_MMCSDMINOR); + + spi = esp_spibus_initialize(CONFIG_NSH_MMCSDSPIPORTNO); + + if (spi == NULL) + { + syslog(LOG_ERR, "ERROR: failed to initialize SPI%d.\n", + CONFIG_NSH_MMCSDSPIPORTNO); + return -ENODEV; + } + + /* Mounts to /dev/mmcsdN where N in the minor number */ + + ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, + CONFIG_NSH_MMCSDSLOTNO, spi); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: failed to bind SPI%d to SD slot %d\n", + CONFIG_NSH_MMCSDSPIPORTNO, CONFIG_NSH_MMCSDSLOTNO); + return ret; + } + + syslog(LOG_INFO, "INFO: MMCSD initialized\n"); + return OK; +} diff --git a/boards/risc-v/esp32h2/common/src/esp_board_spi.c b/boards/risc-v/esp32h2/common/src/esp_board_spi.c index 4e22625e3e8..a94995cd761 100644 --- a/boards/risc-v/esp32h2/common/src/esp_board_spi.c +++ b/boards/risc-v/esp32h2/common/src/esp_board_spi.c @@ -52,6 +52,11 @@ uint8_t esp_spi2_status(struct spi_dev_s *dev, uint32_t devid) { uint8_t status = 0; + if (devid == SPIDEV_MMCSD(0)) + { + return SPI_STATUS_PRESENT; + } + return status; } diff --git a/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c b/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c index 57b27de4a1a..ae47ae9ddb1 100644 --- a/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c +++ b/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c @@ -119,6 +119,10 @@ # include "espressif/esp_sha.h" #endif +#ifdef CONFIG_MMCSD_SPI +# include "esp_board_mmcsd.h" +#endif + #include "esp32h2-devkit.h" /**************************************************************************** @@ -282,6 +286,14 @@ int esp_bringup(void) # endif /* CONFIG_ESPRESSIF_SPI_BITBANG */ #endif /* CONFIG_ESPRESSIF_SPI */ +#if defined(CONFIG_ESPRESSIF_SPI) && defined(CONFIG_MMCSD_SPI) + ret = esp_mmcsd_spi_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: failed to init MMCSD SPI\n"); + } +#endif + #ifdef CONFIG_ESPRESSIF_SPIFLASH ret = board_spiflash_init(); if (ret)