You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/05/08 16:59:59 UTC

[nuttx] branch master updated (1d2ebf91a1 -> f29e802ca8)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from 1d2ebf91a1 Kconfig: Fix help attribute
     new 64402a1c4c nucleo-h743zi: add composite device configuration
     new fbf1e859ee nucleo-144: add composite device configuration
     new 09b2e9df7a stm32f4discovery/stm32_mmcsd.c: remove redundant SCK pin configuration, it's already selected in board.h
     new 023c0d7034 stm32f4discovery/stm32_usbmsc.c: fix SD card initialization
     new f29e802ca8 stm32f4discovery: add composite device configuration

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../stm32f4discovery/configs/composite/defconfig   | 103 ++++++
 boards/arm/stm32/stm32f4discovery/src/Make.defs    |   4 +
 .../arm/stm32/stm32f4discovery/src/stm32_bringup.c |   2 +-
 .../stm32/stm32f4discovery/src/stm32_composite.c   | 347 +++++++++++++++++++++
 .../arm/stm32/stm32f4discovery/src/stm32_mmcsd.c   |   1 -
 .../arm/stm32/stm32f4discovery/src/stm32_usbmsc.c  |   2 +-
 .../nucleo-144/configs/f722-composite/Make.defs    |  39 +++
 .../nucleo-144/configs/f722-composite/defconfig    |  86 +++++
 boards/arm/stm32f7/nucleo-144/src/Makefile         |   4 +
 .../arm/stm32f7/nucleo-144/src/stm32_composite.c   | 347 +++++++++++++++++++++
 .../nucleo-h743zi/configs/composite/defconfig      |  95 ++++++
 .../stm32h7/nucleo-h743zi/configs/rndis/defconfig  |  82 +++++
 boards/arm/stm32h7/nucleo-h743zi/src/Makefile      |  12 +
 .../arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h  |  22 ++
 .../arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c  |  29 +-
 .../stm32h7/nucleo-h743zi/src/stm32_composite.c    | 347 +++++++++++++++++++++
 .../nucleo-h743zi}/src/stm32_mmcsd.c               |  65 ++--
 boards/arm/stm32h7/nucleo-h743zi/src/stm32_spi.c   |  28 +-
 .../nucleo-h743zi}/src/stm32_usbmsc.c              |  19 +-
 19 files changed, 1572 insertions(+), 62 deletions(-)
 create mode 100644 boards/arm/stm32/stm32f4discovery/configs/composite/defconfig
 create mode 100644 boards/arm/stm32/stm32f4discovery/src/stm32_composite.c
 create mode 100644 boards/arm/stm32f7/nucleo-144/configs/f722-composite/Make.defs
 create mode 100644 boards/arm/stm32f7/nucleo-144/configs/f722-composite/defconfig
 create mode 100644 boards/arm/stm32f7/nucleo-144/src/stm32_composite.c
 create mode 100644 boards/arm/stm32h7/nucleo-h743zi/configs/composite/defconfig
 create mode 100644 boards/arm/stm32h7/nucleo-h743zi/configs/rndis/defconfig
 create mode 100644 boards/arm/stm32h7/nucleo-h743zi/src/stm32_composite.c
 copy boards/arm/{stm32/stm32f4discovery => stm32h7/nucleo-h743zi}/src/stm32_mmcsd.c (64%)
 copy boards/arm/{stm32/stm32f4discovery => stm32h7/nucleo-h743zi}/src/stm32_usbmsc.c (77%)


[nuttx] 03/05: stm32f4discovery/stm32_mmcsd.c: remove redundant SCK pin configuration, it's already selected in board.h

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 09b2e9df7a4bb38a1270d911723bf3fe783c7685
Author: raiden00pl <ra...@railab.me>
AuthorDate: Mon Apr 3 16:06:46 2023 +0200

    stm32f4discovery/stm32_mmcsd.c: remove redundant SCK pin configuration, it's already selected in board.h
---
 boards/arm/stm32/stm32f4discovery/src/stm32_mmcsd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_mmcsd.c b/boards/arm/stm32/stm32f4discovery/src/stm32_mmcsd.c
index 7815a7fc4b..2d2f71d45e 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_mmcsd.c
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32_mmcsd.c
@@ -78,7 +78,6 @@ int stm32_mmcsd_initialize(int port, int minor)
   int rv;
 
   stm32_configgpio(GPIO_MMCSD_NCD);   /* Assign SD_DET */
-  stm32_configgpio(GPIO_SPI2_SCK_2);  /* Assign PB13 as SPI2_SCK */
   stm32_configgpio(GPIO_MMCSD_NSS);   /* Assign CS */
   stm32_gpiowrite(GPIO_MMCSD_NSS, 1); /* Ensure the CS is inactive */
 


[nuttx] 04/05: stm32f4discovery/stm32_usbmsc.c: fix SD card initialization

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 023c0d703417c7250049ec4658f500a6ad3c3715
Author: raiden00pl <ra...@railab.me>
AuthorDate: Mon Apr 3 16:07:17 2023 +0200

    stm32f4discovery/stm32_usbmsc.c: fix SD card initialization
---
 boards/arm/stm32/stm32f4discovery/src/stm32_usbmsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_usbmsc.c b/boards/arm/stm32/stm32f4discovery/src/stm32_usbmsc.c
index a209fc1c79..14d557c7b6 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_usbmsc.c
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32_usbmsc.c
@@ -63,7 +63,7 @@ int board_usbmsc_initialize(int port)
    */
 
 #ifndef CONFIG_NSH_BUILTIN_APPS
-  return stm32_sdinitialize(CONFIG_SYSTEM_USBMSC_DEVMINOR1);
+  return stm32_mmcsd_initialize(2, CONFIG_SYSTEM_USBMSC_DEVMINOR1);
 #else
   return OK;
 #endif


[nuttx] 02/05: nucleo-144: add composite device configuration

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit fbf1e859eefed50130b1e108295c991232635f49
Author: raiden00pl <ra...@railab.me>
AuthorDate: Fri Mar 24 12:54:30 2023 +0100

    nucleo-144: add composite device configuration
---
 .../nucleo-144/configs/f722-composite/Make.defs    |  39 +++
 .../nucleo-144/configs/f722-composite/defconfig    |  86 +++++
 boards/arm/stm32f7/nucleo-144/src/Makefile         |   4 +
 .../arm/stm32f7/nucleo-144/src/stm32_composite.c   | 347 +++++++++++++++++++++
 4 files changed, 476 insertions(+)

