فهرست منبع

tinyusb: add support of esp32s3 target

add support of new esp32s3 target and the board
update the roles.mk wrapper to allow dfu flashing of espressif chip
update examples to allow compilation for esp32s3_addax_1 board
once the code is tested the PR to original tinyusb repo will be submitted
Alex Lisitsyn 5 سال پیش
والد
کامیت
2f0cb8b5f1
51فایلهای تغییر یافته به همراه257 افزوده شده و 85 حذف شده
  1. 4 3
      .github/workflows/build.yml
  2. 1 1
      README.md
  3. 1 1
      examples/device/board_test/CMakeLists.txt
  4. 1 2
      examples/device/board_test/sdkconfig.defaults
  5. 10 2
      examples/device/board_test/src/CMakeLists.txt
  6. 1 1
      examples/device/board_test/src/main.c
  7. 1 1
      examples/device/cdc_msc/CMakeLists.txt
  8. 1 1
      examples/device/cdc_msc_freertos/CMakeLists.txt
  9. 0 2
      examples/device/cdc_msc_freertos/sdkconfig.defaults
  10. 13 2
      examples/device/cdc_msc_freertos/src/CMakeLists.txt
  11. 3 3
      examples/device/cdc_msc_freertos/src/main.c
  12. 2 2
      examples/device/hid_composite_freertos/CMakeLists.txt
  13. 0 2
      examples/device/hid_composite_freertos/sdkconfig.defaults
  14. 13 2
      examples/device/hid_composite_freertos/src/CMakeLists.txt
  15. 3 3
      examples/device/hid_composite_freertos/src/main.c
  16. 1 1
      examples/host/cdc_msc_hid/CMakeLists.txt
  17. 3 0
      examples/make.mk
  18. 2 2
      examples/rules.mk
  19. 3 0
      hw/bsp/board_mcu.h
  20. 0 6
      hw/bsp/esp32s2/family.cmake
  21. 0 36
      hw/bsp/esp32s2/family.mk
  22. 3 5
      hw/bsp/esp32sx/boards/CMakeLists.txt
  23. 15 0
      hw/bsp/esp32sx/boards/adafruit_feather_esp32s2/CMakeLists.txt
  24. 0 0
      hw/bsp/esp32sx/boards/adafruit_feather_esp32s2/board.h
  25. 3 0
      hw/bsp/esp32sx/boards/adafruit_feather_esp32s2/board.mk
  26. 15 0
      hw/bsp/esp32sx/boards/adafruit_magtag_29gray/CMakeLists.txt
  27. 0 0
      hw/bsp/esp32sx/boards/adafruit_magtag_29gray/board.h
  28. 3 0
      hw/bsp/esp32sx/boards/adafruit_magtag_29gray/board.mk
  29. 15 0
      hw/bsp/esp32sx/boards/adafruit_metro_esp32s2/CMakeLists.txt
  30. 0 0
      hw/bsp/esp32sx/boards/adafruit_metro_esp32s2/board.h
  31. 3 0
      hw/bsp/esp32sx/boards/adafruit_metro_esp32s2/board.mk
  32. 0 0
      hw/bsp/esp32sx/boards/esp32sx.c
  33. 15 0
      hw/bsp/esp32sx/boards/espressif_addax_1/CMakeLists.txt
  34. 44 0
      hw/bsp/esp32sx/boards/espressif_addax_1/board.h
  35. 3 0
      hw/bsp/esp32sx/boards/espressif_addax_1/board.mk
  36. 14 0
      hw/bsp/esp32sx/boards/espressif_kaluga_1/CMakeLists.txt
  37. 0 0
      hw/bsp/esp32sx/boards/espressif_kaluga_1/board.h
  38. 3 0
      hw/bsp/esp32sx/boards/espressif_kaluga_1/board.mk
  39. 14 0
      hw/bsp/esp32sx/boards/espressif_saola_1/CMakeLists.txt
  40. 0 0
      hw/bsp/esp32sx/boards/espressif_saola_1/board.h
  41. 3 0
      hw/bsp/esp32sx/boards/espressif_saola_1/board.mk
  42. 0 0
      hw/bsp/esp32sx/components/led_strip/CMakeLists.txt
  43. 0 0
      hw/bsp/esp32sx/components/led_strip/include/led_strip.h
  44. 0 0
      hw/bsp/esp32sx/components/led_strip/src/led_strip_rmt_ws2812.c
  45. 6 0
      hw/bsp/esp32sx/family.cmake
  46. 26 0
      hw/bsp/esp32sx/family.mk
  47. 2 2
      src/osal/osal_freertos.h
  48. 4 3
      src/portable/espressif/esp32sx/dcd_esp32sx.c
  49. 1 0
      src/tusb_option.h
  50. 1 1
      tools/build_esp32sx.py
  51. 1 1
      tools/build_family.py

