Explorar o código

update cmake build to work with esp32s2 and rp2040

hathach %!s(int64=5) %!d(string=hai) anos
pai
achega
b6e9c42b02

+ 7 - 6
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)

+ 1 - 1
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

+ 20 - 8
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

+ 6 - 0
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)

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

@@ -1,2 +0,0 @@
-# Cross Compiler for ESP32
-CROSS_COMPILE = xtensa-esp32s2-elf-

+ 0 - 0
hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c → hw/bsp/rp2040/boards/raspberry_pi_pico/board_raspberry_pi_pico.c


+ 3 - 0
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)

+ 1 - 0
hw/bsp/rp2040/family_extra.cmake

@@ -0,0 +1 @@
+pico_sdk_init()