diff --git a/ports/psoc6/Makefile b/ports/psoc6/Makefile index 40d2de9a849ab..5ce58de782cd2 100644 --- a/ports/psoc6/Makefile +++ b/ports/psoc6/Makefile @@ -1,13 +1,35 @@ -# get active board from mtb-lib makefile -# mtb-lib makefile set TARGET board by using -# "mtb_set_bsp" target or targets depending on it -# as "mtb_init". +BOARD ?= + +# Check if the ModusToolbox setup has been initialized +# If that is the case, get active board MTB_LIB_DIR = mtb-libs -MTB_LIB_MAKEFILE = $(MTB_LIB_DIR)/Makefile -BOARD ?= $(shell egrep '^ *TARGET' $(MTB_LIB_MAKEFILE) | sed 's/^.*= *//g' | sed 's/APP_//') +MTB_LIBS_APP_INFO = $(MTB_LIB_DIR)/build/get_app_info.txt +ifneq ($(wildcard $(MTB_LIBS_APP_INFO)),) + ACTIVE_BOARD = $(shell egrep '^ *MTB_TARGET' $(MTB_LIBS_APP_INFO) | sed 's/^.*= *//g' | sed 's/APP_//') +endif + +# Get active board from mtb-lib previous runs +# The board is set only after make mtb_init +# has been run. +ifeq ($(BOARD),) + ifeq ($(ACTIVE_BOARD),) + $(error ModusToolbox not initialized. Run "make mtb_init BOARD=" to configure the environment. ) + else + BOARD = $(ACTIVE_BOARD) + endif +else + ifneq ($(ACTIVE_BOARD),) + ifneq ($(ACTIVE_BOARD), $(BOARD)) + $(info Active PSoC6 board : $(ACTIVE_BOARD)) + $(info PSoc6 board : $(BOARD)) + $(error Active BOARD is different from passed BOARD. Re-run "make mtb_init BOARD=" to set another board. ) + endif + endif +endif + BOARD_DIR = boards/$(BOARD) -$(info Active PSoC6 board : $(BOARD)) +$(info PSoC6 board : $(BOARD)) ifeq ($(wildcard $(BOARD_DIR)/.),) $(error Invalid BOARD specified) @@ -79,7 +101,6 @@ else MICROPY_ROM_TEXT_COMPRESSION ?= 1 endif - $(info Compiling in $(CONFIG) mode !) #ToDo: Post adding af functionality, refactor to minimize dependent variables in py script if possible @@ -163,7 +184,7 @@ SRC_C = help.c \ main.c \ mphalport.c \ frozen_content.c \ - $(BUILD)/pins_$(BOARD).c + pins_$(BOARD).c SRC_ASM += shared/runtime/gchelper_thumb1.s diff --git a/ports/psoc6/mtb-libs/Makefile b/ports/psoc6/mtb-libs/Makefile index 219ad25170124..c266b5ea44993 100755 --- a/ports/psoc6/mtb-libs/Makefile +++ b/ports/psoc6/mtb-libs/Makefile @@ -42,12 +42,7 @@ MTB_TYPE=COMBINED # configurations. If TARGET is manually edited, ensure TARGET_.mtb with a # valid URL exists in the application, run 'make getlibs' to fetch BSP contents # and update or regenerate launch configurations for your IDE. -TARGET=APP_CY8CPROTO-062-4343W - -# # Board dependencies -# ifeq ($(TARGET),APP_CY8CPROTO-062-4343W) -# NETWORK_ENABLE = 1 -# endif +TARGET=APP_$(BOARD) # Name of application (used to derive name of final linked file). # diff --git a/ports/psoc6/mtb-libs/makefile_mtb.mk b/ports/psoc6/mtb-libs/makefile_mtb.mk index c9303d4edd7a2..fba8d4581ccb1 100644 --- a/ports/psoc6/mtb-libs/makefile_mtb.mk +++ b/ports/psoc6/mtb-libs/makefile_mtb.mk @@ -1,18 +1,18 @@ # get variable definitions from main makefile MTB_LIBS_DIR = mtb-libs MTB_MAIN_MAKEFILE := $(MTB_LIBS_DIR)/Makefile -MTB_TARGET := $(shell egrep '^ *TARGET' $(MTB_MAIN_MAKEFILE) | sed 's/^.*= *//g') +# MTB_TARGET := $(shell egrep '^ *TARGET' $(MTB_MAIN_MAKEFILE) | sed 's/^.*= *//g') MTB_CONFIG ?= $(shell egrep '^ *CONFIG' $(MTB_MAIN_MAKEFILE) | sed 's/^.*= *//g') MTB_LIBS_BUILD_DIR := $(MTB_LIBS_DIR)/$(BUILD) -MTB_LIBS_BOARD_BUILD_DIR := $(MTB_LIBS_BUILD_DIR)/$(MTB_TARGET)/$(MPY_MTB_CONFIG) +MTB_LIBS_BOARD_BUILD_DIR := $(MTB_LIBS_BUILD_DIR)/APP_$(BOARD)/$(MPY_MTB_CONFIG) -MPY_MTB_LIB_NAME = $(file < $(MTB_LIBS_BOARD_BUILD_DIR)/artifact.rsp) +MTB_STATIC_LIB_NAME = $(file < $(MTB_LIBS_BOARD_BUILD_DIR)/artifact.rsp) $(info MTB_MAIN_MAKEFILE : $(MTB_MAIN_MAKEFILE)) -$(info MTB_TARGET : $(MTB_TARGET)) +$(info MTB_TARGET : APP_$(BOARD)) $(info MTB_CONFIG : $(MTB_CONFIG)) -$(info MTB_LIB_NAME : $(MPY_MTB_LIB_NAME)) +$(info MTB_LIB_NAME : $(MTB_STATIC_LIB_NAME)) $(info MTB_LIBS_BUILD_DIR : $(MTB_LIBS_BUILD_DIR)) $(info MTB_LIBS_BOARD_BUILD_DIR : $(MTB_LIBS_BOARD_BUILD_DIR)) @@ -77,7 +77,7 @@ mtb_deinit: clean # Some of the configuration variables are passed to the ModusToolbox # Makefile to include/exclude certain middleware libraries and components -MPY_MTB_MAKE_VARS = MICROPY_PY_NETWORK=$(MICROPY_PY_NETWORK) MICROPY_PY_SSL=$(MICROPY_PY_SSL) +MPY_MTB_MAKE_VARS = MICROPY_PY_NETWORK=$(MICROPY_PY_NETWORK) MICROPY_PY_SSL=$(MICROPY_PY_SSL) BOARD=$(BOARD) # build MTB project mtb_build: @@ -96,7 +96,7 @@ mtb_get_build_flags: mtb_build $(eval INC += $(subst -I,-I$(MTB_LIBS_DIR)/,$(MPY_MTB_INCLUDE_DIRS))) $(eval INC += -I$(BOARD_DIR)) $(eval MPY_MTB_LIBRARIES = $(file < $(MTB_LIBS_BOARD_BUILD_DIR)/liblist.rsp)) - $(eval LIBS += $(MTB_LIBS_BOARD_BUILD_DIR)/$(MPY_MTB_LIB_NAME)) + $(eval LIBS += $(MTB_LIBS_BOARD_BUILD_DIR)/$(MTB_STATIC_LIB_NAME)) $(eval CFLAGS += $(shell $(PYTHON) $(MTB_LIBS_DIR)/mtb_build_info.py ccxxflags $(MTB_LIBS_BOARD_BUILD_DIR)/.cycompiler )) $(eval CXXFLAGS += $(CFLAGS)) $(eval LDFLAGS += $(shell $(PYTHON) $(MTB_LIBS_DIR)/mtb_build_info.py ldflags $(MTB_LIBS_BOARD_BUILD_DIR)/.cylinker $(MTB_LIBS_DIR)))