+ 4 - 3
.github/workflows/build.yml

@@ -180,9 +180,9 @@ jobs:
         asset_content_type: application/zip
 
   # ---------------------------------------
-  # Build ESP32S2 family
+  # Build ESP32SX family
   # ---------------------------------------
-  build-esp32s2:
+  build-esp32sx:
     runs-on: ubuntu-latest
     strategy:
       fail-fast: false
@@ -192,6 +192,7 @@ jobs:
         - 'adafruit_feather_esp32s2'
         - 'adafruit_magtag_29gray'
         - 'adafruit_metro_esp32s2'
+        - 'espressif_addax_1'
         - 'espressif_kaluga_1'
         - 'espressif_saola_1'
 
@@ -206,7 +207,7 @@ jobs:
       uses: actions/checkout@v2
 
     - name: Build
-      run: docker run --rm -v $PWD:/project -w /project espressif/idf:latest python3 tools/build_esp32s2.py ${{ matrix.board }}
+      run: docker run --rm -v $PWD:/project -w /project espressif/idf:latest python3 tools/build_esp32sx.py ${{ matrix.board }}
 
   # ---------------------------------------
   # Build msp430 family

+ 1 - 1
README.md

@@ -31,7 +31,7 @@ Special thanks to all the people who spent their precious time and effort to hel
 The stack supports the following MCUs:
 
 - **Dialog:** DA1469x
-- **Espressif:** ESP32-S2
+- **Espressif:** ESP32-S2, ESP32-S3
 - **MicroChip:** SAMD11, SAMD21, SAMD51, SAME5x, SAMG55
 - **NordicSemi:** nRF52833, nRF52840
 - **Nuvoton:** NUC120, NUC121/NUC125, NUC126, NUC505

+ 1 - 1
examples/device/board_test/CMakeLists.txt

@@ -7,7 +7,7 @@ set(TOP "../../..")
 get_filename_component(TOP "${TOP}" REALPATH)
 
 # Check for -DFAMILY=
-if(FAMILY STREQUAL "esp32s2")
+if(FAMILY STREQUAL "esp32sx")
   cmake_minimum_required(VERSION 3.5)
 
   include(${TOP}/hw/bsp/${FAMILY}/family.cmake)

+ 1 - 2
examples/device/board_test/sdkconfig.defaults

@@ -1,4 +1,3 @@
 CONFIG_IDF_CMAKE=y
-CONFIG_IDF_TARGET="esp32s2"
-CONFIG_IDF_TARGET_ESP32S2=y
+CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
 CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y

+ 10 - 2
examples/device/board_test/src/CMakeLists.txt

@@ -1,10 +1,18 @@
-# FAMILY = "esp32s2"
+# FAMILY = esp32sx
 idf_component_register(SRCS "main.c"
                     INCLUDE_DIRS "."
                     REQUIRES freertos soc)
                     
