diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index c09ffe215..ee0d7ef58 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -1,15 +1,16 @@ -# The following five lines of boilerplate have to be in your project's -# CMakeLists in this exact order for cmake to work correctly 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) -# Add example src and bsp directories -set(EXTRA_COMPONENT_DIRS "src" "${TOP}/hw/bsp/esp32s2/boards" "${TOP}/hw/bsp/esp32s2/components") +# Check for -DFAMILY= +if(NOT DEFINED FAMILY) + message(FATAL_ERROR "Invalid FAMILY specified") +endif() -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(SUPPORTED_TARGETS esp32s2) +include(${TOP}/hw/bsp/${FAMILY}/family.cmake) project(board_test) + +include(${TOP}/hw/bsp/${FAMILY}/family_extra.cmake OPTIONAL) diff --git a/examples/make.mk b/examples/make.mk index bf3b36a62..da0f60d2f 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -40,7 +40,7 @@ ifeq ($(FAMILY),) include $(TOP)/hw/bsp/$(BOARD)/board.mk else # Include Family and Board specific defs - include $(TOP)/$(FAMILY_PATH)/family.mk + -include $(TOP)/$(FAMILY_PATH)/family.mk SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c)) endif diff --git a/examples/rules.mk b/examples/rules.mk index fb1fe76c2..b61af1d55 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -2,34 +2,46 @@ # Common make rules for all examples # --------------------------------------- -ifeq ($(CROSS_COMPILE),xtensa-esp32s2-elf-) +ifeq ($(FAMILY),esp32s2) # Espressif IDF use CMake build system, this add wrapper target to call idf.py .PHONY: all clean flash .DEFAULT_GOAL := all all: - idf.py -B$(BUILD) -DBOARD=$(BOARD) build + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) build build: all clean: - idf.py -B$(BUILD) -DBOARD=$(BOARD) clean + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) clean + +fullclean: + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) fullclean flash: - idf.py -B$(BUILD) -DBOARD=$(BOARD) flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) flash bootloader-flash: - idf.py -B$(BUILD) -DBOARD=$(BOARD) bootloader-flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) bootloader-flash app-flash: - idf.py -B$(BUILD) -DBOARD=$(BOARD) app-flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) app-flash erase: - idf.py -B$(BUILD) -DBOARD=$(BOARD) erase_flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) erase_flash monitor: - idf.py -B$(BUILD) -DBOARD=$(BOARD) monitor + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) monitor + +else ifeq ($(FAMILY),rp2040) + +all: + [ -d $(BUILD) ] || cmake -S . -B $(BUILD) -DFAMILY=$(FAMILY) -DPICO_BUILD_DOCS=0 + $(MAKE) -C $(BUILD) + +clean: + $(RM) -rf $(BUILD) else # GNU Make build system diff --git a/hw/bsp/esp32s2/family.cmake b/hw/bsp/esp32s2/family.cmake new file mode 100644 index 000000000..c19221b14 --- /dev/null +++ b/hw/bsp/esp32s2/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/esp32s2/boards" "${TOP}/hw/bsp/esp32s2/components") +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +set(SUPPORTED_TARGETS esp32s2) diff --git a/hw/bsp/esp32s2/family.mk b/hw/bsp/esp32s2/family.mk deleted file mode 100644 index 167ef6226..000000000 --- a/hw/bsp/esp32s2/family.mk +++ /dev/null @@ -1,2 +0,0 @@ -# Cross Compiler for ESP32 -CROSS_COMPILE = xtensa-esp32s2-elf- diff --git a/hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c b/hw/bsp/rp2040/boards/raspberry_pi_pico/board_raspberry_pi_pico.c similarity index 100% rename from hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c rename to hw/bsp/rp2040/boards/raspberry_pi_pico/board_raspberry_pi_pico.c diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake new file mode 100644 index 000000000..8a3882cc0 --- /dev/null +++ b/hw/bsp/rp2040/family.cmake @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.12) +set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) +include(${PICO_SDK_PATH}/pico_sdk_init.cmake) diff --git a/hw/bsp/rp2040/family_extra.cmake b/hw/bsp/rp2040/family_extra.cmake new file mode 100644 index 000000000..661845844 --- /dev/null +++ b/hw/bsp/rp2040/family_extra.cmake @@ -0,0 +1 @@ +pico_sdk_init()