From 3b2f8942bcf424c9b24a1a67e064d5eb14c8819f Mon Sep 17 00:00:00 2001 From: billyuanyk Date: Sun, 12 Apr 2026 21:00:50 +0700 Subject: [PATCH] Update CMake of Communication to support U2x Devices --- net_dev/canif/CMakeLists.txt | 378 ++++++++++++++++++----------------- net_dev/eth/CMakeLists.txt | 4 + net_protocols/CMakeLists.txt | 4 + 3 files changed, 199 insertions(+), 187 deletions(-) diff --git a/net_dev/canif/CMakeLists.txt b/net_dev/canif/CMakeLists.txt index a8395dc..66180d8 100755 --- a/net_dev/canif/CMakeLists.txt +++ b/net_dev/canif/CMakeLists.txt @@ -1,187 +1,191 @@ -# ############################################################################## -# components/communication/net_dev/canif/CMakeLists.txt -# -# Copyright (c) 2025 Li Auto Inc. and its affiliates -# Licensed 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. -# -# ############################################################################## - -if(CONFIG_MODULE_CANIF) - # 头文件引入 - set( INCLUDE_DIR - # GENERAL - ${NUTTX_APPS_DIR}/components/include/autosar/ - ${NUTTX_APPS_DIR}/components/include/ - ${GENDATA_DIR}/Os - ${GENDATA_DIR}/Rte - ${GENDATA_DIR}/PduR - ${GENDATA_DIR}/CanIf - ${GENDATA_DIR}/CanNm - ${GENDATA_DIR}/Nm - ${GENDATA_DIR}/Memmap - ${NUTTX_APPS_DIR}/${APPS_DIR}/apps - ${NUTTX_APPS_DIR}/components/rt_framework/inc - - #vcos log - ${NUTTX_APPS_DIR}/components/maintaining/vcos_log/inc - #CanIf inc - ${CMAKE_CURRENT_SOURCE_DIR}/inc - #PduR inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../pdu_router/inc - ) - - if(CONFIG_MODULE_CANTP) - list(APPEND INCLUDE_DIR - #CanTp inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../../diagnostics/transport/cantp/inc - ${GENDATA_DIR}/CanTp - ) - endif() - - if(CONFIG_MODULE_CANNM) - list(APPEND INCLUDE_DIR - #CanNm inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../net_manager/cannm/inc - ${GENDATA_DIR}/CanNm - ) - endif() - if(CONFIG_MODULE_NM) - list(APPEND INCLUDE_DIR - #Nm inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../net_manager/nm/inc - ${GENDATA_DIR}/Nm - ) - endif() - if(CONFIG_MODULE_COMM) - list(APPEND INCLUDE_DIR - #ComM inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../net_manager/comm/inc - ${GENDATA_DIR}/ComM - ) - endif() - if(CONFIG_MODULE_CANSM) - list(APPEND INCLUDE_DIR - #ComM inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../net_manager/cansm/inc - ${GENDATA_DIR}/CanSM - ) - endif() - if(CONFIG_SERVM_ECUM) - list(APPEND INCLUDE_DIR - #EcuM inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../../system_services/service_management/sysm_init/inc - ${GENDATA_DIR}/sysm/EcuM - ) - endif() - if (CONFIG_MODULE_CANTRCV1145) - list(APPEND INCLUDE_DIR - ${GENDATA_DIR}/CanTrcv1145 - ) - endif() - if (CONFIG_ARCH_SIM) - list(APPEND INCLUDE_DIR - ${SIM_DRIVERS_DIR}/tja1145/inc - ) - elseif(NOT CONFIG_ARCH_CHIP_E3650 AND CONFIG_MODULE_CANTRCV1145) - list(APPEND INCLUDE_DIR - #CanTrcv1145 inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../net_dev/cantrcv1145/inc - ) - endif() - if(CONFIG_MODULE_DEM) - list(APPEND INCLUDE_DIR - #dem inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../../diagnostics/service/dem/inc - ${GENDATA_DIR}/Dem - ) - endif() - if(CONFIG_MODULE_CANTSYN) - list(APPEND INCLUDE_DIR - #tsync inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../../system_services/time/tsync/inc - ${GENDATA_DIR}/CanTSyn - ) - endif() - if(CONFIG_MODULE_STBM) - list(APPEND INCLUDE_DIR - #stbm inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../../system_services/time/time_manager/inc - ${GENDATA_DIR}/StbM - ) - endif() - if(CONFIG_MODULE_ETHIF) - list(APPEND INCLUDE_DIR - #ethif inc - ${CMAKE_CURRENT_SOURCE_DIR}/../../net_dev/eth - ${GENDATA_DIR}/EthIf - ${NUTTX_APPS_DIR}/components/communication/net_protocols/sockets - ${NUTTX_APPS_DIR}/components/communication/external/lwip - ${GENDATA_DIR}/EthIf - ${GENDATA_DIR}/Lwip - ${GENDATA_DIR}/TcpIp - ) - if(CONFIG_ARCH_CHIP_E3650) - #ethdriver inc - list(APPEND INCLUDE_DIR - ${ETH_STACK_E3XX_GETHMAC_DIR}/e3650 - ) - elseif(CONFIG_ARCH_CHIP_CUSTOM_TC397) - list(APPEND INCLUDE_DIR - ${ETH_STACK_TC3xx_GETHMAC_DIR} - ) - endif() - endif() - - # Can driver - if (CONFIG_ARCH_SIM) - list(APPEND INCLUDE_DIR - ${SIM_DRIVERS_CANSTACK_INCLUDE_DIRS} - ${SIM_DRIVERS_DIR}/spi/inc - ) - elseif(CONFIG_ARCH_CHIP_CUSTOM_TC397) - list(APPEND INCLUDE_DIR - ${CAN_STACK_TC3XX_DIR} - ) - elseif(CONFIG_ARCH_CHIP_E3650) - list(APPEND INCLUDE_DIR - ${CAN_STACK_E3XX_DIR} - ) - elseif(CONFIG_ARCH_CHIP_J6E) - list(APPEND INCLUDE_DIR - ${CAN_STACK_J6E_DIR} - ) - endif() - # 收集 CanIf 目录下的所需 .c 文件 - file(GLOB CANIF_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c" - ) - - # 合并所有源文件 - set( CANIF_CAN_SRCS - ${CANIF_SOURCES} - ${GENDATA_DIR}/CanIf/canif_cfg.c - ${GENDATA_DIR}/CanIf/canif_pbcfg.c - ) - - nuttx_add_library(can_canif STATIC) - target_sources(can_canif PRIVATE ${CANIF_CAN_SRCS}) - target_include_directories(can_canif PRIVATE ${INCLUDE_DIR}) - - if (CONFIG_ARCH_SIM) - target_link_libraries(can_canif PRIVATE sim_can) - elseif(CONFIG_ARCH_CHIP_CUSTOM_TC397) - target_link_libraries(can_canif PRIVATE can_driver) - elseif(CONFIG_ARCH_CHIP_E3650) - target_link_libraries(can_canif PRIVATE e3_can_driver) - elseif(CONFIG_ARCH_CHIP_J6E) - target_link_libraries(can_canif PRIVATE j6_can_driver) - endif() -endif() +# ############################################################################## +# components/communication/net_dev/canif/CMakeLists.txt +# +# Copyright (c) 2025 Li Auto Inc. and its affiliates +# Licensed 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. +# +# ############################################################################## + +if(CONFIG_MODULE_CANIF) + # 头文件引入 + set( INCLUDE_DIR + # GENERAL + ${NUTTX_APPS_DIR}/components/include/autosar/ + ${NUTTX_APPS_DIR}/components/include/ + ${GENDATA_DIR}/Os + ${GENDATA_DIR}/Rte + ${GENDATA_DIR}/PduR + ${GENDATA_DIR}/CanIf + ${GENDATA_DIR}/CanNm + ${GENDATA_DIR}/Nm + ${GENDATA_DIR}/Memmap + ${NUTTX_APPS_DIR}/${APPS_DIR}/apps + ${NUTTX_APPS_DIR}/components/rt_framework/inc + + #vcos log + ${NUTTX_APPS_DIR}/components/maintaining/vcos_log/inc + #CanIf inc + ${CMAKE_CURRENT_SOURCE_DIR}/inc + #PduR inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../pdu_router/inc + ) + + if(CONFIG_MODULE_CANTP) + list(APPEND INCLUDE_DIR + #CanTp inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../../diagnostics/transport/cantp/inc + ${GENDATA_DIR}/CanTp + ) + endif() + + if(CONFIG_MODULE_CANNM) + list(APPEND INCLUDE_DIR + #CanNm inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../net_manager/cannm/inc + ${GENDATA_DIR}/CanNm + ) + endif() + if(CONFIG_MODULE_NM) + list(APPEND INCLUDE_DIR + #Nm inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../net_manager/nm/inc + ${GENDATA_DIR}/Nm + ) + endif() + if(CONFIG_MODULE_COMM) + list(APPEND INCLUDE_DIR + #ComM inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../net_manager/comm/inc + ${GENDATA_DIR}/ComM + ) + endif() + if(CONFIG_MODULE_CANSM) + list(APPEND INCLUDE_DIR + #ComM inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../net_manager/cansm/inc + ${GENDATA_DIR}/CanSM + ) + endif() + if(CONFIG_SERVM_ECUM) + list(APPEND INCLUDE_DIR + #EcuM inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../../system_services/service_management/sysm_init/inc + ${GENDATA_DIR}/sysm/EcuM + ) + endif() + if (CONFIG_MODULE_CANTRCV1145) + list(APPEND INCLUDE_DIR + ${GENDATA_DIR}/CanTrcv1145 + ) + endif() + if (CONFIG_ARCH_SIM) + list(APPEND INCLUDE_DIR + ${SIM_DRIVERS_DIR}/tja1145/inc + ) + elseif(NOT CONFIG_ARCH_CHIP_E3650 AND CONFIG_MODULE_CANTRCV1145) + list(APPEND INCLUDE_DIR + #CanTrcv1145 inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../net_dev/cantrcv1145/inc + ) + endif() + if(CONFIG_MODULE_DEM) + list(APPEND INCLUDE_DIR + #dem inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../../diagnostics/service/dem/inc + ${GENDATA_DIR}/Dem + ) + endif() + if(CONFIG_MODULE_CANTSYN) + list(APPEND INCLUDE_DIR + #tsync inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../../system_services/time/tsync/inc + ${GENDATA_DIR}/CanTSyn + ) + endif() + if(CONFIG_MODULE_STBM) + list(APPEND INCLUDE_DIR + #stbm inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../../system_services/time/time_manager/inc + ${GENDATA_DIR}/StbM + ) + endif() + if(CONFIG_MODULE_ETHIF) + list(APPEND INCLUDE_DIR + #ethif inc + ${CMAKE_CURRENT_SOURCE_DIR}/../../net_dev/eth + ${GENDATA_DIR}/EthIf + ${NUTTX_APPS_DIR}/components/communication/net_protocols/sockets + ${NUTTX_APPS_DIR}/components/communication/external/lwip + ${GENDATA_DIR}/EthIf + ${GENDATA_DIR}/Lwip + ${GENDATA_DIR}/TcpIp + ) + if(CONFIG_ARCH_CHIP_E3650) + #ethdriver inc + list(APPEND INCLUDE_DIR + ${ETH_STACK_E3XX_GETHMAC_DIR}/e3650 + ) + elseif(CONFIG_ARCH_CHIP_CUSTOM_TC397) + list(APPEND INCLUDE_DIR + ${ETH_STACK_TC3xx_GETHMAC_DIR} + ) + elseif(CONFIG_ARCH_CHIP_U2BXE) + list(APPEND INCLUDE_DIR + ${ETH_STACK_RH850_GETHMAC_DIR}/u2bx + ) + endif() + endif() + + # Can driver + if (CONFIG_ARCH_SIM) + list(APPEND INCLUDE_DIR + ${SIM_DRIVERS_CANSTACK_INCLUDE_DIRS} + ${SIM_DRIVERS_DIR}/spi/inc + ) + elseif(CONFIG_ARCH_CHIP_CUSTOM_TC397) + list(APPEND INCLUDE_DIR + ${CAN_STACK_TC3XX_DIR} + ) + elseif(CONFIG_ARCH_CHIP_E3650) + list(APPEND INCLUDE_DIR + ${CAN_STACK_E3XX_DIR} + ) + elseif(CONFIG_ARCH_CHIP_J6E) + list(APPEND INCLUDE_DIR + ${CAN_STACK_J6E_DIR} + ) + endif() + # 收集 CanIf 目录下的所需 .c 文件 + file(GLOB CANIF_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c" + ) + + # 合并所有源文件 + set( CANIF_CAN_SRCS + ${CANIF_SOURCES} + ${GENDATA_DIR}/CanIf/canif_cfg.c + ${GENDATA_DIR}/CanIf/canif_pbcfg.c + ) + + nuttx_add_library(can_canif STATIC) + target_sources(can_canif PRIVATE ${CANIF_CAN_SRCS}) + target_include_directories(can_canif PRIVATE ${INCLUDE_DIR}) + + if (CONFIG_ARCH_SIM) + target_link_libraries(can_canif PRIVATE sim_can) + elseif(CONFIG_ARCH_CHIP_CUSTOM_TC397) + target_link_libraries(can_canif PRIVATE can_driver) + elseif(CONFIG_ARCH_CHIP_E3650) + target_link_libraries(can_canif PRIVATE e3_can_driver) + elseif(CONFIG_ARCH_CHIP_J6E) + target_link_libraries(can_canif PRIVATE j6_can_driver) + endif() +endif() diff --git a/net_dev/eth/CMakeLists.txt b/net_dev/eth/CMakeLists.txt index eb42d50..983a1ba 100755 --- a/net_dev/eth/CMakeLists.txt +++ b/net_dev/eth/CMakeLists.txt @@ -57,6 +57,10 @@ if(CONFIG_ETH_STACK) list(APPEND INCLUDE_DIR ${ETH_STACK_J6_GETHMAC_DIR} ) + elseif(CONFIG_ARCH_CHIP_U2BXE) + list(APPEND INCLUDE_DIR + ${ETH_STACK_RH850_GETHMAC_DIR}/u2bx + ) endif() # 收集 EthIf 目录下的所需 .c 文件 diff --git a/net_protocols/CMakeLists.txt b/net_protocols/CMakeLists.txt index 5a8ab2b..74fc125 100755 --- a/net_protocols/CMakeLists.txt +++ b/net_protocols/CMakeLists.txt @@ -59,6 +59,10 @@ if(CONFIG_ETH_STACK) list(APPEND INCLUDE_DIR ${ETH_STACK_TC3xx_GETHMAC_DIR} ) + elseif(CONFIG_ARCH_CHIP_U2BXE) + list(APPEND INCLUDE_DIR + ${ETH_STACK_RH850_GETHMAC_DIR}/u2bx + ) else(CONFIG_ARCH_CHIP_J6E) list(APPEND INCLUDE_DIR ${ETH_STACK_J6_GETHMAC_DIR} -- Gitee