mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-07 05:54:11 +08:00
update all cmake for esp32 build
This commit is contained in:
parent
96718b7ca0
commit
641613c428
@ -1,29 +1,24 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
|
# -DFAMILY=espressif
|
||||||
|
if(FAMILY STREQUAL "espressif")
|
||||||
# Check for -DFAMILY=
|
|
||||||
if(FAMILY MATCHES "^esp32s[2-3]")
|
|
||||||
# use BOARD-Directory name for project id
|
|
||||||
get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
|
||||||
set(PROJECT ${BOARD}-${PROJECT})
|
|
||||||
|
|
||||||
# TOP is absolute path to root directory of TinyUSB git repo
|
# TOP is absolute path to root directory of TinyUSB git repo
|
||||||
set(TOP "../../..")
|
set(TOP "../../..")
|
||||||
get_filename_component(TOP "${TOP}" REALPATH)
|
get_filename_component(TOP "${TOP}" REALPATH)
|
||||||
|
endif()
|
||||||
|
|
||||||
project(${PROJECT})
|
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
|
||||||
|
|
||||||
else()
|
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
|
||||||
|
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
|
project(${PROJECT})
|
||||||
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
|
|
||||||
|
|
||||||
project(${PROJECT})
|
# Checks this example is valid for the family and initializes the project
|
||||||
|
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
|
||||||
# Checks this example is valid for the family and initializes the project
|
|
||||||
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
|
|
||||||
|
|
||||||
|
# Other family such as rp2040
|
||||||
|
if(NOT FAMILY STREQUAL "espressif")
|
||||||
add_executable(${PROJECT})
|
add_executable(${PROJECT})
|
||||||
|
|
||||||
# Example source
|
# Example source
|
||||||
|
@ -1,17 +1,7 @@
|
|||||||
# FAMILY = esp32sx
|
|
||||||
idf_component_register(SRCS "main.c"
|
idf_component_register(SRCS "main.c"
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
REQUIRES freertos soc)
|
REQUIRES freertos soc tinyusb_src)
|
||||||
|
|
||||||
file(TO_NATIVE_PATH "${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}/board.cmake" board_cmake)
|
|
||||||
|
|
||||||
if(EXISTS ${board_cmake})
|
|
||||||
include(${board_cmake})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
|
|
||||||
target_include_directories(${COMPONENT_TARGET} PUBLIC
|
target_include_directories(${COMPONENT_TARGET} PUBLIC
|
||||||
"${FREERTOS_ORIG_INCLUDE_PATH}"
|
|
||||||
"${TOP}/hw"
|
"${TOP}/hw"
|
||||||
"${TOP}/src"
|
)
|
||||||
)
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "bsp/board.h"
|
#include "bsp/board.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
// MACRO CONSTANT TYPEDEF PROTOTYPES
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
/* Blink pattern
|
/* Blink pattern
|
||||||
|
@ -5,7 +5,3 @@ idf_component_register(SRCS "main.c" "usb_descriptors.c" "msc_disk.c"
|
|||||||
target_include_directories(${COMPONENT_TARGET} PUBLIC
|
target_include_directories(${COMPONENT_TARGET} PUBLIC
|
||||||
"${TOP}/hw"
|
"${TOP}/hw"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(${COMPONENT_TARGET} PUBLIC
|
|
||||||
ESP_PLATFORM
|
|
||||||
)
|
|
||||||
|
@ -54,7 +54,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This examples use FreeRTOS
|
// This examples use FreeRTOS
|
||||||
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
||||||
|
#endif
|
||||||
|
|
||||||
// Espressif IDF requires "freertos/" prefix in include path
|
// Espressif IDF requires "freertos/" prefix in include path
|
||||||
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# use BOARD-Directory name for project id
|
|
||||||
get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
|
||||||
set(PROJECT ${BOARD}-${PROJECT})
|
|
||||||
|
|
||||||
# TOP is absolute path to root directory of TinyUSB git repo
|
# TOP is absolute path to root directory of TinyUSB git repo
|
||||||
|
# needed for esp32sx build. TODO could be removed later on
|
||||||
set(TOP "../../..")
|
set(TOP "../../..")
|
||||||
get_filename_component(TOP "${TOP}" REALPATH)
|
get_filename_component(TOP "${TOP}" REALPATH)
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
|
||||||
|
|
||||||
|
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
|
||||||
|
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
|
project(${PROJECT})
|
||||||
|
|
||||||
|
# Checks this example is valid for the family and initializes the project
|
||||||
|
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
# Check for -DFAMILY=
|
# Check for -DFAMILY=
|
||||||
if(FAMILY MATCHES "^esp32s[2-3]")
|
if(NOT FAMILY STREQUAL "espressif")
|
||||||
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
|
|
||||||
project(${PROJECT})
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
|
message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,35 +1,7 @@
|
|||||||
idf_component_register(SRCS "main.c" "usb_descriptors.c"
|
idf_component_register(SRCS "main.c" "usb_descriptors.c"
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
REQUIRES freertos soc)
|
REQUIRES freertos soc tinyusb_src)
|
||||||
|
|
||||||
file(TO_NATIVE_PATH "${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}/board.cmake" board_cmake)
|
|
||||||
|
|
||||||
if(EXISTS ${board_cmake})
|
|
||||||
include(${board_cmake})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_include_directories(${COMPONENT_TARGET} PUBLIC
|
target_include_directories(${COMPONENT_TARGET} PUBLIC
|
||||||
"${TOP}/hw"
|
"${TOP}/hw"
|
||||||
"${TOP}/src"
|
)
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_definitions(${COMPONENT_TARGET} PUBLIC
|
|
||||||
ESP_PLATFORM
|
|
||||||
)
|
|
||||||
|
|
||||||
target_sources(${COMPONENT_TARGET} PUBLIC
|
|
||||||
"${TOP}/src/tusb.c"
|
|
||||||
"${TOP}/src/common/tusb_fifo.c"
|
|
||||||
"${TOP}/src/device/usbd.c"
|
|
||||||
"${TOP}/src/device/usbd_control.c"
|
|
||||||
"${TOP}/src/class/cdc/cdc_device.c"
|
|
||||||
"${TOP}/src/class/dfu/dfu_rt_device.c"
|
|
||||||
"${TOP}/src/class/hid/hid_device.c"
|
|
||||||
"${TOP}/src/class/midi/midi_device.c"
|
|
||||||
"${TOP}/src/class/msc/msc_device.c"
|
|
||||||
"${TOP}/src/class/net/ecm_rndis_device.c"
|
|
||||||
"${TOP}/src/class/net/ncm_device.c"
|
|
||||||
"${TOP}/src/class/usbtmc/usbtmc_device.c"
|
|
||||||
"${TOP}/src/class/vendor/vendor_device.c"
|
|
||||||
"${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c"
|
|
||||||
)
|
|
||||||
|
@ -54,7 +54,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This examples use FreeRTOS
|
// This examples use FreeRTOS
|
||||||
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
||||||
|
#endif
|
||||||
|
|
||||||
// Espressif IDF requires "freertos/" prefix in include path
|
// Espressif IDF requires "freertos/" prefix in include path
|
||||||
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
||||||
|
@ -1,14 +1,8 @@
|
|||||||
idf_component_register(SRCS family.c
|
idf_component_register(SRCS family.c
|
||||||
INCLUDE_DIRS "." "${BOARD}"
|
INCLUDE_DIRS "." "${BOARD}"
|
||||||
PRIV_REQUIRES "driver"
|
PRIV_REQUIRES "driver"
|
||||||
REQUIRES freertos src led_strip)
|
REQUIRES led_strip src tinyusb_src)
|
||||||
|
|
||||||
# Apply board specific content
|
|
||||||
include("${BOARD}/board.cmake")
|
|
||||||
|
|
||||||
idf_component_get_property(FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
|
|
||||||
target_include_directories(${COMPONENT_TARGET} PUBLIC
|
target_include_directories(${COMPONENT_TARGET} PUBLIC
|
||||||
"${FREERTOS_ORIG_INCLUDE_PATH}"
|
|
||||||
"${TOP}/hw"
|
"${TOP}/hw"
|
||||||
"${TOP}/src"
|
|
||||||
)
|
)
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* This file is part of the TinyUSB stack.
|
* This file is part of the TinyUSB stack.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../board.h"
|
#include "bsp/board.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
#include "esp_rom_gpio.h"
|
#include "esp_rom_gpio.h"
|
||||||
|
@ -19,6 +19,7 @@ endif()
|
|||||||
|
|
||||||
list(APPEND compile_options
|
list(APPEND compile_options
|
||||||
"-DCFG_TUSB_MCU=${tusb_mcu}"
|
"-DCFG_TUSB_MCU=${tusb_mcu}"
|
||||||
|
"-DCFG_TUSB_OS=OPT_OS_FREERTOS"
|
||||||
#"-DCFG_TUSB_DEBUG=1"
|
#"-DCFG_TUSB_DEBUG=1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ if __name__ == '__main__':
|
|||||||
# If examples are not specified in arguments, build all
|
# If examples are not specified in arguments, build all
|
||||||
all_examples = []
|
all_examples = []
|
||||||
for dir1 in os.scandir("examples"):
|
for dir1 in os.scandir("examples"):
|
||||||
if dir1.is_dir():
|
if dir1.is_dir() and 'cmake-build' not in dir1.name:
|
||||||
for entry in os.scandir(dir1.path):
|
for entry in os.scandir(dir1.path):
|
||||||
if entry.is_dir():
|
if entry.is_dir():
|
||||||
all_examples.append(dir1.name + '/' + entry.name)
|
all_examples.append(dir1.name + '/' + entry.name)
|
||||||
@ -52,7 +52,7 @@ if __name__ == '__main__':
|
|||||||
# If family are not specified in arguments, build all
|
# If family are not specified in arguments, build all
|
||||||
all_families = []
|
all_families = []
|
||||||
for entry in os.scandir("hw/bsp"):
|
for entry in os.scandir("hw/bsp"):
|
||||||
if entry.is_dir() and os.path.isdir(entry.path + "/boards") and entry.name != 'espressif'
|
if entry.is_dir() and os.path.isdir(entry.path + "/boards") and entry.name != 'espressif':
|
||||||
all_families.append(entry.name)
|
all_families.append(entry.name)
|
||||||
filter_with_input(all_families)
|
filter_with_input(all_families)
|
||||||
all_families.sort()
|
all_families.sort()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user