Commit 4bc2810c authored by Roman Okhrimenko's avatar Roman Okhrimenko Committed by Roman Okhrimenko
Browse files

cypress: Rework makefiles, reorganise source, add 062_1M and 062_512k support

parent 48281627
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -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 @@ ifneq ($(COMPILER), GCC_ARM)
$(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)
@@ -58,10 +63,20 @@ endif
# Define start of application, RAM start and size, slot size
ifeq ($(PLATFORM), PSOC_062_2M)
	DEFINES_APP += -DRAM_START=0x08040000
	DEFINES_APP += -DRAM_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
endif


# Collect Test Application sources
SOURCES_APP_SRC := $(wildcard $(CUR_APP_PATH)/*.c)
@@ -80,6 +95,7 @@ $(error Only GCC ARM is supported at this moment)
endif

ASM_FILES_APP :=
ASM_FILES_APP += $(ASM_FILES_STARTUP)

# We still need this for MCUBoot apps signing
IMGTOOL_PATH ?=	../../scripts/imgtool.py
+1 −34
Original line number Diff line number Diff line
@@ -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/*.
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/pin_pac
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)
+6 −0
Original line number Diff line number Diff line
@@ -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
+0 −109
Original line number Diff line number Diff line
################################################################################
# \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
+11 −1
Original line number Diff line number Diff line
@@ -63,7 +63,8 @@ MEMORY
     * Your changes must be aligned with the corresponding memory regions for the CM4 core in 'xx_cm4_dual.ld',
     * where 'xx' is the device group; for example, 'cy8c6xx7_cm4_dual.ld'.
     */
    ram               (rwx)   : ORIGIN = 0x08020000, LENGTH = 0x20000
    public_ram        (rw)    : ORIGIN = 0x08000000, LENGTH = 0x800
    ram               (rwx)   : ORIGIN = 0x08000800, LENGTH = 0x1F800
    flash             (rx)    : ORIGIN = 0x10000000, LENGTH = 0x18000

    /* This is a 32K flash region used for EEPROM emulation. This region can also be used as the general purpose flash.
@@ -233,6 +234,15 @@ SECTIONS
        __ram_vectors_end__   = .;
    } > ram

    /* Unprotected public RAM */
    .cy_sharedmem (NOLOAD):
    {
        . = ALIGN(4);
        __public_ram_start__ = .;
        KEEP(*(.cy_sharedmem))
        . = ALIGN(4);
        __public_ram_end__ = .;
    } > public_ram

    .data __ram_vectors_end__ : AT (__etext)
    {
Loading