diff --git a/boards/arm/stm32f7/nucleo-144/configs/f722-composite/Make.defs b/boards/arm/stm32f7/nucleo-144/configs/f722-composite/Make.defs
new file mode 100644
index 0000000000..7107672e69
--- /dev/null
+++ b/boards/arm/stm32f7/nucleo-144/configs/f722-composite/Make.defs
@@ -0,0 +1,39 @@
+############################################################################
+# boards/arm/stm32f7/nucleo-144/configs/f722-composite/Make.defs
+#
+# 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.
+#
+############################################################################
+
+include $(TOPDIR)/.config
+include $(TOPDIR)/tools/Config.mk
+include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
+
+LDSCRIPT = f722-flash.ld
+ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
+
+ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
+
+CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
+CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
+CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
+CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
+CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+AFLAGS := $(CFLAGS) -D__ASSEMBLY__
+
+NXFLATLDFLAGS1 = -r -d -warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
+LDNXFLATFLAGS = -e main -s 2048
diff --git a/boards/arm/stm32f7/nucleo-144/configs/f722-composite/defconfig b/boards/arm/stm32f7/nucleo-144/configs/f722-composite/defconfig
new file mode 100644
index 0000000000..3bd41ccb58
--- /dev/null
+++ b/boards/arm/stm32f7/nucleo-144/configs/f722-composite/defconfig
@@ -0,0 +1,86 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_ARCH_FPU is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="nucleo-144"
+CONFIG_ARCH_BOARD_NUCLEO_144=y
+CONFIG_ARCH_BUTTONS=y
+CONFIG_ARCH_CHIP="stm32f7"
+CONFIG_ARCH_CHIP_STM32F722ZE=y
+CONFIG_ARCH_CHIP_STM32F7=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARMV7M_DCACHE=y
+CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
+CONFIG_ARMV7M_DTCM=y
+CONFIG_ARMV7M_ICACHE=y
+CONFIG_BOARD_LOOPSPERMSEC=43103
+CONFIG_BUILTIN=y
+CONFIG_CDCACM=y
+CONFIG_CDCACM_COMPOSITE=y
+CONFIG_COMPOSITE_IAD=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_FS_PROCFS=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_MM_REGIONS=2
+CONFIG_NET=y
+CONFIG_NETDB_DNSCLIENT=y
+CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x0
+CONFIG_NETDEV_LATEINIT=y
+CONFIG_NETDEV_STATISTICS=y
+CONFIG_NETINIT_DHCPC=y
+CONFIG_NETINIT_DRIPADDR=0x0
+CONFIG_NETINIT_MACADDR_1=0xdeadcafe
+CONFIG_NETINIT_NETMASK=0x0
+CONFIG_NETINIT_NOMAC=y
+CONFIG_NETINIT_THREAD=y
+CONFIG_NETUTILS_DHCPC=y
+CONFIG_NETUTILS_IPERF=y
+CONFIG_NETUTILS_TELNETD=y
+CONFIG_NET_ARP_SEND=y
+CONFIG_NET_BROADCAST=y
+CONFIG_NET_ICMP=y
+CONFIG_NET_ICMP_SOCKET=y
+CONFIG_NET_LL_GUARDSIZE=50
+CONFIG_NET_LOOPBACK=y
+CONFIG_NET_STATISTICS=y
+CONFIG_NET_TCP=y
+CONFIG_NET_TCP_WRITE_BUFFERS=y
+CONFIG_NET_UDP=y
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_LINELEN=64
+CONFIG_NSH_READLINE=y
+CONFIG_NUCLEO_CONSOLE_VIRTUAL=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_RAM_SIZE=245760
+CONFIG_RAM_START=0x20010000
+CONFIG_RAW_BINARY=y
+CONFIG_RNDIS=y
+CONFIG_RNDIS_COMPOSITE=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_LPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SPI=y
+CONFIG_STACK_COLORATION=y
+CONFIG_START_DAY=30
+CONFIG_START_MONTH=11
+CONFIG_START_YEAR=2015
+CONFIG_STM32F7_OTGFS=y
+CONFIG_STM32F7_SERIALBRK_BSDCOMPAT=y
+CONFIG_STM32F7_SERIAL_DISABLE_REORDERING=y
+CONFIG_STM32F7_USART_BREAKS=y
+CONFIG_SYSTEM_COMPOSITE=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_TASK_NAME_SIZE=0
+CONFIG_USART3_SERIAL_CONSOLE=y
+CONFIG_USBDEV=y
+CONFIG_USBDEV_COMPOSITE=y
diff --git a/boards/arm/stm32f7/nucleo-144/src/Makefile b/boards/arm/stm32f7/nucleo-144/src/Makefile
index 75463c845d..1c946d49ac 100644
--- a/boards/arm/stm32f7/nucleo-144/src/Makefile
+++ b/boards/arm/stm32f7/nucleo-144/src/Makefile
@@ -85,4 +85,8 @@ CSRCS += stm32_cansock.c
 endif
 endif
 
+ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
+CSRCS += stm32_composite.c
+endif
+
 include $(TOPDIR)/boards/Board.mk
