Skip to content
Permalink
dedd43b505
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
404 lines (348 sloc) 15.2 KB
################################################################################
# \file Makefile
# \version 1.0
#
# \brief
# Top-level application make file.
#
################################################################################
# \copyright
# Copyright 2022, Cypress Semiconductor Corporation (an Infineon company)
# 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.
################################################################################
################################################################################
# Basic Configuration
################################################################################
-include ./libs/mtb.mk
# Target board/hardware (BSP).
# To change the target, it is recommended to use the Library manager
# ('make modlibs' from command line), which will also update Eclipse IDE launch
# configurations. If TARGET is manually edited, ensure TARGET_<BSP>.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=CY8CKIT-064S0S2-4343W
# Underscore needed for $(TARGET) directory
TARGET_UNDERSCORE=$(subst -,_,$(TARGET))
# Core processor
CORE?=CM4
# Name of application (used to derive name of final linked file).
#
# If APPNAME is edited, ensure to update or regenerate launch
# configurations for your IDE.
APPNAME=mtb-example-aws-iot-ota-mqtt
# Name of toolchain to use. Options include:
#
# GCC_ARM -- GCC provided with ModusToolbox IDE
# ARM -- ARM Compiler (must be installed separately)
# IAR -- IAR Compiler (must be installed separately)
#
# See also: CY_COMPILER_PATH below
TOOLCHAIN=GCC_ARM
# Default build configuration. Options include:
#
# Debug -- build with minimal optimizations, focus on debugging.
# Release -- build with full optimizations
# Custom -- build with custom configuration, set the optimization flag in CFLAGS
#
# If CONFIG is manually edited, ensure to update or regenerate launch configurations
# for your IDE.
CONFIG=Debug
# If set to "true" or "1", display full command-lines when building.
VERBOSE=
# Set to 1 to add OTA defines, sources, and libraries (must be used with MCUBoot)
# NOTE: Extra code must be called from your app to initialize the OTA middleware.
OTA_SUPPORT=1
# Set to 1 to add OTA external Flash support.
OTA_USE_EXTERNAL_FLASH?=1
################################################################################
# Advanced Configuration
################################################################################
# Enable optional code that is ordinarily disabled by default.
#
# Available components depend on the specific targeted hardware and firmware
# in use. In general, if you have
#
# COMPONENTS=foo bar
#
# ... then code in directories named COMPONENT_foo and COMPONENT_bar will be
# added to the build
#
COMPONENTS=FREERTOS MBEDTLS LWIP SECURE_SOCKETS
# Like COMPONENTS, but disable optional code that was enabled by default.
DISABLE_COMPONENTS=
# By default the build system automatically looks in the Makefile's directory
# tree for source code and builds it. The SOURCES variable can be used to
# manually add source code to the build process from a location not searched
# by default, or otherwise not found by the build system.
SOURCES=
# Like SOURCES, but for include directories. Value should be paths to
# directories (without a leading -I).
INCLUDES = ./configs
INCLUDES += $(SEARCH_anycloud-ota)/configs
ifeq ($(TARGET), CY8CKIT-064S0S2-4343W)
# Add the trusted firmware library include path before the MbedTLS library include path
INCLUDES += $(call CY_MACRO_FINDLIB,trusted-firmware-m)/COMPONENT_TFM_NS_INTERFACE/include
DEFINES = CY_TFM_PSA_SUPPORTED TFM_MULTI_CORE_NS_OS CY_SECURE_SOCKETS_PKCS_SUPPORT
else
CY_IGNORE = $(SEARCH_trusted-firmware-m) $(SEARCH_freertos-pkcs11-psa)
endif
# Custom configuration of mbedtls library.
MBEDTLSFLAGS = MBEDTLS_USER_CONFIG_FILE='"mbedtls_user_config.h"'
# Add additional defines to the build process (without a leading -D).
DEFINES += $(MBEDTLSFLAGS) CYBSP_WIFI_CAPABLE CY_RTOS_AWARE CY_RETARGET_IO_CONVERT_LF_TO_CRLF CY_OTA_FLASH_SUPPORT
# Disable custom http config header file
DEFINES += HTTP_DO_NOT_USE_CUSTOM_CONFIG
# CY8CPROTO-062-4343W board shares the same GPIO for the user button (USER BTN1)
# and the CYW4343W host wake up pin. Since this example uses the GPIO for
# interfacing with the user button, the SDIO interrupt to wake up the host is
# disabled by setting CY_WIFI_HOST_WAKE_SW_FORCE to '0'.
ifeq ($(TARGET), CY8CPROTO-062-4343W)
DEFINES+=CY_WIFI_HOST_WAKE_SW_FORCE=0
endif
# Select softfp or hardfp floating point. Default is softfp.
VFP_SELECT=
# Additional / custom C compiler flags.
#
# NOTE: Includes and defines should use the INCLUDES and DEFINES variable
# above.
CFLAGS=
# Additional / custom C++ compiler flags.
#
# NOTE: Includes and defines should use the INCLUDES and DEFINES variable
# above.
CXXFLAGS=
# Additional / custom assembler flags.
#
# NOTE: Includes and defines should use the INCLUDES and DEFINES variable
# above.
ASFLAGS=
# Additional / custom linker flags.
ifeq ($(TOOLCHAIN),GCC_ARM)
LDFLAGS=-Wl,--undefined=uxTopUsedPriority
else
ifeq ($(TOOLCHAIN),IAR)
LDFLAGS=--keep uxTopUsedPriority
else
ifeq ($(TOOLCHAIN),ARM)
LDFLAGS=--undefined=uxTopUsedPriority
else
LDFLAGS=
endif
endif
endif
# Additional / custom libraries to link in to the application.
LDLIBS=
# Path to the linker script to use (if empty, use the default linker script).
LINKER_SCRIPT=
# Custom pre-build commands to run.
PREBUILD=
# Custom post-build commands to run.
POSTBUILD=
# Check for default Version values
# Change the version here or over-ride by setting an environment variable
# before building the application.
#
# Example: export APP_VERSION_MAJOR=2
#
APP_VERSION_MAJOR?=1
APP_VERSION_MINOR?=0
APP_VERSION_BUILD?=0
###########################################################################
# OTA Support
###########################################################################
ifeq ($(OTA_SUPPORT),1)
# IMPORTANT NOTE: These defines are also used in the building of MCUBOOT
# they must EXACTLY match the values added to
# mcuboot/boot/cypress/MCUBootApp/MCUBootApp.mk
#
# Must be a multiple of 1024 (must leave __vectors on a 1k boundary)
MCUBOOT_HEADER_SIZE=0x400
MCUBOOT_IMAGE_NUMBER=1
ifeq ($(TARGET),CY8CKIT-064S0S2-4343W)
OTA_USE_EXTERNAL_FLASH=1
CY_FLASH_ERASE_VALUE=0xFF
MCUBOOT_MAX_IMG_SECTORS=2000
MCUBOOT_BOOTLOADER_SIZE=0x00050000
CY_BOOT_SCRATCH_SIZE=0x00001000
CY_BOOT_BOOTLOADER_SIZE=$(MCUBOOT_BOOTLOADER_SIZE)
CY_BOOT_PRIMARY_1_START=0x00050000
CY_BOOT_PRIMARY_1_SIZE=0x11C000
CY_BOOT_SECONDARY_1_START=0x00024400
CY_BOOT_SECONDARY_1_SIZE=$(CY_BOOT_PRIMARY_1_SIZE)
CY_SECURE_POLICY_NAME=policy_multi_CM0_CM4_tfm_dev_certs
else
ifeq ($(TARGET),CY8CKIT-064B0S2-4343W)
OTA_USE_EXTERNAL_FLASH=1
CY_FLASH_ERASE_VALUE=0xFF
MCUBOOT_MAX_IMG_SECTORS=3584
MCUBOOT_BOOTLOADER_SIZE=0x00000000
CY_BOOT_SCRATCH_SIZE=0x000C0000
CY_BOOT_BOOTLOADER_SIZE=$(MCUBOOT_BOOTLOADER_SIZE)
CY_BOOT_PRIMARY_1_START=0x00000000
CY_BOOT_PRIMARY_1_SIZE=0x001C8000
CY_BOOT_SECONDARY_1_START=0x00038400
CY_BOOT_SECONDARY_1_SIZE=$(CY_BOOT_PRIMARY_1_SIZE)
CY_SECURE_POLICY_NAME=policy_single_CM0_CM4_smif_swap
else
# For kits other than CY8CKIT-064B0S2-4343W & CY8CKIT-064S0S2-4343W
ifeq ($(OTA_USE_EXTERNAL_FLASH),1)
MCUBOOT_MAX_IMG_SECTORS=3584
CY_BOOT_SCRATCH_SIZE=0x00004000
MCUBOOT_BOOTLOADER_SIZE=0x00018000
CY_BOOT_BOOTLOADER_SIZE=$(MCUBOOT_BOOTLOADER_SIZE)
CY_BOOT_PRIMARY_1_START=0x00018000
CY_BOOT_PRIMARY_1_SIZE=0x001C0000
CY_BOOT_SECONDARY_1_START=0x00000000
CY_BOOT_SECONDARY_1_SIZE=0x001C0000
CY_FLASH_ERASE_VALUE=0xFF
else
MCUBOOT_MAX_IMG_SECTORS=32
CY_BOOT_SCRATCH_SIZE=0x00010000
MCUBOOT_BOOTLOADER_SIZE=0x00018000
CY_BOOT_BOOTLOADER_SIZE=$(MCUBOOT_BOOTLOADER_SIZE)
CY_BOOT_PRIMARY_1_START=0x00018000
CY_BOOT_PRIMARY_1_SIZE=0x000EE000
CY_BOOT_SECONDARY_1_SIZE=$(CY_BOOT_PRIMARY_1_SIZE)
CY_BOOT_PRIMARY_2_SIZE=0x01000
CY_BOOT_SECONDARY_2_START=0x001E0000
CY_FLASH_ERASE_VALUE=0x00
endif
endif
endif
ifeq ($(OTA_USE_EXTERNAL_FLASH),1)
DEFINES+=CY_BOOT_USE_EXTERNAL_FLASH=1
endif
DEFINES+=OTA_SUPPORT=1 \
MCUBOOT_HEADER_SIZE=$(MCUBOOT_HEADER_SIZE) \
MCUBOOT_MAX_IMG_SECTORS=$(MCUBOOT_MAX_IMG_SECTORS) \
CY_BOOT_SCRATCH_SIZE=$(CY_BOOT_SCRATCH_SIZE) \
MCUBOOT_IMAGE_NUMBER=1\
MCUBOOT_BOOTLOADER_SIZE=$(MCUBOOT_BOOTLOADER_SIZE) \
CY_BOOT_BOOTLOADER_SIZE=$(CY_BOOT_BOOTLOADER_SIZE) \
CY_BOOT_PRIMARY_1_START=$(CY_BOOT_PRIMARY_1_START) \
CY_BOOT_PRIMARY_1_SIZE=$(CY_BOOT_PRIMARY_1_SIZE) \
CY_BOOT_SECONDARY_1_START=$(CY_BOOT_SECONDARY_1_START) \
CY_BOOT_SECONDARY_1_SIZE=$(CY_BOOT_SECONDARY_1_SIZE) \
CY_BOOT_PRIMARY_2_SIZE=$(CY_BOOT_PRIMARY_2_SIZE) \
CY_BOOT_SECONDARY_2_START=$(CY_BOOT_SECONDARY_2_START) \
CY_FLASH_ERASE_VALUE=$(CY_FLASH_ERASE_VALUE)\
APP_VERSION_MAJOR=$(APP_VERSION_MAJOR)\
APP_VERSION_MINOR=$(APP_VERSION_MINOR)\
APP_VERSION_BUILD=$(APP_VERSION_BUILD)
CY_HEX_TO_BIN="$(CY_COMPILER_GCC_ARM_DIR)/bin/arm-none-eabi-objcopy"
CY_BUILD_VERSION=$(APP_VERSION_MAJOR).$(APP_VERSION_MINOR).$(APP_VERSION_BUILD)
# build location
BUILD_LOCATION=./build
# output directory for use in the sign_script.bash
OUTPUT_FILE_PATH=$(BUILD_LOCATION)/$(TARGET)/$(CONFIG)
ifeq ($(TARGET),CY8CKIT-064S0S2-4343W)
# Secure boards (PSoC64)
UPGRADE_HEX=$(OUTPUT_FILE_PATH)/$(APPNAME)_upgrade.hex
UPGRADE_BIN=$(OUTPUT_FILE_PATH)/$(APPNAME).bin
# Convert hex to bin
POSTBUILD=$(CY_HEX_TO_BIN) --input-target=ihex --output-target=binary $(UPGRADE_HEX) $(UPGRADE_BIN)
else
# Additional / custom linker flags.
# This needs to be before finding LINKER_SCRIPT_WILDCARD as we need the extension defined
ifeq ($(TOOLCHAIN),GCC_ARM)
CY_ELF_TO_HEX=$(CY_CROSSPATH)/bin/arm-none-eabi-objcopy
CY_ELF_TO_HEX_OPTIONS="-O ihex"
CY_ELF_TO_HEX_FILE_ORDER="elf_first"
CY_TOOLCHAIN_LS_EXT=ld
LDFLAGS+="-Wl,--defsym,MCUBOOT_HEADER_SIZE=$(MCUBOOT_HEADER_SIZE),--defsym,MCUBOOT_BOOTLOADER_SIZE=$(MCUBOOT_BOOTLOADER_SIZE),--defsym,CY_BOOT_PRIMARY_1_SIZE=$(CY_BOOT_PRIMARY_1_SIZE)"
else
ifeq ($(TOOLCHAIN),IAR)
CY_ELF_TO_HEX="$(CY_CROSSPATH)/bin/ielftool"
CY_ELF_TO_HEX_OPTIONS="--ihex"
CY_ELF_TO_HEX_FILE_ORDER="elf_first"
CY_TOOLCHAIN_LS_EXT=icf
LDFLAGS+=--config_def MCUBOOT_HEADER_SIZE=$(MCUBOOT_HEADER_SIZE) --config_def MCUBOOT_BOOTLOADER_SIZE=$(MCUBOOT_BOOTLOADER_SIZE) --config_def CY_BOOT_PRIMARY_1_SIZE=$(CY_BOOT_PRIMARY_1_SIZE)
else
ifeq ($(TOOLCHAIN),ARM)
CY_ELF_TO_HEX=$(CY_CROSSPATH)/bin/fromelf
CY_ELF_TO_HEX_OPTIONS="--i32 --output"
CY_ELF_TO_HEX_FILE_ORDER="hex_first"
CY_TOOLCHAIN_LS_EXT=sct
LDFLAGS+=--pd=-DMCUBOOT_HEADER_SIZE=$(MCUBOOT_HEADER_SIZE) --pd=-DMCUBOOT_BOOTLOADER_SIZE=$(MCUBOOT_BOOTLOADER_SIZE) --pd=-DCY_BOOT_PRIMARY_1_SIZE=$(CY_BOOT_PRIMARY_1_SIZE)
else
LDFLAGS+=
endif #ARM
endif #IAR
endif #GCC_ARM
# Linker Script
LINKER_SCRIPT_WILDCARD:= $(SEARCH_anycloud-ota)/$(TARGET_UNDERSCORE)/COMPONENT_$(CORE)/TOOLCHAIN_$(TOOLCHAIN)/ota/*_ota_int.$(CY_TOOLCHAIN_LS_EXT)
LINKER_SCRIPT:=$(wildcard $(LINKER_SCRIPT_WILDCARD))
# MCUBoot flash support location
MCUBOOT_DIR= $(SEARCH_anycloud-ota)/source/mcuboot
SIGN_SCRIPT_FILE_PATH= $(SEARCH_anycloud-ota)/scripts/sign_script.bash
IMGTOOL_SCRIPT_NAME=imgtool_v1.5.0/imgtool.py
MCUBOOT_SCRIPT_FILE_DIR=$(MCUBOOT_DIR)/scripts
MCUBOOT_KEY_DIR=$(MCUBOOT_DIR)/keys
MCUBOOT_KEY_FILE=$(MCUBOOT_KEY_DIR)/cypress-test-ec-p256.pem
IMGTOOL_COMMAND_ARG=create
CY_SIGNING_KEY_ARG=" "
ifeq ($(TARGET),CY8CKIT-064B0S2-4343W)
IMGTOOL_COMMAND_ARG=do_not_sign
CY_SIGNING_KEY_ARG=" "
endif
POSTBUILD=$(SIGN_SCRIPT_FILE_PATH) $(OUTPUT_FILE_PATH) $(APPNAME) $(CY_PYTHON_PATH)\
$(CY_ELF_TO_HEX) $(CY_ELF_TO_HEX_OPTIONS) $(CY_ELF_TO_HEX_FILE_ORDER)\
$(MCUBOOT_SCRIPT_FILE_DIR) $(IMGTOOL_SCRIPT_NAME) $(IMGTOOL_COMMAND_ARG) $(CY_FLASH_ERASE_VALUE) $(MCUBOOT_HEADER_SIZE)\
$(MCUBOOT_MAX_IMG_SECTORS) $(CY_BUILD_VERSION) $(CY_BOOT_PRIMARY_1_START) $(CY_BOOT_PRIMARY_1_SIZE)\
$(CY_HEX_TO_BIN) $(CY_SIGNING_KEY_ARG)
endif
endif
################################################################################
# Paths
################################################################################
# Relative path to the project directory (default is the Makefile's directory).
#
# This controls where automatic source code discovery looks for code.
CY_APP_PATH=
# Relative path to the shared repo location.
#
# All .mtb files have the format, <URI>#<COMMIT>#<LOCATION>. If the <LOCATION> field
# begins with $$ASSET_REPO$$, then the repo is deposited in the path specified by
# the CY_GETLIBS_SHARED_PATH variable. The default location is one directory level
# above the current app directory.
# This is used with CY_GETLIBS_SHARED_NAME variable, which specifies the directory name.
CY_GETLIBS_SHARED_PATH=../
# Directory name of the shared repo location.
#
CY_GETLIBS_SHARED_NAME=mtb_shared
# Absolute path to the compiler's "bin" directory.
#
# The default depends on the selected TOOLCHAIN (GCC_ARM uses the ModusToolbox
# IDE provided compiler by default).
CY_COMPILER_PATH=
# Locate ModusToolbox IDE helper tools folders in default installation
# locations for Windows, Linux, and macOS.
CY_WIN_HOME=$(subst \,/,$(USERPROFILE))
CY_TOOLS_PATHS ?= $(wildcard \
$(CY_WIN_HOME)/ModusToolbox/tools_* \
$(HOME)/ModusToolbox/tools_* \
/Applications/ModusToolbox/tools_*)
# If you install ModusToolbox IDE in a custom location, add the path to its
# "tools_X.Y" folder (where X and Y are the version number of the tools
# folder). Make sure you use forward slashes.
CY_TOOLS_PATHS+=
# Default to the newest installed tools folder, or the users override (if it's
# found).
CY_TOOLS_DIR=$(lastword $(sort $(wildcard $(CY_TOOLS_PATHS))))
ifeq ($(CY_TOOLS_DIR),)
$(error Unable to find any of the available CY_TOOLS_PATHS -- $(CY_TOOLS_PATHS). On Windows, use forward slashes.)
endif
$(info Tools Directory: $(CY_TOOLS_DIR))
include $(CY_TOOLS_DIR)/make/start.mk