+string(REGEX MATCH "^(esp32s[2-3])*" chip_target "$ENV{IDF_TARGET}")
+
+if(NOT chip_target)
+    message(FATAL_ERROR "Incorrect target: $ENV{IDF_TARGET}" )
+endif()
+
+string(TOUPPER ${chip_target} upper_case_target)
+
 target_compile_options(${COMPONENT_TARGET} PUBLIC
-  "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+  "-DCFG_TUSB_MCU=OPT_MCU_${upper_case_target}"
   "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
 )
 

+ 1 - 1
examples/device/board_test/src/main.c

@@ -70,7 +70,7 @@ int main(void)
   return 0;
 }
 
-#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
+#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3
 void app_main(void)
 {
   main();

+ 1 - 1
examples/device/cdc_msc/CMakeLists.txt

@@ -7,7 +7,7 @@ set(TOP "../../..")
 get_filename_component(TOP "${TOP}" REALPATH)
 
 # Check for -DFAMILY=
-if(FAMILY STREQUAL "esp32s2")
+if(FAMILY STREQUAL "esp32sx")
   cmake_minimum_required(VERSION 3.5)
   include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
   project(${PROJECT})

+ 1 - 1
examples/device/cdc_msc_freertos/CMakeLists.txt

@@ -9,7 +9,7 @@ set(TOP "../../..")
 get_filename_component(TOP "${TOP}" REALPATH)
 
 # Check for -DFAMILY=
-if(FAMILY STREQUAL "esp32s2")
+if(FAMILY STREQUAL "esp32sx")
   include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
   project(${PROJECT})
 

+ 0 - 2
examples/device/cdc_msc_freertos/sdkconfig.defaults

@@ -1,5 +1,3 @@
 CONFIG_IDF_CMAKE=y
-CONFIG_IDF_TARGET="esp32s2"
-CONFIG_IDF_TARGET_ESP32S2=y
 CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
 CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y

+ 13 - 2
examples/device/cdc_msc_freertos/src/CMakeLists.txt

@@ -2,8 +2,19 @@ idf_component_register(SRCS "main.c" "usb_descriptors.c" "msc_disk.c"
                     INCLUDE_DIRS "."
                     REQUIRES freertos soc)
 
+string(REGEX MATCH "^(esp32s[2-3])*" chip_target "$ENV{IDF_TARGET}")
+
+if(NOT chip_target)
+    message(FATAL_ERROR "Incorrect target: $ENV{IDF_TARGET}" )
+else()
+    set(chip_family "esp32sx")
+endif()
+
+string(TOUPPER ${chip_target} upper_case_target)
+
 target_compile_options(${COMPONENT_TARGET} PUBLIC
-  "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+  "-DCFG_TUSB_MCU=OPT_MCU_${upper_case_target}"
+  "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
 )
 
 idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
@@ -26,5 +37,5 @@ target_sources(${COMPONENT_TARGET} PUBLIC
   "${TOP}/src/class/net/net_device.c"
   "${TOP}/src/class/usbtmc/usbtmc_device.c"
   "${TOP}/src/class/vendor/vendor_device.c"
-  "${TOP}/src/portable/espressif/esp32s2/dcd_esp32s2.c"
+  "${TOP}/src/portable/espressif/${chip_family}/dcd_${chip_family}.c"
 )

+ 3 - 3
examples/device/cdc_msc_freertos/src/main.c

@@ -94,15 +94,15 @@ int main(void)
   // Create CDC task
   (void) xTaskCreateStatic( cdc_task, "cdc", CDC_STACK_SZIE, NULL, configMAX_PRIORITIES-2, cdc_stack, &cdc_taskdef);
 
-  // skip starting scheduler (and return) for ESP32-S2
-#if CFG_TUSB_MCU != OPT_MCU_ESP32S2
+  // skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
+#if CFG_TUSB_MCU != OPT_MCU_ESP32S2 && CFG_TUSB_MCU != OPT_MCU_ESP32S3
   vTaskStartScheduler();
 #endif
 
   return 0;
 }
 
