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 46648d25fc104d71c05d2110ee0b75d31d221bc2 Author: raiden00pl <[email protected]> AuthorDate: Wed Nov 25 21:00:31 2026 +0100 !arch/arm/stm32h7: Move the FDCAN drivers to common/stm32 as FDCAN v2. stm32_fdcan.c, stm32_fdcan_sock.c and hardware/stm32_fdcan.h become stm32_fdcan_mcan_v2.c, stm32_fdcan_mcan_v2_sock.c and hardware/stm32_fdcan_mcan_v2.h, and STM32_HAVE_FDCAN_H7 becomes STM32_HAVE_IP_FDCAN_MCAN_V2, like the other STM32 IP flags. The arm_netinitialize() prototype in stm32_fdcan_sock.h uses the guard of arm_internal.h, so the header builds without networking. BREAKING CHANGE: STM32_HAVE_FDCAN_H7 is removed. Quick fix: select STM32_HAVE_IP_FDCAN_MCAN_V2 in out-of-tree chip Kconfig files. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: raiden00pl <[email protected]> --- .github/CODEOWNERS | 4 ++-- Documentation/guides/chip-specific/stm32_ports.rst | 2 +- arch/arm/src/common/stm32/CMakeLists.txt | 9 +++++++++ arch/arm/src/common/stm32/Kconfig.fdcan | 2 +- arch/arm/src/common/stm32/Kconfig.have | 6 +++--- arch/arm/src/common/stm32/Make.defs | 9 +++++++++ arch/arm/src/common/stm32/hardware/stm32_fdcan.h | 2 ++ .../stm32/hardware/stm32_fdcan_mcan_v2.h} | 8 ++++---- .../stm32_fdcan.c => common/stm32/stm32_fdcan_mcan_v2.c} | 5 ++--- .../stm32/stm32_fdcan_mcan_v2_sock.c} | 2 +- arch/arm/src/stm32h7/CMakeLists.txt | 8 -------- arch/arm/src/stm32h7/Kconfig | 2 +- arch/arm/src/stm32h7/Make.defs | 8 -------- boards/arm/common/stm32/include/stm32_can_setup.h | 2 +- boards/arm/common/stm32/include/stm32_cansock_setup.h | 2 +- boards/arm/common/stm32/src/CMakeLists.txt | 2 +- boards/arm/common/stm32/src/Make.defs | 2 +- boards/arm/common/stm32/src/board_common.c | 4 ++-- 18 files changed, 41 insertions(+), 38 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index db261616a62..246920f22f0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1624,6 +1624,7 @@ arch/arm/src/common/stm32/hardware/stm32_exti_v1v2.h [email protected] dani arch/arm/src/common/stm32/hardware/stm32_exti_v1v2_m0.h [email protected] [email protected] [email protected] [email protected] [email protected] arch/arm/src/common/stm32/hardware/stm32_fdcan.h [email protected] [email protected] [email protected] [email protected] [email protected] arch/arm/src/common/stm32/hardware/stm32_fdcan_mcan.h [email protected] [email protected] +arch/arm/src/common/stm32/hardware/stm32_fdcan_mcan_v2.h [email protected] [email protected] [email protected] [email protected] [email protected] arch/arm/src/common/stm32/hardware/stm32_flash.h [email protected] [email protected] arch/arm/src/common/stm32/hardware/stm32_flash_m0.h [email protected] [email protected] [email protected] arch/arm/src/common/stm32/hardware/stm32_flash_v1v2.h [email protected] [email protected] [email protected] [email protected] [email protected] @@ -1735,6 +1736,7 @@ arch/arm/src/common/stm32/stm32_exti_wakeup_m3m4_v1.c [email protected] arch/arm/src/common/stm32/stm32_fdcan.h [email protected] [email protected] [email protected] [email protected] arch/arm/src/common/stm32/stm32_fdcan_mcan_v1.c [email protected] [email protected] [email protected] [email protected] [email protected] arch/arm/src/common/stm32/stm32_fdcan_mcan_v1_sock.c [email protected] [email protected] [email protected] [email protected] [email protected] +arch/arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c [email protected] [email protected] [email protected] [email protected] [email protected] arch/arm/src/common/stm32/stm32_flash.h [email protected] [email protected] [email protected] [email protected] [email protected] arch/arm/src/common/stm32/stm32_flash_m0_g0c0.c [email protected] [email protected] [email protected] arch/arm/src/common/stm32/stm32_flash_m3m4_f1f3.c [email protected] [email protected] [email protected] [email protected] [email protected] @@ -4137,7 +4139,6 @@ arch/arm/src/stm32h7/hardware/stm32_dma.h [email protected] alin.jerpelea@sony. arch/arm/src/stm32h7/hardware/stm32_dmamux.h [email protected] [email protected] [email protected] [email protected] arch/arm/src/stm32h7/hardware/stm32_ethernet.h [email protected] [email protected] [email protected] [email protected] arch/arm/src/stm32h7/hardware/stm32_exti.h [email protected] [email protected] [email protected] [email protected] -arch/arm/src/stm32h7/hardware/stm32_fdcan.h [email protected] [email protected] [email protected] [email protected] [email protected] arch/arm/src/stm32h7/hardware/stm32_flash.h [email protected] [email protected] [email protected] [email protected] arch/arm/src/stm32h7/hardware/stm32_fmc.h [email protected] [email protected] [email protected] arch/arm/src/stm32h7/hardware/stm32_gpio.h [email protected] [email protected] [email protected] [email protected] @@ -4193,7 +4194,6 @@ arch/arm/src/stm32h7/stm32_exti.h [email protected] [email protected] arch/arm/src/stm32h7/stm32_exti_alarm.c [email protected] [email protected] [email protected] [email protected] arch/arm/src/stm32h7/stm32_exti_gpio.c [email protected] [email protected] [email protected] [email protected] [email protected] arch/arm/src/stm32h7/stm32_exti_wakeup.c [email protected] [email protected] [email protected] -arch/arm/src/stm32h7/stm32_fdcan_sock.c [email protected] [email protected] [email protected] [email protected] [email protected] arch/arm/src/stm32h7/stm32_fdcan_sock.h [email protected] [email protected] arch/arm/src/stm32h7/stm32_flash.c [email protected] [email protected] [email protected] [email protected] [email protected] arch/arm/src/stm32h7/stm32_flash.h [email protected] [email protected] [email protected] diff --git a/Documentation/guides/chip-specific/stm32_ports.rst b/Documentation/guides/chip-specific/stm32_ports.rst index e33785b922e..a86a61ba6cb 100644 --- a/Documentation/guides/chip-specific/stm32_ports.rst +++ b/Documentation/guides/chip-specific/stm32_ports.rst @@ -676,7 +676,7 @@ Peripheral Core version Driver ============ ============ ============================================ ADC to be done arch/arm/src/stm32h7/stm32_adc.c BDMA to be done arch/arm/src/stm32h7/stm32_dma.c -CAN/FDCAN FDCAN arch/arm/src/stm32h7/stm32_fdcan_sock.c +CAN/FDCAN FDCAN arch/arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c DAC to be done not supported DMA v2 style arch/arm/src/stm32h7/stm32_dma.c DMA2D to be done not supported diff --git a/arch/arm/src/common/stm32/CMakeLists.txt b/arch/arm/src/common/stm32/CMakeLists.txt index 71e65ebab71..8ad4a8d18ad 100644 --- a/arch/arm/src/common/stm32/CMakeLists.txt +++ b/arch/arm/src/common/stm32/CMakeLists.txt @@ -120,6 +120,15 @@ if(CONFIG_STM32_FDCAN AND CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V1) endif() endif() +if(CONFIG_STM32_FDCAN AND CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V2) + if(CONFIG_STM32_FDCAN_CHARDRIVER) + list(APPEND SRCS stm32_fdcan_mcan_v2.c) + endif() + if(CONFIG_STM32_FDCAN_SOCKET) + list(APPEND SRCS stm32_fdcan_mcan_v2_sock.c) + endif() +endif() + if(CONFIG_MDIO_BUS AND CONFIG_STM32_HAVE_IP_ETHMAC_V2) if(CONFIG_STM32_ETH_MDIO_GPIO) list(APPEND SRCS stm32_mdio_gpio.c) diff --git a/arch/arm/src/common/stm32/Kconfig.fdcan b/arch/arm/src/common/stm32/Kconfig.fdcan index 1424ebc4d17..43f92c8c471 100644 --- a/arch/arm/src/common/stm32/Kconfig.fdcan +++ b/arch/arm/src/common/stm32/Kconfig.fdcan @@ -3,7 +3,7 @@ # menu "FDCAN Driver Configuration" - depends on STM32_HAVE_FDCAN_H7 && STM32_FDCAN_SOCKET && (STM32_FDCAN1 || STM32_FDCAN2 || STM32_FDCAN3) + depends on STM32_HAVE_IP_FDCAN_MCAN_V2 && STM32_FDCAN_SOCKET && (STM32_FDCAN1 || STM32_FDCAN2 || STM32_FDCAN3) menu "FDCAN1 Configuration" depends on STM32_FDCAN1 diff --git a/arch/arm/src/common/stm32/Kconfig.have b/arch/arm/src/common/stm32/Kconfig.have index de39424f8de..f11db17dc44 100644 --- a/arch/arm/src/common/stm32/Kconfig.have +++ b/arch/arm/src/common/stm32/Kconfig.have @@ -385,9 +385,6 @@ config STM32_HAVE_ETHERNET # FDCAN capabilities -config STM32_HAVE_FDCAN_H7 - bool - config STM32_HAVE_FDCAN1 bool @@ -400,6 +397,9 @@ config STM32_HAVE_FDCAN3 config STM32_HAVE_IP_FDCAN_MCAN_V1 bool +config STM32_HAVE_IP_FDCAN_MCAN_V2 + bool + # FLASH capabilities config STM32_HAVE_FLASH_ART_ACCELERATOR diff --git a/arch/arm/src/common/stm32/Make.defs b/arch/arm/src/common/stm32/Make.defs index c4338728abc..6e81621bbfc 100644 --- a/arch/arm/src/common/stm32/Make.defs +++ b/arch/arm/src/common/stm32/Make.defs @@ -131,6 +131,15 @@ CHIP_CSRCS += stm32_fdcan_mcan_v1_sock.c endif endif +ifeq ($(CONFIG_STM32_FDCAN)$(CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V2),yy) +ifeq ($(CONFIG_STM32_FDCAN_CHARDRIVER),y) +CHIP_CSRCS += stm32_fdcan_mcan_v2.c +endif +ifeq ($(CONFIG_STM32_FDCAN_SOCKET),y) +CHIP_CSRCS += stm32_fdcan_mcan_v2_sock.c +endif +endif + ifeq ($(CONFIG_MDIO_BUS)$(CONFIG_STM32_HAVE_IP_ETHMAC_V2),yy) ifeq ($(CONFIG_STM32_ETH_MDIO_GPIO),y) CHIP_CSRCS += stm32_mdio_gpio.c diff --git a/arch/arm/src/common/stm32/hardware/stm32_fdcan.h b/arch/arm/src/common/stm32/hardware/stm32_fdcan.h index 0f49dd75e4a..d571fe6d494 100644 --- a/arch/arm/src/common/stm32/hardware/stm32_fdcan.h +++ b/arch/arm/src/common/stm32/hardware/stm32_fdcan.h @@ -29,6 +29,8 @@ #if defined(CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V1) # include "hardware/stm32_fdcan_mcan.h" +#elif defined(CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V2) +# include "hardware/stm32_fdcan_mcan_v2.h" #else # error "Unsupported STM32 FDCAN" #endif diff --git a/arch/arm/src/stm32h7/hardware/stm32_fdcan.h b/arch/arm/src/common/stm32/hardware/stm32_fdcan_mcan_v2.h similarity index 99% rename from arch/arm/src/stm32h7/hardware/stm32_fdcan.h rename to arch/arm/src/common/stm32/hardware/stm32_fdcan_mcan_v2.h index 264c222761f..251f87061bf 100644 --- a/arch/arm/src/stm32h7/hardware/stm32_fdcan.h +++ b/arch/arm/src/common/stm32/hardware/stm32_fdcan_mcan_v2.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/stm32h7/hardware/stm32_fdcan.h + * arch/arm/src/common/stm32/hardware/stm32_fdcan_mcan_v2.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_FDCAN_H -#define __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_FDCAN_H +#ifndef __ARCH_ARM_SRC_COMMON_STM32_HARDWARE_STM32_FDCAN_MCAN_V2_H +#define __ARCH_ARM_SRC_COMMON_STM32_HARDWARE_STM32_FDCAN_MCAN_V2_H /* ************************************************************************** * Included Files @@ -1721,4 +1721,4 @@ # define EXTFILTER_F1_EFT_CLASSIC (2 << EXTFILTER_F1_EFT_SHIFT) /* Classic filter: SF1ID=filter SF2ID=mask */ # define EXTFILTER_F1_EFT_NOXIDAM (3 << EXTFILTER_F1_EFT_SHIFT) /* Range filter from EF1ID to EF2ID, no XIDAM */ -#endif /* __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_FDCAN_H */ +#endif /* __ARCH_ARM_SRC_COMMON_STM32_HARDWARE_STM32_FDCAN_MCAN_V2_H */ diff --git a/arch/arm/src/stm32h7/stm32_fdcan.c b/arch/arm/src/common/stm32/stm32_fdcan_mcan_v2.c similarity index 99% rename from arch/arm/src/stm32h7/stm32_fdcan.c rename to arch/arm/src/common/stm32/stm32_fdcan_mcan_v2.c index ac166438dfa..724f6b99602 100644 --- a/arch/arm/src/stm32h7/stm32_fdcan.c +++ b/arch/arm/src/common/stm32/stm32_fdcan_mcan_v2.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/stm32h7/stm32_fdcan.c + * arch/arm/src/common/stm32/stm32_fdcan_mcan_v2.c * * SPDX-License-Identifier: Apache-2.0 * @@ -41,10 +41,9 @@ #include <nuttx/can/can.h> #include "arm_internal.h" +#include "stm32.h" #include "stm32_fdcan.h" #include "hardware/stm32_pinmap.h" -#include "stm32_gpio.h" -#include "stm32_rcc.h" /**************************************************************************** * Pre-processor Definitions diff --git a/arch/arm/src/stm32h7/stm32_fdcan_sock.c b/arch/arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c similarity index 99% rename from arch/arm/src/stm32h7/stm32_fdcan_sock.c rename to arch/arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c index ff372c5ec49..6920a776437 100644 --- a/arch/arm/src/stm32h7/stm32_fdcan_sock.c +++ b/arch/arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/stm32h7/stm32_fdcan_sock.c + * arch/arm/src/common/stm32/stm32_fdcan_mcan_v2_sock.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/arch/arm/src/stm32h7/CMakeLists.txt b/arch/arm/src/stm32h7/CMakeLists.txt index 52cb1bb16c0..15bb816e9bb 100644 --- a/arch/arm/src/stm32h7/CMakeLists.txt +++ b/arch/arm/src/stm32h7/CMakeLists.txt @@ -66,14 +66,6 @@ if(CONFIG_STM32_ADC) list(APPEND SRCS stm32_adc.c) endif() -if(CONFIG_STM32_FDCAN_CHARDRIVER) - list(APPEND SRCS stm32_fdcan.c) -endif() - -if(CONFIG_STM32_FDCAN_SOCKET) - list(APPEND SRCS stm32_fdcan_sock.c) -endif() - if(CONFIG_STM32_BBSRAM) list(APPEND SRCS stm32_bbsram.c) endif() diff --git a/arch/arm/src/stm32h7/Kconfig b/arch/arm/src/stm32h7/Kconfig index dd7b1f21f43..f6d58e1e849 100644 --- a/arch/arm/src/stm32h7/Kconfig +++ b/arch/arm/src/stm32h7/Kconfig @@ -113,7 +113,7 @@ config STM32_H7_PERIPHERALS select STM32_HAVE_IP_OTG_V2 select STM32_HAVE_OTGHS_USBDEV select STM32_HAVE_USART_RXFIFO_THRESHOLD - select STM32_HAVE_FDCAN_H7 + select STM32_HAVE_IP_FDCAN_MCAN_V2 select STM32_HAVE_ETHERNET select STM32_HAVE_IP_ETHMAC_V2 select STM32_HAVE_FMC diff --git a/arch/arm/src/stm32h7/Make.defs b/arch/arm/src/stm32h7/Make.defs index fc6ba0ec7d7..6af5322fa66 100644 --- a/arch/arm/src/stm32h7/Make.defs +++ b/arch/arm/src/stm32h7/Make.defs @@ -69,14 +69,6 @@ ifeq ($(CONFIG_STM32_DAC),y) CHIP_CSRCS += stm32_dac.c endif -ifeq ($(CONFIG_STM32_FDCAN_CHARDRIVER),y) -CHIP_CSRCS += stm32_fdcan.c -endif - -ifeq ($(CONFIG_STM32_FDCAN_SOCKET),y) -CHIP_CSRCS += stm32_fdcan_sock.c -endif - ifeq ($(CONFIG_STM32_BBSRAM),y) CHIP_CSRCS += stm32_bbsram.c endif diff --git a/boards/arm/common/stm32/include/stm32_can_setup.h b/boards/arm/common/stm32/include/stm32_can_setup.h index 84b31c0caae..2c8a1de6885 100644 --- a/boards/arm/common/stm32/include/stm32_can_setup.h +++ b/boards/arm/common/stm32/include/stm32_can_setup.h @@ -60,7 +60,7 @@ extern "C" #if (defined(CONFIG_STM32_CAN_CHARDRIVER) || \ defined(CONFIG_STM32_FDCAN_CHARDRIVER)) && \ - !defined(CONFIG_STM32_HAVE_FDCAN_H7) + !defined(CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V2) int stm32_can_setup(void); #endif diff --git a/boards/arm/common/stm32/include/stm32_cansock_setup.h b/boards/arm/common/stm32/include/stm32_cansock_setup.h index c0ac49205eb..04d031fe2ff 100644 --- a/boards/arm/common/stm32/include/stm32_cansock_setup.h +++ b/boards/arm/common/stm32/include/stm32_cansock_setup.h @@ -59,7 +59,7 @@ extern "C" ****************************************************************************/ #if (defined(CONFIG_STM32_CAN_SOCKET) || defined(CONFIG_STM32_FDCAN_SOCKET)) && \ - !defined(CONFIG_STM32_HAVE_FDCAN_H7) + !defined(CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V2) int stm32_cansock_setup(void); #endif diff --git a/boards/arm/common/stm32/src/CMakeLists.txt b/boards/arm/common/stm32/src/CMakeLists.txt index 67488f3e9ca..f105a6df3da 100644 --- a/boards/arm/common/stm32/src/CMakeLists.txt +++ b/boards/arm/common/stm32/src/CMakeLists.txt @@ -208,7 +208,7 @@ if(CONFIG_AUDIO_CS4344) list(APPEND SRCS stm32_cs4344.c) endif() -if(NOT CONFIG_STM32_HAVE_FDCAN_H7) +if(NOT CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V2) if(CONFIG_STM32_CAN_CHARDRIVER OR CONFIG_STM32_FDCAN_CHARDRIVER) list(APPEND SRCS stm32_can_setup.c) endif() diff --git a/boards/arm/common/stm32/src/Make.defs b/boards/arm/common/stm32/src/Make.defs index 343575aba44..5ba67a1b17e 100644 --- a/boards/arm/common/stm32/src/Make.defs +++ b/boards/arm/common/stm32/src/Make.defs @@ -224,7 +224,7 @@ ifeq ($(CONFIG_AUDIO_CS4344),y) CSRCS += stm32_cs4344.c endif -ifneq ($(CONFIG_STM32_HAVE_FDCAN_H7),y) +ifneq ($(CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V2),y) ifneq ($(CONFIG_STM32_CAN_CHARDRIVER)$(CONFIG_STM32_FDCAN_CHARDRIVER),) CSRCS += stm32_can_setup.c endif diff --git a/boards/arm/common/stm32/src/board_common.c b/boards/arm/common/stm32/src/board_common.c index ac7aa58aea8..372be66086e 100644 --- a/boards/arm/common/stm32/src/board_common.c +++ b/boards/arm/common/stm32/src/board_common.c @@ -37,12 +37,12 @@ #if (defined(CONFIG_STM32_CAN_CHARDRIVER) || \ defined(CONFIG_STM32_FDCAN_CHARDRIVER)) && \ - !defined(CONFIG_STM32_HAVE_FDCAN_H7) + !defined(CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V2) # define HAVE_CAN_SETUP #endif #if (defined(CONFIG_STM32_CAN_SOCKET) || defined(CONFIG_STM32_FDCAN_SOCKET)) && \ - !defined(CONFIG_STM32_HAVE_FDCAN_H7) + !defined(CONFIG_STM32_HAVE_IP_FDCAN_MCAN_V2) # define HAVE_CANSOCK_SETUP #endif
