diff options
| author | hathach <[email protected]> | 2025-12-13 14:56:15 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2025-12-13 14:56:15 +0700 |
| commit | 80886fb32a9610d863246726950ffefeb2ffb21b (patch) | |
| tree | 8914ea1e2702d6ebf8e8346ca4641a402e91b321 /examples | |
| parent | 7a4af1e9b833d334cca8fa98bc200d4738cb6b82 (diff) | |
| parent | 3a4d02ba9f150b74df08384d16fac124a7c27485 (diff) | |
Merge branch 'refs/heads/master' into hcd_fsdev
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/CMakeLists.txt | 26 | ||||
| -rw-r--r-- | examples/build_system/cmake/toolchain/arm_clang.cmake | 1 | ||||
| -rw-r--r-- | examples/build_system/cmake/toolchain/arm_iar.cmake | 3 | ||||
| -rw-r--r-- | examples/build_system/cmake/toolchain/common.cmake | 37 | ||||
| -rw-r--r-- | examples/build_system/make/toolchain/gcc_common.mk | 3 | ||||
| -rw-r--r-- | examples/device/CMakeLists.txt | 63 | ||||
| -rw-r--r-- | examples/dual/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | examples/host/CMakeLists.txt | 20 |
8 files changed, 99 insertions, 64 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d34c6ed5d..b34131c2b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -5,7 +5,25 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../hw/bsp/family_support.cmake) project(tinyusb_examples C CXX ASM) -add_subdirectory(device) -add_subdirectory(dual) -add_subdirectory(host) -add_subdirectory(typec) +set(EXAMPLES_LIST + device + dual + host + typec + ) +set(MAPJSON_PATTERNS "") + +foreach (example ${EXAMPLES_LIST}) + add_subdirectory(${example}) + list(APPEND MAPJSON_PATTERNS "${CMAKE_BINARY_DIR}/${example}/*/*.map.json") +endforeach () + +# Post-build: run metrics.py on all map.json files +find_package(Python3 REQUIRED COMPONENTS Interpreter) +add_custom_target(tinyusb_metrics + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../tools/metrics.py + combine -f tinyusb/src -j -o ${CMAKE_BINARY_DIR}/metrics + ${MAPJSON_PATTERNS} + COMMENT "Generating average code size metrics" + VERBATIM + ) diff --git a/examples/build_system/cmake/toolchain/arm_clang.cmake b/examples/build_system/cmake/toolchain/arm_clang.cmake index dba637367..e5ca82fab 100644 --- a/examples/build_system/cmake/toolchain/arm_clang.cmake +++ b/examples/build_system/cmake/toolchain/arm_clang.cmake @@ -7,7 +7,6 @@ if (NOT DEFINED CMAKE_CXX_COMPILER) endif () set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) -set(TOOLCHAIN_ASM_FLAGS "-x assembler-with-cpp") find_program(CMAKE_SIZE llvm-size) find_program(CMAKE_OBJCOPY llvm-objcopy) diff --git a/examples/build_system/cmake/toolchain/arm_iar.cmake b/examples/build_system/cmake/toolchain/arm_iar.cmake index 0b7e0b585..67d100bbc 100644 --- a/examples/build_system/cmake/toolchain/arm_iar.cmake +++ b/examples/build_system/cmake/toolchain/arm_iar.cmake @@ -24,7 +24,8 @@ set(CMAKE_C_ICSTAT ${CMAKE_IAR_CSTAT} --checks=${CMAKE_CURRENT_LIST_DIR}/cstat_sel_checks.txt --db=${CMAKE_BINARY_DIR}/cstat.db --sarif_dir=${CMAKE_BINARY_DIR}/cstat_sarif - --exclude ${TOP}/hw/mcu --exclude ${TOP}/lib + --exclude=${TOP}/hw/mcu + --exclude=${TOP}/lib ) endif () diff --git a/examples/build_system/cmake/toolchain/common.cmake b/examples/build_system/cmake/toolchain/common.cmake index 14449b01d..e610a349b 100644 --- a/examples/build_system/cmake/toolchain/common.cmake +++ b/examples/build_system/cmake/toolchain/common.cmake @@ -20,37 +20,32 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_CPU}.cmake) # ---------------------------------------------------------------------------- # Compile flags # ---------------------------------------------------------------------------- +set(TOOLCHAIN_C_FLAGS) +set(TOOLCHAIN_ASM_FLAGS) +set(TOOLCHAIN_EXE_LINKER_FLAGS) + if (TOOLCHAIN STREQUAL "gcc" OR TOOLCHAIN STREQUAL "clang") list(APPEND TOOLCHAIN_COMMON_FLAGS -fdata-sections -ffunction-sections # -fsingle-precision-constant # not supported by clang -fno-strict-aliasing + -g # include debug info for bloaty ) - list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS - -Wl,--print-memory-usage - -Wl,--gc-sections - -Wl,--cref - ) + set(TOOLCHAIN_EXE_LINKER_FLAGS "-Wl,--print-memory-usage -Wl,--gc-sections -Wl,--cref") + + if (TOOLCHAIN STREQUAL clang) + set(TOOLCHAIN_ASM_FLAGS "-x assembler-with-cpp") + endif () elseif (TOOLCHAIN STREQUAL "iar") - list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS - --diag_suppress=Li065 - ) + set(TOOLCHAIN_C_FLAGS --debug) + set(TOOLCHAIN_EXE_LINKER_FLAGS --diag_suppress=Li065) endif () # join the toolchain flags into a single string list(JOIN TOOLCHAIN_COMMON_FLAGS " " TOOLCHAIN_COMMON_FLAGS) -foreach (LANG IN ITEMS C CXX ASM) - set(CMAKE_${LANG}_FLAGS_INIT ${TOOLCHAIN_COMMON_FLAGS}) - # optimization flags for LOG, LOGGER ? - #set(CMAKE_${LANG}_FLAGS_RELEASE_INIT "-Os") - #set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0") -endforeach () - -# Assembler -if (DEFINED TOOLCHAIN_ASM_FLAGS) - set(CMAKE_ASM_FLAGS_INIT "${CMAKE_ASM_FLAGS_INIT} ${TOOLCHAIN_ASM_FLAGS}") -endif () -# Linker -list(JOIN TOOLCHAIN_EXE_LINKER_FLAGS " " CMAKE_EXE_LINKER_FLAGS_INIT) +set(CMAKE_C_FLAGS_INIT "${TOOLCHAIN_COMMON_FLAGS} ${TOOLCHAIN_C_FLAGS}") +set(CMAKE_CXX_FLAGS_INIT "${TOOLCHAIN_COMMON_FLAGS} ${TOOLCHAIN_C_FLAGS}") +set(CMAKE_ASM_FLAGS_INIT "${TOOLCHAIN_COMMON_FLAGS} ${TOOLCHAIN_ASM_FLAGS}") +set(CMAKE_EXE_LINKER_FLAGS_INIT ${TOOLCHAIN_EXE_LINKER_FLAGS}) diff --git a/examples/build_system/make/toolchain/gcc_common.mk b/examples/build_system/make/toolchain/gcc_common.mk index 0cbb6774d..42fd01183 100644 --- a/examples/build_system/make/toolchain/gcc_common.mk +++ b/examples/build_system/make/toolchain/gcc_common.mk @@ -31,6 +31,9 @@ CFLAGS += \ -Wreturn-type \ -Wredundant-decls \ +CFLAGS_CLANG += \ + -Wno-error=unknown-warning-option + # -Wmissing-prototypes \ # conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion # -Wconversion diff --git a/examples/device/CMakeLists.txt b/examples/device/CMakeLists.txt index eb625ea51..660df67cb 100644 --- a/examples/device/CMakeLists.txt +++ b/examples/device/CMakeLists.txt @@ -6,31 +6,38 @@ project(tinyusb_device_examples C CXX ASM) family_initialize_project(tinyusb_device_examples ${CMAKE_CURRENT_LIST_DIR}) # family_add_subdirectory will filter what to actually add based on selected FAMILY -family_add_subdirectory(audio_4_channel_mic) -family_add_subdirectory(audio_test) -family_add_subdirectory(audio_4_channel_mic_freertos) -family_add_subdirectory(audio_test_freertos) -family_add_subdirectory(audio_test_multi_rate) -family_add_subdirectory(board_test) -family_add_subdirectory(cdc_dual_ports) -family_add_subdirectory(cdc_msc) -family_add_subdirectory(cdc_msc_freertos) -family_add_subdirectory(cdc_uac2) -family_add_subdirectory(dfu) -family_add_subdirectory(dfu_runtime) -family_add_subdirectory(dynamic_configuration) -family_add_subdirectory(hid_boot_interface) -family_add_subdirectory(hid_composite) -family_add_subdirectory(hid_composite_freertos) -family_add_subdirectory(hid_generic_inout) -family_add_subdirectory(hid_multiple_interface) -family_add_subdirectory(midi_test) -family_add_subdirectory(msc_dual_lun) -family_add_subdirectory(mtp) -family_add_subdirectory(net_lwip_webserver) -family_add_subdirectory(uac2_headset) -family_add_subdirectory(uac2_speaker_fb) -family_add_subdirectory(usbtmc) -family_add_subdirectory(video_capture) -family_add_subdirectory(video_capture_2ch) -family_add_subdirectory(webusb_serial) +set(EXAMPLE_LIST + audio_4_channel_mic + audio_4_channel_mic_freertos + audio_test + audio_test_freertos + audio_test_multi_rate + board_test + cdc_dual_ports + cdc_msc + cdc_msc_freertos + cdc_uac2 + dfu + dfu_runtime + dynamic_configuration + hid_boot_interface + hid_composite + hid_composite_freertos + hid_generic_inout + hid_multiple_interface + midi_test + midi_test_freertos + msc_dual_lun + mtp + net_lwip_webserver + uac2_headset + uac2_speaker_fb + usbtmc + video_capture + video_capture_2ch + webusb_serial + ) + +foreach (example ${EXAMPLE_LIST}) + family_add_subdirectory(${example}) +endforeach () diff --git a/examples/dual/CMakeLists.txt b/examples/dual/CMakeLists.txt index c5e3ffce4..4978f1fab 100644 --- a/examples/dual/CMakeLists.txt +++ b/examples/dual/CMakeLists.txt @@ -9,6 +9,12 @@ if (FAMILY STREQUAL "rp2040" AND NOT TARGET tinyusb_pico_pio_usb) message("Skipping dual host/device mode examples as Pico-PIO-USB is not available") else () # family_add_subdirectory will filter what to actually add based on selected FAMILY - family_add_subdirectory(host_hid_to_device_cdc) - family_add_subdirectory(host_info_to_device_cdc) + set(EXAMPLE_LIST + host_hid_to_device_cdc + host_info_to_device_cdc + ) + + foreach (example ${EXAMPLE_LIST}) + family_add_subdirectory(${example}) + endforeach () endif () diff --git a/examples/host/CMakeLists.txt b/examples/host/CMakeLists.txt index 2783dd84e..f8e0ce692 100644 --- a/examples/host/CMakeLists.txt +++ b/examples/host/CMakeLists.txt @@ -6,10 +6,16 @@ project(tinyusb_host_examples C CXX ASM) family_initialize_project(tinyusb_host_examples ${CMAKE_CURRENT_LIST_DIR}) # family_add_subdirectory will filter what to actually add based on selected FAMILY -family_add_subdirectory(bare_api) -family_add_subdirectory(cdc_msc_hid) -family_add_subdirectory(cdc_msc_hid_freertos) -family_add_subdirectory(device_info) -family_add_subdirectory(hid_controller) -family_add_subdirectory(midi_rx) -family_add_subdirectory(msc_file_explorer) +set(EXAMPLE_LIST + bare_api + cdc_msc_hid + cdc_msc_hid_freertos + device_info + hid_controller + midi_rx + msc_file_explorer + ) + +foreach (example ${EXAMPLE_LIST}) + family_add_subdirectory(${example}) +endforeach () |
