From 120efee34f78f85b8aa32da38cb65beadd93a816 Mon Sep 17 00:00:00 2001 From: Kostiantyn Tkachov Date: Thu, 4 Jun 2020 21:16:09 +0300 Subject: [PATCH] Use cypress cy-mbedtls-acceleration revision w/o HAL Signed-off-by: Kostiantyn Tkachov Signed-off-by: Roman Okhrimenko --- boot/cypress/BlinkyApp/Readme.md | 20 +++++++++++++++++++- boot/cypress/MCUBootApp/MCUBootApp.mk | 4 ++++ boot/cypress/cy_flash_pal/cy_flash_map.c | 5 +++++ boot/cypress/libs/cy-mbedtls-acceleration | 2 +- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/boot/cypress/BlinkyApp/Readme.md b/boot/cypress/BlinkyApp/Readme.md index 76220773..5f8ca866 100644 --- a/boot/cypress/BlinkyApp/Readme.md +++ b/boot/cypress/BlinkyApp/Readme.md @@ -69,6 +69,24 @@ To get appropriate artifact for second image PRIMARY slot run this command: *Note:* only 2 images are supported at the moment. +**How to build upgrade image for external memory:** + +For prepare MCUBoot to work with external memory please refer to MCUBoot/ExternalMemory.md + +For build BlinkyApp upgarde image for external memory use command: + + make app APP_NAME=BlinkyApp PLATFORM=PSOC_062_2M IMG_TYPE=UPGRADE HEADER_OFFSET=0x7FE8000 ERASED_VALUE=0xff + +`HEADER_OFFSET` defines the offset from original boot image address. This one in line above suggests secondary slot will start from `0x18000000`. + +`ERASED_VALUE` defines the memory cell contents in erased state. It is `0x00` for PSoC6's internal Flash and `0xff` for S25FL512S. + +In case of using muti-image configuration, upgrade image for second application can be built using next command: + + make app APP_NAME=BlinkyApp PLATFORM=PSOC_062_2M IMG_TYPE=UPGRADE HEADER_OFFSET=0x8028000 ERASED_VALUE=0xff + + Note: for S25FL512S block address shuld be mutiple by 0x40000 + **Post-Build:** Post build action is executed at compile time for `BlinkyApp`. In case of build for `PSOC_062_2M` platform it calls `imgtool` from `MCUBoot` scripts and adds signature to compiled image. @@ -83,7 +101,7 @@ Hex file names to use for programming: `BlinkyApp` always produce build artifacts in 2 separate folders - `boot` and `upgrade`. -`BlinkyApp` built to run with `MCUBootApp` produces files with name BlinkyApp.hex in `boot` directory and `BlinkyApp_upgrade.hex` in `upgrade` folder. These files are ready to be flashed to the board. +`BlinkyApp` built to run with `MCUBootApp` produces files with name BlinkyApp.hex in `boot` directory and `BlinkyApp_upgrade.hex` in `upgrade` folder. These files are ready to be flashed to the board. `BlinkyApp_unsigned.hex` hex file is also preserved in both cases for possible troubleshooting. diff --git a/boot/cypress/MCUBootApp/MCUBootApp.mk b/boot/cypress/MCUBootApp/MCUBootApp.mk index d2a8ff81..7cd9450b 100644 --- a/boot/cypress/MCUBootApp/MCUBootApp.mk +++ b/boot/cypress/MCUBootApp/MCUBootApp.mk @@ -28,6 +28,7 @@ COMPILER ?= GCC_ARM USE_CRYPTO_HW ?= 1 +USE_EXTERNAL_FLASH ?= 0 MCUBOOT_IMAGE_NUMBER ?= 1 ifneq ($(COMPILER), GCC_ARM) @@ -45,10 +46,13 @@ DEFINES_APP := -DMBEDTLS_CONFIG_FILE="\"mcuboot_crypto_config.h\"" DEFINES_APP += -DECC256_KEY_FILE="\"keys/$(SIGN_KEY_FILE).pub\"" DEFINES_APP += -DCORE=$(CORE) DEFINES_APP += -DMCUBOOT_IMAGE_NUMBER=$(MCUBOOT_IMAGE_NUMBER) +ifeq ($(USE_EXTERNAL_FLASH), 1) DEFINES_APP += -DCY_BOOT_USE_EXTERNAL_FLASH +endif ifeq ($(USE_CRYPTO_HW), 1) DEFINES_APP += -DMBEDTLS_USER_CONFIG_FILE="\"mcuboot_crypto_acc_config.h\"" +DEFINES_APP += -DCY_CRYPTO_HAL_DISABLE endif # Collect MCUBoot sourses SOURCES_MCUBOOT := $(wildcard $(CURDIR)/../bootutil/src/*.c) diff --git a/boot/cypress/cy_flash_pal/cy_flash_map.c b/boot/cypress/cy_flash_pal/cy_flash_map.c index 55b7cb85..5bfbb2b5 100644 --- a/boot/cypress/cy_flash_pal/cy_flash_map.c +++ b/boot/cypress/cy_flash_pal/cy_flash_map.c @@ -124,12 +124,17 @@ static struct flash_area secondary_2 = .fa_id = FLASH_AREA_IMAGE_SECONDARY(1), /* TODO: it is for external flash memory .fa_device_id = FLASH_DEVICE_EXTERNAL_FLASH(CY_BOOT_EXTERNAL_DEVICE_INDEX), */ +#ifndef CY_BOOT_USE_EXTERNAL_FLASH .fa_device_id = FLASH_DEVICE_INTERNAL_FLASH, .fa_off = CY_FLASH_BASE +\ CY_BOOT_BOOTLOADER_SIZE +\ CY_BOOT_PRIMARY_1_SIZE +\ CY_BOOT_SECONDARY_1_SIZE +\ CY_BOOT_PRIMARY_2_SIZE, +#else + .fa_device_id = FLASH_DEVICE_EXTERNAL_FLASH(CY_BOOT_EXTERNAL_DEVICE_INDEX), + .fa_off = CY_SMIF_BASE_MEM_OFFSET + 0x40000, +#endif .fa_size = CY_BOOT_SECONDARY_2_SIZE }; #endif diff --git a/boot/cypress/libs/cy-mbedtls-acceleration b/boot/cypress/libs/cy-mbedtls-acceleration index 33aecf1d..79a9d8e5 160000 --- a/boot/cypress/libs/cy-mbedtls-acceleration +++ b/boot/cypress/libs/cy-mbedtls-acceleration @@ -1 +1 @@ -Subproject commit 33aecf1d51fa63620daa14fe1d75d7bb085b2178 +Subproject commit 79a9d8e5e0a98531d8b17f94f3f040359e9cdd9d