diff --git a/boards/arm/stm32f7/nucleo-144/src/stm32_composite.c b/boards/arm/stm32f7/nucleo-144/src/stm32_composite.c
new file mode 100644
index 0000000000..12d37b4ae1
--- /dev/null
+++ b/boards/arm/stm32f7/nucleo-144/src/stm32_composite.c
@@ -0,0 +1,347 @@
+/****************************************************************************
+ * boards/arm/stm32f7/nucleo-144/src/stm32_composite.c
+ *
+ * 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 <nuttx/config.h>
+#include <sys/types.h>
+#include <debug.h>
+#include <assert.h>
+
+#include <nuttx/usb/usbdev.h>
+#include <nuttx/usb/rndis.h>
+#include <nuttx/usb/cdcacm.h>
+#include <nuttx/usb/usbmsc.h>
+#include <nuttx/usb/composite.h>
+
+#include "stm32_otg.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define COMPOSITE0_DEV (3)
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+static void *g_mschandle;
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_mscclassobject
+ *
+ * Description:
+ *   If the mass storage class driver is part of composite device, then
+ *   its instantiation and configuration is a multi-step, board-specific,
+ *   process (See comments for usbmsc_configure below).  In this case,
+ *   board-specific logic must provide board_mscclassobject().
+ *
+ *   board_mscclassobject() is called from the composite driver.  It must
+ *   encapsulate the instantiation and configuration of the mass storage
+ *   class and the return the mass storage device's class driver instance
+ *   to the composite driver.
+ *
+ * Input Parameters:
+ *   classdev - The location to return the mass storage class' device
+ *     instance.
+ *
+ * Returned Value:
+ *   0 on success; a negated errno on failure
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+static int board_mscclassobject(int minor,
+                                struct usbdev_devinfo_s *devinfo,
+                                struct usbdevclass_driver_s **classdev)
+{
+  int ret;
+
+  DEBUGASSERT(g_mschandle == NULL);
+
+  /* Configure the mass storage device */
+
+  uinfo("Configuring with NLUNS=1\n");
+  ret = usbmsc_configure(1, &g_mschandle);
+  if (ret < 0)
+    {
+      uerr("ERROR: usbmsc_configure failed: %d\n", -ret);
+      return ret;
+    }
+
+  uinfo("MSC handle=%p\n", g_mschandle);
+
+  /* Bind the LUN(s) */
+
+  uinfo("Bind LUN=0 to /dev/mmcsd0\n");
+  ret = usbmsc_bindlun(g_mschandle, "/dev/mmcsd0", 0, 0, 0, false);
+  if (ret < 0)
+    {
+      uerr("ERROR: usbmsc_bindlun failed for LUN 1 at /dev/mmcsd0: %d\n",
+           ret);
+      usbmsc_uninitialize(g_mschandle);
+      g_mschandle = NULL;
+      return ret;
+    }
+
+  /* Get the mass storage device's class object */
+
+  ret = usbmsc_classobject(g_mschandle, devinfo, classdev);
+  if (ret < 0)
+    {
+      uerr("ERROR: usbmsc_classobject failed: %d\n", -ret);
+      usbmsc_uninitialize(g_mschandle);
+      g_mschandle = NULL;
+    }
+
+  return ret;
+}
+#endif
+
+/****************************************************************************
+ * Name: board_mscuninitialize
+ *
+ * Description:
+ *   Un-initialize the USB storage class driver.
+ *   This is just an application specific wrapper for usbmsc_unitialize()
+ *   that is called form the composite device logic.
+ *
+ * Input Parameters:
+ *   classdev - The class driver instrance previously give to the composite
+ *     driver by board_mscclassobject().
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+static void board_mscuninitialize(struct usbdevclass_driver_s *classdev)
+{
+  if (g_mschandle)
+    {
+      usbmsc_uninitialize(g_mschandle);
+    }
+
+  g_mschandle = NULL;
+}
+#endif
+
+/****************************************************************************
+ * Name:  board_composite_connect
+ *
+ * Description:
+ *   Connect the USB composite device on the specified USB device port for
+ *   configuration 0.
+ *
+ * Input Parameters:
+ *   port     - The USB device port.
+ *
+ * Returned Value:
+ *   A non-NULL handle value is returned on success.  NULL is returned on
+ *   any failure.
+ *
+ ****************************************************************************/
+
+static void *board_composite0_connect(int port)
+{
+  struct composite_devdesc_s dev[COMPOSITE0_DEV];
+  int ifnobase = 0;
+  int strbase  = COMPOSITE_NSTRIDS;
+  int dev_idx = 0;
+  int epin = 1;
+  int epout = 1;
+
+#ifdef CONFIG_RNDIS_COMPOSITE
+  /* Configure the RNDIS USB device */
+
+  /* Ask the rndis driver to fill in the constants we didn't
+   * know here.
+   */
+
+  usbdev_rndis_get_composite_devdesc(&dev[dev_idx]);
+
+  /* Interfaces */
+
+  dev[dev_idx].devinfo.ifnobase = ifnobase;
+  dev[dev_idx].minor = 0;
+
+  /* Strings */
+
+  dev[dev_idx].devinfo.strbase = strbase;
+
+  /* Endpoints */
+
+  dev[dev_idx].devinfo.epno[RNDIS_EP_INTIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[RNDIS_EP_BULKIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[RNDIS_EP_BULKOUT_IDX] = epout++;
+
+  /* Count up the base numbers */
+
+  ifnobase += dev[dev_idx].devinfo.ninterfaces;
+  strbase += dev[dev_idx].devinfo.nstrings;
+
+  dev_idx += 1;
+#endif
+
+#ifdef CONFIG_CDCACM_COMPOSITE
+  /* Configure the CDC/ACM device */
+
+  /* Ask the cdcacm driver to fill in the constants we didn't
+   * know here.
+   */
+
+  cdcacm_get_composite_devdesc(&dev[dev_idx]);
+
+  /* Overwrite and correct some values... */
+
+  /* The callback functions for the CDC/ACM class */
+
+  dev[dev_idx].classobject  = cdcacm_classobject;
+  dev[dev_idx].uninitialize = cdcacm_uninitialize;
+
+  /* Interfaces */
+
+  dev[dev_idx].devinfo.ifnobase = ifnobase;             /* Offset to Interface-IDs */
+  dev[dev_idx].minor = 0;                               /* The minor interface number */
+
+  /* Strings */
+
+  dev[dev_idx].devinfo.strbase = strbase;               /* Offset to String Numbers */
+
+  /* Endpoints */
+
+  dev[dev_idx].devinfo.epno[CDCACM_EP_INTIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[CDCACM_EP_BULKIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = epout++;
+
+  /* Count up the base numbers */
+
+  ifnobase += dev[dev_idx].devinfo.ninterfaces;
+  strbase  += dev[dev_idx].devinfo.nstrings;
+
+  dev_idx += 1;
+#endif
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+  /* Configure the mass storage device device */
+
+  /* Ask the usbmsc driver to fill in the constants we didn't
+   * know here.
+   */
+
+  usbmsc_get_composite_devdesc(&dev[dev_idx]);
+
+  /* Overwrite and correct some values... */
+
+  /* The callback functions for the USBMSC class */
+
+  dev[dev_idx].classobject  = board_mscclassobject;
+  dev[dev_idx].uninitialize = board_mscuninitialize;
+
+  /* Interfaces */
+
+  dev[dev_idx].devinfo.ifnobase = ifnobase;               /* Offset to Interface-IDs */
+  dev[dev_idx].minor = 0;                                 /* The minor interface number */
+
+  /* Strings */
+
+  dev[dev_idx].devinfo.strbase = strbase;                 /* Offset to String Numbers */
+
+  /* Endpoints */
+
+  dev[dev_idx].devinfo.epno[USBMSC_EP_BULKIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[USBMSC_EP_BULKOUT_IDX] = epout++;
+
+  /* Count up the base numbers */
+
+  ifnobase += dev[dev_idx].devinfo.ninterfaces;
+  strbase  += dev[dev_idx].devinfo.nstrings;
+
+  dev_idx += 1;
+#endif
+
+  /* Sanity checks */
+
+  DEBUGASSERT(epin < STM32_NENDPOINTS);
+  DEBUGASSERT(epout < STM32_NENDPOINTS);
+
+  return composite_initialize(dev_idx, dev);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_composite_initialize
+ *
+ * Description:
+ *   Perform architecture specific initialization of a composite USB device.
+ *
+ ****************************************************************************/
+
+int board_composite_initialize(int port)
+{
+  return OK;
+}
+
+/****************************************************************************
+ * Name:  board_composite_connect
+ *
+ * Description:
+ *   Connect the USB composite device on the specified USB device port using
+ *   the specified configuration.  The interpretation of the configid is
+ *   board specific.
+ *
+ * Input Parameters:
+ *   port     - The USB device port.
+ *   configid - The USB composite configuration
+ *
+ * Returned Value:
+ *   A non-NULL handle value is returned on success.  NULL is returned on
+ *   any failure.
+ *
+ ****************************************************************************/
+
+void *board_composite_connect(int port, int configid)
+{
+  if (configid == 0)
+    {
+      return board_composite0_connect(port);
+    }
+  else
+    {
+      return NULL;
+    }
+}


[nuttx] 05/05: stm32f4discovery: add composite device configuration

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit f29e802ca8005007b87994e8a15f19d8e23660e7
Author: raiden00pl <ra...@railab.me>
AuthorDate: Mon Apr 3 16:07:46 2023 +0200

    stm32f4discovery: add composite device configuration
---
 .../stm32f4discovery/configs/composite/defconfig   | 103 ++++++
 boards/arm/stm32/stm32f4discovery/src/Make.defs    |   4 +
 .../arm/stm32/stm32f4discovery/src/stm32_bringup.c |   2 +-
 .../stm32/stm32f4discovery/src/stm32_composite.c   | 347 +++++++++++++++++++++
 4 files changed, 455 insertions(+), 1 deletion(-)

diff --git a/boards/arm/stm32/stm32f4discovery/configs/composite/defconfig b/boards/arm/stm32/stm32f4discovery/configs/composite/defconfig
new file mode 100644
index 0000000000..ecb7a136d0
--- /dev/null
+++ b/boards/arm/stm32/stm32f4discovery/configs/composite/defconfig
@@ -0,0 +1,103 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_ARCH_FPU is not set
+# CONFIG_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+# CONFIG_SPI_CALLBACK is not set
+CONFIG_ALLOW_BSD_COMPONENTS=y
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="stm32f4discovery"
+CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
+CONFIG_ARCH_BUTTONS=y
+CONFIG_ARCH_CHIP="stm32"
+CONFIG_ARCH_CHIP_STM32=y
+CONFIG_ARCH_CHIP_STM32F407VG=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARD_LOOPSPERMSEC=16717
+CONFIG_BUILTIN=y
+CONFIG_COMPOSITE_IAD=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_ELF=y
+CONFIG_EXAMPLES_HELLO=m
+CONFIG_FAT_LCNAMES=y
+CONFIG_FAT_LFN=y
+CONFIG_FS_FAT=y
+CONFIG_FS_PROCFS=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_STACKSIZE=3072
+CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBC_ENVPATH=y
+CONFIG_LIBC_EXECFUNCS=y
+CONFIG_MMCSD=y
+CONFIG_NET=y
+CONFIG_NETDB_DNSCLIENT=y
+CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x0
+CONFIG_NETINIT_DHCPC=y
+CONFIG_NETINIT_DRIPADDR=0x0
+CONFIG_NETINIT_MACADDR_1=0xdeadcafe
+CONFIG_NETINIT_NETMASK=0x0
+CONFIG_NETINIT_NOMAC=y
+CONFIG_NETINIT_THREAD=y
+CONFIG_NETUTILS_DHCPC=y
+CONFIG_NETUTILS_IPERF=y
+CONFIG_NETUTILS_TELNETD=y
+CONFIG_NETUTILS_WEBCLIENT=y
+CONFIG_NET_ARP_SEND=y
+CONFIG_NET_BROADCAST=y
+CONFIG_NET_ICMP=y
+CONFIG_NET_ICMP_SOCKET=y
+CONFIG_NET_LL_GUARDSIZE=50
+CONFIG_NET_LOOPBACK=y
+CONFIG_NET_STATISTICS=y
+CONFIG_NET_TCP=y
+CONFIG_NET_TCP_WRITE_BUFFERS=y
+CONFIG_NET_UDP=y
+CONFIG_NFS=y
+CONFIG_NFS_STATISTICS=y
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_FILE_APPS=y
+CONFIG_NSH_LINELEN=128
+CONFIG_NSH_READLINE=y
+CONFIG_NSH_SYMTAB=y
+CONFIG_NSH_SYMTAB_ARRAYNAME="g_symtab"
+CONFIG_NSH_SYMTAB_COUNTNAME="g_nsymbols"
+CONFIG_PATH_INITIAL="/mnt/nfs/bin"
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_RAM_SIZE=114688
+CONFIG_RAM_START=0x20000000
+CONFIG_RAW_BINARY=y
+CONFIG_RNDIS=y
+CONFIG_RNDIS_COMPOSITE=y
+CONFIG_SCHED_LPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SENSORS=y
+CONFIG_START_DAY=13
+CONFIG_START_MONTH=9
+CONFIG_START_YEAR=2014
+CONFIG_STM32_DMA2=y
+CONFIG_STM32_DMACAPABLE=y
+CONFIG_STM32_JTAG_SW_ENABLE=y
+CONFIG_STM32_OTGFS=y
+CONFIG_STM32_PWR=y
+CONFIG_STM32_SPI2=y
+CONFIG_STM32_USART2=y
+CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_COMPOSITE=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_PING=y
+CONFIG_USART2_SERIAL_CONSOLE=y
+CONFIG_USBDEV=y
+CONFIG_USBDEV_COMPOSITE=y
+CONFIG_USBMSC=y
+CONFIG_USBMSC_COMPOSITE=y
diff --git a/boards/arm/stm32/stm32f4discovery/src/Make.defs b/boards/arm/stm32/stm32f4discovery/src/Make.defs
index 6e17e93d6e..b95b3aad3c 100644
--- a/boards/arm/stm32/stm32f4discovery/src/Make.defs
+++ b/boards/arm/stm32/stm32f4discovery/src/Make.defs
@@ -187,6 +187,10 @@ ifeq ($(CONFIG_INPUT_DJOYSTICK),y)
   CSRCS += stm32_djoystick.c
 endif
 
+ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
+  CSRCS += stm32_composite.c
+endif
+
 DEPPATH += --dep-path board
 VPATH += :board
 CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
index 8aef29a9f2..855f85a3ea 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
@@ -573,7 +573,7 @@ int stm32_bringup(void)
     }
 #endif
 
-#if defined(CONFIG_RNDIS)
+#if defined(CONFIG_RNDIS) && !defined(CONFIG_RNDIS_COMPOSITE)
   uint8_t mac[6];
   mac[0] = 0xa0; /* TODO */
   mac[1] = (CONFIG_NETINIT_MACADDR_2 >> (8 * 0)) & 0xff;
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_composite.c b/boards/arm/stm32/stm32f4discovery/src/stm32_composite.c
new file mode 100644
index 0000000000..ab4a34139d
--- /dev/null
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32_composite.c
@@ -0,0 +1,347 @@
+/****************************************************************************
+ * boards/arm/stm32/stm32f4discovery/src/stm32_composite.c
+ *
+ * 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 <nuttx/config.h>
+#include <sys/types.h>
+#include <debug.h>
+#include <assert.h>
+
+#include <nuttx/usb/usbdev.h>
+#include <nuttx/usb/rndis.h>
+#include <nuttx/usb/cdcacm.h>
+#include <nuttx/usb/usbmsc.h>
+#include <nuttx/usb/composite.h>
+
+#include "stm32_otgfs.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define COMPOSITE0_DEV (3)
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+static void *g_mschandle;
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_mscclassobject
+ *
+ * Description:
+ *   If the mass storage class driver is part of composite device, then
+ *   its instantiation and configuration is a multi-step, board-specific,
+ *   process (See comments for usbmsc_configure below).  In this case,
+ *   board-specific logic must provide board_mscclassobject().
+ *
+ *   board_mscclassobject() is called from the composite driver.  It must
+ *   encapsulate the instantiation and configuration of the mass storage
+ *   class and the return the mass storage device's class driver instance
+ *   to the composite driver.
+ *
+ * Input Parameters:
+ *   classdev - The location to return the mass storage class' device
+ *     instance.
+ *
+ * Returned Value:
+ *   0 on success; a negated errno on failure
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+static int board_mscclassobject(int minor,
+                                struct usbdev_devinfo_s *devinfo,
+                                struct usbdevclass_driver_s **classdev)
+{
+  int ret;
+
+  DEBUGASSERT(g_mschandle == NULL);
+
+  /* Configure the mass storage device */
+
+  uinfo("Configuring with NLUNS=1\n");
+  ret = usbmsc_configure(1, &g_mschandle);
+  if (ret < 0)
+    {
+      uerr("ERROR: usbmsc_configure failed: %d\n", -ret);
+      return ret;
+    }
+
+  uinfo("MSC handle=%p\n", g_mschandle);
+
+  /* Bind the LUN(s) */
+
+  uinfo("Bind LUN=0 to /dev/mmcsd0\n");
+  ret = usbmsc_bindlun(g_mschandle, "/dev/mmcsd0", 0, 0, 0, false);
+  if (ret < 0)
+    {
+      uerr("ERROR: usbmsc_bindlun failed for LUN 1 at /dev/mmcsd0: %d\n",
+           ret);
+      usbmsc_uninitialize(g_mschandle);
+      g_mschandle = NULL;
+      return ret;
+    }
+
+  /* Get the mass storage device's class object */
+
+  ret = usbmsc_classobject(g_mschandle, devinfo, classdev);
+  if (ret < 0)
+    {
+      uerr("ERROR: usbmsc_classobject failed: %d\n", -ret);
+      usbmsc_uninitialize(g_mschandle);
+      g_mschandle = NULL;
+    }
+
+  return ret;
+}
+#endif
+
+/****************************************************************************
+ * Name: board_mscuninitialize
+ *
+ * Description:
+ *   Un-initialize the USB storage class driver.
+ *   This is just an application specific wrapper for usbmsc_unitialize()
+ *   that is called form the composite device logic.
+ *
+ * Input Parameters:
+ *   classdev - The class driver instrance previously give to the composite
+ *     driver by board_mscclassobject().
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+static void board_mscuninitialize(struct usbdevclass_driver_s *classdev)
+{
+  if (g_mschandle)
+    {
+      usbmsc_uninitialize(g_mschandle);
+    }
+
+  g_mschandle = NULL;
+}
+#endif
+
+/****************************************************************************
+ * Name:  board_composite_connect
+ *
+ * Description:
+ *   Connect the USB composite device on the specified USB device port for
+ *   configuration 0.
+ *
+ * Input Parameters:
+ *   port     - The USB device port.
+ *
+ * Returned Value:
+ *   A non-NULL handle value is returned on success.  NULL is returned on
+ *   any failure.
+ *
+ ****************************************************************************/
+
+static void *board_composite0_connect(int port)
+{
+  struct composite_devdesc_s dev[COMPOSITE0_DEV];
+  int ifnobase = 0;
+  int strbase  = COMPOSITE_NSTRIDS;
+  int dev_idx = 0;
+  int epin = 1;
+  int epout = 1;
+
+#ifdef CONFIG_RNDIS_COMPOSITE
+  /* Configure the RNDIS USB device */
+
+  /* Ask the rndis driver to fill in the constants we didn't
+   * know here.
+   */
+
+  usbdev_rndis_get_composite_devdesc(&dev[dev_idx]);
+
+  /* Interfaces */
+
+  dev[dev_idx].devinfo.ifnobase = ifnobase;
+  dev[dev_idx].minor = 0;
+
+  /* Strings */
+
+  dev[dev_idx].devinfo.strbase = strbase;
+
+  /* Endpoints */
+
+  dev[dev_idx].devinfo.epno[RNDIS_EP_INTIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[RNDIS_EP_BULKIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[RNDIS_EP_BULKOUT_IDX] = epout++;
+
+  /* Count up the base numbers */
+
+  ifnobase += dev[dev_idx].devinfo.ninterfaces;
+  strbase += dev[dev_idx].devinfo.nstrings;
+
+  dev_idx += 1;
+#endif
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+  /* Configure the mass storage device device */
+
+  /* Ask the usbmsc driver to fill in the constants we didn't
+   * know here.
+   */
+
+  usbmsc_get_composite_devdesc(&dev[dev_idx]);
+
+  /* Overwrite and correct some values... */
+
+  /* The callback functions for the USBMSC class */
+
+  dev[dev_idx].classobject  = board_mscclassobject;
+  dev[dev_idx].uninitialize = board_mscuninitialize;
+
+  /* Interfaces */
+
+  dev[dev_idx].devinfo.ifnobase = ifnobase;               /* Offset to Interface-IDs */
+  dev[dev_idx].minor = 0;                                 /* The minor interface number */
+
+  /* Strings */
+
+  dev[dev_idx].devinfo.strbase = strbase;                 /* Offset to String Numbers */
+
+  /* Endpoints */
+
+  dev[dev_idx].devinfo.epno[USBMSC_EP_BULKIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[USBMSC_EP_BULKOUT_IDX] = epout++;
+
+  /* Count up the base numbers */
+
+  ifnobase += dev[dev_idx].devinfo.ninterfaces;
+  strbase  += dev[dev_idx].devinfo.nstrings;
+
+  dev_idx += 1;
+#endif
+
+#ifdef CONFIG_CDCACM_COMPOSITE
+  /* Configure the CDC/ACM device */
+
+  /* Ask the cdcacm driver to fill in the constants we didn't
+   * know here.
+   */
+
+  cdcacm_get_composite_devdesc(&dev[dev_idx]);
+
+  /* Overwrite and correct some values... */
+
+  /* The callback functions for the CDC/ACM class */
+
+  dev[dev_idx].classobject  = cdcacm_classobject;
+  dev[dev_idx].uninitialize = cdcacm_uninitialize;
+
+  /* Interfaces */
+
+  dev[dev_idx].devinfo.ifnobase = ifnobase;             /* Offset to Interface-IDs */
+  dev[dev_idx].minor = 0;                               /* The minor interface number */
+
+  /* Strings */
+
+  dev[dev_idx].devinfo.strbase = strbase;               /* Offset to String Numbers */
+
+  /* Endpoints */
+
+  dev[dev_idx].devinfo.epno[CDCACM_EP_INTIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[CDCACM_EP_BULKIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = epout++;
+
+  /* Count up the base numbers */
+
+  ifnobase += dev[dev_idx].devinfo.ninterfaces;
+  strbase += dev[dev_idx].devinfo.nstrings;
+
+  dev_idx += 1;
+#endif
+
+  /* Sanity checks */
+
+  DEBUGASSERT(epin < STM32_NENDPOINTS);
+  DEBUGASSERT(epout < STM32_NENDPOINTS);
+
+  return composite_initialize(dev_idx, dev);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_composite_initialize
+ *
+ * Description:
+ *   Perform architecture specific initialization of a composite USB device.
+ *
+ ****************************************************************************/
+
+int board_composite_initialize(int port)
+{
+  return OK;
+}
+
+/****************************************************************************
+ * Name:  board_composite_connect
+ *
+ * Description:
+ *   Connect the USB composite device on the specified USB device port using
+ *   the specified configuration.  The interpretation of the configid is
+ *   board specific.
+ *
+ * Input Parameters:
+ *   port     - The USB device port.
+ *   configid - The USB composite configuration
+ *
+ * Returned Value:
+ *   A non-NULL handle value is returned on success.  NULL is returned on
+ *   any failure.
+ *
+ ****************************************************************************/
+
+void *board_composite_connect(int port, int configid)
+{
+  if (configid == 0)
+    {
+      return board_composite0_connect(port);
+    }
+  else
+    {
+      return NULL;
+    }
+}


[nuttx] 01/05: nucleo-h743zi: add composite device configuration

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 64402a1c4cee074ec56bfc092682bcc2c2065a0d
Author: raiden00pl <ra...@railab.me>
AuthorDate: Fri Mar 24 12:54:02 2023 +0100

    nucleo-h743zi: add composite device configuration
---
 .../nucleo-h743zi/configs/composite/defconfig      |  95 ++++++
 .../stm32h7/nucleo-h743zi/configs/rndis/defconfig  |  82 +++++
 boards/arm/stm32h7/nucleo-h743zi/src/Makefile      |  12 +
 .../arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h  |  22 ++
 .../arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c  |  29 +-
 .../stm32h7/nucleo-h743zi/src/stm32_composite.c    | 347 +++++++++++++++++++++
 boards/arm/stm32h7/nucleo-h743zi/src/stm32_mmcsd.c |  88 ++++++
 boards/arm/stm32h7/nucleo-h743zi/src/stm32_spi.c   |  28 +-
 .../arm/stm32h7/nucleo-h743zi/src/stm32_usbmsc.c   |  59 ++++
 9 files changed, 759 insertions(+), 3 deletions(-)

diff --git a/boards/arm/stm32h7/nucleo-h743zi/configs/composite/defconfig b/boards/arm/stm32h7/nucleo-h743zi/configs/composite/defconfig
new file mode 100644
index 0000000000..e18d977ddf
--- /dev/null
+++ b/boards/arm/stm32h7/nucleo-h743zi/configs/composite/defconfig
@@ -0,0 +1,95 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_SPI_CALLBACK is not set
+# CONFIG_STANDARD_SERIAL is not set
+# CONFIG_STM32H7_USE_LEGACY_PINMAP is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="nucleo-h743zi"
+CONFIG_ARCH_BOARD_NUCLEO_H743ZI=y
+CONFIG_ARCH_CHIP="stm32h7"
+CONFIG_ARCH_CHIP_STM32H743ZI=y
+CONFIG_ARCH_CHIP_STM32H7=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARMV7M_DCACHE=y
+CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
+CONFIG_ARMV7M_DTCM=y
+CONFIG_ARMV7M_ICACHE=y
+CONFIG_BOARD_LOOPSPERMSEC=43103
+CONFIG_BUILTIN=y
+CONFIG_CDCACM=y
+CONFIG_CDCACM_COMPOSITE=y
+CONFIG_COMPOSITE_IAD=y
+CONFIG_COMPOSITE_MSFT_OS_DESCRIPTORS=y
+CONFIG_COMPOSITE_PRODUCTID=0x2022
+CONFIG_COMPOSITE_SERIALSTR="12345"
+CONFIG_COMPOSITE_VENDORID=0x03eb
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_FS_FAT=y
+CONFIG_FS_PROCFS=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_MMCSD=y
+CONFIG_MM_REGIONS=4
+CONFIG_NET=y
+CONFIG_NETDB_DNSCLIENT=y
+CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x0
+CONFIG_NETDEV_LATEINIT=y
+CONFIG_NETINIT_DHCPC=y
+CONFIG_NETINIT_DRIPADDR=0x0
+CONFIG_NETINIT_MACADDR_1=0xdeadcafe
+CONFIG_NETINIT_NETMASK=0x0
+CONFIG_NETINIT_NOMAC=y
+CONFIG_NETINIT_THREAD=y
+CONFIG_NETUTILS_DHCPC=y
+CONFIG_NETUTILS_IPERF=y
+CONFIG_NET_ARP_SEND=y
+CONFIG_NET_BROADCAST=y
+CONFIG_NET_ICMP=y
+CONFIG_NET_ICMP_SOCKET=y
+CONFIG_NET_LL_GUARDSIZE=50
+CONFIG_NET_LOOPBACK=y
+CONFIG_NET_STATISTICS=y
+CONFIG_NET_TCP=y
+CONFIG_NET_TCP_WRITE_BUFFERS=y
+CONFIG_NET_UDP=y
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_DISABLE_IFUPDOWN=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_LINELEN=64
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_RAM_SIZE=245760
+CONFIG_RAM_START=0x20010000
+CONFIG_RAW_BINARY=y
+CONFIG_RNDIS=y
+CONFIG_RNDIS_COMPOSITE=y
+CONFIG_RNDIS_NWRREQS=2
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_LPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=6
+CONFIG_START_MONTH=12
+CONFIG_START_YEAR=2011
+CONFIG_STM32H7_HSI48=y
+CONFIG_STM32H7_OTGFS=y
+CONFIG_STM32H7_SPI3=y
+CONFIG_STM32H7_USART3=y
+CONFIG_SYSTEM_COMPOSITE=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_USBMSC=y
+CONFIG_TASK_NAME_SIZE=0
+CONFIG_USART3_SERIAL_CONSOLE=y
+CONFIG_USBDEV=y
+CONFIG_USBDEV_COMPOSITE=y
+CONFIG_USBMSC=y
+CONFIG_USBMSC_COMPOSITE=y
+CONFIG_USBMSC_NOT_STALL_BULKEP=y
diff --git a/boards/arm/stm32h7/nucleo-h743zi/configs/rndis/defconfig b/boards/arm/stm32h7/nucleo-h743zi/configs/rndis/defconfig
new file mode 100644
index 0000000000..8bcb4b1f9d
--- /dev/null
+++ b/boards/arm/stm32h7/nucleo-h743zi/configs/rndis/defconfig
@@ -0,0 +1,82 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_STANDARD_SERIAL is not set
+# CONFIG_STM32H7_USE_LEGACY_PINMAP is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="nucleo-h743zi"
+CONFIG_ARCH_BOARD_NUCLEO_H743ZI=y
+CONFIG_ARCH_CHIP="stm32h7"
+CONFIG_ARCH_CHIP_STM32H743ZI=y
+CONFIG_ARCH_CHIP_STM32H7=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARMV7M_DCACHE=y
+CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
+CONFIG_ARMV7M_DTCM=y
+CONFIG_ARMV7M_ICACHE=y
+CONFIG_BOARDCTL_USBDEVCTRL=y
+CONFIG_BOARD_LOOPSPERMSEC=43103
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_EXPERIMENTAL=y
+CONFIG_FS_PROCFS=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_MM_REGIONS=4
+CONFIG_NET=y
+CONFIG_NETDB_DNSCLIENT=y
+CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x0
+CONFIG_NETDEV_LATEINIT=y
+CONFIG_NETDEV_STATISTICS=y
+CONFIG_NETINIT_DHCPC=y
+CONFIG_NETINIT_DRIPADDR=0x0
+CONFIG_NETINIT_MACADDR_1=0xdeadcafe
+CONFIG_NETINIT_NETMASK=0x0
+CONFIG_NETINIT_NOMAC=y
+CONFIG_NETINIT_THREAD=y
+CONFIG_NETUTILS_DHCPC=y
+CONFIG_NETUTILS_IPERF=y
+CONFIG_NETUTILS_TELNETD=y
+CONFIG_NET_ARP_SEND=y
+CONFIG_NET_BROADCAST=y
+CONFIG_NET_ICMP=y
+CONFIG_NET_ICMP_SOCKET=y
+CONFIG_NET_LL_GUARDSIZE=50
+CONFIG_NET_LOOPBACK=y
+CONFIG_NET_STATISTICS=y
+CONFIG_NET_TCP=y
+CONFIG_NET_TCP_WRITE_BUFFERS=y
+CONFIG_NET_UDP=y
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_DISABLE_IFUPDOWN=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_LINELEN=64
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_RAM_SIZE=245760
+CONFIG_RAM_START=0x20010000
+CONFIG_RAW_BINARY=y
+CONFIG_RNDIS=y
+CONFIG_RNDIS_NWRREQS=2
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_LPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SPI=y
+CONFIG_START_DAY=6
+CONFIG_START_MONTH=12
+CONFIG_START_YEAR=2011
+CONFIG_STM32H7_HSI48=y
+CONFIG_STM32H7_OTGFS=y
+CONFIG_STM32H7_USART3=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_TASK_NAME_SIZE=0
+CONFIG_USART3_SERIAL_CONSOLE=y
+CONFIG_USBDEV=y
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/Makefile b/boards/arm/stm32h7/nucleo-h743zi/src/Makefile
index 842f918605..85d8e69733 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/src/Makefile
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/Makefile
@@ -100,4 +100,16 @@ ifeq ($(CONFIG_BOARDCTL_BOOT_IMAGE),y)
 CSRCS += stm32_boot_image.c
 endif
 
+ifeq ($(CONFIG_USBMSC),y)
+CSRCS += stm32_usbmsc.c
+endif
+
+ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
+CSRCS += stm32_composite.c
+endif
+
+ifeq ($(CONFIG_MMCSD),y)
+CSRCS += stm32_mmcsd.c
+endif
+
 include $(TOPDIR)/boards/Board.mk
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h b/boards/arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h
index efa36c35da..56bb67da5f 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h
@@ -196,6 +196,16 @@
                             GPIO_OUTPUT_CLEAR | GPIO_PORTF | GPIO_PIN12)
 #define GPIO_NRF24L01_IRQ  (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTD | GPIO_PIN15)
 
+/* MMC/SD
+ * CS  - PD15 (D9)
+ * NCD - PF12 (D8)
+ */
+
+#define GPIO_MMCSD_CS    (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
+                          GPIO_OUTPUT_SET | GPIO_PORTD | GPIO_PIN15)
+#define GPIO_MMCSD_NCD    (GPIO_INPUT | GPIO_PULLUP | GPIO_EXTI |  \
+                           GPIO_PORTF | GPIO_PIN12)
+
 /* LMS9DS1 configuration */
 
 #define LMS9DS1_I2CBUS 1
@@ -380,4 +390,16 @@ int stm32_progmem_init(void);
 #endif  /* HAVE_PROGMEM_CHARDEV */
 #endif
 
+/****************************************************************************
+ * Name: stm32_mmcsd_initialize
+ *
+ * Description:
+ *   Initialize SPI-based SD card and card detect thread.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_MMCSD_SPI
+int stm32_mmcsd_initialize(int minor);
+#endif
+
 #endif /* __BOARDS_ARM_STM32H7_NUCLEO_H743ZI_SRC_NUCLEO_H743ZI_H */
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c
index daadf7f1e5..c29ef796e5 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c
@@ -59,6 +59,10 @@
 #  include "stm32_wdg.h"
 #endif
 
+#ifdef CONFIG_RNDIS
+#  include <nuttx/usb/rndis.h>
+#endif
+
 #include "stm32_gpio.h"
 
 /****************************************************************************
@@ -307,7 +311,8 @@ int stm32_bringup(void)
     }
 #endif /* CONFIG_WL_NRF24L01 */
 
-#if defined(CONFIG_CDCACM) && !defined(CONFIG_CDCACM_CONSOLE)
+#if defined(CONFIG_CDCACM) && !defined(CONFIG_CDCACM_CONSOLE) && \
+    !defined(CONFIG_CDCACM_COMPOSITE)
   /* Initialize CDCACM */
 
   syslog(LOG_INFO, "Initialize CDCACM device\n");
@@ -319,6 +324,28 @@ int stm32_bringup(void)
     }
 #endif /* CONFIG_CDCACM & !CONFIG_CDCACM_CONSOLE */
 
+#if defined(CONFIG_RNDIS) && !defined(CONFIG_RNDIS_COMPOSITE)
+  uint8_t mac[6];
+  mac[0] = 0xa0; /* TODO */
+  mac[1] = (CONFIG_NETINIT_MACADDR_2 >> (8 * 0)) & 0xff;
+  mac[2] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 3)) & 0xff;
+  mac[3] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 2)) & 0xff;
+  mac[4] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 1)) & 0xff;
+  mac[5] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 0)) & 0xff;
+  usbdev_rndis_initialize(mac);
+#endif
+
+#ifdef CONFIG_MMCSD_SPI
+  /* Initialize the MMC/SD SPI driver (SPI3 is used) */
+
+  ret = stm32_mmcsd_initialize(CONFIG_NSH_MMCSDMINOR);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "Failed to initialize SD slot %d: %d\n",
+             CONFIG_NSH_MMCSDMINOR, ret);
+    }
+#endif
+
 #ifdef CONFIG_PWM
   /* Initialize PWM and register the PWM device. */
 
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_composite.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_composite.c
new file mode 100644
index 0000000000..33582a526d
--- /dev/null
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_composite.c
@@ -0,0 +1,347 @@
+/****************************************************************************
+ * boards/arm/stm32h7/nucleo-h743zi/src/stm32_composite.c
+ *
+ * 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 <nuttx/config.h>
+#include <sys/types.h>
+#include <debug.h>
+#include <assert.h>
+
+#include <nuttx/usb/usbdev.h>
+#include <nuttx/usb/rndis.h>
+#include <nuttx/usb/cdcacm.h>
+#include <nuttx/usb/usbmsc.h>
+#include <nuttx/usb/composite.h>
+
+#include "stm32_otg.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define COMPOSITE0_DEV (3)
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+static void *g_mschandle;
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_mscclassobject
+ *
+ * Description:
+ *   If the mass storage class driver is part of composite device, then
+ *   its instantiation and configuration is a multi-step, board-specific,
+ *   process (See comments for usbmsc_configure below).  In this case,
+ *   board-specific logic must provide board_mscclassobject().
+ *
+ *   board_mscclassobject() is called from the composite driver.  It must
+ *   encapsulate the instantiation and configuration of the mass storage
+ *   class and the return the mass storage device's class driver instance
+ *   to the composite driver.
+ *
+ * Input Parameters:
+ *   classdev - The location to return the mass storage class' device
+ *     instance.
+ *
+ * Returned Value:
+ *   0 on success; a negated errno on failure
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+static int board_mscclassobject(int minor,
+                                struct usbdev_devinfo_s *devinfo,
+                                struct usbdevclass_driver_s **classdev)
+{
+  int ret;
+
+  DEBUGASSERT(g_mschandle == NULL);
+
+  /* Configure the mass storage device */
+
+  uinfo("Configuring with NLUNS=1\n");
+  ret = usbmsc_configure(1, &g_mschandle);
+  if (ret < 0)
+    {
+      uerr("ERROR: usbmsc_configure failed: %d\n", -ret);
+      return ret;
+    }
+
+  uinfo("MSC handle=%p\n", g_mschandle);
+
+  /* Bind the LUN(s) */
+
+  uinfo("Bind LUN=0 to /dev/mmcsd0\n");
+  ret = usbmsc_bindlun(g_mschandle, "/dev/mmcsd0", 0, 0, 0, false);
+  if (ret < 0)
+    {
+      uerr("ERROR: usbmsc_bindlun failed for LUN 1 at /dev/mmcsd0: %d\n",
+           ret);
+      usbmsc_uninitialize(g_mschandle);
+      g_mschandle = NULL;
+      return ret;
+    }
+
+  /* Get the mass storage device's class object */
+
+  ret = usbmsc_classobject(g_mschandle, devinfo, classdev);
+  if (ret < 0)
+    {
+      uerr("ERROR: usbmsc_classobject failed: %d\n", -ret);
+      usbmsc_uninitialize(g_mschandle);
+      g_mschandle = NULL;
+    }
+
+  return ret;
+}
+#endif
+
+/****************************************************************************
+ * Name: board_mscuninitialize
+ *
+ * Description:
+ *   Un-initialize the USB storage class driver.
+ *   This is just an application specific wrapper for usbmsc_unitialize()
+ *   that is called form the composite device logic.
+ *
+ * Input Parameters:
+ *   classdev - The class driver instrance previously give to the composite
+ *     driver by board_mscclassobject().
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+static void board_mscuninitialize(struct usbdevclass_driver_s *classdev)
+{
+  if (g_mschandle)
+    {
+      usbmsc_uninitialize(g_mschandle);
+    }
+
+  g_mschandle = NULL;
+}
+#endif
+
+/****************************************************************************
+ * Name:  board_composite_connect
+ *
+ * Description:
+ *   Connect the USB composite device on the specified USB device port for
+ *   configuration 0.
+ *
+ * Input Parameters:
+ *   port     - The USB device port.
+ *
+ * Returned Value:
+ *   A non-NULL handle value is returned on success.  NULL is returned on
+ *   any failure.
+ *
+ ****************************************************************************/
+
+static void *board_composite0_connect(int port)
+{
+  struct composite_devdesc_s dev[COMPOSITE0_DEV];
+  int ifnobase = 0;
+  int strbase  = COMPOSITE_NSTRIDS;
+  int dev_idx = 0;
+  int epin = 1;
+  int epout = 1;
+
+#ifdef CONFIG_RNDIS_COMPOSITE
+  /* Configure the RNDIS USB device */
+
+  /* Ask the rndis driver to fill in the constants we didn't
+   * know here.
+   */
+
+  usbdev_rndis_get_composite_devdesc(&dev[dev_idx]);
+
+  /* Interfaces */
+
+  dev[dev_idx].devinfo.ifnobase = ifnobase;
+  dev[dev_idx].minor = 0;
+
+  /* Strings */
+
+  dev[dev_idx].devinfo.strbase = strbase;
+
+  /* Endpoints */
+
+  dev[dev_idx].devinfo.epno[RNDIS_EP_INTIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[RNDIS_EP_BULKIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[RNDIS_EP_BULKOUT_IDX] = epout++;
+
+  /* Count up the base numbers */
+
+  ifnobase += dev[dev_idx].devinfo.ninterfaces;
+  strbase += dev[dev_idx].devinfo.nstrings;
+
+  dev_idx += 1;
+#endif
+
+#ifdef CONFIG_CDCACM_COMPOSITE
+  /* Configure the CDC/ACM device */
+
+  /* Ask the cdcacm driver to fill in the constants we didn't
+   * know here.
+   */
+
+  cdcacm_get_composite_devdesc(&dev[dev_idx]);
+
+  /* Overwrite and correct some values... */
+
+  /* The callback functions for the CDC/ACM class */
+
+  dev[dev_idx].classobject  = cdcacm_classobject;
+  dev[dev_idx].uninitialize = cdcacm_uninitialize;
+
+  /* Interfaces */
+
+  dev[dev_idx].devinfo.ifnobase = ifnobase;             /* Offset to Interface-IDs */
+  dev[dev_idx].minor = 0;                               /* The minor interface number */
+
+  /* Strings */
+
+  dev[dev_idx].devinfo.strbase = strbase;               /* Offset to String Numbers */
+
+  /* Endpoints */
+
+  dev[dev_idx].devinfo.epno[CDCACM_EP_INTIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[CDCACM_EP_BULKIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = epout++;
+
+  /* Count up the base numbers */
+
+  ifnobase += dev[dev_idx].devinfo.ninterfaces;
+  strbase  += dev[dev_idx].devinfo.nstrings;
+
+  dev_idx += 1;
+#endif
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+  /* Configure the mass storage device device */
+
+  /* Ask the usbmsc driver to fill in the constants we didn't
+   * know here.
+   */
+
+  usbmsc_get_composite_devdesc(&dev[dev_idx]);
+
+  /* Overwrite and correct some values... */
+
+  /* The callback functions for the USBMSC class */
+
+  dev[dev_idx].classobject  = board_mscclassobject;
+  dev[dev_idx].uninitialize = board_mscuninitialize;
+
+  /* Interfaces */
+
+  dev[dev_idx].devinfo.ifnobase = ifnobase;               /* Offset to Interface-IDs */
+  dev[dev_idx].minor = 0;                                 /* The minor interface number */
+
+  /* Strings */
+
+  dev[dev_idx].devinfo.strbase = strbase;                 /* Offset to String Numbers */
+
+  /* Endpoints */
+
+  dev[dev_idx].devinfo.epno[USBMSC_EP_BULKIN_IDX] = epin++;
+  dev[dev_idx].devinfo.epno[USBMSC_EP_BULKOUT_IDX] = epout++;
+
+  /* Count up the base numbers */
+
+  ifnobase += dev[dev_idx].devinfo.ninterfaces;
+  strbase  += dev[dev_idx].devinfo.nstrings;
+
+  dev_idx += 1;
+#endif
+
+  /* Sanity checks */
+
+  DEBUGASSERT(epin < STM32_NENDPOINTS);
+  DEBUGASSERT(epout < STM32_NENDPOINTS);
+
+  return composite_initialize(dev_idx, dev);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_composite_initialize
+ *
+ * Description:
+ *   Perform architecture specific initialization of a composite USB device.
+ *
+ ****************************************************************************/
+
+int board_composite_initialize(int port)
+{
+  return OK;
+}
+
+/****************************************************************************
+ * Name:  board_composite_connect
+ *
+ * Description:
+ *   Connect the USB composite device on the specified USB device port using
+ *   the specified configuration.  The interpretation of the configid is
+ *   board specific.
+ *
+ * Input Parameters:
+ *   port     - The USB device port.
+ *   configid - The USB composite configuration
+ *
+ * Returned Value:
+ *   A non-NULL handle value is returned on success.  NULL is returned on
+ *   any failure.
+ *
+ ****************************************************************************/
+
+void *board_composite_connect(int port, int configid)
+{
+  if (configid == 0)
+    {
+      return board_composite0_connect(port);
+    }
+  else
+    {
+      return NULL;
+    }
+}
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_mmcsd.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_mmcsd.c
new file mode 100644
index 0000000000..95a39609d1
--- /dev/null
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_mmcsd.c
@@ -0,0 +1,88 @@
+/****************************************************************************
+ * boards/arm/stm32h7/nucleo-h743zi/src/stm32_mmcsd.c
+ *
+ * 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 <nuttx/config.h>
+
+#include <debug.h>
+#include <nuttx/mmcsd.h>
+#include <nuttx/spi/spi.h>
+
+#include <arch/board/board.h>
+
+#include "stm32_spi.h"
+
+#include "nucleo-h743zi.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_DISABLE_MOUNTPOINT
+#  error "SD driver requires CONFIG_DISABLE_MOUNTPOINT to be disabled"
+#endif
+
+#ifndef CONFIG_STM32H7_SPI3
+#  error "MMC/SD requires SPI3 enabled"
+#endif
+
+#define MMCSD_SPI_PORT (3)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_mmcsd_initialize
+ *
+ * Description:
+ *   Initialize SPI-based SD card and card detect thread.
+ *
+ ****************************************************************************/
+
+int stm32_mmcsd_initialize(int minor)
+{
+  struct spi_dev_s *spi;
+  int ret;
+
+  mcinfo("INFO: Initializing mmcsd port %d minor %d\n",
+         MMCSD_SPI_PORT, minor);
+
+  spi = stm32_spibus_initialize(MMCSD_SPI_PORT);
+  if (spi == NULL)
+    {
+      mcerr("ERROR: Failed to initialize SPI port %d\n", MMCSD_SPI_PORT);
+      return -ENODEV;
+    }
+
+  ret = mmcsd_spislotinitialize(minor, 0, spi);
+  if (ret < 0)
+    {
+      mcerr("ERROR: Failed to bind SPI port %d to SD slot %d\n",
+            MMCSD_SPI_PORT, minor);
+      return ret;
+    }
+
+  mcinfo("INFO: mmcsd card has been initialized successfully\n");
+  return OK;
+}
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_spi.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_spi.c
index 18f0b0970a..84aaa55e63 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_spi.c
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_spi.c
@@ -62,14 +62,21 @@ void stm32_spidev_initialize(void)
    */
 
 #ifdef CONFIG_STM32H7_SPI3
+  spiinfo("Configure GPIO for SPI3/CS\n");
+
 #  ifdef CONFIG_WL_NRF24L01
   /* Configure the SPI-based NRF24L01 chip select GPIO */
 
-  spiinfo("Configure GPIO for SPI3/CS\n");
-
   stm32_configgpio(GPIO_NRF24L01_CS);
   stm32_gpiowrite(GPIO_NRF24L01_CS, true);
 #  endif
+#  ifdef CONFIG_MMCSD_SPI
+  /* Configure the SPI-based MMC/SD chip select and card detect GPIO */
+
+  stm32_configgpio(GPIO_MMCSD_CS);
+  stm32_gpiowrite(GPIO_MMCSD_CS, true);
+  stm32_configgpio(GPIO_MMCSD_NCD);
+#endif
 #endif
 }
 
@@ -143,6 +150,13 @@ void stm32_spi3select(struct spi_dev_s *dev,
         stm32_gpiowrite(GPIO_NRF24L01_CS, !selected);
         break;
 #endif
+
+#ifdef CONFIG_MMCSD_SPI
+      case SPIDEV_MMCSD(0):
+        stm32_gpiowrite(GPIO_MMCSD_CS, !selected);
+        break;
+#endif
+
       default:
         break;
     }
@@ -158,6 +172,16 @@ uint8_t stm32_spi3status(struct spi_dev_s *dev, uint32_t devid)
         status |= SPI_STATUS_PRESENT;
         break;
 #endif
+
+#ifdef CONFIG_MMCSD_SPI
+      case SPIDEV_MMCSD(0):
+
+        /* Note: SD_DET is pulled high when there's no SD card present. */
+
+        status |= stm32_gpioread(GPIO_MMCSD_NCD);
+        break;
+#endif
+
       default:
         break;
     }
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usbmsc.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usbmsc.c
new file mode 100644
index 0000000000..0ccfaca81e
--- /dev/null
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usbmsc.c
@@ -0,0 +1,59 @@
+/****************************************************************************
+ * boards/arm/stm32h7/nucleo-h743zi/src/stm32_usbmsc.c
+ *
+ * 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 <nuttx/config.h>
+
+#include <stdio.h>
+#include <syslog.h>
+#include <errno.h>
+
+#include <nuttx/board.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_usbmsc_initialize
+ *
+ * Description:
+ *   Perform architecture specific initialization as needed to establish
+ *   the mass storage device that will be exported by the USB MSC device.
+ *
+ ****************************************************************************/
+
+int board_usbmsc_initialize(int port)
+{
+  /* If system/usbmsc is built as an NSH command, then SD slot should
+   * already have been initialized in board_app_initialize()
+   * (see stm32_appinit.c).
+   * In this case, there is nothing further to be done here.
+   */
+
+#ifndef CONFIG_NSH_BUILTIN_APPS
+  stm32_mmcsd_initialize(0);
+#else
+  return OK;
+#endif
+}