You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by bt...@apache.org on 2020/11/22 08:29:03 UTC
[incubator-nuttx] 04/04: board: nucleo-h743zi USB Host fixups
This is an automated email from the ASF dual-hosted git repository.
btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 87d8e5dda20990c8aad24fe80364a2602ce81cf8
Author: Brennan Ashton <ba...@brennanashton.com>
AuthorDate: Sat Nov 21 13:16:59 2020 -0800
board: nucleo-h743zi USB Host fixups
---
arch/arm/src/stm32f7/stm32_otg.h | 39 +++++++--------
arch/arm/src/stm32h7/stm32_otg.h | 42 ++++++++--------
arch/arm/src/stm32h7/stm32_otghost.c | 4 +-
boards/arm/stm32h7/nucleo-h743zi/Kconfig | 17 +++++++
.../nucleo-h743zi/configs/otg_fs_host/defconfig | 4 +-
.../arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h | 57 ++++++++++++++++++++--
.../arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c | 6 +--
boards/arm/stm32h7/nucleo-h743zi/src/stm32_usb.c | 6 +++
8 files changed, 122 insertions(+), 53 deletions(-)
diff --git a/arch/arm/src/stm32f7/stm32_otg.h b/arch/arm/src/stm32f7/stm32_otg.h
index 90672ae..0ddd843 100644
--- a/arch/arm/src/stm32f7/stm32_otg.h
+++ b/arch/arm/src/stm32f7/stm32_otg.h
@@ -1,4 +1,4 @@
-/************************************************************************************
+/****************************************************************************
* arch/arm/src/stm32f7/stm32_otg.h
*
* Copyright (C) 2012-2013, 2016 Gregory Nutt. All rights reserved.
@@ -31,14 +31,14 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************************************/
+ ****************************************************************************/
#ifndef __ARCH_ARM_SRC_STM32F7_STM32_OTG_H
#define __ARCH_ARM_SRC_STM32F7_STM32_OTG_H
-/************************************************************************************
+/****************************************************************************
* Included Files
- ************************************************************************************/
+ ****************************************************************************/
#include <nuttx/config.h>
@@ -49,11 +49,11 @@
#if defined(CONFIG_STM32F7_OTGFS) || defined(CONFIG_STM32F7_OTGFSHS)
-/************************************************************************************
+/****************************************************************************
* Pre-processor Definitions
- ************************************************************************************/
+ ****************************************************************************/
-/* Configuration ********************************************************************/
+/* Configuration ************************************************************/
#ifndef CONFIG_OTG_PRI
# define CONFIG_OTG_PRI NVIC_SYSH_PRIORITY_DEFAULT
@@ -83,9 +83,9 @@
# define STM32_OTG_FIFO_SIZE 4096
#endif
-/************************************************************************************
- * Public Functions
- ************************************************************************************/
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
#ifndef __ASSEMBLY__
@@ -105,9 +105,9 @@ extern "C"
* Initialize USB host device controller hardware.
*
* Input Parameters:
- * controller -- If the device supports more than USB host controller, then
- * this identifies which controller is being initializeed. Normally, this
- * is just zero.
+ * controller -- If the device supports more than USB host controller,
+ * then this identifies which controller is being initialized.
+ * Normally, this is just zero.
*
* Returned Value:
* And instance of the USB host interface. The controlling task should
@@ -128,17 +128,18 @@ struct usbhost_connection_s;
FAR struct usbhost_connection_s *stm32_otghost_initialize(int controller);
#endif
-/************************************************************************************
+/****************************************************************************
* Name: stm32_usbsuspend
*
* Description:
- * Board logic must provide the stm32_usbsuspend logic if the OTG FS device driver
- * is used. This function is called whenever the USB enters or leaves suspend
- * mode. This is an opportunity for the board logic to shutdown clocks, power,
- * etc. while the USB is suspended.
+ * Board logic must provide the stm32_usbsuspend logic if the OTG FS
+ * device driver is used. This function is called whenever the USB enters
+ * or leaves suspend mode. This is an opportunity for the board logic to
+ * shutdown clocks, power, etc. while the USB is suspended.
*
- ************************************************************************************/
+ ****************************************************************************/
+struct usbdev_s;
void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume);
#undef EXTERN
diff --git a/arch/arm/src/stm32h7/stm32_otg.h b/arch/arm/src/stm32h7/stm32_otg.h
index 2831236..d765539 100644
--- a/arch/arm/src/stm32h7/stm32_otg.h
+++ b/arch/arm/src/stm32h7/stm32_otg.h
@@ -1,4 +1,4 @@
-/************************************************************************************
+/****************************************************************************
* arch/arm/src/stm32h7/stm32_otg.h
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
@@ -31,14 +31,14 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************************************/
+ ****************************************************************************/
#ifndef __ARCH_ARM_SRC_STM32H7_STM32_OTG_H
#define __ARCH_ARM_SRC_STM32H7_STM32_OTG_H
-/************************************************************************************
+/****************************************************************************
* Included Files
- ************************************************************************************/
+ ****************************************************************************/
#include <nuttx/config.h>
@@ -49,15 +49,16 @@
#if defined(CONFIG_STM32H7_OTGFS) || defined(CONFIG_STM32H7_OTGHS)
-/************************************************************************************
+/****************************************************************************
* Pre-processor Definitions
- ************************************************************************************/
-/* Configuration ********************************************************************/
+ ****************************************************************************/
+
+/* Configuration ************************************************************/
#if defined(CONFIG_STM32H7_OTGFS)
# define STM32_IRQ_OTG STM32_IRQ_OTGFS
# define STM32_OTG_BASE STM32_OTGFS_BASE /* OTG FS */
-# define STM32_NENDPOINTS (7) /* ep0-8 x 2 for IN and OUT but driver internals use byte to map + one bit for direction */
+# define STM32_NENDPOINTS (7) /* ep0-8 x 2 for IN and OUT but driver internals use byte to map + one bit for direction */
# define GPIO_OTG_DM GPIO_OTGFS_DM
# define GPIO_OTG_DP GPIO_OTGFS_DP
# define GPIO_OTG_ID GPIO_OTGFS_ID
@@ -68,7 +69,7 @@
#if defined(CONFIG_STM32H7_OTGHS)
# define STM32_IRQ_OTG STM32_IRQ_OTGHS
# define STM32_OTG_BASE STM32_OTGHS_BASE /* OTG HS/FS */
-# define STM32_NENDPOINTS (7) /* ep0-8 x 2 for IN and OUT but driver internals use byte to map + one bit for direction */
+# define STM32_NENDPOINTS (7) /* ep0-8 x 2 for IN and OUT but driver internals use byte to map + one bit for direction */
# define GPIO_OTG_DM GPIO_OTGHS_DM
# define GPIO_OTG_DP GPIO_OTGHS_DP
# define GPIO_OTG_ID GPIO_OTGHS_ID
@@ -76,9 +77,9 @@
# define STM32_OTG_FIFO_SIZE 4096
#endif
-/************************************************************************************
- * Public Functions
- ************************************************************************************/
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
#ifndef __ASSEMBLY__
@@ -99,8 +100,8 @@ extern "C"
*
* Input Parameters:
* controller -- If the device supports more than USB host controller, then
- * this identifies which controller is being initializeed. Normally, this
- * is just zero.
+ * this identifies which controller is being initialized. Normally,
+ * this is just zero.
*
* Returned Value:
* And instance of the USB host interface. The controlling task should
@@ -121,17 +122,18 @@ struct usbhost_connection_s;
FAR struct usbhost_connection_s *stm32_otgfshost_initialize(int controller);
#endif
-/************************************************************************************
+/****************************************************************************
* Name: stm32_usbsuspend
*
* Description:
- * Board logic must provide the stm32_usbsuspend logic if the OTG FS device driver
- * is used. This function is called whenever the USB enters or leaves suspend
- * mode. This is an opportunity for the board logic to shutdown clocks, power,
- * etc. while the USB is suspended.
+ * Board logic must provide the stm32_usbsuspend logic if the OTG FS
+ * device driver is used. This function is called whenever the USB enters
+ * or leaves suspend mode. This is an opportunity for the board logic to
+ * shutdown clocks, power, etc. while the USB is suspended.
*
- ************************************************************************************/
+ ****************************************************************************/
+struct usbdev_s;
void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume);
#undef EXTERN
diff --git a/arch/arm/src/stm32h7/stm32_otghost.c b/arch/arm/src/stm32h7/stm32_otghost.c
index 1a0a7bc..9126b52 100644
--- a/arch/arm/src/stm32h7/stm32_otghost.c
+++ b/arch/arm/src/stm32h7/stm32_otghost.c
@@ -73,9 +73,7 @@
#include "stm32_otg.h"
#include "stm32_usbhost.h"
-#if defined(CONFIG_USBHOST) && defined(CONFIG_STM32H7_OTGFS) && defined(CONFIG_EXPERIMENTAL)
-
-#warning OTG host not tested for STM32H7!
+#if defined(CONFIG_USBHOST) && defined(CONFIG_STM32H7_OTGFS)
/****************************************************************************
* Pre-processor Definitions
diff --git a/boards/arm/stm32h7/nucleo-h743zi/Kconfig b/boards/arm/stm32h7/nucleo-h743zi/Kconfig
index b3ba773..c648632 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/Kconfig
+++ b/boards/arm/stm32h7/nucleo-h743zi/Kconfig
@@ -4,6 +4,23 @@
#
if ARCH_BOARD_NUCLEO_H743ZI
+
+choice
+ prompt "STM Nucleo-144 Board Variant"
+ default STM_NUCLEO144_MB1364
+
+config STM_NUCLEO144_MB1364
+ bool "Nucleo-H743ZI2 (MB1364)"
+ ---help---
+ This is the current version of the Nucelo-144 for the H743ZI
+
+config STM_NUCLEO144_MB1137
+ bool "Nucleo-H743ZI (MB1137)"
+ ---help---
+ This is the origional version of the Nucelo-144 for the H743ZI
+
+endchoice
+
config STM32_ROMFS
bool "Automount baked-in ROMFS image"
default n
diff --git a/boards/arm/stm32h7/nucleo-h743zi/configs/otg_fs_host/defconfig b/boards/arm/stm32h7/nucleo-h743zi/configs/otg_fs_host/defconfig
index 788b7b2..5ff7526 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/configs/otg_fs_host/defconfig
+++ b/boards/arm/stm32h7/nucleo-h743zi/configs/otg_fs_host/defconfig
@@ -17,11 +17,9 @@ CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
CONFIG_ARMV7M_DTCM=y
CONFIG_ARMV7M_ICACHE=y
-CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
CONFIG_BOARD_LOOPSPERMSEC=43103
CONFIG_BUILTIN=y
CONFIG_DEBUG_SYMBOLS=y
-CONFIG_EXPERIMENTAL=y
CONFIG_FAT_LCNAMES=y
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
@@ -31,7 +29,7 @@ CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBM=y
CONFIG_MAX_TASKS=16
-CONFIG_MM_REGIONS=3
+CONFIG_MM_REGIONS=4
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h b/boards/arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h
index 1972022..fd84a4a 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/nucleo-h743zi.h
@@ -52,6 +52,38 @@
/* Configuration ************************************************************/
+#define HAVE_PROC 1
+#define HAVE_USBDEV 1
+#define HAVE_USBHOST 1
+#define HAVE_USBMONITOR 1
+
+/* Can't support USB host or device features if USB OTG FS is not enabled */
+
+#ifndef CONFIG_STM32H7_OTGFS
+# undef HAVE_USBDEV
+# undef HAVE_USBHOST
+# undef HAVE_USBMONITOR
+#endif
+
+/* Can't support USB device monitor if USB device is not enabled */
+
+#ifndef CONFIG_USBDEV
+# undef HAVE_USBDEV
+# undef HAVE_USBMONITOR
+#endif
+
+/* Can't support USB host is USB host is not enabled */
+
+#ifndef CONFIG_USBHOST
+# undef HAVE_USBHOST
+#endif
+
+/* Check if we should enable the USB monitor before starting NSH */
+
+#if !defined(CONFIG_USBDEV_TRACE) || !defined(CONFIG_USBMONITOR)
+# undef HAVE_USBMONITOR
+#endif
+
/* procfs File System */
#ifdef CONFIG_FS_PROCFS
@@ -112,8 +144,13 @@
#define GPIO_OTGFS_VBUS (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz| \
GPIO_OPENDRAIN|GPIO_PORTA|GPIO_PIN9)
-#define GPIO_OTGFS_PWRON (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz| \
+#if defined(CONFIG_STM_NUCLEO144_MB1137)
+# define GPIO_OTGFS_PWRON (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz| \
GPIO_PUSHPULL|GPIO_PORTG|GPIO_PIN6)
+#elif defined(CONFIG_STM_NUCLEO144_MB1364)
+# define GPIO_OTGFS_PWRON (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz| \
+ GPIO_PUSHPULL|GPIO_PORTD|GPIO_PIN10)
+#endif
#ifdef CONFIG_USBHOST
# define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_EXTI|GPIO_FLOAT| \
@@ -234,12 +271,26 @@ int stm32_gpio_initialize(void);
*
* Description:
* Called from stm32_usbinitialize very early in inialization to setup
- * USB-related GPIO pins for the nucleo-144 board.
+ * USB-related GPIO pins for the NUCLEO-H743ZI board.
*
****************************************************************************/
#ifdef CONFIG_STM32H7_OTGFS
-void stm32_usbinitialize(void);
+void weak_function stm32_usbinitialize(void);
+#endif
+
+/****************************************************************************
+ * Name: stm32_usbhost_initialize
+ *
+ * Description:
+ * Called at application startup time to initialize the USB host
+ * functionality. This function will start a thread that will monitor for
+ * device connection/disconnection events.
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_STM32H7_OTGFS) && defined(CONFIG_USBHOST)
+int stm32_usbhost_initialize(void);
#endif
/****************************************************************************
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c
index 0e85ea4..f49d3d0 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_bringup.c
@@ -44,16 +44,12 @@
#include <syslog.h>
#include <errno.h>
-#define HAVE_USBHOST 1
-#define CONFIG_USBMONITOR 1
-
#ifdef CONFIG_USBMONITOR
#include <nuttx/usb/usbmonitor.h>
#endif
-#ifdef CONFIG_STM32_OTGFS
+#ifdef CONFIG_STM32H7_OTGFS
#include "stm32_usbhost.h"
-#include "stm32_usb.h"
#endif
#include "nucleo-h743zi.h"
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usb.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usb.c
index 8127e22..c7ce67c 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usb.c
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usb.c
@@ -275,7 +275,13 @@ void stm32_usbhost_vbusdrive(int iface, bool enable)
/* Set the Power Switch by driving the active high enable pin */
+#if defined(CONFIG_STM_NUCLEO144_MB1137)
stm32_gpiowrite(GPIO_OTGFS_PWRON, enable);
+#elif defined(CONFIG_STM_NUCLEO144_MB1364)
+ stm32_gpiowrite(GPIO_OTGFS_PWRON, !enable);
+#else
+# error "Non-supported board"
+#endif
}
#endif