-#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
+#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3
 void app_main(void)
 {
   main();

+ 2 - 2
examples/device/hid_composite_freertos/CMakeLists.txt

@@ -9,10 +9,10 @@ set(TOP "../../..")
 get_filename_component(TOP "${TOP}" REALPATH)
 
 # Check for -DFAMILY=
-if(FAMILY STREQUAL "esp32s2")
+if(FAMILY STREQUAL "esp32sx")
   include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
   project(${PROJECT})
 
 else()
-  message(FATAL_ERROR "Invalid FAMILY specified")
+  message(FATAL_ERROR "Invalid FAMILY specified: ${FAMILY}")
 endif()

+ 0 - 2
examples/device/hid_composite_freertos/sdkconfig.defaults

@@ -1,5 +1,3 @@
 CONFIG_IDF_CMAKE=y
-CONFIG_IDF_TARGET="esp32s2"
-CONFIG_IDF_TARGET_ESP32S2=y
 CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
 CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y

+ 13 - 2
examples/device/hid_composite_freertos/src/CMakeLists.txt

@@ -2,8 +2,19 @@ idf_component_register(SRCS "main.c" "usb_descriptors.c"
                     INCLUDE_DIRS "."
                     REQUIRES freertos soc)
 
+string(REGEX MATCH "^(esp32s[2-3])*" chip_target "$ENV{IDF_TARGET}")
+
+if(NOT chip_target)
+    message(FATAL_ERROR "Incorrect target: $ENV{IDF_TARGET}" )
+else()
+    set(chip_family "esp32sx")
+endif()
+
+string(TOUPPER ${chip_target} upper_case_target)
+
 target_compile_options(${COMPONENT_TARGET} PUBLIC
-  "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+  "-DCFG_TUSB_MCU=OPT_MCU_${upper_case_target}"
+  "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
 )
 
 idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
@@ -26,5 +37,5 @@ target_sources(${COMPONENT_TARGET} PUBLIC
   "${TOP}/src/class/net/net_device.c"
   "${TOP}/src/class/usbtmc/usbtmc_device.c"
   "${TOP}/src/class/vendor/vendor_device.c"
-  "${TOP}/src/portable/espressif/esp32s2/dcd_esp32s2.c"
+  "${TOP}/src/portable/espressif/${chip_family}/dcd_${chip_family}.c"
 )

+ 3 - 3
examples/device/hid_composite_freertos/src/main.c

@@ -95,15 +95,15 @@ int main(void)
   // Create HID task
   (void) xTaskCreateStatic( hid_task, "hid", HID_STACK_SZIE, NULL, configMAX_PRIORITIES-2, hid_stack, &hid_taskdef);
 
-  // skip starting scheduler (and return) for ESP32-S2
-#if CFG_TUSB_MCU != OPT_MCU_ESP32S2
+  // skip starting scheduler (and return) for ESP32-S2 or ESP32-S3
+#if CFG_TUSB_MCU != OPT_MCU_ESP32S2 && CFG_TUSB_MCU != OPT_MCU_ESP32S3
   vTaskStartScheduler();
 #endif
 
   return 0;
 }
 
