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

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

commit 5d5f6138cba64173a5148d3f90fc710eb39d54bd
Author: raiden00pl <[email protected]>
AuthorDate: Wed Nov 4 12:34:13 2026 +0100

    arch/arm/stm32: Build the OTG v2 drivers only for a selected role.
    
    The OTG device and host drivers were built whenever USBDEV or USBHOST
    was enabled and failed with #error when no OTG FS or HS instance had
    that role, for example USBHOST with only OTG HS as device.  Build each
    driver only when an instance has its role.
    
    Assisted-by: Claude:claude-fable-5-1
    Signed-off-by: raiden00pl <[email protected]>
---
 arch/arm/src/common/stm32/CMakeLists.txt | 4 ++--
 arch/arm/src/common/stm32/Make.defs      | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/src/common/stm32/CMakeLists.txt 
b/arch/arm/src/common/stm32/CMakeLists.txt
index 232950cfcf7..cef85ca6dfa 100644
--- a/arch/arm/src/common/stm32/CMakeLists.txt
+++ b/arch/arm/src/common/stm32/CMakeLists.txt
@@ -116,10 +116,10 @@ if(CONFIG_STM32_SDMMC AND CONFIG_STM32_HAVE_IP_SDMMC_V2)
 endif()
 
 if(CONFIG_STM32_HAVE_IP_OTG_V2)
-  if(CONFIG_USBDEV)
+  if(CONFIG_STM32_OTGFS_USBDEV OR CONFIG_STM32_OTGHS_USBDEV)
     list(APPEND SRCS stm32_otgdev_v2.c)
   endif()
-  if(CONFIG_USBHOST)
+  if(CONFIG_STM32_OTGFS_HOST OR CONFIG_STM32_OTGHS_HOST)
     list(APPEND SRCS stm32_otghost_v2.c)
     if(CONFIG_USBHOST_TRACE OR CONFIG_DEBUG_USB)
       list(APPEND SRCS stm32_usbhost_v2.c)
diff --git a/arch/arm/src/common/stm32/Make.defs 
b/arch/arm/src/common/stm32/Make.defs
index 996ad94cc98..95cd99f01ba 100644
--- a/arch/arm/src/common/stm32/Make.defs
+++ b/arch/arm/src/common/stm32/Make.defs
@@ -127,10 +127,10 @@ CHIP_CSRCS += stm32_sdmmc_v2.c
 endif
 
 ifeq ($(CONFIG_STM32_HAVE_IP_OTG_V2),y)
-ifeq ($(CONFIG_USBDEV),y)
+ifneq ($(CONFIG_STM32_OTGFS_USBDEV)$(CONFIG_STM32_OTGHS_USBDEV),)
 CHIP_CSRCS += stm32_otgdev_v2.c
 endif
-ifeq ($(CONFIG_USBHOST),y)
+ifneq ($(CONFIG_STM32_OTGFS_HOST)$(CONFIG_STM32_OTGHS_HOST),)
 CHIP_CSRCS += stm32_otghost_v2.c
 ifeq ($(CONFIG_USBHOST_TRACE),y)
 CHIP_CSRCS += stm32_usbhost_v2.c

Reply via email to