From ffad6eaf80900a858e22378e68de8b21b96c769e Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 00:12:20 +0700 Subject: [PATCH 01/18] cmake esp32s2 and rp2040 getting along --- examples/device/board_test/CMakeLists.txt | 71 +++++----------- examples/device/board_test/src/CMakeLists.txt | 1 + examples/device/cdc_msc/CMakeLists.txt | 80 +++++-------------- hw/bsp/rp2040/family.cmake | 46 +++++++++++ hw/bsp/rp2040/family_extra.cmake | 1 - 5 files changed, 85 insertions(+), 114 deletions(-) delete mode 100644 hw/bsp/rp2040/family_extra.cmake diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index 54a4009f..e8cab165 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -8,58 +8,23 @@ set(TOP "../../..") get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= -if(NOT DEFINED FAMILY) +if(FAMILY STREQUAL "esp32s2") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + project(${PROJECT}) + +elseif(FAMILY STREQUAL "rp2040") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + src/main.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + src + ) + +else() message(FATAL_ERROR "Invalid FAMILY specified") endif() - -include(${TOP}/hw/bsp/${FAMILY}/family.cmake) -project(${PROJECT}) - -if(FAMILY STREQUAL "rp2040") - -pico_sdk_init() - -add_executable(${PROJECT}) - -# TinyUSB Stack source -set(SRC_TINYUSB - ${TOP}/src/tusb.c - ${TOP}/src/common/tusb_fifo.c - ${TOP}/src/device/usbd.c - ${TOP}/src/device/usbd_control.c - ${TOP}/src/class/audio/audio_device.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/net_device.c - ${TOP}/src/class/usbtmc/usbtmc_device.c - ${TOP}/src/class/vendor/vendor_device.c - ${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c - ${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c -) - -target_sources(${PROJECT} PUBLIC - src/main.c - ${TOP}/hw/bsp/${FAMILY}/family.c - ${SRC_TINYUSB} -) - -target_include_directories(${PROJECT} PUBLIC - src/ - ${TOP}/hw - ${TOP}/src - ${TOP}/hw/bsp/${FAMILY}/boards/${BOARD} -) - -target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_MCU=OPT_MCU_RP2040 - CFG_TUSB_OS=OPT_OS_PICO -) - -target_link_libraries(${PROJECT} pico_stdlib) - -pico_add_extra_outputs(${PROJECT}) - -endif() diff --git a/examples/device/board_test/src/CMakeLists.txt b/examples/device/board_test/src/CMakeLists.txt index 29ae46a3..e5966106 100644 --- a/examples/device/board_test/src/CMakeLists.txt +++ b/examples/device/board_test/src/CMakeLists.txt @@ -1,3 +1,4 @@ +# FAMILY = "esp32s2" idf_component_register(SRCS "main.c" INCLUDE_DIRS "." REQUIRES freertos soc) diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt index ada122b6..0dc9c58e 100644 --- a/examples/device/cdc_msc/CMakeLists.txt +++ b/examples/device/cdc_msc/CMakeLists.txt @@ -8,65 +8,25 @@ set(TOP "../../..") get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= -if(NOT DEFINED FAMILY) +if(FAMILY STREQUAL "esp32s2") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + project(${PROJECT}) + +elseif(FAMILY STREQUAL "rp2040") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + src/main.c + src/msc_disk.c + src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + src + ) + +else() message(FATAL_ERROR "Invalid FAMILY specified") endif() - -include(${TOP}/hw/bsp/${FAMILY}/family.cmake) -project(${PROJECT}) - -if(FAMILY STREQUAL "rp2040") - -pico_sdk_init() - -add_executable(${PROJECT}) - -# TinyUSB Stack source -set(SRC_TINYUSB - ${TOP}/src/tusb.c - ${TOP}/src/common/tusb_fifo.c - ${TOP}/src/device/usbd.c - ${TOP}/src/device/usbd_control.c - ${TOP}/src/class/audio/audio_device.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/net_device.c - ${TOP}/src/class/usbtmc/usbtmc_device.c - ${TOP}/src/class/vendor/vendor_device.c - ${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c - ${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c -) - -# Example source -set(SRC_EXAMPLE - src/main.c - src/msc_disk.c - src/usb_descriptors.c -) - -target_sources(${PROJECT} PUBLIC - ${SRC_EXAMPLE} - ${TOP}/hw/bsp/${FAMILY}/family.c - ${SRC_TINYUSB} -) - -target_include_directories(${PROJECT} PUBLIC - src/ - ${TOP}/hw - ${TOP}/src - ${TOP}/hw/bsp/${FAMILY}/boards/${BOARD} -) - -target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_MCU=OPT_MCU_RP2040 - CFG_TUSB_OS=OPT_OS_PICO -) - -target_link_libraries(${PROJECT} pico_stdlib) - -pico_add_extra_outputs(${PROJECT}) - -endif() diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index 8a3882cc..ef6c9f41 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -1,3 +1,49 @@ cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + +project(${PROJECT}) + +pico_sdk_init() + +add_executable(${PROJECT}) + +# TinyUSB Stack source +set(SRC_TINYUSB + ${TOP}/src/tusb.c + ${TOP}/src/common/tusb_fifo.c + ${TOP}/src/device/usbd.c + ${TOP}/src/device/usbd_control.c + ${TOP}/src/class/audio/audio_device.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/net_device.c + ${TOP}/src/class/usbtmc/usbtmc_device.c + ${TOP}/src/class/vendor/vendor_device.c + ${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c + ${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c +) + +target_sources(${PROJECT} PUBLIC + ${TOP}/hw/bsp/${FAMILY}/family.c + ${SRC_TINYUSB} +) + +target_include_directories(${PROJECT} PUBLIC + ${TOP}/hw + ${TOP}/src + ${TOP}/hw/bsp/${FAMILY}/boards/${BOARD} +) + +target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_MCU=OPT_MCU_RP2040 + CFG_TUSB_OS=OPT_OS_PICO +) + +target_link_libraries(${PROJECT} pico_stdlib) + +pico_add_extra_outputs(${PROJECT}) diff --git a/hw/bsp/rp2040/family_extra.cmake b/hw/bsp/rp2040/family_extra.cmake deleted file mode 100644 index 66184584..00000000 --- a/hw/bsp/rp2040/family_extra.cmake +++ /dev/null @@ -1 +0,0 @@ -pico_sdk_init() From 959a94b98d020ee2f6a05e36be56c1618dd6ed78 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 00:44:17 +0700 Subject: [PATCH 02/18] rp2040 audio_test compile --- examples/device/audio_test/CMakeLists.txt | 35 ++++++++++++++++++++ examples/device/audio_test/src/tusb_config.h | 2 ++ examples/device/board_test/CMakeLists.txt | 17 +++++++--- examples/device/cdc_msc/CMakeLists.txt | 21 ++++++++---- hw/bsp/rp2040/family.cmake | 15 --------- tools/build_family.py | 6 ++++ 6 files changed, 71 insertions(+), 25 deletions(-) create mode 100644 examples/device/audio_test/CMakeLists.txt diff --git a/examples/device/audio_test/CMakeLists.txt b/examples/device/audio_test/CMakeLists.txt new file mode 100644 index 00000000..a1dc14b0 --- /dev/null +++ b/examples/device/audio_test/CMakeLists.txt @@ -0,0 +1,35 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/audio_test/src/tusb_config.h b/examples/device/audio_test/src/tusb_config.h index 5d94858e..61e63f07 100644 --- a/examples/device/audio_test/src/tusb_config.h +++ b/examples/device/audio_test/src/tusb_config.h @@ -45,7 +45,9 @@ extern "C" { #define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE #endif +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif #ifndef CFG_TUSB_DEBUG #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index e8cab165..c405c2ea 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.5) - # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) @@ -9,22 +7,33 @@ get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= if(FAMILY STREQUAL "esp32s2") + cmake_minimum_required(VERSION 3.5) include(${TOP}/hw/bsp/${FAMILY}/family.cmake) project(${PROJECT}) elseif(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) # Example source target_sources(${PROJECT} PUBLIC - src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c ) # Example include target_include_directories(${PROJECT} PUBLIC - src + ${CMAKE_CURRENT_SOURCE_DIR}/src ) + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + else() message(FATAL_ERROR "Invalid FAMILY specified") endif() diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt index 0dc9c58e..a8be05ad 100644 --- a/examples/device/cdc_msc/CMakeLists.txt +++ b/examples/device/cdc_msc/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.5) - # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) @@ -9,24 +7,35 @@ get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= if(FAMILY STREQUAL "esp32s2") + cmake_minimum_required(VERSION 3.5) include(${TOP}/hw/bsp/${FAMILY}/family.cmake) project(${PROJECT}) elseif(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) # Example source target_sources(${PROJECT} PUBLIC - src/main.c - src/msc_disk.c - src/usb_descriptors.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_disk.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c ) # Example include target_include_directories(${PROJECT} PUBLIC - src + ${CMAKE_CURRENT_SOURCE_DIR}/src ) + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + else() message(FATAL_ERROR "Invalid FAMILY specified") endif() diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index ef6c9f41..dd0123de 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -1,14 +1,3 @@ -cmake_minimum_required(VERSION 3.12) - -set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) -include(${PICO_SDK_PATH}/pico_sdk_init.cmake) - -project(${PROJECT}) - -pico_sdk_init() - -add_executable(${PROJECT}) - # TinyUSB Stack source set(SRC_TINYUSB ${TOP}/src/tusb.c @@ -43,7 +32,3 @@ target_compile_definitions(${PROJECT} PUBLIC CFG_TUSB_MCU=OPT_MCU_RP2040 CFG_TUSB_OS=OPT_OS_PICO ) - -target_link_libraries(${PROJECT} pico_stdlib) - -pico_add_extra_outputs(${PROJECT}) diff --git a/tools/build_family.py b/tools/build_family.py index 7f2c1a70..eb0ef9d8 100644 --- a/tools/build_family.py +++ b/tools/build_family.py @@ -95,7 +95,13 @@ def build_size(example, board): def skip_example(example, board): ex_dir = 'examples/' + example + + # family.mk board_mk = 'hw/bsp/{}/family.mk'.format(family) + + # family.cmake + if not os.path.exists(board_mk): + board_mk = 'hw/bsp/{}/family.cmake'.format(family) with open(board_mk) as mk: mk_contents = mk.read() From 26522d0ec5825280626f49c7191b7964826bed91 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 00:47:49 +0700 Subject: [PATCH 03/18] rp2040 dual cdc compiled and tested --- examples/device/cdc_dual_ports/CMakeLists.txt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/device/cdc_dual_ports/CMakeLists.txt diff --git a/examples/device/cdc_dual_ports/CMakeLists.txt b/examples/device/cdc_dual_ports/CMakeLists.txt new file mode 100644 index 00000000..a1dc14b0 --- /dev/null +++ b/examples/device/cdc_dual_ports/CMakeLists.txt @@ -0,0 +1,35 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() From 599b428e13a9b71e20a5b3272a3b0c07686cf57c Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 00:52:46 +0700 Subject: [PATCH 04/18] rp2040 dfu_rt dynamic_configuration compiled not tested, but should be OK --- examples/device/dfu_rt/CMakeLists.txt | 35 ++++++++++++++++++ examples/device/dfu_rt/src/tusb_config.h | 3 +- .../dynamic_configuration/CMakeLists.txt | 36 +++++++++++++++++++ .../dynamic_configuration/src/tusb_config.h | 3 +- 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 examples/device/dfu_rt/CMakeLists.txt create mode 100644 examples/device/dynamic_configuration/CMakeLists.txt diff --git a/examples/device/dfu_rt/CMakeLists.txt b/examples/device/dfu_rt/CMakeLists.txt new file mode 100644 index 00000000..a1dc14b0 --- /dev/null +++ b/examples/device/dfu_rt/CMakeLists.txt @@ -0,0 +1,35 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/dfu_rt/src/tusb_config.h b/examples/device/dfu_rt/src/tusb_config.h index 22657326..abdbe752 100644 --- a/examples/device/dfu_rt/src/tusb_config.h +++ b/examples/device/dfu_rt/src/tusb_config.h @@ -46,8 +46,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/dynamic_configuration/CMakeLists.txt b/examples/device/dynamic_configuration/CMakeLists.txt new file mode 100644 index 00000000..78337186 --- /dev/null +++ b/examples/device/dynamic_configuration/CMakeLists.txt @@ -0,0 +1,36 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_disk.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/dynamic_configuration/src/tusb_config.h b/examples/device/dynamic_configuration/src/tusb_config.h index 2f8072f8..23073faf 100644 --- a/examples/device/dynamic_configuration/src/tusb_config.h +++ b/examples/device/dynamic_configuration/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 From 4101df7a75c10710011d7e5cafa5b3737c45295a Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 00:54:58 +0700 Subject: [PATCH 05/18] rp2040 hid_composite compiled and tested --- examples/device/hid_composite/CMakeLists.txt | 35 +++++++++++++++++++ .../device/hid_composite/src/tusb_config.h | 3 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 examples/device/hid_composite/CMakeLists.txt diff --git a/examples/device/hid_composite/CMakeLists.txt b/examples/device/hid_composite/CMakeLists.txt new file mode 100644 index 00000000..a1dc14b0 --- /dev/null +++ b/examples/device/hid_composite/CMakeLists.txt @@ -0,0 +1,35 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/hid_composite/src/tusb_config.h b/examples/device/hid_composite/src/tusb_config.h index d8e6b73e..3e608ed3 100644 --- a/examples/device/hid_composite/src/tusb_config.h +++ b/examples/device/hid_composite/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 From 87daf284219bdbe8468e4d3641246bba3ce016d4 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 01:26:16 +0700 Subject: [PATCH 06/18] rp2040 skip freertos example --- examples/device/cdc_msc_freertos/.skip.MCU_RP2040 | 0 examples/device/hid_composite_freertos/.skip.MCU_RP2040 | 0 tools/build_family.py | 6 +++--- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 examples/device/cdc_msc_freertos/.skip.MCU_RP2040 create mode 100644 examples/device/hid_composite_freertos/.skip.MCU_RP2040 diff --git a/examples/device/cdc_msc_freertos/.skip.MCU_RP2040 b/examples/device/cdc_msc_freertos/.skip.MCU_RP2040 new file mode 100644 index 00000000..e69de29b diff --git a/examples/device/hid_composite_freertos/.skip.MCU_RP2040 b/examples/device/hid_composite_freertos/.skip.MCU_RP2040 new file mode 100644 index 00000000..e69de29b diff --git a/tools/build_family.py b/tools/build_family.py index eb0ef9d8..848996a3 100644 --- a/tools/build_family.py +++ b/tools/build_family.py @@ -107,12 +107,12 @@ def skip_example(example, board): mk_contents = mk.read() # Skip all OPT_MCU_NONE these are WIP port - if '-DCFG_TUSB_MCU=OPT_MCU_NONE' in mk_contents: + if 'CFG_TUSB_MCU=OPT_MCU_NONE' in mk_contents: return 1 # Skip if CFG_TUSB_MCU in board.mk to match skip file for skip_file in glob.iglob(ex_dir + '/.skip.MCU_*'): - mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(skip_file).split('.')[2] + mcu_cflag = 'CFG_TUSB_MCU=OPT_' + os.path.basename(skip_file).split('.')[2] if mcu_cflag in mk_contents: return 1 @@ -120,7 +120,7 @@ def skip_example(example, board): only_list = list(glob.iglob(ex_dir + '/.only.MCU_*')) if len(only_list) > 0: for only_file in only_list: - mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(only_file).split('.')[2] + mcu_cflag = 'CFG_TUSB_MCU=OPT_' + os.path.basename(only_file).split('.')[2] if mcu_cflag in mk_contents: return 0 return 1 From bcf16c04bd6b31591e953ee15e47afe5241bdc58 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 24 Jan 2021 01:28:56 +0700 Subject: [PATCH 07/18] enable ci for rp2040 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1732027..b9e5d4f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: family: - 'imxrt' - 'nrf' - #- 'rp2040' + - 'rp2040' - 'samd21' - 'samd51' - 'stm32f4' From ed280e3ec1a49a9816cfd1651113c251d4c00eca Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 12:21:50 +0700 Subject: [PATCH 08/18] correct ci scripts --- tools/build_board.py | 2 +- tools/build_esp32s2.py | 2 +- tools/build_family.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/build_board.py b/tools/build_board.py index cf3a8fb9..464ee68c 100644 --- a/tools/build_board.py +++ b/tools/build_board.py @@ -44,7 +44,7 @@ filter_with_input(all_boards) all_boards.sort() def build_board(example, board): - global success_count, fail_count, skip_count + global success_count, fail_count, skip_count, exit_status start_time = time.monotonic() flash_size = "-" sram_size = "-" diff --git a/tools/build_esp32s2.py b/tools/build_esp32s2.py index cff0cc33..9823e8c5 100644 --- a/tools/build_esp32s2.py +++ b/tools/build_esp32s2.py @@ -42,7 +42,7 @@ filter_with_input(all_boards) all_boards.sort() def build_board(example, board): - global success_count, fail_count, skip_count + global success_count, fail_count, skip_count, exit_status start_time = time.monotonic() flash_size = "-" sram_size = "-" diff --git a/tools/build_family.py b/tools/build_family.py index 848996a3..ae1bf078 100644 --- a/tools/build_family.py +++ b/tools/build_family.py @@ -55,7 +55,7 @@ def build_family(example, family): build_board(example, board) def build_board(example, board): - global success_count, fail_count, skip_count + global success_count, fail_count, skip_count, exit_status start_time = time.monotonic() flash_size = "-" sram_size = "-" From c2b0083f0aaa234fbcb237bc223d8bf89ee1b212 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 12:49:04 +0700 Subject: [PATCH 09/18] change msp430 caching, use url for cache key --- .github/workflows/build.yml | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9e5d4f3..62b4a95b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -94,22 +94,33 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v1 + - name: Checkout TinyUSB + uses: actions/checkout@v2 + with: + submodules: 'true' + + - name: Checkout Sub-Submodules + run: | + # some submodule has it own submodules that need to be fetched as well + git submodule update --init --recursive hw/mcu/microchip + git submodule update --init --recursive lib/FreeRTOS + + # Add MSP430 URL to env + echo >> $GITHUB_ENV MSP430GCC_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2 + - name: Cache MSP430 Toolchain uses: actions/cache@v2 id: cache-msp430 with: - path: /tmp/dl/ + path: $HOME/msp430-gcc/ # Increment gcc version number at end when updating downloads - key: ${{ runner.os }}-msp430-9.2.0.50 + key: ${{ runner.os }}-${{ env.MSP430GCC_URL }} - name: Install MSP430 Toolchain if: steps.cache-msp430.outputs.cache-hit != 'true' - env: - MSP430GCC_URL: http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2 run: | - mkdir -p /tmp/dl/ - [ -f "/tmp/dl/msp430-gcc.tar.bz2" ] || wget --progress=dot:mega $MSP430GCC_URL -O /tmp/dl/msp430-gcc.tar.bz2 - tar -C $HOME -xaf /tmp/dl/msp430-gcc.tar.bz2 + wget --progress=dot:mega $MSP430GCC_URL -O msp430-gcc.tar.bz2 + tar -C $HOME/msp430-gcc -xaf msp430-gcc.tar.bz2 - name: Install Toolchains run: | @@ -121,18 +132,7 @@ jobs: echo `echo $HOME/opt/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/*/.content/bin` >> $GITHUB_PATH # TI MSP430 GCC - echo `echo $HOME/msp430-gcc-*_linux64/bin` >> $GITHUB_PATH - - - name: Checkout TinyUSB - uses: actions/checkout@v2 - with: - submodules: 'true' - - - name: Checkout Sub-Submodules - run: | - # some submodule has it own submodules that need to be fetched as well - git submodule update --init --recursive hw/mcu/microchip - git submodule update --init --recursive lib/FreeRTOS + echo `echo $HOME/msp430-gcc/msp430-gcc-*_linux64/bin` >> $GITHUB_PATH - name: Build run: python3 tools/build_board.py ${{ matrix.example }} From 0fe0757657925c892360b1102cc2f6b4ca9e7a03 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 12:53:24 +0700 Subject: [PATCH 10/18] correct msp430 cache --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62b4a95b..3d37b750 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -120,6 +120,7 @@ jobs: if: steps.cache-msp430.outputs.cache-hit != 'true' run: | wget --progress=dot:mega $MSP430GCC_URL -O msp430-gcc.tar.bz2 + mkdir -p $HOME/msp430-gcc tar -C $HOME/msp430-gcc -xaf msp430-gcc.tar.bz2 - name: Install Toolchains From ec458292fecbf16be425e5497722f647911de969 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 13:25:47 +0700 Subject: [PATCH 11/18] fix host build --- src/common/tusb_types.h | 3 ++- src/host/usbh.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h index 5ab15aa3..2b4ceb69 100644 --- a/src/common/tusb_types.h +++ b/src/common/tusb_types.h @@ -48,7 +48,8 @@ typedef enum { TUSB_SPEED_FULL = 0, TUSB_SPEED_LOW , - TUSB_SPEED_HIGH + TUSB_SPEED_HIGH, + TUSB_SPEED_INVALID = 0xff, }tusb_speed_t; /// defined base on USB Specs Endpoint's bmAttributes diff --git a/src/host/usbh.c b/src/host/usbh.c index 10ae991f..f278f4d9 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -153,7 +153,7 @@ tusb_device_state_t tuh_device_get_state (uint8_t const dev_addr) tusb_speed_t tuh_device_get_speed (uint8_t const dev_addr) { - TU_ASSERT( dev_addr <= CFG_TUSB_HOST_DEVICE_MAX, TUSB_DEVICE_STATE_UNPLUG); + TU_ASSERT( dev_addr <= CFG_TUSB_HOST_DEVICE_MAX, TUSB_SPEED_INVALID); return (tusb_speed_t) _usbh_devices[dev_addr].speed; } From 83614418b588464873ccbd3fcaeef3d03917bd0e Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 13:28:23 +0700 Subject: [PATCH 12/18] get all device example build with rp2040 (except freeRTOS) --- examples/device/audio_test/CMakeLists.txt | 5 ++ examples/device/board_test/CMakeLists.txt | 5 ++ examples/device/cdc_dual_ports/CMakeLists.txt | 5 ++ examples/device/cdc_msc/CMakeLists.txt | 5 ++ examples/device/dfu_rt/CMakeLists.txt | 5 ++ .../dynamic_configuration/CMakeLists.txt | 5 ++ examples/device/hid_composite/CMakeLists.txt | 5 ++ .../device/hid_generic_inout/CMakeLists.txt | 40 +++++++++ .../hid_generic_inout/src/tusb_config.h | 3 +- .../hid_multiple_interface/CMakeLists.txt | 40 +++++++++ .../hid_multiple_interface/src/tusb_config.h | 3 +- examples/device/midi_test/CMakeLists.txt | 40 +++++++++ examples/device/midi_test/src/tusb_config.h | 3 +- examples/device/msc_dual_lun/CMakeLists.txt | 41 +++++++++ .../device/msc_dual_lun/src/tusb_config.h | 3 +- .../device/net_lwip_webserver/CMakeLists.txt | 87 +++++++++++++++++++ .../net_lwip_webserver/src/tusb_config.h | 3 +- examples/device/uac2_headset/CMakeLists.txt | 40 +++++++++ .../device/uac2_headset/src/tusb_config.h | 2 + examples/device/usbtmc/CMakeLists.txt | 41 +++++++++ examples/device/usbtmc/src/tusb_config.h | 3 +- examples/device/webusb_serial/CMakeLists.txt | 40 +++++++++ .../device/webusb_serial/src/tusb_config.h | 3 +- examples/host/cdc_msc_hid/src/tusb_config.h | 2 + hw/bsp/rp2040/family.cmake | 1 - 25 files changed, 422 insertions(+), 8 deletions(-) create mode 100644 examples/device/hid_generic_inout/CMakeLists.txt create mode 100644 examples/device/hid_multiple_interface/CMakeLists.txt create mode 100644 examples/device/midi_test/CMakeLists.txt create mode 100644 examples/device/msc_dual_lun/CMakeLists.txt create mode 100644 examples/device/net_lwip_webserver/CMakeLists.txt create mode 100644 examples/device/uac2_headset/CMakeLists.txt create mode 100644 examples/device/usbtmc/CMakeLists.txt create mode 100644 examples/device/webusb_serial/CMakeLists.txt diff --git a/examples/device/audio_test/CMakeLists.txt b/examples/device/audio_test/CMakeLists.txt index a1dc14b0..99ee77bd 100644 --- a/examples/device/audio_test/CMakeLists.txt +++ b/examples/device/audio_test/CMakeLists.txt @@ -27,6 +27,11 @@ if(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index c405c2ea..68577ba7 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -31,6 +31,11 @@ elseif(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/cdc_dual_ports/CMakeLists.txt b/examples/device/cdc_dual_ports/CMakeLists.txt index a1dc14b0..99ee77bd 100644 --- a/examples/device/cdc_dual_ports/CMakeLists.txt +++ b/examples/device/cdc_dual_ports/CMakeLists.txt @@ -27,6 +27,11 @@ if(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt index a8be05ad..7f5d5a99 100644 --- a/examples/device/cdc_msc/CMakeLists.txt +++ b/examples/device/cdc_msc/CMakeLists.txt @@ -33,6 +33,11 @@ elseif(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/dfu_rt/CMakeLists.txt b/examples/device/dfu_rt/CMakeLists.txt index a1dc14b0..99ee77bd 100644 --- a/examples/device/dfu_rt/CMakeLists.txt +++ b/examples/device/dfu_rt/CMakeLists.txt @@ -27,6 +27,11 @@ if(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/dynamic_configuration/CMakeLists.txt b/examples/device/dynamic_configuration/CMakeLists.txt index 78337186..f2646572 100644 --- a/examples/device/dynamic_configuration/CMakeLists.txt +++ b/examples/device/dynamic_configuration/CMakeLists.txt @@ -28,6 +28,11 @@ if(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/hid_composite/CMakeLists.txt b/examples/device/hid_composite/CMakeLists.txt index a1dc14b0..99ee77bd 100644 --- a/examples/device/hid_composite/CMakeLists.txt +++ b/examples/device/hid_composite/CMakeLists.txt @@ -27,6 +27,11 @@ if(FAMILY STREQUAL "rp2040") ${CMAKE_CURRENT_SOURCE_DIR}/src ) + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + target_link_libraries(${PROJECT} pico_stdlib) pico_add_extra_outputs(${PROJECT}) diff --git a/examples/device/hid_generic_inout/CMakeLists.txt b/examples/device/hid_generic_inout/CMakeLists.txt new file mode 100644 index 00000000..99ee77bd --- /dev/null +++ b/examples/device/hid_generic_inout/CMakeLists.txt @@ -0,0 +1,40 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/hid_generic_inout/src/tusb_config.h b/examples/device/hid_generic_inout/src/tusb_config.h index 347cb06d..1b8b91c4 100644 --- a/examples/device/hid_generic_inout/src/tusb_config.h +++ b/examples/device/hid_generic_inout/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/hid_multiple_interface/CMakeLists.txt b/examples/device/hid_multiple_interface/CMakeLists.txt new file mode 100644 index 00000000..99ee77bd --- /dev/null +++ b/examples/device/hid_multiple_interface/CMakeLists.txt @@ -0,0 +1,40 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/hid_multiple_interface/src/tusb_config.h b/examples/device/hid_multiple_interface/src/tusb_config.h index 412f9b00..a0aa17a9 100644 --- a/examples/device/hid_multiple_interface/src/tusb_config.h +++ b/examples/device/hid_multiple_interface/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/midi_test/CMakeLists.txt b/examples/device/midi_test/CMakeLists.txt new file mode 100644 index 00000000..99ee77bd --- /dev/null +++ b/examples/device/midi_test/CMakeLists.txt @@ -0,0 +1,40 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/midi_test/src/tusb_config.h b/examples/device/midi_test/src/tusb_config.h index d0c327e2..61b9b655 100644 --- a/examples/device/midi_test/src/tusb_config.h +++ b/examples/device/midi_test/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/msc_dual_lun/CMakeLists.txt b/examples/device/msc_dual_lun/CMakeLists.txt new file mode 100644 index 00000000..08456540 --- /dev/null +++ b/examples/device/msc_dual_lun/CMakeLists.txt @@ -0,0 +1,41 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_disk_dual.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/msc_dual_lun/src/tusb_config.h b/examples/device/msc_dual_lun/src/tusb_config.h index e153a796..44da21e5 100644 --- a/examples/device/msc_dual_lun/src/tusb_config.h +++ b/examples/device/msc_dual_lun/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/net_lwip_webserver/CMakeLists.txt b/examples/device/net_lwip_webserver/CMakeLists.txt new file mode 100644 index 00000000..695dd7c5 --- /dev/null +++ b/examples/device/net_lwip_webserver/CMakeLists.txt @@ -0,0 +1,87 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # lwip Stack source + set(SRC_LWIP + ${TOP}/lib/lwip/src/core/altcp.c + ${TOP}/lib/lwip/src/core/altcp_alloc.c + ${TOP}/lib/lwip/src/core/altcp_tcp.c + ${TOP}/lib/lwip/src/core/def.c + ${TOP}/lib/lwip/src/core/dns.c + ${TOP}/lib/lwip/src/core/inet_chksum.c + ${TOP}/lib/lwip/src/core/init.c + ${TOP}/lib/lwip/src/core/ip.c + ${TOP}/lib/lwip/src/core/mem.c + ${TOP}/lib/lwip/src/core/memp.c + ${TOP}/lib/lwip/src/core/netif.c + ${TOP}/lib/lwip/src/core/pbuf.c + ${TOP}/lib/lwip/src/core/raw.c + ${TOP}/lib/lwip/src/core/stats.c + ${TOP}/lib/lwip/src/core/sys.c + ${TOP}/lib/lwip/src/core/tcp.c + ${TOP}/lib/lwip/src/core/tcp_in.c + ${TOP}/lib/lwip/src/core/tcp_out.c + ${TOP}/lib/lwip/src/core/timeouts.c + ${TOP}/lib/lwip/src/core/udp.c + ${TOP}/lib/lwip/src/core/ipv4/autoip.c + ${TOP}/lib/lwip/src/core/ipv4/dhcp.c + ${TOP}/lib/lwip/src/core/ipv4/etharp.c + ${TOP}/lib/lwip/src/core/ipv4/icmp.c + ${TOP}/lib/lwip/src/core/ipv4/igmp.c + ${TOP}/lib/lwip/src/core/ipv4/ip4.c + ${TOP}/lib/lwip/src/core/ipv4/ip4_addr.c + ${TOP}/lib/lwip/src/core/ipv4/ip4_frag.c + ${TOP}/lib/lwip/src/netif/ethernet.c + ${TOP}/lib/lwip/src/netif/slipif.c + ${TOP}/lib/lwip/src/apps/http/httpd.c + ${TOP}/lib/lwip/src/apps/http/fs.c + ${TOP}/lib/networking/dhserver.c + ${TOP}/lib/networking/dnserver.c + ${TOP}/lib/networking/rndis_reports.c + ) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ${SRC_LWIP} + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${TOP}/lib/lwip/src/include + ${TOP}/lib/lwip/src/include/ipv4 + ${TOP}/lib/lwip/src/include/lwip/apps + ${TOP}/lib/networking + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + PBUF_POOL_SIZE=2 + TCP_WND=2*TCP_MSS + HTTPD_USE_CUSTOM_FSDATA=0 + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/net_lwip_webserver/src/tusb_config.h b/examples/device/net_lwip_webserver/src/tusb_config.h index b6d0e7a8..262d4ebc 100644 --- a/examples/device/net_lwip_webserver/src/tusb_config.h +++ b/examples/device/net_lwip_webserver/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/uac2_headset/CMakeLists.txt b/examples/device/uac2_headset/CMakeLists.txt new file mode 100644 index 00000000..99ee77bd --- /dev/null +++ b/examples/device/uac2_headset/CMakeLists.txt @@ -0,0 +1,40 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/uac2_headset/src/tusb_config.h b/examples/device/uac2_headset/src/tusb_config.h index d19feeb8..ebf18167 100644 --- a/examples/device/uac2_headset/src/tusb_config.h +++ b/examples/device/uac2_headset/src/tusb_config.h @@ -46,7 +46,9 @@ extern "C" { #define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE #endif +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif #ifndef CFG_TUSB_DEBUG // Can be set during compilation i.e.: make LOG= BOARD= diff --git a/examples/device/usbtmc/CMakeLists.txt b/examples/device/usbtmc/CMakeLists.txt new file mode 100644 index 00000000..03bb0438 --- /dev/null +++ b/examples/device/usbtmc/CMakeLists.txt @@ -0,0 +1,41 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usbtmc_app.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/usbtmc/src/tusb_config.h b/examples/device/usbtmc/src/tusb_config.h index 603e6745..a192d0db 100644 --- a/examples/device/usbtmc/src/tusb_config.h +++ b/examples/device/usbtmc/src/tusb_config.h @@ -46,8 +46,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/webusb_serial/CMakeLists.txt b/examples/device/webusb_serial/CMakeLists.txt new file mode 100644 index 00000000..99ee77bd --- /dev/null +++ b/examples/device/webusb_serial/CMakeLists.txt @@ -0,0 +1,40 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/webusb_serial/src/tusb_config.h b/examples/device/webusb_serial/src/tusb_config.h index 48c9ddad..26b81b38 100644 --- a/examples/device/webusb_serial/src/tusb_config.h +++ b/examples/device/webusb_serial/src/tusb_config.h @@ -64,8 +64,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/host/cdc_msc_hid/src/tusb_config.h b/examples/host/cdc_msc_hid/src/tusb_config.h index d8cf993b..fabc7765 100644 --- a/examples/host/cdc_msc_hid/src/tusb_config.h +++ b/examples/host/cdc_msc_hid/src/tusb_config.h @@ -45,7 +45,9 @@ #define CFG_TUSB_RHPORT0_MODE OPT_MODE_HOST #endif +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index dd0123de..edd57a39 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -30,5 +30,4 @@ target_include_directories(${PROJECT} PUBLIC target_compile_definitions(${PROJECT} PUBLIC CFG_TUSB_MCU=OPT_MCU_RP2040 - CFG_TUSB_OS=OPT_OS_PICO ) From 8bec3be68cd37e945a4ccd62951d09dc114bcbdb Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 13:46:23 +0700 Subject: [PATCH 13/18] try fixing msp430 cache --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d37b750..cabb8f59 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -112,9 +112,9 @@ jobs: uses: actions/cache@v2 id: cache-msp430 with: - path: $HOME/msp430-gcc/ + path: ${{ env.HOME }}/msp430-gcc/ # Increment gcc version number at end when updating downloads - key: ${{ runner.os }}-${{ env.MSP430GCC_URL }} + key: ${{ runner.os }}-${{ env.MSP430GCC_URL }}-210125 - name: Install MSP430 Toolchain if: steps.cache-msp430.outputs.cache-hit != 'true' From 066d268007780c30e77f75588f29625cc62e5295 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 15:38:29 +0700 Subject: [PATCH 14/18] try to cache all toolchains to speed up ci --- .github/workflows/build.yml | 57 +++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cabb8f59..928eab81 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -105,35 +105,50 @@ jobs: git submodule update --init --recursive hw/mcu/microchip git submodule update --init --recursive lib/FreeRTOS - # Add MSP430 URL to env - echo >> $GITHUB_ENV MSP430GCC_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2 + - name: Pre-Install Toolchain + run: | + # Add Toolchain URL to env + echo >> $GITHUB_ENV ARM_GCC_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 + echo >> $GITHUB_ENV MSP430_GCC_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2 + echo >> $GITHUB_ENV RISCV_GCC_URL=https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.08/riscv64-unknown-elf-gcc-10.1.0-2020.08.2-x86_64-linux-ubuntu14.tar.gz - - name: Cache MSP430 Toolchain + - name: Cache Toolchain uses: actions/cache@v2 - id: cache-msp430 + id: cache-toolchain with: - path: ${{ env.HOME }}/msp430-gcc/ - # Increment gcc version number at end when updating downloads - key: ${{ runner.os }}-${{ env.MSP430GCC_URL }}-210125 + path: ${{ HOME }}/cache/ + key: ${{ runner.os }}-21-01-25-${{ env.ARM_GCC_URL }}-${{ env.RISCV_GCC_URL }}-${{ env.MSP430_GCC_URL }} - - name: Install MSP430 Toolchain + - name: Install Toolchain if: steps.cache-msp430.outputs.cache-hit != 'true' run: | - wget --progress=dot:mega $MSP430GCC_URL -O msp430-gcc.tar.bz2 - mkdir -p $HOME/msp430-gcc - tar -C $HOME/msp430-gcc -xaf msp430-gcc.tar.bz2 + # ARM GCC + mkdir -p $HOME/cache/arm-gcc + wget --progress=dot:mega $ARM_GCC_URL -O arm-gcc.tar.bz2 + tar -C $HOME/cache/arm-gcc -xaf arm-gcc.tar.bz2 - - name: Install Toolchains - run: | - # ARM & RISC-V GCC from xpack - npm install --global xpm - xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest - xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@latest - echo `echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH - echo `echo $HOME/opt/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/*/.content/bin` >> $GITHUB_PATH + # MSP430 GCC + mkdir -p $HOME/cache/msp430-gcc + wget --progress=dot:mega $MSP430_GCC_URL -O msp430-gcc.tar.bz2 + tar -C $HOME/cache/msp430-gcc -xaf msp430-gcc.tar.bz2 - # TI MSP430 GCC - echo `echo $HOME/msp430-gcc/msp430-gcc-*_linux64/bin` >> $GITHUB_PATH + # RISC-V GCC + mkdir -p $HOME/cache/riscv-gcc + wget --progress=dot:mega $RISCV_GCC_URL -O riscv-gcc.tar.gz + tar -C $HOME/cache/riscv-gcc -xaf riscv-gcc.tar.gz + + - name: Post-Install Toolchains + run: | + ls $HOME/cache/* + + # ARM + echo >> $GITHUB_PATH `echo $HOME/cache/arm-gcc/gcc-arm-none-eabi-*/bin` + + # MSP430 + echo >> $GITHUB_PATH `echo $HOME/cache/msp430-gcc/msp430-gcc-*/bin` + + # RISC-V + echo >> $GITHUB_PATH `echo $HOME/cache/riscv-gcc/riscv64-*/bin` - name: Build run: python3 tools/build_board.py ${{ matrix.example }} From 8820aa8715b962d80bfde678ba879517abe48957 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 15:42:06 +0700 Subject: [PATCH 15/18] fix ci --- .github/workflows/build.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 928eab81..99dd26c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -116,39 +116,39 @@ jobs: uses: actions/cache@v2 id: cache-toolchain with: - path: ${{ HOME }}/cache/ + path: ~/cache/ key: ${{ runner.os }}-21-01-25-${{ env.ARM_GCC_URL }}-${{ env.RISCV_GCC_URL }}-${{ env.MSP430_GCC_URL }} - name: Install Toolchain if: steps.cache-msp430.outputs.cache-hit != 'true' run: | # ARM GCC - mkdir -p $HOME/cache/arm-gcc + mkdir -p ~/cache/arm-gcc wget --progress=dot:mega $ARM_GCC_URL -O arm-gcc.tar.bz2 - tar -C $HOME/cache/arm-gcc -xaf arm-gcc.tar.bz2 + tar -C ~/cache/arm-gcc -xaf arm-gcc.tar.bz2 # MSP430 GCC - mkdir -p $HOME/cache/msp430-gcc + mkdir -p ~/cache/msp430-gcc wget --progress=dot:mega $MSP430_GCC_URL -O msp430-gcc.tar.bz2 - tar -C $HOME/cache/msp430-gcc -xaf msp430-gcc.tar.bz2 + tar -C ~/cache/msp430-gcc -xaf msp430-gcc.tar.bz2 # RISC-V GCC - mkdir -p $HOME/cache/riscv-gcc + mkdir -p ~/cache/riscv-gcc wget --progress=dot:mega $RISCV_GCC_URL -O riscv-gcc.tar.gz - tar -C $HOME/cache/riscv-gcc -xaf riscv-gcc.tar.gz + tar -C ~/cache/riscv-gcc -xaf riscv-gcc.tar.gz - name: Post-Install Toolchains run: | - ls $HOME/cache/* + ls ~/cache/* # ARM - echo >> $GITHUB_PATH `echo $HOME/cache/arm-gcc/gcc-arm-none-eabi-*/bin` + echo >> $GITHUB_PATH `echo ~/cache/arm-gcc/gcc-arm-none-eabi-*/bin` # MSP430 - echo >> $GITHUB_PATH `echo $HOME/cache/msp430-gcc/msp430-gcc-*/bin` + echo >> $GITHUB_PATH `echo ~/cache/msp430-gcc/msp430-gcc-*/bin` # RISC-V - echo >> $GITHUB_PATH `echo $HOME/cache/riscv-gcc/riscv64-*/bin` + echo >> $GITHUB_PATH `echo ~/cache/riscv-gcc/riscv64-*/bin` - name: Build run: python3 tools/build_board.py ${{ matrix.example }} From 2a3bb7867970fdb5b384c21dbae16120b1f7ef68 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 15:55:58 +0700 Subject: [PATCH 16/18] change riscv toolchain to xpack --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 99dd26c8..c56feec7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -110,7 +110,7 @@ jobs: # Add Toolchain URL to env echo >> $GITHUB_ENV ARM_GCC_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 echo >> $GITHUB_ENV MSP430_GCC_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2 - echo >> $GITHUB_ENV RISCV_GCC_URL=https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.08/riscv64-unknown-elf-gcc-10.1.0-2020.08.2-x86_64-linux-ubuntu14.tar.gz + echo >> $GITHUB_ENV RISCV_GCC_URL=https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz - name: Cache Toolchain uses: actions/cache@v2 @@ -148,7 +148,7 @@ jobs: echo >> $GITHUB_PATH `echo ~/cache/msp430-gcc/msp430-gcc-*/bin` # RISC-V - echo >> $GITHUB_PATH `echo ~/cache/riscv-gcc/riscv64-*/bin` + echo >> $GITHUB_PATH `echo ~/cache/riscv-gcc/xpack-riscv-*/bin` - name: Build run: python3 tools/build_board.py ${{ matrix.example }} From 314c82b2ecc0898bbb031de6c69141aab575cdd7 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 16:11:18 +0700 Subject: [PATCH 17/18] more with toolchain cache --- .github/workflows/build.yml | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c56feec7..2fa504fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,12 +41,30 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v1 - - name: Install Toolchains + - name: Pre-Install Toolchain run: | - # ARM GCC from xpack - npm install --global xpm - xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest - echo `echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH + # Add Toolchain URL to env + echo >> $GITHUB_ENV ARM_GCC_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 + + - name: Cache Toolchain + uses: actions/cache@v2 + id: cache-toolchain + with: + path: ~/cache/ + key: ${{ runner.os }}-21-01-26-${{ env.ARM_GCC_URL }} + + - name: Install Toolchain + if: steps.cache-toolchain.outputs.cache-hit != 'true' + run: | + # ARM GCC + mkdir -p ~/cache/arm-gcc + wget --progress=dot:mega $ARM_GCC_URL -O arm-gcc.tar.bz2 + tar -C ~/cache/arm-gcc -xaf arm-gcc.tar.bz2 + + - name: Post-Install Toolchains + run: | + # ARM + echo >> $GITHUB_PATH `echo ~/cache/arm-gcc/gcc-arm-none-eabi-*/bin` - name: Checkout TinyUSB uses: actions/checkout@v2 @@ -117,10 +135,10 @@ jobs: id: cache-toolchain with: path: ~/cache/ - key: ${{ runner.os }}-21-01-25-${{ env.ARM_GCC_URL }}-${{ env.RISCV_GCC_URL }}-${{ env.MSP430_GCC_URL }} + key: ${{ runner.os }}-21-01-26-${{ env.ARM_GCC_URL }}-${{ env.RISCV_GCC_URL }}-${{ env.MSP430_GCC_URL }} - name: Install Toolchain - if: steps.cache-msp430.outputs.cache-hit != 'true' + if: steps.cache-toolchain.outputs.cache-hit != 'true' run: | # ARM GCC mkdir -p ~/cache/arm-gcc From 6e027b1c4b454a573c6bcb9599d016d98bb6d05a Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 25 Jan 2021 16:42:00 +0700 Subject: [PATCH 18/18] revert ci cache toolchain, use xpack for armgcc and risv since there is only 30s in difference --- .github/workflows/build.yml | 73 ++++++++++--------------------------- 1 file changed, 20 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2fa504fc..bf1c63d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,30 +41,12 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v1 - - name: Pre-Install Toolchain + - name: Install Toolchains run: | - # Add Toolchain URL to env - echo >> $GITHUB_ENV ARM_GCC_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 - - - name: Cache Toolchain - uses: actions/cache@v2 - id: cache-toolchain - with: - path: ~/cache/ - key: ${{ runner.os }}-21-01-26-${{ env.ARM_GCC_URL }} - - - name: Install Toolchain - if: steps.cache-toolchain.outputs.cache-hit != 'true' - run: | - # ARM GCC - mkdir -p ~/cache/arm-gcc - wget --progress=dot:mega $ARM_GCC_URL -O arm-gcc.tar.bz2 - tar -C ~/cache/arm-gcc -xaf arm-gcc.tar.bz2 - - - name: Post-Install Toolchains - run: | - # ARM - echo >> $GITHUB_PATH `echo ~/cache/arm-gcc/gcc-arm-none-eabi-*/bin` + # ARM GCC from xpack + npm install --global xpm + xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest + echo `echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH - name: Checkout TinyUSB uses: actions/checkout@v2 @@ -123,50 +105,35 @@ jobs: git submodule update --init --recursive hw/mcu/microchip git submodule update --init --recursive lib/FreeRTOS - - name: Pre-Install Toolchain - run: | - # Add Toolchain URL to env - echo >> $GITHUB_ENV ARM_GCC_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 + # Add msp430-gcc url to env echo >> $GITHUB_ENV MSP430_GCC_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2 - echo >> $GITHUB_ENV RISCV_GCC_URL=https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz - - name: Cache Toolchain + - name: Cache MSP430-GCC uses: actions/cache@v2 - id: cache-toolchain + id: cache-msp430 with: path: ~/cache/ - key: ${{ runner.os }}-21-01-26-${{ env.ARM_GCC_URL }}-${{ env.RISCV_GCC_URL }}-${{ env.MSP430_GCC_URL }} + key: ${{ runner.os }}-21-01-26-${{ env.MSP430_GCC_URL }} - - name: Install Toolchain - if: steps.cache-toolchain.outputs.cache-hit != 'true' + - name: Install MSP430-GCC + if: steps.cache-msp430.outputs.cache-hit != 'true' run: | - # ARM GCC - mkdir -p ~/cache/arm-gcc - wget --progress=dot:mega $ARM_GCC_URL -O arm-gcc.tar.bz2 - tar -C ~/cache/arm-gcc -xaf arm-gcc.tar.bz2 - # MSP430 GCC mkdir -p ~/cache/msp430-gcc wget --progress=dot:mega $MSP430_GCC_URL -O msp430-gcc.tar.bz2 tar -C ~/cache/msp430-gcc -xaf msp430-gcc.tar.bz2 - # RISC-V GCC - mkdir -p ~/cache/riscv-gcc - wget --progress=dot:mega $RISCV_GCC_URL -O riscv-gcc.tar.gz - tar -C ~/cache/riscv-gcc -xaf riscv-gcc.tar.gz - - - name: Post-Install Toolchains - run: | - ls ~/cache/* + - name: Install Toolchains + run: | + # ARM & RISC-V GCC from xpack + npm install --global xpm + xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest + xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@latest + echo `echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH + echo `echo $HOME/opt/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/*/.content/bin` >> $GITHUB_PATH - # ARM - echo >> $GITHUB_PATH `echo ~/cache/arm-gcc/gcc-arm-none-eabi-*/bin` - - # MSP430 + # TI MSP430 GCC echo >> $GITHUB_PATH `echo ~/cache/msp430-gcc/msp430-gcc-*/bin` - - # RISC-V - echo >> $GITHUB_PATH `echo ~/cache/riscv-gcc/xpack-riscv-*/bin` - name: Build run: python3 tools/build_board.py ${{ matrix.example }}