-#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
+#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3
 void app_main(void)
 {
   main();

+ 1 - 1
examples/host/cdc_msc_hid/CMakeLists.txt

@@ -7,7 +7,7 @@ set(TOP "../../..")
 get_filename_component(TOP "${TOP}" REALPATH)
 
 # Check for -DFAMILY=
-if(FAMILY STREQUAL "esp32s2")
+if(FAMILY STREQUAL "esp32sx")
   cmake_minimum_required(VERSION 3.5)
   include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
   project(${PROJECT})

+ 3 - 0
examples/make.mk

@@ -27,6 +27,9 @@ endif
 # Board within family
 ifeq ($(BOARD_PATH),)
   BOARD_PATH := $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/*/boards/$(BOARD)))
+ifneq ($(wildcard $(TOP)/hw/bsp/*/boards/$(BOARD)/board.mk),)
+    include $(TOP)/hw/bsp/*/boards/$(BOARD)/board.mk
+endif
   FAMILY := $(word 3, $(subst /, ,$(BOARD_PATH)))
   FAMILY_PATH = hw/bsp/$(FAMILY)
 endif

+ 2 - 2
examples/rules.mk

@@ -5,8 +5,8 @@
 # Set all as default goal
 .DEFAULT_GOAL := all
 
-# ESP32-S2 and RP2040 has its own CMake build system
-ifneq ($(FAMILY),esp32s2)
+# ESP32-SX and RP2040 has its own CMake build system
+ifneq ($(FAMILY),esp32sx)
 ifneq ($(FAMILY),rp2040)
 # ---------------------------------------
 # GNU Make build system

+ 3 - 0
hw/bsp/board_mcu.h

@@ -115,6 +115,9 @@
 #elif CFG_TUSB_MCU == OPT_MCU_ESP32S2
   // no header needed
 
+#elif CFG_TUSB_MCU == OPT_MCU_ESP32S3
+  // no header needed
+
 #elif CFG_TUSB_MCU == OPT_MCU_DA1469X
   #include "DA1469xAB.h"
 

+ 0 - 6
hw/bsp/esp32s2/family.cmake

@@ -1,6 +0,0 @@
-cmake_minimum_required(VERSION 3.5)
-
-# Add example src and bsp directories
-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)

+ 0 - 36
hw/bsp/esp32s2/family.mk

@@ -1,36 +0,0 @@
-#DEPS_SUBMODULES +=
-
-.PHONY: all clean flash
-
-all:
-	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) build
-
-build: all
-
-clean:
-	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) clean
-
-fullclean:
-	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) fullclean
-
-flash:
-	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) flash
-
-bootloader-flash:
-	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) bootloader-flash
-
-app-flash:
-	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) app-flash
-
-erase:
-	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) erase_flash
-
-monitor:
-	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) monitor
-
-uf2: $(BUILD)/$(PROJECT).uf2
-
-UF2_FAMILY_ID = 0xbfdd4eee
-$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).bin
-	@echo CREATE $@
-	$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -b 0x0 -c -o $@ $^

+ 3 - 5
hw/bsp/esp32s2/boards/CMakeLists.txt → hw/bsp/esp32sx/boards/CMakeLists.txt

@@ -1,12 +1,10 @@
-idf_component_register(SRCS esp32s2.c
+idf_component_register(SRCS esp32sx.c
                     INCLUDE_DIRS "." "${BOARD}"
                     PRIV_REQUIRES "driver"
                     REQUIRES freertos src led_strip)
 
-target_compile_options(${COMPONENT_TARGET} PUBLIC
-  "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
-  "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
-)
+# Apply board specific content
+add_subdirectory(${BOARD})
 
 idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
 target_include_directories(${COMPONENT_TARGET} PUBLIC

+ 15 - 0
hw/bsp/esp32sx/boards/adafruit_feather_esp32s2/CMakeLists.txt

@@ -0,0 +1,15 @@
+# Apply board specific context here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+message(STATUS "Apply board specific content ${BOARD}: $ENV{IDF_TARGET} " )
+idf_build_get_property(idf_target IDF_TARGET)
+
+if(NOT ${idf_target} STREQUAL "esp32s2")
+    message(STATUS "Incorrect target for board ${BOARD}: $ENV{IDF_TARGET} " )
+    set(IDF_TARGET "esp32s2" FORCE)
+endif()
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+  "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+  "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+)

+ 0 - 0
hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.h → hw/bsp/esp32sx/boards/adafruit_feather_esp32s2/board.h


+ 3 - 0
hw/bsp/esp32sx/boards/adafruit_feather_esp32s2/board.mk

@@ -0,0 +1,3 @@
+IDF_TARGET = esp32s2
+
+$(info Processing of board.mk for board: $(BOARD){$(BOARD_PATH)}, family: $(FAMILY), target: $(IDF_TARGET))

+ 15 - 0
hw/bsp/esp32sx/boards/adafruit_magtag_29gray/CMakeLists.txt

@@ -0,0 +1,15 @@
+# Apply board specific context here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+message(STATUS "Apply board specific content ${BOARD}: $ENV{IDF_TARGET} " )
+idf_build_get_property(idf_target IDF_TARGET)
+
+if(NOT ${idf_target} STREQUAL "esp32s2")
+    message(STATUS "Incorrect target for board ${BOARD}: $ENV{IDF_TARGET} " )
+    set(IDF_TARGET "esp32s2" FORCE)
+endif()
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+  "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+  "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+)

+ 0 - 0
hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.h → hw/bsp/esp32sx/boards/adafruit_magtag_29gray/board.h


+ 3 - 0
hw/bsp/esp32sx/boards/adafruit_magtag_29gray/board.mk

@@ -0,0 +1,3 @@
+IDF_TARGET = esp32s2
+
+$(info Processing of board.mk for board: $(BOARD){$(BOARD_PATH)}, family: $(FAMILY), target: $(IDF_TARGET))

+ 15 - 0
hw/bsp/esp32sx/boards/adafruit_metro_esp32s2/CMakeLists.txt

@@ -0,0 +1,15 @@
+# Apply board specific context here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+message(STATUS "Apply board specific content ${BOARD}: $ENV{IDF_TARGET} " )
+idf_build_get_property(idf_target IDF_TARGET)
+
+if(NOT ${idf_target} STREQUAL "esp32s2")
+    message(STATUS "Incorrect target for board ${BOARD}: $ENV{IDF_TARGET} " )
+    set(IDF_TARGET "esp32s2" FORCE)
+endif()
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+  "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+  "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+)

+ 0 - 0
hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.h → hw/bsp/esp32sx/boards/adafruit_metro_esp32s2/board.h


+ 3 - 0
hw/bsp/esp32sx/boards/adafruit_metro_esp32s2/board.mk

@@ -0,0 +1,3 @@
+IDF_TARGET = esp32s2
+
+$(info Processing of board.mk for board: $(BOARD){$(BOARD_PATH)}, family: $(FAMILY), target: $(IDF_TARGET))

+ 0 - 0
hw/bsp/esp32s2/boards/esp32s2.c → hw/bsp/esp32sx/boards/esp32sx.c


+ 15 - 0
hw/bsp/esp32sx/boards/espressif_addax_1/CMakeLists.txt

@@ -0,0 +1,15 @@
+# Apply board specific content here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+message(STATUS "Apply board specific content ${BOARD}: $ENV{IDF_TARGET} " )
+idf_build_get_property(idf_target IDF_TARGET)
+
+if(NOT ${idf_target} STREQUAL "esp32s3")
+    message(STATUS "Incorrect target for board ${BOARD}: $ENV{IDF_TARGET} " )
+    set(IDF_TARGET "esp32s3" FORCE)
+endif()
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+  "-DCFG_TUSB_MCU=OPT_MCU_ESP32S3"
+  "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+)

+ 44 - 0
hw/bsp/esp32sx/boards/espressif_addax_1/board.h

@@ -0,0 +1,44 @@
+/* 
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, 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
+
+// Note: On the production version (v1.1) WS2812 is connected to GPIO 47
+#define NEOPIXEL_PIN          47
+
+#define BUTTON_PIN            0
+#define BUTTON_STATE_ACTIVE   0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */

