cypress: Rework makefiles, reorganise source, add 062_1M and 062_512k support
Signed-off-by: Roman Okhrimenko <roman.okhrimenko@cypress.com>
Signed-off-by: Roman Okhrimenko <roman.okhrimenko@infineon.com>
diff --git a/boot/cypress/BlinkyApp/BlinkyApp.mk b/boot/cypress/BlinkyApp/BlinkyApp.mk
index c60f27e..5ff2080 100644
--- a/boot/cypress/BlinkyApp/BlinkyApp.mk
+++ b/boot/cypress/BlinkyApp/BlinkyApp.mk
@@ -23,6 +23,8 @@
# limitations under the License.
################################################################################
+include host.mk
+
# Cypress' MCUBoot Application supports GCC ARM only at this moment
# Set defaults to:
# - compiler GCC
@@ -31,6 +33,9 @@
COMPILER ?= GCC_ARM
IMG_TYPE ?= BOOT
+# For which core this application is built
+CORE ?= CM4
+
# image type can be BOOT or UPGRADE
IMG_TYPES = BOOT UPGRADE
@@ -42,11 +47,11 @@
$(error Only GCC ARM is supported at this moment)
endif
-CUR_APP_PATH = $(CURDIR)/$(APP_NAME)
+CUR_APP_PATH = $(PRJ_DIR)/$(APP_NAME)
-include $(CUR_APP_PATH)/platforms.mk
-include $(CUR_APP_PATH)/libs.mk
-include $(CUR_APP_PATH)/toolchains.mk
+include $(PRJ_DIR)/platforms.mk
+include $(PRJ_DIR)/common_libs.mk
+include $(PRJ_DIR)/toolchains.mk
# Application-specific DEFINES
ifeq ($(IMG_TYPE), BOOT)
@@ -59,10 +64,20 @@
ifeq ($(PLATFORM), PSOC_062_2M)
DEFINES_APP += -DRAM_START=0x08040000
DEFINES_APP += -DRAM_SIZE=0x10000
- DEFINES_APP += -DUSER_APP_START=0x10018000
- SLOT_SIZE ?= 0x10000
+else ifeq ($(PLATFORM), PSOC_062_1M)
+ DEFINES_APP += -DRAM_START=0x08020000
+ DEFINES_APP += -DRAM_SIZE=0x10000
+else ifeq ($(PLATFORM), PSOC_062_512K)
+ DEFINES_APP += -DRAM_START=0x08020000
+ DEFINES_APP += -DRAM_SIZE=0x10000
endif
+
+DEFINES_APP += -DRAM_SIZE=0x10000
+DEFINES_APP += -DUSER_APP_START=0x10018000
+SLOT_SIZE ?= 0x10000
+
+
# Collect Test Application sources
SOURCES_APP_SRC := $(wildcard $(CUR_APP_PATH)/*.c)
# Collect all the sources
@@ -80,6 +95,7 @@
endif
ASM_FILES_APP :=
+ASM_FILES_APP += $(ASM_FILES_STARTUP)
# We still need this for MCUBoot apps signing
IMGTOOL_PATH ?= ../../scripts/imgtool.py
diff --git a/boot/cypress/BlinkyApp/libs.mk b/boot/cypress/BlinkyApp/libs.mk
index 9f1846c..7994d13 100644
--- a/boot/cypress/BlinkyApp/libs.mk
+++ b/boot/cypress/BlinkyApp/libs.mk
@@ -28,10 +28,7 @@
################################################################################
PDL_VERSION = 121
#
-CUR_LIBS_PATH = $(CURDIR)/libs
-
-# Collect source files for PDL
-SOURCES_PDL := $(wildcard $(CUR_LIBS_PATH)/pdl/psoc6pdl/drivers/source/*.c)
+CUR_LIBS_PATH = $(PRJ_DIR)/libs
# Collect source files for Retarget-io
SOURCES_RETARGET_IO := $(wildcard $(CUR_LIBS_PATH)/retarget-io/*.c)
@@ -42,19 +39,10 @@
SOURCES_HAL += $(wildcard $(CUR_LIBS_PATH)/psoc6hal/COMPONENT_PSOC6HAL/source/triggers/*.c)
SOURCES_HAL += $(wildcard $(CUR_LIBS_PATH)/psoc6hal/COMPONENT_PSOC6HAL/source/pin_packages/*.c)
-# PDL related include directories
-INCLUDE_DIRS_PDL := $(CUR_LIBS_PATH)/pdl/psoc6pdl/drivers/include
-INCLUDE_DIRS_PDL += $(CUR_LIBS_PATH)/pdl/psoc6pdl/devices/include/ip
-INCLUDE_DIRS_PDL += $(CUR_LIBS_PATH)/pdl/psoc6pdl/devices/include
-INCLUDE_DIRS_PDL += $(CUR_LIBS_PATH)/pdl/psoc6pdl/cmsis/include
-
# Retarget-io related include directories
INCLUDE_DIRS_RETARGET_IO := $(CUR_LIBS_PATH)/retarget-io
INCLUDE_DIRS_WATCHDOG := $(CUR_LIBS_PATH)/watchdog
-# core-libs related include directories
-INCLUDE_DIRS_CORE_LIB := $(CUR_LIBS_PATH)/core-lib/include
-
# Collect dirrectories containing headers for PSOC6 HAL
INCLUDE_DIRS_HAL := $(CUR_LIBS_PATH)/psoc6hal/include
INCLUDE_DIRS_HAL += $(CUR_LIBS_PATH)/psoc6hal/COMPONENT_PSOC6HAL/include
@@ -62,32 +50,11 @@
INCLUDE_DIRS_HAL += $(CUR_LIBS_PATH)/psoc6hal/COMPONENT_PSOC6HAL/include/triggers
# Collected source files for libraries
-SOURCES_LIBS := $(SOURCES_PDL)
-SOURCES_LIBS += $(SOURCES_PLATFORM)
SOURCES_LIBS += $(SOURCES_RETARGET_IO)
SOURCES_LIBS += $(SOURCES_WATCHDOG)
SOURCES_LIBS += $(SOURCES_HAL)
# Collected include directories for libraries
-INCLUDE_DIRS_LIBS := $(addprefix -I,$(INCLUDE_DIRS_PDL))
-INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_DIRS_PLATFORM))
INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_DIRS_RETARGET_IO))
INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_DIRS_WATCHDOG))
-INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_DIRS_CORE_LIB))
INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_DIRS_HAL))
-
-ASM_FILES_PDL :=
-ifeq ($(COMPILER), GCC_ARM)
-ASM_FILES_PDL += $(CUR_LIBS_PATH)/pdl/psoc6pdl/drivers/source/TOOLCHAIN_GCC_ARM/cy_syslib_gcc.S
-else
-$(error Only GCC ARM is supported at this moment)
-endif
-
-ASM_FILES_LIBS := $(ASM_FILES_PDL)
-ASM_FILES_LIBS += $(ASM_FILES_PLATFORM)
-
-# Add define for PDL version
-DEFINES_PDL += -DPDL_VERSION=$(PDL_VERSION)
-
-DEFINES_LIBS := $(DEFINES_PLATFORM)
-DEFINES_LIBS += $(DEFINES_PDL)
diff --git a/boot/cypress/BlinkyApp/main.c b/boot/cypress/BlinkyApp/main.c
index e08fdd0..97e1c84 100644
--- a/boot/cypress/BlinkyApp/main.c
+++ b/boot/cypress/BlinkyApp/main.c
@@ -38,6 +38,12 @@
#warning "Check if User LED is correct for your target board."
#define LED_PORT GPIO_PRT13
#define LED_PIN 7U
+#elif defined(PSOC_062_1M)
+#define LED_PORT GPIO_PRT13
+#define LED_PIN 7U
+#elif defined(PSOC_062_512K)
+#define LED_PORT GPIO_PRT11
+#define LED_PIN 1U
#endif
#define LED_NUM 5U
diff --git a/boot/cypress/BlinkyApp/platforms.mk b/boot/cypress/BlinkyApp/platforms.mk
deleted file mode 100644
index 2f4faf9..0000000
--- a/boot/cypress/BlinkyApp/platforms.mk
+++ /dev/null
@@ -1,109 +0,0 @@
-################################################################################
-# \file targets.mk
-# \version 1.0
-#
-# \brief
-# Makefile to describe supported boards and platforms for Cypress MCUBoot based applications.
-#
-################################################################################
-# \copyright
-# Copyright 2018-2019 Cypress Semiconductor Corporation
-# SPDX-License-Identifier: Apache-2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-################################################################################
-
-# Target PLATFORM BlinkyApp is built for. PSOC_064_2M is set as default
-# Supported:
-# - PSOC_064_2M
-# - PSOC_064_1M
-# - PSOC_064_512K
-# - PSOC_062_2M
-
-# default TARGET
-PLATFORM ?= PSOC_064_2M
-#
-SB_PLATFORMS := PSOC_064_2M PSOC_064_1M PSOC_064_512K
-PLATFORMS := PSOC_062_2M $(SB_PLATFORMS)
-
-# For which core this application is built
-CORE := CM4
-
-# Set paths for related folders
-CUR_LIBS_PATH := $(CURDIR)/libs
-PLATFORMS_PATH := $(CURDIR)/platforms
-PLATFORM_PATH := $(PLATFORMS_PATH)/$(PLATFORM)
-
-# Target dependent definitions
-ifeq ($(PLATFORM), PSOC_064_2M)
-DEVICE ?= CYB0644ABZI-S2D44
-PLATFORM_SUFFIX := 02
-else ifeq ($(PLATFORM), PSOC_064_1M)
-DEVICE ?= CYB06447BZI-BLD53
-PLATFORM_SUFFIX := 01
-else ifeq ($(PLATFORM), PSOC_064_512K)
-DEVICE ?= CYB06445LQI-S3D42
-PLATFORM_SUFFIX := 03
-else ifeq ($(PLATFORM), PSOC_062_2M)
-DEVICE ?= CY8C624ABZI-D44
-PLATFORM_SUFFIX := 02
-endif
-
-# Check if path to cysecuretools is set in case Secure Boot target
-ifneq ($(filter $(PLATFORM), $(SB_PLATFORMS)),)
-ifeq ($(CY_SEC_TOOLS_PATH), )
-$(error Variable CY_SEC_TOOLS_PATH - path to cysecuretools package not set. \
- Use `python -m pip show cysecuretools` to determine intallation folder.` \
- Then set it in Makefile to continue work.)
-endif
-endif
-
-# Collect C source files for PLATFORM
-SOURCES_PLATFORM += $(wildcard $(PLATFORMS_PATH)/*.c)
-SOURCES_PLATFORM += $(wildcard $(PLATFORM_PATH)/$(CORE)/*.c)
-# Exclude system file for cm4
-SOURCES_PLATFORM := $(filter-out %/system_psoc6_cm0plus.c, $(SOURCES_PLATFORM))
-
-# Collect dirrectories containing headers for PLATFORM
-INCLUDE_DIRS_PLATFORM := $(PLATFORMS_PATH)
-INCLUDE_DIRS_PLATFORM += $(PLATFORM_PATH)/$(CORE)
-
-# Collect Assembler files for PLATFORM
-STARTUP_FILE := $(PLATFORM_PATH)/$(CORE)/$(COMPILER)/startup_psoc6_$(PLATFORM_SUFFIX)_cm4
-
-ifeq ($(COMPILER), GCC_ARM)
- ASM_FILES_PLATFORM := $(STARTUP_FILE).S
-else
-$(error Only GCC ARM is supported at this moment)
-endif
-
-# Add device name from PLATFORM makefile to defines
-DEFINES += $(DEVICE)
-
-# Get defines from PLATFORM makefile and convert it to regular -DMY_NAME style
-ifneq ($(DEFINES),)
- DEFINES_PLATFORM :=$(addprefix -D, $(subst -,_,$(DEFINES)))
-endif
-
-DEFINES_PLATFORM += $(addprefix -D, $(PLATFORM))
-
-ifneq ($(COMPILER), GCC_ARM)
-$(error Only GCC ARM is supported at this moment)
-endif
-ifeq ($(MAKEINFO) , 1)
-$(info ==============================================================================)
-$(info = PLATFORM files =)
-$(info ==============================================================================)
-$(info $(SOURCES_PLATFORM))
-$(info $(ASM_FILES_PLATFORM))
-endif
diff --git a/boot/cypress/BlinkyApp/toolchains.mk b/boot/cypress/BlinkyApp/toolchains.mk
deleted file mode 100644
index 55c62d5..0000000
--- a/boot/cypress/BlinkyApp/toolchains.mk
+++ /dev/null
@@ -1,128 +0,0 @@
-################################################################################
-# \file toolchains.mk
-# \version 1.0
-#
-# \brief
-# Makefile to describe supported toolchains for Cypress MCUBoot based applications.
-#
-################################################################################
-# \copyright
-# Copyright 2018-2019 Cypress Semiconductor Corporation
-# SPDX-License-Identifier: Apache-2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-################################################################################
-
-# Compilers
-GCC_ARM := 1
-IAR := 2
-ARM := 3
-OTHER := 4
-
-ifeq ($(MAKEINFO), 1)
-$(info $(COMPILER))
-endif
-# Detect host OS to make resolving compiler pathes easier
-UNAME_S := $(shell uname -s)
-ifeq ($(UNAME_S), Darwin)
- HOST_OS = osx
-else
- ifeq ($(UNAME_S), Linux)
- HOST_OS = linux
- else
- HOST_OS = win
- endif
-endif
-
-# Path to the compiler installation
-# NOTE: Absolute pathes for now for the sake of development
-ifeq ($(HOST_OS), win)
- ifeq ($(COMPILER), GCC_ARM)
- TOOLCHAIN_PATH ?= c:/Users/$(USERNAME)/ModusToolbox/tools_2.1/gcc-7.2.1
- MY_TOOLCHAIN_PATH:=$(subst \,/,$(TOOLCHAIN_PATH))
- TOOLCHAIN_PATH := $(MY_TOOLCHAIN_PATH)
- GCC_PATH := $(TOOLCHAIN_PATH)
- # executables
- CC := "$(GCC_PATH)/bin/arm-none-eabi-gcc"
- LD := $(CC)
-
- else ifeq ($(COMPILER), IAR)
- IAR_PATH := C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/arm
- # executables
- CC := "$(IAR_PATH)/bin/iccarm.exe"
- AS := "$(IAR_PATH)/bin/iasmarm.exe"
- LD := "$(IAR_PATH)/bin/ilinkarm.exe"
- endif
-
-else ifeq ($(HOST_OS), osx)
- TOOLCHAIN_PATH ?= /opt/gcc-arm-none-eabi
- GCC_PATH := $(TOOLCHAIN_PATH)
-
- CC := "$(GCC_PATH)/bin/arm-none-eabi-gcc"
- LD := $(CC)
-
-else ifeq ($(HOST_OS), linux)
- TOOLCHAIN_PATH ?= /usr/bin/gcc-arm-none-eabi/bin/arm-none-eabi-gcc
- GCC_PATH := $(TOOLCHAIN_PATH)
- # executables
- CC := "$(GCC_PATH)/bin/arm-none-eabi-gcc"
- LD := $(CC)
-endif
-
-PDL_ELFTOOL := "hal/tools/$(HOST_OS)/elf/cymcuelftool"
-
-OBJDUMP := "$(GCC_PATH)/bin/arm-none-eabi-objdump"
-OBJCOPY := "$(GCC_PATH)/bin/arm-none-eabi-objcopy"
-
-# Set flags for toolchain executables
-ifeq ($(COMPILER), GCC_ARM)
- # set build-in compiler flags
- CFLAGS_COMMON := -mcpu=cortex-m4 -mthumb -mfloat-abi=soft -fno-stack-protector -ffunction-sections -fdata-sections -ffat-lto-objects -fstrict-aliasing -g -Wall -Wextra
- ifeq ($(BUILDCFG), Debug)
- CFLAGS_COMMON += -Og -g3
- else ifeq ($(BUILDCFG), Release)
- CFLAGS_COMMON += -Os -g
- else
- $(error BUILDCFG : '$(BUILDCFG)' is not supported)
- endif
- # add defines and includes
- CFLAGS := $(CFLAGS_COMMON) $(INCLUDES)
- CC_DEPEND = -MD -MP -MF
-
- LDFLAGS_COMMON := -mcpu=cortex-m4 -mthumb -specs=nano.specs -ffunction-sections -fdata-sections -Wl,--gc-sections -L "$(GCC_PATH)/lib/gcc/arm-none-eabi/7.2.1/thumb/v6-m" -ffat-lto-objects -g --enable-objc-gc
- ifeq ($(BUILDCFG), Debug)
- LDFLAGS_COMMON += -Og
- else ifeq ($(BUILDCFG), Release)
- LDFLAGS_COMMON += -Os
- else
- $(error BUILDCFG : '$(BUILDCFG)' is not supported)
- endif
- LDFLAGS_NANO := -L "$(GCC_PATH)/arm-none-eabi/lib/thumb/v6-m"
- LDFLAGS := $(LDFLAGS_COMMON) $(LDFLAGS_NANO)
-
-else ifeq ($(COMPILER), IAR)
-
- CFLAGS := --debug --endian=little --cpu=Cortex-M4 -e --fpu=None --dlib_config "$(IAR_PATH)\INC\c\DLib_Config_Normal.h"
- CFLAGS += -Ohz --silent
- CFLAGS += $(INCLUDES)
- CC_DEPEND = --dependencies
-
- AS_FLAGS := -s+ "-M<>" -w+ -r --cpu Cortex-M4 --fpu None -S
-
- LINKER_SCRIPT := $(CHIP_SERIES).icf
-
- #options to extend stack analize: --log call_graph --log_file $(OUT)/stack_usage_$(SUFFIX).txt
- LDFLAGS_STACK_USAGE := --stack_usage_control $(STACK_CONTROL_FILE) --diag_suppress=Ls015 --diag_suppress=Ls016
- LDFLAGS_COMMON := --vfe --text_out locale --silent --inline --merge_duplicate_sections
- LDFLAGS := $(LDFLAGS_COMMON) $(LDFLAGS_STACK_USAGE) --config $(LINKER_SCRIPT) --map $(OUT_TARGET)/$(APP_NAME).map --entry Cy_FB_ResetHandler --no_exceptions
-endif