From 3973ec4b5e457aecf742da47dac3c91d1a143865 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Thu, 8 Apr 2021 12:15:15 -0500 Subject: [PATCH 01/17] rp2040: fix debug compilation error --- src/portable/raspberrypi/rp2040/hcd_rp2040.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/portable/raspberrypi/rp2040/hcd_rp2040.c b/src/portable/raspberrypi/rp2040/hcd_rp2040.c index 5201d1d4c..48cf8b602 100644 --- a/src/portable/raspberrypi/rp2040/hcd_rp2040.c +++ b/src/portable/raspberrypi/rp2040/hcd_rp2040.c @@ -294,7 +294,6 @@ static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t dev_addr, uint8_t uint8_t const num = tu_edpt_number(ep_addr); tusb_dir_t const dir = tu_edpt_dir(ep_addr); - bool in = ep_addr & TUSB_DIR_IN_MASK; ep->ep_addr = ep_addr; ep->dev_addr = dev_addr; From edbccb5e19692a95d72f0467901818a0e1cf7251 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Sun, 30 May 2021 18:37:51 -0500 Subject: [PATCH 02/17] don't override CFG_TUSB_OS in cdc_dual_ports example --- examples/device/cdc_dual_ports/src/tusb_config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/device/cdc_dual_ports/src/tusb_config.h b/examples/device/cdc_dual_ports/src/tusb_config.h index 7db520dd1..c7e87bf67 100644 --- a/examples/device/cdc_dual_ports/src/tusb_config.h +++ b/examples/device/cdc_dual_ports/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 95f2478146ef83d18b52408c0692222bf2a15053 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Sun, 30 May 2021 18:41:07 -0500 Subject: [PATCH 03/17] Rework rp2040 examples and CMake build: - Examples should be CMake buildable from their own subdirectory; such a build will error out based on matching .skip.MCU_xxx or a mismatched .only.MCU_ - It should be possible to build from a higher level and use .skip.MCU_ and .only.MCU_ to filter which examples get built - The intention is for the CMakeLists.txts in the examples to be non family specific and without MCU based IFs. I have started this work, but am not really sure the state of the esp32 stuff; in any case the plan is to have everything encapsulated in the FAMILY/family.cmake - pico_examples now just includes examples/device/CMakeLists.txt and examples/host/CMakeLists.txt directly, as they also build correctly when included from there. Note that .skip.MCU_ for esp32 in the directories it wasn't previously avaiable has not been added, as the .skip is common to the regular Makefile builds also. It isn't clear whether these examples should build for esp32, but if not .skip should be added. --- examples/device/CMakeLists.txt | 27 ++++ .../device/audio_4_channel_mic/CMakeLists.txt | 51 +++--- examples/device/audio_test/CMakeLists.txt | 51 +++--- examples/device/board_test/CMakeLists.txt | 47 +++--- examples/device/cdc_dual_ports/CMakeLists.txt | 49 +++--- examples/device/cdc_msc/CMakeLists.txt | 51 +++--- examples/device/dfu/CMakeLists.txt | 49 +++--- examples/device/dfu_runtime/CMakeLists.txt | 51 +++--- .../dynamic_configuration/CMakeLists.txt | 51 +++--- examples/device/hid_composite/CMakeLists.txt | 49 +++--- .../device/hid_generic_inout/CMakeLists.txt | 51 +++--- .../hid_multiple_interface/CMakeLists.txt | 51 +++--- examples/device/midi_test/CMakeLists.txt | 51 +++--- examples/device/msc_dual_lun/CMakeLists.txt | 53 +++---- .../device/net_lwip_webserver/CMakeLists.txt | 146 +++++++++--------- examples/device/uac2_headset/CMakeLists.txt | 51 +++--- examples/device/usbtmc/CMakeLists.txt | 51 +++--- examples/device/webusb_serial/CMakeLists.txt | 51 +++--- examples/host/CMakeLists.txt | 9 ++ examples/host/cdc_msc_hid/CMakeLists.txt | 53 +++---- hw/bsp/esp32s2/family.cmake | 4 + hw/bsp/esp32s3/family.cmake | 4 + hw/bsp/family.cmake | 61 ++++++++ .../{boards/raspberry_pi_pico => }/board.h | 12 +- .../adafruit_feather_rp2040/board.cmake | 1 - .../boards/adafruit_feather_rp2040/board.h | 53 ------- .../adafruit_itsybitsy_rp2040/board.cmake | 1 - .../boards/adafruit_itsybitsy_rp2040/board.h | 53 ------- .../boards/adafruit_qt_rp2040/board.cmake | 1 - .../rp2040/boards/adafruit_qt_rp2040/board.h | 55 ------- .../boards/raspberry_pi_pico/board.cmake | 1 - hw/bsp/rp2040/family.c | 15 +- hw/bsp/rp2040/family.cmake | 128 +++++++-------- hw/mcu/microchip | 2 +- hw/mcu/sony/cxd56/spresense-exported-sdk | 2 +- lib/lwip | 2 +- 36 files changed, 616 insertions(+), 822 deletions(-) create mode 100644 examples/device/CMakeLists.txt create mode 100644 examples/host/CMakeLists.txt create mode 100644 hw/bsp/family.cmake rename hw/bsp/rp2040/{boards/raspberry_pi_pico => }/board.h (80%) delete mode 100644 hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake delete mode 100644 hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.h delete mode 100644 hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake delete mode 100644 hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.h delete mode 100644 hw/bsp/rp2040/boards/adafruit_qt_rp2040/board.cmake delete mode 100644 hw/bsp/rp2040/boards/adafruit_qt_rp2040/board.h delete mode 100644 hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake diff --git a/examples/device/CMakeLists.txt b/examples/device/CMakeLists.txt new file mode 100644 index 000000000..4ed693cde --- /dev/null +++ b/examples/device/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.5) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../hw/bsp/${FAMILY}/family.cmake) + +project(tinyusb_device_examples) +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(board_test) +family_add_subdirectory(cdc_dual_ports) +family_add_subdirectory(cdc_msc) +family_add_subdirectory(cdc_msc_freertos) +family_add_subdirectory(dfu) +family_add_subdirectory(dfu_runtime) +family_add_subdirectory(dynamic_configuration) +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(net_lwip_webserver) +family_add_subdirectory(uac2_headset) +family_add_subdirectory(usbtmc) +family_add_subdirectory(webusb_serial) diff --git a/examples/device/audio_4_channel_mic/CMakeLists.txt b/examples/device/audio_4_channel_mic/CMakeLists.txt index f2c81c4d3..b653fc91f 100644 --- a/examples/device/audio_4_channel_mic/CMakeLists.txt +++ b/examples/device/audio_4_channel_mic/CMakeLists.txt @@ -1,37 +1,28 @@ -# use BOARD-Directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +project(${PROJECT}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +add_executable(${PROJECT}) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c +) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) diff --git a/examples/device/audio_test/CMakeLists.txt b/examples/device/audio_test/CMakeLists.txt index f2c81c4d3..fac0ca64f 100644 --- a/examples/device/audio_test/CMakeLists.txt +++ b/examples/device/audio_test/CMakeLists.txt @@ -1,37 +1,28 @@ -# use BOARD-Directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +project(${PROJECT}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +add_executable(${PROJECT}) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c +) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index c41ad92ab..5bb8cb700 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -1,44 +1,41 @@ 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 -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) # Check for -DFAMILY= if(FAMILY MATCHES "^esp32s[2-3]") - 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 + set(TOP "../../..") + get_filename_component(TOP "${TOP}" REALPATH) include(${TOP}/hw/bsp/${FAMILY}/family.cmake) project(${PROJECT}) -elseif(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) +else() + + # Family chooses name based on passed name and vars (e.g. -) + get_filename_component(DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) + family_get_project_name(PROJECT "${DIR_NAME}") + project(${PROJECT}) + 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/main.c + ) # Example include target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) - -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") + # Configure compilation flags and libraries for the example... see the corresponding function + # in hw/bsp/FAMILY/family.cmake for details. + family_configure_device_example(${PROJECT}) endif() diff --git a/examples/device/cdc_dual_ports/CMakeLists.txt b/examples/device/cdc_dual_ports/CMakeLists.txt index 4160c0c88..18367a893 100644 --- a/examples/device/cdc_dual_ports/CMakeLists.txt +++ b/examples/device/cdc_dual_ports/CMakeLists.txt @@ -1,37 +1,28 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +project(${PROJECT}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +add_executable(${PROJECT}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt index 6c828a396..5da761a04 100644 --- a/examples/device/cdc_msc/CMakeLists.txt +++ b/examples/device/cdc_msc/CMakeLists.txt @@ -1,38 +1,29 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +project(${PROJECT}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # 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 - ) +add_executable(${PROJECT}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +# 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 defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/dfu/CMakeLists.txt b/examples/device/dfu/CMakeLists.txt index 4160c0c88..18367a893 100644 --- a/examples/device/dfu/CMakeLists.txt +++ b/examples/device/dfu/CMakeLists.txt @@ -1,37 +1,28 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +project(${PROJECT}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +add_executable(${PROJECT}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/dfu_runtime/CMakeLists.txt b/examples/device/dfu_runtime/CMakeLists.txt index 2bac7c329..18367a893 100644 --- a/examples/device/dfu_runtime/CMakeLists.txt +++ b/examples/device/dfu_runtime/CMakeLists.txt @@ -1,37 +1,28 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +project(${PROJECT}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +add_executable(${PROJECT}) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/dynamic_configuration/CMakeLists.txt b/examples/device/dynamic_configuration/CMakeLists.txt index a99b755d3..5da761a04 100644 --- a/examples/device/dynamic_configuration/CMakeLists.txt +++ b/examples/device/dynamic_configuration/CMakeLists.txt @@ -1,38 +1,29 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +project(${PROJECT}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # 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 - ) +add_executable(${PROJECT}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +# 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 defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/hid_composite/CMakeLists.txt b/examples/device/hid_composite/CMakeLists.txt index 3b677b3b1..18367a893 100644 --- a/examples/device/hid_composite/CMakeLists.txt +++ b/examples/device/hid_composite/CMakeLists.txt @@ -1,37 +1,28 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +project(${PROJECT}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +add_executable(${PROJECT}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/hid_generic_inout/CMakeLists.txt b/examples/device/hid_generic_inout/CMakeLists.txt index 2bac7c329..18367a893 100644 --- a/examples/device/hid_generic_inout/CMakeLists.txt +++ b/examples/device/hid_generic_inout/CMakeLists.txt @@ -1,37 +1,28 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +project(${PROJECT}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +add_executable(${PROJECT}) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/hid_multiple_interface/CMakeLists.txt b/examples/device/hid_multiple_interface/CMakeLists.txt index 2bac7c329..18367a893 100644 --- a/examples/device/hid_multiple_interface/CMakeLists.txt +++ b/examples/device/hid_multiple_interface/CMakeLists.txt @@ -1,37 +1,28 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +project(${PROJECT}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +add_executable(${PROJECT}) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/midi_test/CMakeLists.txt b/examples/device/midi_test/CMakeLists.txt index 2bac7c329..18367a893 100644 --- a/examples/device/midi_test/CMakeLists.txt +++ b/examples/device/midi_test/CMakeLists.txt @@ -1,37 +1,28 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +project(${PROJECT}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +add_executable(${PROJECT}) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/msc_dual_lun/CMakeLists.txt b/examples/device/msc_dual_lun/CMakeLists.txt index 8b4722278..f60be8eda 100644 --- a/examples/device/msc_dual_lun/CMakeLists.txt +++ b/examples/device/msc_dual_lun/CMakeLists.txt @@ -1,38 +1,29 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +project(${PROJECT}) - # 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 - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +add_executable(${PROJECT}) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# 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 + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/net_lwip_webserver/CMakeLists.txt b/examples/device/net_lwip_webserver/CMakeLists.txt index 4325b4ea6..63cca04a8 100644 --- a/examples/device/net_lwip_webserver/CMakeLists.txt +++ b/examples/device/net_lwip_webserver/CMakeLists.txt @@ -1,84 +1,82 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# 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) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +include(${TOP}/hw/bsp/${FAMILY}/family.cmake) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - # 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 - ) +project(${PROJECT}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ${SRC_LWIP} - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) + +add_executable(${PROJECT}) + +# 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 + ${TOP}/lib/lwip/src/include + ${TOP}/lib/lwip/src/include/ipv4 + ${TOP}/lib/lwip/src/include/lwip/apps + ${TOP}/lib/networking + ) + +target_sources(${PROJECT} PUBLIC + ${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 + ) + +target_compile_definitions(${PROJECT} PUBLIC + PBUF_POOL_SIZE=2 + TCP_WND=2*TCP_MSS + HTTPD_USE_CUSTOM_FSDATA=0 +) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) - # 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 - ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() diff --git a/examples/device/uac2_headset/CMakeLists.txt b/examples/device/uac2_headset/CMakeLists.txt index 2bac7c329..18367a893 100644 --- a/examples/device/uac2_headset/CMakeLists.txt +++ b/examples/device/uac2_headset/CMakeLists.txt @@ -1,37 +1,28 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +project(${PROJECT}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +add_executable(${PROJECT}) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/usbtmc/CMakeLists.txt b/examples/device/usbtmc/CMakeLists.txt index c14595dbe..4306da8cb 100644 --- a/examples/device/usbtmc/CMakeLists.txt +++ b/examples/device/usbtmc/CMakeLists.txt @@ -1,38 +1,29 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +project(${PROJECT}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # 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 - ) +add_executable(${PROJECT}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +# 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 defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/device/webusb_serial/CMakeLists.txt b/examples/device/webusb_serial/CMakeLists.txt index 2bac7c329..18367a893 100644 --- a/examples/device/webusb_serial/CMakeLists.txt +++ b/examples/device/webusb_serial/CMakeLists.txt @@ -1,37 +1,28 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +project(${PROJECT}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +add_executable(${PROJECT}) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_device_example(${PROJECT}) \ No newline at end of file diff --git a/examples/host/CMakeLists.txt b/examples/host/CMakeLists.txt new file mode 100644 index 000000000..c70d11d5b --- /dev/null +++ b/examples/host/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.5) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../hw/bsp/${FAMILY}/family.cmake) + +project(tinyusb_host_examples) +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(cdc_msc_hid) diff --git a/examples/host/cdc_msc_hid/CMakeLists.txt b/examples/host/cdc_msc_hid/CMakeLists.txt index ac57bf6dd..ad0f412e2 100644 --- a/examples/host/cdc_msc_hid/CMakeLists.txt +++ b/examples/host/cdc_msc_hid/CMakeLists.txt @@ -1,38 +1,29 @@ -# use directory name for project id -get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(PROJECT ${BOARD}-${PROJECT}) +cmake_minimum_required(VERSION 3.5) -# TOP is absolute path to root directory of TinyUSB git repo -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/${FAMILY}/family.cmake) -# Check for -DFAMILY= -if(FAMILY STREQUAL "rp2040") - cmake_minimum_required(VERSION 3.12) - - include(${TOP}/hw/bsp/${FAMILY}/pico_sdk_import.cmake) - project(${PROJECT}) - add_executable(${PROJECT}) +# gets PROJECT name for the example (e.g. -) +family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) - include(${TOP}/hw/bsp/${FAMILY}/family.cmake) +project(${PROJECT}) - # Example source - target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/hid_app.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_app.c - ) +# Checks this example is valid for the family and initializes the project +family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}) - # Example include - target_include_directories(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src - ) +add_executable(${PROJECT}) - # Example defines - target_compile_definitions(${PROJECT} PUBLIC - CFG_TUSB_OS=OPT_OS_PICO - ) +# Example source +target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/hid_app.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_app.c + ) -else() - message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}") -endif() +# Example include +target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + +# Configure compilation flags and libraries for the example... see the corresponding function +# in hw/bsp/FAMILY/family.cmake for details. +family_configure_host_example(${PROJECT}) \ No newline at end of file diff --git a/hw/bsp/esp32s2/family.cmake b/hw/bsp/esp32s2/family.cmake index c19221b14..656f7d852 100644 --- a/hw/bsp/esp32s2/family.cmake +++ b/hw/bsp/esp32s2/family.cmake @@ -4,3 +4,7 @@ cmake_minimum_required(VERSION 3.5) set(EXTRA_COMPONENT_DIRS "src" "${TOP}/hw/bsp/esp32s2/boards" "${TOP}/hw/bsp/esp32s2/components") include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(SUPPORTED_TARGETS esp32s2) + +# include basic family CMake functionality +set(FAMILY_MCUS esp32s2 ESP32S2) +include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake) diff --git a/hw/bsp/esp32s3/family.cmake b/hw/bsp/esp32s3/family.cmake index 558ec5752..e57920bf7 100644 --- a/hw/bsp/esp32s3/family.cmake +++ b/hw/bsp/esp32s3/family.cmake @@ -4,3 +4,7 @@ cmake_minimum_required(VERSION 3.5) set(EXTRA_COMPONENT_DIRS "src" "${TOP}/hw/bsp/esp32s3/boards" "${TOP}/hw/bsp/esp32s3/components") include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(SUPPORTED_TARGETS esp32s3) + +# include basic family CMake functionality +set(FAMILY_MCUS esp32s3 ESP32S3) # TODO MERGE THIS WITH supported targets? +include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake) diff --git a/hw/bsp/family.cmake b/hw/bsp/family.cmake new file mode 100644 index 000000000..124399675 --- /dev/null +++ b/hw/bsp/family.cmake @@ -0,0 +1,61 @@ +if (NOT FAMILY_MCUS) + set(FAMILY_MCUS ${FAMILY}) +endif() + +# save it in case of re-inclusion +set(FAMILY_MCUS ${FAMILY_MCUS} CACHE INTERNAL "") + +function(family_filter RESULT DIR) + get_filename_component(DIR ${DIR} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + file(GLOB ONLYS "${DIR}/.only.MCU_*") + if (ONLYS) + foreach(MCU IN LISTS FAMILY_MCUS) + if (EXISTS ${DIR}/.only.MCU_${MCU}) + set(${RESULT} 1 PARENT_SCOPE) + return() + endif() + endforeach() + else() + foreach(MCU IN LISTS FAMILY_MCUS) + if (EXISTS ${DIR}/.skip.MCU_${MCU}) + set(${RESULT} 0 PARENT_SCOPE) + return() + endif() + endforeach() + endif() + set(${RESULT} 1 PARENT_SCOPE) +endfunction() + +function(family_add_subdirectory DIR) + family_filter(SHOULD_ADD "${DIR}") + if (SHOULD_ADD) + add_subdirectory(${DIR}) + endif() +endfunction() + +function(family_get_project_name OUTPUT_NAME DIR) + get_filename_component(SHORT_NAME ${DIR} NAME) + if (TINYUSB_FAMILY_PROJECT_NAME_INCLUDES_BOARD OR NOT DEFINED TINYUSB_FAMILY_PROJECT_NAME_INCLUDES_BOARD) + set(${OUTPUT_NAME} ${TINYUSB_FAMILY_PROJECT_NAME_PREFIX}${BOARD}-${SHORT_NAME} PARENT_SCOPE) + else() + set(${OUTPUT_NAME} ${TINYUSB_FAMILY_PROJECT_NAME_PREFIX}${SHORT_NAME} PARENT_SCOPE) + endif() +endfunction() + +function(family_initialize_project PROJECT DIR) + family_filter(ALLOWED "${DIR}") + if (NOT ALLOWED) + get_filename_component(SHORT_NAME ${DIR} NAME) + message(FATAL_ERROR "${SHORT_NAME} is not supported on FAMILY=${FAMILY}") + endif() +endfunction() + +# configure an executable target to link to tinyusb in device mode, and add the board implementation +function(family_configure_device_example TARGET) + # default implentation is empty, the function should be redefined in the FAMILY/family.cmake +endfunction() + +# configure an executable target to link to tinyusb in host mode, and add the board implementation +function(family_configure_host_example TARGET) + # default implentation is empty, the function should be redefined in the FAMILY/family.cmake +endfunction() diff --git a/hw/bsp/rp2040/boards/raspberry_pi_pico/board.h b/hw/bsp/rp2040/board.h similarity index 80% rename from hw/bsp/rp2040/boards/raspberry_pi_pico/board.h rename to hw/bsp/rp2040/board.h index e4a6514ad..237f29dc2 100644 --- a/hw/bsp/rp2040/boards/raspberry_pi_pico/board.h +++ b/hw/bsp/rp2040/board.h @@ -31,16 +31,20 @@ extern "C" { #endif +#ifdef PICO_DEFAULT_LED_PIN #define LED_PIN PICO_DEFAULT_LED_PIN -#define LED_STATE_ON 1 +#define LED_STATE_ON (!(PICO_DEFAULT_LED_PIN_INVERTED)) +#endif // Button pin is BOOTSEL which is flash CS pin #define BUTTON_BOOTSEL #define BUTTON_STATE_ACTIVE 0 -#define UART_DEV uart0 -#define UART_TX_PIN 0 -#define UART_RX_PIN 1 +#if defined(PICO_DEFAULT_UART_TX_PIN) && defined(PICO_DEFAULT_UART_RX_PIN) && defined(PICO_DEFAULT_UART) +#define UART_DEV PICO_DEFAULT_UART +#define UART_TX_PIN PICO_DEFAULT_UART_TX_PIN +#define UART_RX_PIN PICO_DEFAULT_UART_RX_PIN +#endif #ifdef __cplusplus } diff --git a/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake b/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake deleted file mode 100644 index ea4070cf3..000000000 --- a/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake +++ /dev/null @@ -1 +0,0 @@ -set(PICO_DEFAULT_BOOT_STAGE2_FILE "${PICO_SDK_PATH}/src/rp2_common/boot_stage2/boot2_generic_03h.S") diff --git a/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.h b/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.h deleted file mode 100644 index 281b215d3..000000000 --- a/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2021, Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#ifndef BOARD_H_ -#define BOARD_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#define LED_PIN 13 -#define LED_STATE_ON 1 - -#define NEOPIXEL_PIN 16 -#define NEOPIXEL_POWER_PIN 17 -#define NEOPIXEL_POWER_STATE 1 - -// Button pin is BOOTSEL which is flash CS pin -#define BUTTON_BOOTSEL -#define BUTTON_STATE_ACTIVE 0 - -#define UART_DEV uart0 -#define UART_TX_PIN 0 -#define UART_RX_PIN 1 - -#ifdef __cplusplus - } -#endif - -#endif /* BOARD_H_ */ diff --git a/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake b/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake deleted file mode 100644 index eb9f219d2..000000000 --- a/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake +++ /dev/null @@ -1 +0,0 @@ -set(PICO_DEFAULT_BOOT_STAGE2_FILE "${PICO_SDK_PATH}/src/rp2_common/boot_stage2/boot2_w25q080.S") diff --git a/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.h b/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.h deleted file mode 100644 index 72265176c..000000000 --- a/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2021, Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#ifndef BOARD_H_ -#define BOARD_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#define LED_PIN 11 -#define LED_STATE_ON 1 - -#define NEOPIXEL_PIN 17 -#define NEOPIXEL_POWER_PIN 16 -#define NEOPIXEL_POWER_STATE 1 - -// Button pin is BOOTSEL which is flash CS pin -#define BUTTON_BOOTSEL -#define BUTTON_STATE_ACTIVE 0 - -#define UART_DEV uart0 -#define UART_TX_PIN 0 -#define UART_RX_PIN 1 - -#ifdef __cplusplus - } -#endif - -#endif /* BOARD_H_ */ diff --git a/hw/bsp/rp2040/boards/adafruit_qt_rp2040/board.cmake b/hw/bsp/rp2040/boards/adafruit_qt_rp2040/board.cmake deleted file mode 100644 index eb9f219d2..000000000 --- a/hw/bsp/rp2040/boards/adafruit_qt_rp2040/board.cmake +++ /dev/null @@ -1 +0,0 @@ -set(PICO_DEFAULT_BOOT_STAGE2_FILE "${PICO_SDK_PATH}/src/rp2_common/boot_stage2/boot2_w25q080.S") diff --git a/hw/bsp/rp2040/boards/adafruit_qt_rp2040/board.h b/hw/bsp/rp2040/boards/adafruit_qt_rp2040/board.h deleted file mode 100644 index c0915f704..000000000 --- a/hw/bsp/rp2040/boards/adafruit_qt_rp2040/board.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2021, Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#ifndef BOARD_H_ -#define BOARD_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -// TODO QT RP2040 only has neopixel -#define LED_PIN 11 -#define LED_STATE_ON 1 - -#define NEOPIXEL_PIN 12 -#define NEOPIXEL_POWER_PIN 11 -#define NEOPIXEL_POWER_STATE 1 - -// Button pin is BOOTSEL which is flash CS pin -#define BUTTON_BOOTSEL -#define BUTTON_STATE_ACTIVE 0 - - -#define UART_DEV uart0 -#define UART_TX_PIN 0 -#define UART_RX_PIN 1 - -#ifdef __cplusplus - } -#endif - -#endif /* BOARD_H_ */ diff --git a/hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake b/hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake deleted file mode 100644 index eb9f219d2..000000000 --- a/hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake +++ /dev/null @@ -1 +0,0 @@ -set(PICO_DEFAULT_BOOT_STAGE2_FILE "${PICO_SDK_PATH}/src/rp2_common/boot_stage2/boot2_w25q080.S") diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c index 9995c23d7..b2dbd3e6a 100644 --- a/hw/bsp/rp2040/family.c +++ b/hw/bsp/rp2040/family.c @@ -26,6 +26,7 @@ */ #include "pico/stdlib.h" +#include "pico/binary_info.h" #include "hardware/gpio.h" #include "hardware/sync.h" #include "hardware/structs/ioqspi.h" @@ -110,10 +111,14 @@ void stdio_rtt_init(void) #endif +#ifdef UART_DEV +static uart_inst_t *uart_inst; +#endif void board_init(void) { #ifdef LED_PIN + bi_decl(bi_1pin_with_name(LED_PIN, "LED")); gpio_init(LED_PIN); gpio_set_dir(LED_PIN, GPIO_OUT); #endif @@ -123,7 +128,9 @@ void board_init(void) #endif #ifdef UART_DEV - stdio_uart_init_full(UART_DEV, CFG_BOARD_UART_BAUDRATE, UART_TX_PIN, UART_RX_PIN); + bi_decl(bi_2pins_with_func(UART_TX_PIN, UART_TX_PIN, GPIO_FUNC_UART)); + uart_inst = uart_get_instance(UART_DEV); + stdio_uart_init_full(uart_inst, CFG_BOARD_UART_BAUDRATE, UART_TX_PIN, UART_RX_PIN); #endif #if defined(LOGGER_RTT) @@ -164,7 +171,7 @@ int board_uart_read(uint8_t* buf, int len) { #ifdef UART_DEV for(int i=0;i Date: Mon, 31 May 2021 10:06:07 -0500 Subject: [PATCH 04/17] Fix up build_family style builds: - added back pre-existing board directories which now just select PICO_BOARD - added boards/pico_sdk which just uses the pre-existing PICO_BOARD setting - fixed rp2040/family.cmake to include the magic string "CFG_TUSB_MCU=OPT_MCU_RP2040" expected by build_family.py --- examples/device/board_test/CMakeLists.txt | 8 +++++--- hw/bsp/esp32s2/family.cmake | 2 +- hw/bsp/esp32s3/family.cmake | 2 +- .../boards/adafruit_feather_rp2040/board.cmake | 1 + .../adafruit_itsybitsy_rp2040/board.cmake | 1 + .../boards/adafruit_qtpy_rp2040/board.cmake | 1 + hw/bsp/rp2040/boards/pico_sdk/board.cmake | 1 + .../boards/raspberry_pi_pico/board.cmake | 1 + hw/bsp/rp2040/family.cmake | 18 ++++++++++-------- lib/CMSIS_5 | 2 +- 10 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake create mode 100644 hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake create mode 100644 hw/bsp/rp2040/boards/adafruit_qtpy_rp2040/board.cmake create mode 100644 hw/bsp/rp2040/boards/pico_sdk/board.cmake create mode 100644 hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index 5bb8cb700..8cd5b9ea4 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -17,12 +17,14 @@ if(FAMILY MATCHES "^esp32s[2-3]") else() - # Family chooses name based on passed name and vars (e.g. -) - get_filename_component(DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - family_get_project_name(PROJECT "${DIR_NAME}") + # gets PROJECT name for the example (e.g. -) + 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}) + add_executable(${PROJECT}) # Example source diff --git a/hw/bsp/esp32s2/family.cmake b/hw/bsp/esp32s2/family.cmake index 656f7d852..02957fa1d 100644 --- a/hw/bsp/esp32s2/family.cmake +++ b/hw/bsp/esp32s2/family.cmake @@ -6,5 +6,5 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(SUPPORTED_TARGETS esp32s2) # include basic family CMake functionality -set(FAMILY_MCUS esp32s2 ESP32S2) +set(FAMILY_MCUS ESP32S2) include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake) diff --git a/hw/bsp/esp32s3/family.cmake b/hw/bsp/esp32s3/family.cmake index e57920bf7..b530b326d 100644 --- a/hw/bsp/esp32s3/family.cmake +++ b/hw/bsp/esp32s3/family.cmake @@ -6,5 +6,5 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(SUPPORTED_TARGETS esp32s3) # include basic family CMake functionality -set(FAMILY_MCUS esp32s3 ESP32S3) # TODO MERGE THIS WITH supported targets? +set(FAMILY_MCUS ESP32S3) include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake) diff --git a/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake b/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake new file mode 100644 index 000000000..e527a8ce3 --- /dev/null +++ b/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake @@ -0,0 +1 @@ +set(PICO_BOARD adafruit_feather_rp2040) \ No newline at end of file diff --git a/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake b/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake new file mode 100644 index 000000000..3fd2dd06b --- /dev/null +++ b/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake @@ -0,0 +1 @@ +set(PICO_BOARD adafruit_itsybitsy_rp2040) \ No newline at end of file diff --git a/hw/bsp/rp2040/boards/adafruit_qtpy_rp2040/board.cmake b/hw/bsp/rp2040/boards/adafruit_qtpy_rp2040/board.cmake new file mode 100644 index 000000000..469929c51 --- /dev/null +++ b/hw/bsp/rp2040/boards/adafruit_qtpy_rp2040/board.cmake @@ -0,0 +1 @@ +set(PICO_BOARD adafruit_qtpy_rp2040) \ No newline at end of file diff --git a/hw/bsp/rp2040/boards/pico_sdk/board.cmake b/hw/bsp/rp2040/boards/pico_sdk/board.cmake new file mode 100644 index 000000000..d57cbe52b --- /dev/null +++ b/hw/bsp/rp2040/boards/pico_sdk/board.cmake @@ -0,0 +1 @@ +# This builds with settings based purely on the current PICO_BOARD set via the SDK diff --git a/hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake b/hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake new file mode 100644 index 000000000..8280c835d --- /dev/null +++ b/hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake @@ -0,0 +1 @@ +set(PICO_BOARD pico) \ No newline at end of file diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index 544718a6e..cc9bf65bd 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -3,17 +3,18 @@ if (NOT TARGET _rp2040_family_inclusion_marker) add_library(_rp2040_family_inclusion_marker INTERFACE) # include basic family CMake functionality - set(FAMILY_MCUS RP2040 rp2040) - include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake) - - if (BOARD AND NOT PICO_BOARD) - message("Defaulting PICO_BOARD from BOARD ('${BOARD}')") - set(PICO_BOARD ${BOARD}) - endif() + set(FAMILY_MCUS RP2040) # add the SDK in case we are standalone tinyusb example (noop if already present) include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_import.cmake) - set(BOARD ${PICO_BOARD}) + + include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake) + + # todo should we default to pico_sdk? + if (NOT BOARD) + message(FATAL_ERROR "BOARD must be specified") + endif() + include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") @@ -24,6 +25,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker) target_compile_definitions(tinyusb_additions INTERFACE PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1 + CFG_TUSB_MCU=OPT_MCU_RP2040 # this is already included in the SDK, but needed here for build_family.py grep ) if(DEFINED LOG) diff --git a/lib/CMSIS_5 b/lib/CMSIS_5 index 202852626..b7b26f50d 160000 --- a/lib/CMSIS_5 +++ b/lib/CMSIS_5 @@ -1 +1 @@ -Subproject commit 20285262657d1b482d132d20d755c8c330d55c1f +Subproject commit b7b26f50d00072812aec8453f643e24bafedccb5 From 13951b43c22ffe5bad531c2d7e5d22d540e82118 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Mon, 31 May 2021 10:58:14 -0500 Subject: [PATCH 05/17] set PICO_TINYUSB_PATH for when building from within tinyusb without pico-sdk/tinyusb submodule --- hw/bsp/rp2040/family.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index cc9bf65bd..cb9d8094a 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -20,6 +20,10 @@ if (NOT TARGET _rp2040_family_inclusion_marker) set(TOP "../../..") get_filename_component(TOP "${TOP}" REALPATH) + if (NOT PICO_TINYUSB_PATH) + set(PICO_TINYUSB_PATH ${TOP}) + endif() + # tinyusb_additions will hold our extra settings libraries add_library(tinyusb_additions INTERFACE) From db138a530cadfc91241ac158a188cefe7452c90e Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Mon, 31 May 2021 11:10:55 -0500 Subject: [PATCH 06/17] Switch checks to use tinyusb-0.10.0 branch of pico-sdk due to circular dependency --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ed20b859..0c91bda84 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,6 +68,7 @@ jobs: if: matrix.family == 'rp2040' run: | git clone --depth 1 https://github.com/raspberrypi/pico-sdk ~/pico-sdk + git checkout tinyusb-0.10.0 echo >> $GITHUB_ENV PICO_SDK_PATH=~/pico-sdk - name: Set Toolchain URL From 90d7483d925eab3ab2c05d286d0671cb8ec66ecc Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Mon, 31 May 2021 11:18:26 -0500 Subject: [PATCH 07/17] guard stdio_uart_init_full with LIB_PICO_STDUI_UART as the function doesn't exist otherwise --- hw/bsp/rp2040/family.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c index b2dbd3e6a..10ead2776 100644 --- a/hw/bsp/rp2040/family.c +++ b/hw/bsp/rp2040/family.c @@ -127,7 +127,7 @@ void board_init(void) #ifndef BUTTON_BOOTSEL #endif -#ifdef UART_DEV +#if defined(UART_DEV) && defined(LIB_PICO_STDIO_UART) bi_decl(bi_2pins_with_func(UART_TX_PIN, UART_TX_PIN, GPIO_FUNC_UART)); uart_inst = uart_get_instance(UART_DEV); stdio_uart_init_full(uart_inst, CFG_BOARD_UART_BAUDRATE, UART_TX_PIN, UART_RX_PIN); From 9b17acd1683cc6cd4ea1835991daf15fe8e2e368 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Mon, 31 May 2021 11:23:14 -0500 Subject: [PATCH 08/17] actually fix pico-sdk checkout to checkout the right branch --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c91bda84..09236db65 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,8 +67,7 @@ jobs: - name: Checkout pico-sdk if: matrix.family == 'rp2040' run: | - git clone --depth 1 https://github.com/raspberrypi/pico-sdk ~/pico-sdk - git checkout tinyusb-0.10.0 + git clone --depth 1 -b tinyusb-0.10.0 https://github.com/raspberrypi/pico-sdk ~/pico-sdk echo >> $GITHUB_ENV PICO_SDK_PATH=~/pico-sdk - name: Set Toolchain URL From f5572e24b25800c133b2f9fd4eae02e0934cd935 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Mon, 31 May 2021 11:49:15 -0500 Subject: [PATCH 09/17] restore unintentionally modified submodules --- hw/mcu/microchip | 2 +- hw/mcu/sony/cxd56/spresense-exported-sdk | 2 +- lib/CMSIS_5 | 2 +- lib/lwip | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/mcu/microchip b/hw/mcu/microchip index 66b5a1199..f7087f047 160000 --- a/hw/mcu/microchip +++ b/hw/mcu/microchip @@ -1 +1 @@ -Subproject commit 66b5a11995025426224e0ba6f377322e6e8893b6 +Subproject commit f7087f04783c896627061fc151fa3527b73733c7 diff --git a/hw/mcu/sony/cxd56/spresense-exported-sdk b/hw/mcu/sony/cxd56/spresense-exported-sdk index b473b28a1..2ec2a1538 160000 --- a/hw/mcu/sony/cxd56/spresense-exported-sdk +++ b/hw/mcu/sony/cxd56/spresense-exported-sdk @@ -1 +1 @@ -Subproject commit b473b28a14a03f3d416b6e2c071bcfd4fb92cb63 +Subproject commit 2ec2a1538362696118dc3fdf56f33dacaf8f4067 diff --git a/lib/CMSIS_5 b/lib/CMSIS_5 index b7b26f50d..202852626 160000 --- a/lib/CMSIS_5 +++ b/lib/CMSIS_5 @@ -1 +1 @@ -Subproject commit b7b26f50d00072812aec8453f643e24bafedccb5 +Subproject commit 20285262657d1b482d132d20d755c8c330d55c1f diff --git a/lib/lwip b/lib/lwip index 0192fe773..159e31b68 160000 --- a/lib/lwip +++ b/lib/lwip @@ -1 +1 @@ -Subproject commit 0192fe773ec28e11f66ec76f4e827fbb58b7e257 +Subproject commit 159e31b689577dbf69cf0683bbaffbd71fa5ee10 From 8782d0b8df507a0d2e1f7a12a27a76d50e0d4477 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Tue, 1 Jun 2021 09:04:08 -0500 Subject: [PATCH 10/17] fix rp2040 examples build from local tinyusb tree --- hw/bsp/rp2040/family.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index cb9d8094a..ee17d4d46 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -17,7 +17,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker) include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake) # TOP is absolute path to root directory of TinyUSB git repo - set(TOP "../../..") + set(TOP "${CMAKE_CURRENT_LIST_DIR}/../../..") get_filename_component(TOP "${TOP}" REALPATH) if (NOT PICO_TINYUSB_PATH) From 6e29bf6e54ce08edb2ad5936805af0746639ff39 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Tue, 1 Jun 2021 09:09:25 -0500 Subject: [PATCH 11/17] rename family.cmake to family_common.cmake --- hw/bsp/esp32s2/family.cmake | 2 +- hw/bsp/esp32s3/family.cmake | 2 +- hw/bsp/{family.cmake => family_common.cmake} | 0 hw/bsp/rp2040/family.cmake | 3 ++- hw/mcu/microchip | 2 +- hw/mcu/sony/cxd56/spresense-exported-sdk | 2 +- lib/CMSIS_5 | 2 +- lib/lwip | 2 +- 8 files changed, 8 insertions(+), 7 deletions(-) rename hw/bsp/{family.cmake => family_common.cmake} (100%) diff --git a/hw/bsp/esp32s2/family.cmake b/hw/bsp/esp32s2/family.cmake index 02957fa1d..9eb1627a1 100644 --- a/hw/bsp/esp32s2/family.cmake +++ b/hw/bsp/esp32s2/family.cmake @@ -7,4 +7,4 @@ set(SUPPORTED_TARGETS esp32s2) # include basic family CMake functionality set(FAMILY_MCUS ESP32S2) -include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../family_common.cmake) diff --git a/hw/bsp/esp32s3/family.cmake b/hw/bsp/esp32s3/family.cmake index b530b326d..c99c3728b 100644 --- a/hw/bsp/esp32s3/family.cmake +++ b/hw/bsp/esp32s3/family.cmake @@ -7,4 +7,4 @@ set(SUPPORTED_TARGETS esp32s3) # include basic family CMake functionality set(FAMILY_MCUS ESP32S3) -include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../family_common.cmake) diff --git a/hw/bsp/family.cmake b/hw/bsp/family_common.cmake similarity index 100% rename from hw/bsp/family.cmake rename to hw/bsp/family_common.cmake diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index ee17d4d46..e791648a9 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -8,7 +8,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker) # add the SDK in case we are standalone tinyusb example (noop if already present) include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_import.cmake) - include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/../family_common.cmake) # todo should we default to pico_sdk? if (NOT BOARD) @@ -68,6 +68,7 @@ if (NOT TARGET _rp2040_family_inclusion_marker) endfunction() function(family_initialize_project PROJECT DIR) + # call the original version of this function from family_common.cmake _family_initialize_project(${PROJECT} ${DIR}) enable_language(C CXX ASM) pico_sdk_init() diff --git a/hw/mcu/microchip b/hw/mcu/microchip index f7087f047..66b5a1199 160000 --- a/hw/mcu/microchip +++ b/hw/mcu/microchip @@ -1 +1 @@ -Subproject commit f7087f04783c896627061fc151fa3527b73733c7 +Subproject commit 66b5a11995025426224e0ba6f377322e6e8893b6 diff --git a/hw/mcu/sony/cxd56/spresense-exported-sdk b/hw/mcu/sony/cxd56/spresense-exported-sdk index 2ec2a1538..b473b28a1 160000 --- a/hw/mcu/sony/cxd56/spresense-exported-sdk +++ b/hw/mcu/sony/cxd56/spresense-exported-sdk @@ -1 +1 @@ -Subproject commit 2ec2a1538362696118dc3fdf56f33dacaf8f4067 +Subproject commit b473b28a14a03f3d416b6e2c071bcfd4fb92cb63 diff --git a/lib/CMSIS_5 b/lib/CMSIS_5 index 202852626..b7b26f50d 160000 --- a/lib/CMSIS_5 +++ b/lib/CMSIS_5 @@ -1 +1 @@ -Subproject commit 20285262657d1b482d132d20d755c8c330d55c1f +Subproject commit b7b26f50d00072812aec8453f643e24bafedccb5 diff --git a/lib/lwip b/lib/lwip index 159e31b68..0192fe773 160000 --- a/lib/lwip +++ b/lib/lwip @@ -1 +1 @@ -Subproject commit 159e31b689577dbf69cf0683bbaffbd71fa5ee10 +Subproject commit 0192fe773ec28e11f66ec76f4e827fbb58b7e257 From ebf6461c4279d22e89101d2705fa2c91e4ad2993 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Tue, 1 Jun 2021 10:58:44 -0500 Subject: [PATCH 12/17] damn submodules! --- hw/mcu/microchip | 2 +- hw/mcu/sony/cxd56/spresense-exported-sdk | 2 +- lib/CMSIS_5 | 2 +- lib/lwip | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/mcu/microchip b/hw/mcu/microchip index 66b5a1199..f7087f047 160000 --- a/hw/mcu/microchip +++ b/hw/mcu/microchip @@ -1 +1 @@ -Subproject commit 66b5a11995025426224e0ba6f377322e6e8893b6 +Subproject commit f7087f04783c896627061fc151fa3527b73733c7 diff --git a/hw/mcu/sony/cxd56/spresense-exported-sdk b/hw/mcu/sony/cxd56/spresense-exported-sdk index b473b28a1..2ec2a1538 160000 --- a/hw/mcu/sony/cxd56/spresense-exported-sdk +++ b/hw/mcu/sony/cxd56/spresense-exported-sdk @@ -1 +1 @@ -Subproject commit b473b28a14a03f3d416b6e2c071bcfd4fb92cb63 +Subproject commit 2ec2a1538362696118dc3fdf56f33dacaf8f4067 diff --git a/lib/CMSIS_5 b/lib/CMSIS_5 index b7b26f50d..202852626 160000 --- a/lib/CMSIS_5 +++ b/lib/CMSIS_5 @@ -1 +1 @@ -Subproject commit b7b26f50d00072812aec8453f643e24bafedccb5 +Subproject commit 20285262657d1b482d132d20d755c8c330d55c1f diff --git a/lib/lwip b/lib/lwip index 0192fe773..159e31b68 160000 --- a/lib/lwip +++ b/lib/lwip @@ -1 +1 @@ -Subproject commit 0192fe773ec28e11f66ec76f4e827fbb58b7e257 +Subproject commit 159e31b689577dbf69cf0683bbaffbd71fa5ee10 From 109d02531e3ba208627b4dfab29d29df3d8a4565 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Tue, 1 Jun 2021 11:21:19 -0500 Subject: [PATCH 13/17] remove TINYUSB_FAMILT_PROJECT_NAME_INCLUDES_BOARD setting --- hw/bsp/family_common.cmake | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hw/bsp/family_common.cmake b/hw/bsp/family_common.cmake index 124399675..2544c58c6 100644 --- a/hw/bsp/family_common.cmake +++ b/hw/bsp/family_common.cmake @@ -35,11 +35,7 @@ endfunction() function(family_get_project_name OUTPUT_NAME DIR) get_filename_component(SHORT_NAME ${DIR} NAME) - if (TINYUSB_FAMILY_PROJECT_NAME_INCLUDES_BOARD OR NOT DEFINED TINYUSB_FAMILY_PROJECT_NAME_INCLUDES_BOARD) - set(${OUTPUT_NAME} ${TINYUSB_FAMILY_PROJECT_NAME_PREFIX}${BOARD}-${SHORT_NAME} PARENT_SCOPE) - else() - set(${OUTPUT_NAME} ${TINYUSB_FAMILY_PROJECT_NAME_PREFIX}${SHORT_NAME} PARENT_SCOPE) - endif() + set(${OUTPUT_NAME} ${TINYUSB_FAMILY_PROJECT_NAME_PREFIX}${SHORT_NAME} PARENT_SCOPE) endfunction() function(family_initialize_project PROJECT DIR) From bef33d108a2f183227ccbc1f2027f354415a39fb Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Wed, 2 Jun 2021 08:32:21 -0500 Subject: [PATCH 14/17] move core definition of source file includes from SDK into family.cmake only build webserver example if lwip submodule initialized --- .../device/net_lwip_webserver/CMakeLists.txt | 136 +++++++++--------- hw/bsp/rp2040/family.cmake | 95 ++++++++++-- 2 files changed, 156 insertions(+), 75 deletions(-) diff --git a/examples/device/net_lwip_webserver/CMakeLists.txt b/examples/device/net_lwip_webserver/CMakeLists.txt index 63cca04a8..b8d769c4e 100644 --- a/examples/device/net_lwip_webserver/CMakeLists.txt +++ b/examples/device/net_lwip_webserver/CMakeLists.txt @@ -1,82 +1,84 @@ cmake_minimum_required(VERSION 3.5) -set(TOP "../../..") -get_filename_component(TOP "${TOP}" REALPATH) +if (EXISTS ${TOP}/lib/lwip/src) + set(TOP "../../..") + get_filename_component(TOP "${TOP}" REALPATH) -include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) -# gets PROJECT name for the example (e.g. -) -family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR}) + # gets PROJECT name for the example (e.g. -) + 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}) -add_executable(${PROJECT}) + add_executable(${PROJECT}) -# Example source -target_sources(${PROJECT} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c - ) + # 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 - ${TOP}/lib/lwip/src/include - ${TOP}/lib/lwip/src/include/ipv4 - ${TOP}/lib/lwip/src/include/lwip/apps - ${TOP}/lib/networking - ) + # 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 + ) -target_sources(${PROJECT} PUBLIC - ${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 - ) + target_sources(${PROJECT} PUBLIC + ${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 + ) -target_compile_definitions(${PROJECT} PUBLIC - PBUF_POOL_SIZE=2 - TCP_WND=2*TCP_MSS - HTTPD_USE_CUSTOM_FSDATA=0 -) + target_compile_definitions(${PROJECT} PUBLIC + PBUF_POOL_SIZE=2 + TCP_WND=2*TCP_MSS + HTTPD_USE_CUSTOM_FSDATA=0 + ) -# Configure compilation flags and libraries for the example... see the corresponding function -# in hw/bsp/FAMILY/family.cmake for details. -family_configure_device_example(${PROJECT}) + # Configure compilation flags and libraries for the example... see the corresponding function + # in hw/bsp/FAMILY/family.cmake for details. + family_configure_device_example(${PROJECT}) +endif() diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index e791648a9..e70cbd129 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -5,31 +5,110 @@ if (NOT TARGET _rp2040_family_inclusion_marker) # include basic family CMake functionality set(FAMILY_MCUS RP2040) + if (NOT BOARD) + message(FATAL_ERROR "BOARD must be specified") + endif() + # add the SDK in case we are standalone tinyusb example (noop if already present) include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_import.cmake) include(${CMAKE_CURRENT_LIST_DIR}/../family_common.cmake) - # todo should we default to pico_sdk? - if (NOT BOARD) - message(FATAL_ERROR "BOARD must be specified") - endif() include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "${CMAKE_CURRENT_LIST_DIR}/../../..") get_filename_component(TOP "${TOP}" REALPATH) - if (NOT PICO_TINYUSB_PATH) - set(PICO_TINYUSB_PATH ${TOP}) + if (NOT TOP) + set(TOP ${TOP}) endif() - # tinyusb_additions will hold our extra settings libraries + # Base config for both device and host; wrapped by SDK's tinyusb_common + add_library(tinyusb_common_base INTERFACE) + + target_sources(tinyusb_common_base INTERFACE + ${TOP}/src/tusb.c + ${TOP}/src/common/tusb_fifo.c + ) + + target_include_directories(tinyusb_common_base INTERFACE + ${TOP}/src + ${TOP}/src/common + ${TOP}/hw + ) + + target_link_libraries(tinyusb_common_base INTERFACE + hardware_structs + hardware_irq + hardware_resets + pico_sync + ) + + set(TINYUSB_DEBUG_LEVEL 0) + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + message("Compiling TinyUSB with CFG_TUSB_DEBUG=1") + set(TINYUSB_DEBUG_LEVEL 1) + endif () + + target_compile_definitions(tinyusb_common_base INTERFACE + CFG_TUSB_MCU=OPT_MCU_RP2040 + CFG_TUSB_OS=OPT_OS_PICO + CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL} + ) + + # Base config for device mode; wrapped by SDK's tinyusb_device + add_library(tinyusb_device_base INTERFACE) + target_sources(tinyusb_device_base INTERFACE + ${TOP}/src/portable/raspberrypi/rp2040/dcd_rp2040.c + ${TOP}/src/portable/raspberrypi/rp2040/rp2040_usb.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_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 + ) + + + # Base config for host mode; wrapped by SDK's tinyusb_host + add_library(tinyusb_host_base INTERFACE) + target_sources(tinyusb_host_base INTERFACE + ${TOP}/src/portable/raspberrypi/rp2040/hcd_rp2040.c + ${TOP}/src/portable/raspberrypi/rp2040/rp2040_usb.c + ${TOP}/src/host/usbh.c + ${TOP}/src/host/usbh_control.c + ${TOP}/src/host/hub.c + ${TOP}/src/class/cdc/cdc_host.c + ${TOP}/src/class/hid/hid_host.c + ${TOP}/src/class/msc/msc_host.c + ${TOP}/src/class/vendor/vendor_host.c + ) + + # Sometimes have to do host specific actions in mostly + # common functions + target_compile_definitions(tinyusb_host_base INTERFACE + RP2040_USB_HOST_MODE=1 + ) + + add_library(tinyusb_bsp INTERFACE) + target_sources(tinyusb_bsp INTERFACE + ${TOP}/hw/bsp/rp2040/family.c + ) +# target_include_directories(tinyusb_bsp INTERFACE +# ${TOP}/hw/bsp/rp2040) + + # tinyusb_additions will hold our extra settings for examples add_library(tinyusb_additions INTERFACE) target_compile_definitions(tinyusb_additions INTERFACE PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1 - CFG_TUSB_MCU=OPT_MCU_RP2040 # this is already included in the SDK, but needed here for build_family.py grep ) if(DEFINED LOG) From 1fb211f3900d4ce27083930edf4d8a107c7d4610 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Wed, 2 Jun 2021 09:52:49 -0500 Subject: [PATCH 15/17] minor comment change to force rebuild --- hw/bsp/rp2040/family.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index e70cbd129..8c9b9ec1d 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.13) if (NOT TARGET _rp2040_family_inclusion_marker) add_library(_rp2040_family_inclusion_marker INTERFACE) - # include basic family CMake functionality - set(FAMILY_MCUS RP2040) - if (NOT BOARD) message(FATAL_ERROR "BOARD must be specified") endif() @@ -12,6 +9,8 @@ if (NOT TARGET _rp2040_family_inclusion_marker) # add the SDK in case we are standalone tinyusb example (noop if already present) include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_import.cmake) + # include basic family CMake functionality + set(FAMILY_MCUS RP2040) include(${CMAKE_CURRENT_LIST_DIR}/../family_common.cmake) include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake) From de436e1f766c136edaec298d11c55edd937678fe Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Wed, 2 Jun 2021 11:30:42 -0500 Subject: [PATCH 16/17] undo search replace error --- hw/bsp/rp2040/family.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index 8c9b9ec1d..752eb0cab 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -19,8 +19,8 @@ if (NOT TARGET _rp2040_family_inclusion_marker) set(TOP "${CMAKE_CURRENT_LIST_DIR}/../../..") get_filename_component(TOP "${TOP}" REALPATH) - if (NOT TOP) - set(TOP ${TOP}) + if (NOT PICO_TINYUSB_PATH) + set(PICO_TINYUSB_PATH ${TOP}) endif() # Base config for both device and host; wrapped by SDK's tinyusb_common From fea5cbaf74a033d3f0c462b6bf2d334a67f6a732 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Wed, 2 Jun 2021 12:37:12 -0500 Subject: [PATCH 17/17] fixed net_lwip_webserver cmake build --- examples/device/net_lwip_webserver/CMakeLists.txt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/examples/device/net_lwip_webserver/CMakeLists.txt b/examples/device/net_lwip_webserver/CMakeLists.txt index b8d769c4e..f1f79b2d1 100644 --- a/examples/device/net_lwip_webserver/CMakeLists.txt +++ b/examples/device/net_lwip_webserver/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.5) -if (EXISTS ${TOP}/lib/lwip/src) - set(TOP "../../..") - get_filename_component(TOP "${TOP}" REALPATH) +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) +if (EXISTS ${TOP}/lib/lwip/src) include(${TOP}/hw/bsp/${FAMILY}/family.cmake) # gets PROJECT name for the example (e.g. -) @@ -73,12 +73,9 @@ if (EXISTS ${TOP}/lib/lwip/src) PBUF_POOL_SIZE=2 TCP_WND=2*TCP_MSS HTTPD_USE_CUSTOM_FSDATA=0 - ) + ) # Configure compilation flags and libraries for the example... see the corresponding function # in hw/bsp/FAMILY/family.cmake for details. family_configure_device_example(${PROJECT}) -endif() - - - +endif() \ No newline at end of file