+ 3 - 0
hw/bsp/esp32sx/boards/espressif_addax_1/board.mk

@@ -0,0 +1,3 @@
+IDF_TARGET = esp32s3
+
+$(info Processing of board.mk for board: $(BOARD){$(BOARD_PATH)}, family: $(FAMILY), target: $(IDF_TARGET))

+ 14 - 0
hw/bsp/esp32sx/boards/espressif_kaluga_1/CMakeLists.txt

@@ -0,0 +1,14 @@
+# Apply board specific context here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+idf_build_get_property(idf_target IDF_TARGET)
+
+if( NOT ${idf_target} STREQUAL "esp32s2")
+    message(STATUS "Incorrect target for board ${BOARD}: $ENV{IDF_TARGET} " )
+    set(IDF_TARGET "esp32s2" FORCE)
+endif()
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+  "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+  "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+)

+ 0 - 0
hw/bsp/esp32s2/boards/espressif_kaluga_1/board.h → hw/bsp/esp32sx/boards/espressif_kaluga_1/board.h


+ 3 - 0
hw/bsp/esp32sx/boards/espressif_kaluga_1/board.mk

@@ -0,0 +1,3 @@
+IDF_TARGET = esp32s2
+
+$(info Processing of board.mk for board: $(BOARD){$(BOARD_PATH)}, family: $(FAMILY), target: $(IDF_TARGET))

