summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-03-30 10:41:11 +0700
committerhathach <[email protected]>2023-03-30 10:41:11 +0700
commit641613c428e10a029b172c318d4db077e35fee7d (patch)
treec607eaaa3822fe522bf57f0d24e858fb782b7d81
parent96718b7ca08d1d74cf1ecfb3816b57df50bf1616 (diff)
update all cmake for esp32 build
-rw-r--r--examples/device/board_test/CMakeLists.txt27
-rw-r--r--examples/device/board_test/src/CMakeLists.txt16
-rw-r--r--examples/device/board_test/src/main.c2
-rw-r--r--examples/device/cdc_msc_freertos/CMakeLists.txt2
-rw-r--r--examples/device/cdc_msc_freertos/src/CMakeLists.txt4
-rw-r--r--examples/device/cdc_msc_freertos/src/tusb_config.h2
-rw-r--r--examples/device/hid_composite_freertos/CMakeLists.txt20
-rw-r--r--examples/device/hid_composite_freertos/src/CMakeLists.txt34
-rw-r--r--examples/device/hid_composite_freertos/src/tusb_config.h2
-rw-r--r--hw/bsp/espressif/boards/CMakeLists.txt8
-rw-r--r--hw/bsp/espressif/boards/family.c2
-rw-r--r--hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt1
-rw-r--r--tools/build_family.py4
13 files changed, 40 insertions, 84 deletions
diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt
index 37113578e..b21d56f9e 100644
--- a/examples/device/board_test/CMakeLists.txt
+++ b/examples/device/board_test/CMakeLists.txt
@@ -1,29 +1,24 @@
cmake_minimum_required(VERSION 3.5)
-include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
-
-# 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})
-
+# -DFAMILY=espressif
+if(FAMILY STREQUAL "espressif")
# TOP is absolute path to root directory of TinyUSB git repo
set(TOP "../../..")
get_filename_component(TOP "${TOP}" REALPATH)
+endif()
- project(${PROJECT})
-
-else()
+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})
+# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
+family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
- project(${PROJECT})
+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})
# Example source
diff --git a/examples/device/board_test/src/CMakeLists.txt b/examples/device/board_test/src/CMakeLists.txt
index 37625f441..03f4c7505 100644
--- a/examples/device/board_test/src/CMakeLists.txt
+++ b/examples/device/board_test/src/CMakeLists.txt
@@ -1,17 +1,7 @@
-# FAMILY = esp32sx
idf_component_register(SRCS "main.c"
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
- "${FREERTOS_ORIG_INCLUDE_PATH}"
- "${TOP}/hw"
- "${TOP}/src"
-)
+ "${TOP}/hw"
+ )
diff --git a/examples/device/board_test/src/main.c b/examples/device/board_test/src/main.c
index 3f8d55c52..b11f6f2bb 100644
--- a/examples/device/board_test/src/main.c
+++ b/examples/device/board_test/src/main.c
@@ -30,7 +30,7 @@
#include "bsp/board.h"
//--------------------------------------------------------------------+
-// MACRO CONSTANT TYPEDEF PROTYPES
+// MACRO CONSTANT TYPEDEF PROTOTYPES
//--------------------------------------------------------------------+
/* Blink pattern
diff --git a/examples/device/cdc_msc_freertos/CMakeLists.txt b/examples/device/cdc_msc_freertos/CMakeLists.txt
index 82bf79f19..573924b18 100644
--- a/examples/device/cdc_msc_freertos/CMakeLists.txt
+++ b/examples/device/cdc_msc_freertos/CMakeLists.txt
@@ -16,6 +16,6 @@ project(${PROJECT})
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
# Check for -DFAMILY=
-if(NOT FAMILY STREQUAL "espressif")
+if(NOT FAMILY STREQUAL "espressif")
message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
endif()
diff --git a/examples/device/cdc_msc_freertos/src/CMakeLists.txt b/examples/device/cdc_msc_freertos/src/CMakeLists.txt
index e433e5074..9c597b302 100644
--- a/examples/device/cdc_msc_freertos/src/CMakeLists.txt
+++ b/examples/device/cdc_msc_freertos/src/CMakeLists.txt
@@ -5,7 +5,3 @@ idf_component_register(SRCS "main.c" "usb_descriptors.c" "msc_disk.c"
target_include_directories(${COMPONENT_TARGET} PUBLIC
"${TOP}/hw"
)
-
-target_compile_definitions(${COMPONENT_TARGET} PUBLIC
- ESP_PLATFORM
-)
diff --git a/examples/device/cdc_msc_freertos/src/tusb_config.h b/examples/device/cdc_msc_freertos/src/tusb_config.h
index 0ec8896b9..91efe7d40 100644
--- a/examples/device/cdc_msc_freertos/src/tusb_config.h
+++ b/examples/device/cdc_msc_freertos/src/tusb_config.h
@@ -54,7 +54,9 @@
#endif
// This examples use FreeRTOS
+#ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_FREERTOS
+#endif
// Espressif IDF requires "freertos/" prefix in include path
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
diff --git a/examples/device/hid_composite_freertos/CMakeLists.txt b/examples/device/hid_composite_freertos/CMakeLists.txt
index ed734b954..573924b18 100644
--- a/examples/device/hid_composite_freertos/CMakeLists.txt
+++ b/examples/device/hid_composite_freertos/CMakeLists.txt
@@ -1,17 +1,21 @@
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
+# needed for esp32sx build. TODO could be removed later on
set(TOP "../../..")
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=
-if(FAMILY MATCHES "^esp32s[2-3]")
- include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
- project(${PROJECT})
-else()
+if(NOT FAMILY STREQUAL "espressif")
message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
endif()
diff --git a/examples/device/hid_composite_freertos/src/CMakeLists.txt b/examples/device/hid_composite_freertos/src/CMakeLists.txt
index 25da8fcd7..1e1e465e0 100644
--- a/examples/device/hid_composite_freertos/src/CMakeLists.txt
+++ b/examples/device/hid_composite_freertos/src/CMakeLists.txt
@@ -1,35 +1,7 @@
idf_component_register(SRCS "main.c" "usb_descriptors.c"
INCLUDE_DIRS "."
- REQUIRES freertos soc)
-
-file(TO_NATIVE_PATH "${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}/board.cmake" board_cmake)
-
-if(EXISTS ${board_cmake})
- include(${board_cmake})
-endif()
+ REQUIRES freertos soc tinyusb_src)
target_include_directories(${COMPONENT_TARGET} PUBLIC
- "${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"
-)
+ "${TOP}/hw"
+ )
diff --git a/examples/device/hid_composite_freertos/src/tusb_config.h b/examples/device/hid_composite_freertos/src/tusb_config.h
index 935ae9453..3ba9bf311 100644
--- a/examples/device/hid_composite_freertos/src/tusb_config.h
+++ b/examples/device/hid_composite_freertos/src/tusb_config.h
@@ -54,7 +54,9 @@
#endif
// This examples use FreeRTOS
+#ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_FREERTOS
+#endif
// Espressif IDF requires "freertos/" prefix in include path
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
diff --git a/hw/bsp/espressif/boards/CMakeLists.txt b/hw/bsp/espressif/boards/CMakeLists.txt
index 3832037a9..a5332d715 100644
--- a/hw/bsp/espressif/boards/CMakeLists.txt
+++ b/hw/bsp/espressif/boards/CMakeLists.txt
@@ -1,14 +1,8 @@
idf_component_register(SRCS family.c
INCLUDE_DIRS "." "${BOARD}"
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
- "${FREERTOS_ORIG_INCLUDE_PATH}"
"${TOP}/hw"
- "${TOP}/src"
)
diff --git a/hw/bsp/espressif/boards/family.c b/hw/bsp/espressif/boards/family.c
index 015d8305b..8fc4a1cc8 100644
--- a/hw/bsp/espressif/boards/family.c
+++ b/hw/bsp/espressif/boards/family.c
@@ -24,7 +24,7 @@
* This file is part of the TinyUSB stack.
*/
-#include "../../board.h"
+#include "bsp/board.h"
#include "board.h"
#include "esp_rom_gpio.h"
diff --git a/hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt b/hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt
index 0bd404cee..9aadda43d 100644
--- a/hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt
+++ b/hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt
@@ -19,6 +19,7 @@ endif()
list(APPEND compile_options
"-DCFG_TUSB_MCU=${tusb_mcu}"
+ "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
#"-DCFG_TUSB_DEBUG=1"
)
diff --git a/tools/build_family.py b/tools/build_family.py
index ae0bb282d..f9f7261fe 100644
--- a/tools/build_family.py
+++ b/tools/build_family.py
@@ -42,7 +42,7 @@ if __name__ == '__main__':
# If examples are not specified in arguments, build all
all_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):
if entry.is_dir():
all_examples.append(dir1.name + '/' + entry.name)
@@ -52,7 +52,7 @@ if __name__ == '__main__':
# If family are not specified in arguments, build all
all_families = []
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)
filter_with_input(all_families)
all_families.sort()