update espressif cmake

This commit is contained in:
hathach
2025-11-06 11:39:10 +07:00
parent 58b4104015
commit 0172f40e66
5 changed files with 22 additions and 44 deletions

View File

@ -1,4 +1,3 @@
mcu:ESP32P4
mcu:LPC175X_6X
mcu:LPC177X_8X
mcu:LPC18XX
@ -15,5 +14,6 @@ mcu:STM32F7
mcu:STM32H7
mcu:STM32H7RS
mcu:STM32N6
family:espressif
family:samd21
family:samd5x_e5x

View File

@ -1,7 +1,4 @@
mcu:CH32V20X
mcu:ESP32S2
mcu:ESP32S3
mcu:ESP32P4
mcu:KINETIS_KL
mcu:LPC175X_6X
mcu:LPC177X_8X
@ -21,5 +18,6 @@ mcu:STM32F7
mcu:STM32H7
mcu:STM32H7RS
mcu:STM32N6
family:espressif
family:samd21
family:samd5x_e5x

View File

@ -1,12 +1,12 @@
idf_build_get_property(target IDF_TARGET)
include(CMakePrintHelpers)
set(srcs)
set(includes_public)
set(compile_options)
set(tusb_src "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src")
set(tusb_src ${CMAKE_CURRENT_LIST_DIR}/../../../../../src)
get_filename_component(tusb_src ${tusb_src} ABSOLUTE)
include(${tusb_src}/CMakeLists.txt)
string(TOUPPER OPT_MCU_${target} tusb_mcu)
list(APPEND compile_definitions
set(compile_definitions
CFG_TUSB_MCU=${tusb_mcu}
CFG_TUSB_OS=OPT_OS_FREERTOS
BOARD_TUD_RHPORT=${RHPORT_DEVICE}
@ -14,7 +14,7 @@ list(APPEND compile_definitions
BOARD_TUH_RHPORT=${RHPORT_HOST}
BOARD_TUH_MAX_SPEED=${RHPORT_HOST_SPEED}
)
cmake_print_variables(compile_definitions)
if (target STREQUAL esp32p4)
# P4 change alignment to 64 (DCache line size) for possible DMA configuration
list(APPEND compile_definitions
@ -23,36 +23,11 @@ if (target STREQUAL esp32p4)
)
endif ()
tinyusb_sources_get(srcs)
list(APPEND srcs
# common
${tusb_src}/tusb.c
${tusb_src}/common/tusb_fifo.c
# device
${tusb_src}/device/usbd.c
${tusb_src}/device/usbd_control.c
${tusb_src}/class/audio/audio_device.c
${tusb_src}/class/cdc/cdc_device.c
${tusb_src}/class/dfu/dfu_device.c
${tusb_src}/class/dfu/dfu_rt_device.c
${tusb_src}/class/hid/hid_device.c
${tusb_src}/class/midi/midi_device.c
${tusb_src}/class/msc/msc_device.c
${tusb_src}/class/mtp/mtp_device.c
${tusb_src}/class/net/ecm_rndis_device.c
${tusb_src}/class/net/ncm_device.c
${tusb_src}/class/usbtmc/usbtmc_device.c
${tusb_src}/class/vendor/vendor_device.c
${tusb_src}/class/video/video_device.c
${tusb_src}/portable/synopsys/dwc2/dcd_dwc2.c
${tusb_src}/portable/synopsys/dwc2/hcd_dwc2.c
${tusb_src}/portable/synopsys/dwc2/dwc2_common.c
# host
${tusb_src}/host/usbh.c
${tusb_src}/host/hub.c
${tusb_src}/class/cdc/cdc_host.c
${tusb_src}/class/hid/hid_host.c
${tusb_src}/class/msc/msc_host.c
${tusb_src}/class/vendor/vendor_host.c
)
# use max3421 as host controller
@ -74,7 +49,6 @@ if(DEFINED CFLAGS_CLI)
list(APPEND compile_definitions ${CFLAGS_CLI})
endif()
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${tusb_src}
REQUIRES src
@ -82,4 +56,3 @@ idf_component_register(SRCS ${srcs}
)
target_compile_definitions(${COMPONENT_LIB} PUBLIC ${compile_definitions})
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-error=format)

View File

@ -12,7 +12,7 @@ set(UF2CONV_PY ${TOP}/tools/uf2/utils/uf2conv.py)
#-------------------------------------------------------------
# Toolchain
# Can be changed via -DTOOLCHAIN=gcc|iar or -DCMAKE_C_COMPILER=
# Can be changed via -DTOOLCHAIN=gcc|iar or -DCMAKE_C_COMPILER= or ENV{CC}=
#-------------------------------------------------------------
function(detect_compiler COMPILER_PATH RESULT)
string(FIND ${COMPILER_PATH} "iccarm" IS_IAR)
@ -319,8 +319,8 @@ endfunction()
# Add tinyusb to target
function(family_add_tinyusb TARGET OPT_MCU)
# tinyusb's CMakeList.txt
add_subdirectory(${TOP}/src ${CMAKE_CURRENT_BINARY_DIR}/tinyusb)
# tinyusb's CMakeLists.txt
include(${TOP}/src/CMakeLists.txt)
# Add TinyUSB sources, include and common define
tinyusb_target_add(${TARGET})

View File

@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.20)
# Add tinyusb to a existing target, DCD and HCD drivers are not included
function(tinyusb_target_add TARGET)
target_sources(${TARGET} PRIVATE
# Get TinyUSB sources. Note: DCD and HCD drivers are not included
function(tinyusb_sources_get OUTPUT_VAR)
set(${OUTPUT_VAR}
# common
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/tusb.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/common/tusb_fifo.c
@ -32,7 +32,14 @@ function(tinyusb_target_add TARGET)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/vendor/vendor_host.c
# typec
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/typec/usbc.c
PARENT_SCOPE
)
endfunction()
# Add tinyusb to a existing target
function(tinyusb_target_add TARGET)
tinyusb_sources_get(TINYUSB_SRC)
target_sources(${TARGET} PRIVATE ${TINYUSB_SRC})
target_include_directories(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
# TODO for net driver, should be removed/changed