+ 14 - 0
hw/bsp/esp32sx/boards/espressif_saola_1/CMakeLists.txt

@@ -0,0 +1,14 @@
+# Apply board specific context here
+target_include_directories(${COMPONENT_LIB} PUBLIC .)
+
+idf_build_get_property(idf_target IDF_TARGET)
+
+if(NOT ${idf_target} STREQUAL "esp32s2")
+    message(STATUS "Incorrect target for board ${BOARD}: $ENV{IDF_TARGET} " )
+    set(IDF_TARGET "esp32s2" FORCE)
+endif()
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+  "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+  "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+)

+ 0 - 0
hw/bsp/esp32s2/boards/espressif_saola_1/board.h → hw/bsp/esp32sx/boards/espressif_saola_1/board.h


+ 3 - 0
hw/bsp/esp32sx/boards/espressif_saola_1/board.mk

@@ -0,0 +1,3 @@
+IDF_TARGET = esp32s2
+
+$(info Processing of board.mk for board: $(BOARD){$(BOARD_PATH)}, family: $(FAMILY), target: $(IDF_TARGET))

+ 0 - 0
hw/bsp/esp32s2/components/led_strip/CMakeLists.txt → hw/bsp/esp32sx/components/led_strip/CMakeLists.txt


+ 0 - 0
hw/bsp/esp32s2/components/led_strip/include/led_strip.h → hw/bsp/esp32sx/components/led_strip/include/led_strip.h


+ 0 - 0
hw/bsp/esp32s2/components/led_strip/src/led_strip_rmt_ws2812.c → hw/bsp/esp32sx/components/led_strip/src/led_strip_rmt_ws2812.c


+ 6 - 0
hw/bsp/esp32sx/family.cmake

@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.5)
+
+# Add example src and bsp directories
+set(EXTRA_COMPONENT_DIRS "src" "${TOP}/hw/bsp/esp32sx/boards" "${TOP}/hw/bsp/esp32sx/components")  
+include($ENV{IDF_PATH}/tools/cmake/project.cmake)
+set(SUPPORTED_TARGETS esp32s2 esp32s3)

+ 26 - 0
hw/bsp/esp32sx/family.mk

@@ -0,0 +1,26 @@
+#DEPS_SUBMODULES +=
+
+.PHONY: all clean flash bootloader-flash app-flash erase monitor dfu-flash dfu
+
+all:
+	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) -DIDF_TARGET=$(IDF_TARGET) build
+
+build: all
+
+clean:
+	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) clean
+
+fullclean:
+	if test -f sdkconfig; then $(RM) -f sdkconfig ; fi
+	if test -d $(BUILD); then $(RM) -rf $(BUILD) ; fi
+
+flash bootloader-flash app-flash erase monitor dfu-flash dfu:
+	idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) $@
+
+uf2: $(BUILD)/$(PROJECT).uf2
+
+UF2_FAMILY_ID = 0xbfdd4eee
+$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).bin
+	@echo CREATE $@
+	$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -b 0x0 -c -o $@ $^
+

+ 2 - 2
src/osal/osal_freertos.h

