Skip to content

Commit 641613c

Browse files
committed
update all cmake for esp32 build
1 parent 96718b7 commit 641613c

File tree

13 files changed

+40
-84
lines changed

13 files changed

+40
-84
lines changed

examples/device/board_test/CMakeLists.txt

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
cmake_minimum_required(VERSION 3.5)
22

3-
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
4-
5-
# Check for -DFAMILY=
6-
if(FAMILY MATCHES "^esp32s[2-3]")
7-
# use BOARD-Directory name for project id
8-
get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
9-
set(PROJECT ${BOARD}-${PROJECT})
10-
3+
# -DFAMILY=espressif
4+
if(FAMILY STREQUAL "espressif")
115
# TOP is absolute path to root directory of TinyUSB git repo
126
set(TOP "../../..")
137
get_filename_component(TOP "${TOP}" REALPATH)
8+
endif()
149

15-
project(${PROJECT})
16-
17-
else()
10+
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
1811

19-
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
20-
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
12+
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
13+
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
2114

22-
project(${PROJECT})
15+
project(${PROJECT})
2316

24-
# Checks this example is valid for the family and initializes the project
25-
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
17+
# Checks this example is valid for the family and initializes the project
18+
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
2619

20+
# Other family such as rp2040
21+
if(NOT FAMILY STREQUAL "espressif")
2722
add_executable(${PROJECT})
2823

2924
# Example source
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
# FAMILY = esp32sx
21
idf_component_register(SRCS "main.c"
32
INCLUDE_DIRS "."
4-
REQUIRES freertos soc)
3+
REQUIRES freertos soc tinyusb_src)
54

6-
file(TO_NATIVE_PATH "${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}/board.cmake" board_cmake)
7-
8-
if(EXISTS ${board_cmake})
9-
include(${board_cmake})
10-
endif()
11-
12-
idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
135
target_include_directories(${COMPONENT_TARGET} PUBLIC
14-
"${FREERTOS_ORIG_INCLUDE_PATH}"
15-
"${TOP}/hw"
16-
"${TOP}/src"
17-
)
6+
"${TOP}/hw"
7+
)

examples/device/board_test/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "bsp/board.h"
3131

3232
//--------------------------------------------------------------------+
33-
// MACRO CONSTANT TYPEDEF PROTYPES
33+
// MACRO CONSTANT TYPEDEF PROTOTYPES
3434
//--------------------------------------------------------------------+
3535

3636
/* Blink pattern

examples/device/cdc_msc_freertos/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ project(${PROJECT})
1616
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
1717

1818
# Check for -DFAMILY=
19-
if(NOT FAMILY STREQUAL "espressif")
19+
if(NOT FAMILY STREQUAL "espressif")
2020
message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
2121
endif()

examples/device/cdc_msc_freertos/src/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,3 @@ idf_component_register(SRCS "main.c" "usb_descriptors.c" "msc_disk.c"
55
target_include_directories(${COMPONENT_TARGET} PUBLIC
66
"${TOP}/hw"
77
)
8-
9-
target_compile_definitions(${COMPONENT_TARGET} PUBLIC
10-
ESP_PLATFORM
11-
)

examples/device/cdc_msc_freertos/src/tusb_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
#endif
5555

5656
// This examples use FreeRTOS
57+
#ifndef CFG_TUSB_OS
5758
#define CFG_TUSB_OS OPT_OS_FREERTOS
59+
#endif
5860

5961
// Espressif IDF requires "freertos/" prefix in include path
6062
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
cmake_minimum_required(VERSION 3.5)
22

3-
# use BOARD-Directory name for project id
4-
get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
5-
set(PROJECT ${BOARD}-${PROJECT})
6-
73
# TOP is absolute path to root directory of TinyUSB git repo
4+
# needed for esp32sx build. TODO could be removed later on
85
set(TOP "../../..")
96
get_filename_component(TOP "${TOP}" REALPATH)
107

8+
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
9+
10+
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
11+
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
12+
13+
project(${PROJECT})
14+
15+
# Checks this example is valid for the family and initializes the project
16+
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
17+
1118
# Check for -DFAMILY=
12-
if(FAMILY MATCHES "^esp32s[2-3]")
13-
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
14-
project(${PROJECT})
15-
else()
19+
if(NOT FAMILY STREQUAL "espressif")
1620
message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
1721
endif()
Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,7 @@
11
idf_component_register(SRCS "main.c" "usb_descriptors.c"
22
INCLUDE_DIRS "."
3-
REQUIRES freertos soc)
4-
5-
file(TO_NATIVE_PATH "${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}/board.cmake" board_cmake)
6-
7-
if(EXISTS ${board_cmake})
8-
include(${board_cmake})
9-
endif()
3+
REQUIRES freertos soc tinyusb_src)
104

115
target_include_directories(${COMPONENT_TARGET} PUBLIC
12-
"${TOP}/hw"
13-
"${TOP}/src"
14-
)
15-
16-
target_compile_definitions(${COMPONENT_TARGET} PUBLIC
17-
ESP_PLATFORM
18-
)
19-
20-
target_sources(${COMPONENT_TARGET} PUBLIC
21-
"${TOP}/src/tusb.c"
22-
"${TOP}/src/common/tusb_fifo.c"
23-
"${TOP}/src/device/usbd.c"
24-
"${TOP}/src/device/usbd_control.c"
25-
"${TOP}/src/class/cdc/cdc_device.c"
26-
"${TOP}/src/class/dfu/dfu_rt_device.c"
27-
"${TOP}/src/class/hid/hid_device.c"
28-
"${TOP}/src/class/midi/midi_device.c"
29-
"${TOP}/src/class/msc/msc_device.c"
30-
"${TOP}/src/class/net/ecm_rndis_device.c"
31-
"${TOP}/src/class/net/ncm_device.c"
32-
"${TOP}/src/class/usbtmc/usbtmc_device.c"
33-
"${TOP}/src/class/vendor/vendor_device.c"
34-
"${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c"
35-
)
6+
"${TOP}/hw"
7+
)

examples/device/hid_composite_freertos/src/tusb_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
#endif
5555

5656
// This examples use FreeRTOS
57+
#ifndef CFG_TUSB_OS
5758
#define CFG_TUSB_OS OPT_OS_FREERTOS
59+
#endif
5860

5961
// Espressif IDF requires "freertos/" prefix in include path
6062
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
idf_component_register(SRCS family.c
22
INCLUDE_DIRS "." "${BOARD}"
33
PRIV_REQUIRES "driver"
4-
REQUIRES freertos src led_strip)
4+
REQUIRES led_strip src tinyusb_src)
55

6-
# Apply board specific content
7-
include("${BOARD}/board.cmake")
8-
9-
idf_component_get_property(FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
106
target_include_directories(${COMPONENT_TARGET} PUBLIC
11-
"${FREERTOS_ORIG_INCLUDE_PATH}"
127
"${TOP}/hw"
13-
"${TOP}/src"
148
)

0 commit comments

Comments
 (0)