update cmake build to work with esp32s2 and rp2040

This commit is contained in:
hathach 2021-01-22 14:58:32 +07:00
parent 67a9cdc35b
commit b6e9c42b02
8 changed files with 38 additions and 17 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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)

View File

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

View File

@ -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)

View File

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