@@ -67,7 +67,7 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
     BaseType_t xHigherPriorityTaskWoken;
     BaseType_t res = xSemaphoreGiveFromISR(sem_hdl, &xHigherPriorityTaskWoken);
 
-#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
+#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3
     if ( xHigherPriorityTaskWoken ) portYIELD_FROM_ISR();
 #else
     portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
@@ -150,7 +150,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in
     BaseType_t xHigherPriorityTaskWoken;
     BaseType_t res = xQueueSendToBackFromISR(qhdl, data, &xHigherPriorityTaskWoken);
 
-#if CFG_TUSB_MCU == OPT_MCU_ESP32S2
+#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 || CFG_TUSB_MCU == OPT_MCU_ESP32S3
     if ( xHigherPriorityTaskWoken ) portYIELD_FROM_ISR();
 #else
     portYIELD_FROM_ISR(xHigherPriorityTaskWoken);

+ 4 - 3
src/portable/espressif/esp32s2/dcd_esp32s2.c → src/portable/espressif/esp32sx/dcd_esp32sx.c

@@ -29,14 +29,14 @@
 #include "tusb_option.h"
 #include "common/tusb_fifo.h"
 
-#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 && TUSB_OPT_DEVICE_ENABLED
+#if (((CFG_TUSB_MCU == OPT_MCU_ESP32S2) ||  (CFG_TUSB_MCU == OPT_MCU_ESP32S3)) && TUSB_OPT_DEVICE_ENABLED)
 
 // Espressif
 #include "driver/periph_ctrl.h"
 #include "freertos/xtensa_api.h"
 #include "esp_intr_alloc.h"
 #include "esp_log.h"
-#include "esp32s2/rom/gpio.h"
+#include "driver/gpio.h"
 #include "soc/dport_reg.h"
 #include "soc/gpio_sig_map.h"
 #include "soc/usb_periph.h"
@@ -254,6 +254,7 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const *desc_edpt)
   uint8_t const epnum = tu_edpt_number(desc_edpt->bEndpointAddress);
   uint8_t const dir = tu_edpt_dir(desc_edpt->bEndpointAddress);
 
+  TU_ASSERT(desc_edpt->wMaxPacketSize.size <= 64);
   TU_ASSERT(epnum < EP_MAX);
 
   xfer_ctl_t *xfer = XFER_CTL_BASE(epnum, dir);
@@ -863,5 +864,5 @@ void dcd_int_disable (uint8_t rhport)
   esp_intr_free(usb_ih);
 }
 
-#endif // OPT_MCU_ESP32S2
+#endif // #if OPT_MCU_ESP32S2 || OPT_MCU_ESP32S3
 

+ 1 - 0
src/tusb_option.h

@@ -94,6 +94,7 @@
 
 // Espressif
 #define OPT_MCU_ESP32S2           900 ///< Espressif ESP32-S2
+#define OPT_MCU_ESP32S3           901 ///< Espressif ESP32-S3
 
 // Dialog
 #define OPT_MCU_DA1469X          1000 ///< Dialog Semiconductor DA1469x

+ 1 - 1
tools/build_esp32s2.py → tools/build_esp32sx.py

@@ -35,7 +35,7 @@ all_examples.sort()
 
 # Build all boards if not specified
 all_boards = []
-for entry in os.scandir("hw/bsp/esp32s2/boards"):
+for entry in os.scandir("hw/bsp/esp32sx/boards"):
     if entry.is_dir():
         all_boards.append(entry.name)
 filter_with_input(all_boards)

+ 1 - 1
tools/build_family.py

@@ -38,7 +38,7 @@ all_examples.sort()
 # If family are not specified in arguments, build all
 all_families = []
 for entry in os.scandir("hw/bsp"):
-    if entry.is_dir() and os.path.isdir(entry.path + "/boards") and entry.name != "esp32s2":
+    if entry.is_dir() and os.path.isdir(entry.path + "/boards") and entry.name != "esp32sx":
         all_families.append(entry.name)
             
 filter_with_input(all_families)