Initial commit
Initial commit.
This commit is contained in:
100
bootloader/mcuboot/boot/cypress/MCUBootApp/ExternalMemory.md
Normal file
100
bootloader/mcuboot/boot/cypress/MCUBootApp/ExternalMemory.md
Normal file
@@ -0,0 +1,100 @@
|
||||
### External Memory support for Secondary Slot
|
||||
|
||||
**Description**
|
||||
|
||||
Given document describes the use of external memory module as a secondary (upgrade) slot with Cypress' PSoC6 devices.
|
||||
|
||||
The demonstration device is CY8CPROTO-062-4343W board which is PSoC6 device with 2M of Flash available.
|
||||
The memory module present on board is S25FL512SAGMFI010 512-Mbit external Quad SPI NOR Flash.
|
||||
|
||||
Using external memory for secondary slot allows to nearly double the size of Boot Image.
|
||||
|
||||
**Operation Design and Flow**
|
||||
|
||||
The design is based on using SFDP command's auto-discovery functionality of memory module IC and Cypress' SMIF PDL driver.
|
||||
|
||||
It is assumed that user's design meets following:
|
||||
* The memory-module used is SFDP-compliant;
|
||||
* There only one module is being used for secondary slot;
|
||||
* Only "OWERWRITE" bootloading scheme is used;
|
||||
* The address for secondary slot should start from 0x18000000.
|
||||
This corresponds to PSoC6's SMIF (Serial Memory InterFace) IP block mapping.
|
||||
* The slot size for upgrade slot is even (or smaller) to erase size (0x40000) of given memory module.
|
||||
This requirement is accepted for code simplicity.
|
||||
|
||||
The default flash map implemented is the following:
|
||||
|
||||
Single-image mode.
|
||||
|
||||
`[0x10000000, 0x10018000]` - MCUBootApp (bootloader) area;
|
||||
|
||||
`[0x10018000, 0x10028000]` - primary slot for BlinkyApp;
|
||||
|
||||
`[0x18000000, 0x18010000]` - secondary slot for BlinkyApp;
|
||||
|
||||
`[0x10038000, 0x10039000]` - scratch area (not used);
|
||||
|
||||
Multi(dual)-image mode.
|
||||
|
||||
`[0x10000000, 0x10018000]` - MCUBootApp (bootloader) area;
|
||||
|
||||
`[0x10018000, 0x10028000]` - primary1 slot for BlinkyApp;
|
||||
|
||||
`[0x18000000, 0x18010000]` - secondary1 slot for BlinkyApp;
|
||||
|
||||
`[0x10038000, 0x10048000]` - primary2 slot for user app ;
|
||||
|
||||
`[0x18040000, 0x18050000]` - secondary2 slot for user app;
|
||||
|
||||
`[0x10058000, 0x10059000]` - scratch area (not used);
|
||||
|
||||
Size of slots `0x10000` - 64kB
|
||||
|
||||
**Note 1**: make sure primary, secondary slot and bootloader app sizes are appropriate and correspond to flash area size defined in Applications' linker files.
|
||||
|
||||
**Note 2**: make sure secondary slot start address is aligned (or smaller) to erase size (0x40000 - 256kB).
|
||||
|
||||
MCUBootApp's `main.c` contains the call to Init-SFDP API which performs required GPIO configurations, SMIF IP block configurations, SFDP protocol read and memory-config structure initialization.
|
||||
|
||||
After that MCUBootApp is ready to accept upgrade image from external memory module.
|
||||
|
||||
Once valid upgrade image was accepted the image in external memory will be erased.
|
||||
|
||||
**How to enable external memory support:**
|
||||
|
||||
1. Pass `USE_EXTERNAL_FLASH=1` flag to `make` command when building MCUBootApp.
|
||||
2. Navigate to `cy_flash_map.c` and check if secondary slot start address and size meet the application's needs.
|
||||
3. Define which slave select is used for external memory on a board by setting `smif_id` value in `main.c`.
|
||||
4. Build MCUBootApp as described in `Readme.md`.
|
||||
|
||||
**Note 3**: External memory code is developed basing on PDL and can be run on CM0p core only. It may require modifications if used on CM4.
|
||||
|
||||
**How to build upgrade image for external memory:**
|
||||
|
||||
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.
|
||||
|
||||
**Programming to external memory**
|
||||
|
||||
The MCUBootApp programming can be done similarly to described in `Readme.md`:
|
||||
|
||||
export OPENOCD=/Applications/ModusToolbox/tools_2.1/openocd
|
||||
|
||||
${OPENOCD}/bin/openocd -s ${OPENOCD}/scripts \
|
||||
-f ${OPENOCD}/scripts/interface/kitprog3.cfg \
|
||||
-f ${OPENOCD}/scripts/target/psoc6_2m.cfg \
|
||||
-c "init; psoc6 sflash_restrictions 1" \
|
||||
-c "init; reset init; program PATH_TO_APPLICATION.hex" \
|
||||
-c "resume; reset; exit"
|
||||
|
||||
There is a NULL-pointer placed for SMIF configuration pointer in TOC2 (Table Of Contents, `cy_serial_flash_prog.c`).
|
||||
This is done to force CY8PROTO-062-4343W DAP Link firmware to program external memory with hardcoded values.
|
||||
|
||||
1. Press SW3 Mode button on a board to switch the board into DAP Link mode.
|
||||
2. Once DAP Link removable disk appeared drop (copy) the upgrade image HEX file to it.
|
||||
This will invoke firmware to program external memory.
|
||||
|
||||
**Note 3:** the programming of external memory is limited to S25FL512S p/n only at this moment.
|
||||
418
bootloader/mcuboot/boot/cypress/MCUBootApp/MCUBootApp.ld
Normal file
418
bootloader/mcuboot/boot/cypress/MCUBootApp/MCUBootApp.ld
Normal file
@@ -0,0 +1,418 @@
|
||||
/***************************************************************************//**
|
||||
* \file cy8c6xxa_cm0plus.ld
|
||||
* \version 2.60
|
||||
*
|
||||
* Linker file for the GNU C compiler.
|
||||
*
|
||||
* The main purpose of the linker script is to describe how the sections in the
|
||||
* input files should be mapped into the output file, and to control the memory
|
||||
* layout of the output file.
|
||||
*
|
||||
* \note The entry point location is fixed and starts at 0x10000000. The valid
|
||||
* application image should be placed there.
|
||||
*
|
||||
* \note The linker files included with the PDL template projects must be generic
|
||||
* and handle all common use cases. Your project may not use every section
|
||||
* defined in the linker files. In that case you may see warnings during the
|
||||
* build process. In your project, you can simply comment out or remove the
|
||||
* relevant code in the linker file.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2016-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.
|
||||
*******************************************************************************/
|
||||
|
||||
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
SEARCH_DIR(.)
|
||||
GROUP(-lgcc -lc -lnosys)
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Size of the stack section at the end of CM0+ SRAM */
|
||||
STACK_SIZE = 0x1000;
|
||||
|
||||
/* Force symbol to be entered in the output file as an undefined symbol. Doing
|
||||
* this may, for example, trigger linking of additional modules from standard
|
||||
* libraries. You may list several symbols for each EXTERN, and you may use
|
||||
* EXTERN multiple times. This command has the same effect as the -u command-line
|
||||
* option.
|
||||
*/
|
||||
EXTERN(Reset_Handler)
|
||||
|
||||
/* The MEMORY section below describes the location and size of blocks of memory in the target.
|
||||
* Use this section to specify the memory regions available for allocation.
|
||||
*/
|
||||
MEMORY
|
||||
{
|
||||
/* The ram and flash regions control RAM and flash memory allocation for the CM0+ core.
|
||||
* You can change the memory allocation by editing the 'ram' and 'flash' regions.
|
||||
* Note that 2 KB of RAM (at the end of the SRAM) are reserved for system use.
|
||||
* Using this memory region for other purposes will lead to unexpected behavior.
|
||||
* 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'.
|
||||
*/
|
||||
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.
|
||||
* You can assign sections to this memory region for only one of the cores.
|
||||
* Note some middleware (e.g. BLE, Emulated EEPROM) can place their data into this memory region.
|
||||
* Therefore, repurposing this memory region will prevent such middleware from operation.
|
||||
*/
|
||||
em_eeprom (rx) : ORIGIN = 0x14000000, LENGTH = 0x8000 /* 32 KB */
|
||||
|
||||
/* The following regions define device specific memory regions and must not be changed. */
|
||||
sflash_user_data (rx) : ORIGIN = 0x16000800, LENGTH = 0x800 /* Supervisory flash: User data */
|
||||
sflash_nar (rx) : ORIGIN = 0x16001A00, LENGTH = 0x200 /* Supervisory flash: Normal Access Restrictions (NAR) */
|
||||
sflash_public_key (rx) : ORIGIN = 0x16005A00, LENGTH = 0xC00 /* Supervisory flash: Public Key */
|
||||
sflash_toc_2 (rx) : ORIGIN = 0x16007C00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 */
|
||||
sflash_rtoc_2 (rx) : ORIGIN = 0x16007E00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 Copy */
|
||||
xip (rx) : ORIGIN = 0x18000000, LENGTH = 0x8000000 /* 128 MB */
|
||||
efuse (r) : ORIGIN = 0x90700000, LENGTH = 0x100000 /* 1 MB */
|
||||
}
|
||||
|
||||
/* Library configurations */
|
||||
GROUP(libgcc.a libc.a libm.a libnosys.a)
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with other linker script that defines memory regions FLASH and RAM.
|
||||
* It references following symbols, which must be defined in code:
|
||||
* Reset_Handler : Entry of reset handler
|
||||
*
|
||||
* It defines following symbols, which code can use without definition:
|
||||
* __exidx_start
|
||||
* __exidx_end
|
||||
* __copy_table_start__
|
||||
* __copy_table_end__
|
||||
* __zero_table_start__
|
||||
* __zero_table_end__
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __preinit_array_start
|
||||
* __preinit_array_end
|
||||
* __init_array_start
|
||||
* __init_array_end
|
||||
* __fini_array_start
|
||||
* __fini_array_end
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __end__
|
||||
* end
|
||||
* __HeapLimit
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
* __Vectors_End
|
||||
* __Vectors_Size
|
||||
*/
|
||||
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.cy_app_header :
|
||||
{
|
||||
KEEP(*(.cy_app_header))
|
||||
} > flash
|
||||
|
||||
/* Cortex-M0+ application flash area */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__Vectors = . ;
|
||||
KEEP(*(.vectors))
|
||||
. = ALIGN(4);
|
||||
__Vectors_End = .;
|
||||
__Vectors_Size = __Vectors_End - __Vectors;
|
||||
__end__ = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.text*)
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
/* Read-only code (constants). */
|
||||
*(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > flash
|
||||
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > flash
|
||||
|
||||
__exidx_start = .;
|
||||
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > flash
|
||||
__exidx_end = .;
|
||||
|
||||
|
||||
/* To copy multiple ROM to RAM sections,
|
||||
* uncomment .copy.table section and,
|
||||
* define __STARTUP_COPY_MULTIPLE in startup_psoc6_02_cm0plus.S */
|
||||
.copy.table :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__copy_table_start__ = .;
|
||||
|
||||
/* Copy interrupt vectors from flash to RAM */
|
||||
LONG (__Vectors) /* From */
|
||||
LONG (__ram_vectors_start__) /* To */
|
||||
LONG (__Vectors_End - __Vectors) /* Size */
|
||||
|
||||
/* Copy data section to RAM */
|
||||
LONG (__etext) /* From */
|
||||
LONG (__data_start__) /* To */
|
||||
LONG (__data_end__ - __data_start__) /* Size */
|
||||
|
||||
__copy_table_end__ = .;
|
||||
} > flash
|
||||
|
||||
|
||||
/* To clear multiple BSS sections,
|
||||
* uncomment .zero.table section and,
|
||||
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_psoc6_02_cm0plus.S */
|
||||
.zero.table :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__zero_table_start__ = .;
|
||||
LONG (__bss_start__)
|
||||
LONG (__bss_end__ - __bss_start__)
|
||||
__zero_table_end__ = .;
|
||||
} > flash
|
||||
|
||||
__etext = . ;
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(ram) + LENGTH(ram);
|
||||
__StackLimit = __StackTop - STACK_SIZE ;
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
.stackSpace (NOLOAD) : ALIGN(8)
|
||||
{
|
||||
. = . + STACK_SIZE ;
|
||||
} > ram
|
||||
|
||||
.ramVectors (NOLOAD) : ALIGN(8)
|
||||
{
|
||||
__ram_vectors_start__ = .;
|
||||
KEEP(*(.ram_vectors))
|
||||
__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)
|
||||
{
|
||||
__data_start__ = .;
|
||||
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
KEEP(*(.jcr*))
|
||||
. = ALIGN(4);
|
||||
|
||||
KEEP(*(.cy_ramfunc*))
|
||||
. = ALIGN(4);
|
||||
|
||||
__data_end__ = .;
|
||||
|
||||
} > ram
|
||||
|
||||
|
||||
/* Place variables in the section that should not be initialized during the
|
||||
* device startup.
|
||||
*/
|
||||
.noinit (NOLOAD) : ALIGN(8)
|
||||
{
|
||||
KEEP(*(.noinit))
|
||||
} > ram
|
||||
|
||||
|
||||
/* The uninitialized global or static variables are placed in this section.
|
||||
*
|
||||
* The NOLOAD attribute tells linker that .bss section does not consume
|
||||
* any space in the image. The NOLOAD attribute changes the .bss type to
|
||||
* NOBITS, and that makes linker to A) not allocate section in memory, and
|
||||
* A) put information to clear the section with all zeros during application
|
||||
* loading.
|
||||
*
|
||||
* Without the NOLOAD attribute, the .bss section might get PROGBITS type.
|
||||
* This makes linker to A) allocate zeroed section in memory, and B) copy
|
||||
* this section to RAM during application loading.
|
||||
*/
|
||||
.bss (NOLOAD):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > ram
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
__HeapBase = .;
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
KEEP(*(.heap*))
|
||||
. = ORIGIN(ram) + LENGTH(ram);
|
||||
__HeapLimit = .;
|
||||
} > ram
|
||||
|
||||
|
||||
/* Emulated EEPROM Flash area */
|
||||
.cy_em_eeprom :
|
||||
{
|
||||
KEEP(*(.cy_em_eeprom))
|
||||
} > em_eeprom
|
||||
|
||||
|
||||
/* Supervisory Flash: User data */
|
||||
.cy_sflash_user_data :
|
||||
{
|
||||
KEEP(*(.cy_sflash_user_data))
|
||||
} > sflash_user_data
|
||||
|
||||
|
||||
/* Supervisory Flash: Normal Access Restrictions (NAR) */
|
||||
.cy_sflash_nar :
|
||||
{
|
||||
KEEP(*(.cy_sflash_nar))
|
||||
} > sflash_nar
|
||||
|
||||
|
||||
/* Supervisory Flash: Public Key */
|
||||
.cy_sflash_public_key :
|
||||
{
|
||||
KEEP(*(.cy_sflash_public_key))
|
||||
} > sflash_public_key
|
||||
|
||||
|
||||
/* Supervisory Flash: Table of Content # 2 */
|
||||
.cy_toc_part2 :
|
||||
{
|
||||
KEEP(*(.cy_toc_part2))
|
||||
} > sflash_toc_2
|
||||
|
||||
|
||||
/* Supervisory Flash: Table of Content # 2 Copy */
|
||||
.cy_rtoc_part2 :
|
||||
{
|
||||
KEEP(*(.cy_rtoc_part2))
|
||||
} > sflash_rtoc_2
|
||||
|
||||
|
||||
/* Places the code in the Execute in Place (XIP) section. See the smif driver
|
||||
* documentation for details.
|
||||
*/
|
||||
.cy_xip :
|
||||
{
|
||||
KEEP(*(.cy_xip))
|
||||
} > xip
|
||||
|
||||
|
||||
/* eFuse */
|
||||
.cy_efuse :
|
||||
{
|
||||
KEEP(*(.cy_efuse))
|
||||
} > efuse
|
||||
|
||||
|
||||
/* These sections are used for additional metadata (silicon revision,
|
||||
* Silicon/JTAG ID, etc.) storage.
|
||||
*/
|
||||
.cymeta 0x90500000 : { KEEP(*(.cymeta)) } :NONE
|
||||
}
|
||||
|
||||
|
||||
/* The following symbols used by the cymcuelftool. */
|
||||
/* Flash */
|
||||
__cy_memory_0_start = 0x10000000;
|
||||
__cy_memory_0_length = 0x00200000;
|
||||
__cy_memory_0_row_size = 0x200;
|
||||
|
||||
/* Emulated EEPROM Flash area */
|
||||
__cy_memory_1_start = 0x14000000;
|
||||
__cy_memory_1_length = 0x8000;
|
||||
__cy_memory_1_row_size = 0x200;
|
||||
|
||||
/* Supervisory Flash */
|
||||
__cy_memory_2_start = 0x16000000;
|
||||
__cy_memory_2_length = 0x8000;
|
||||
__cy_memory_2_row_size = 0x200;
|
||||
|
||||
/* XIP */
|
||||
__cy_memory_3_start = 0x18000000;
|
||||
__cy_memory_3_length = 0x08000000;
|
||||
__cy_memory_3_row_size = 0x200;
|
||||
|
||||
/* eFuse */
|
||||
__cy_memory_4_start = 0x90700000;
|
||||
__cy_memory_4_length = 0x100000;
|
||||
__cy_memory_4_row_size = 1;
|
||||
|
||||
/* EOF */
|
||||
113
bootloader/mcuboot/boot/cypress/MCUBootApp/MCUBootApp.mk
Normal file
113
bootloader/mcuboot/boot/cypress/MCUBootApp/MCUBootApp.mk
Normal file
@@ -0,0 +1,113 @@
|
||||
################################################################################
|
||||
# \file MCUBootApp.mk
|
||||
# \version 1.0
|
||||
#
|
||||
# \brief
|
||||
# Makefile for Cypress MCUBoot-based application.
|
||||
#
|
||||
################################################################################
|
||||
# \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.
|
||||
################################################################################
|
||||
|
||||
include host.mk
|
||||
|
||||
# Cypress' MCUBoot Application supports GCC ARM only at this moment
|
||||
# Set default compiler to GCC if not specified from command line
|
||||
COMPILER ?= GCC_ARM
|
||||
|
||||
USE_CRYPTO_HW ?= 0
|
||||
USE_EXTERNAL_FLASH ?= 0
|
||||
MCUBOOT_IMAGE_NUMBER ?= 1
|
||||
ENC_IMG ?= 0
|
||||
|
||||
# For which core this application is built
|
||||
CORE ?= CM0P
|
||||
|
||||
ifneq ($(COMPILER), GCC_ARM)
|
||||
$(error Only GCC ARM is supported at this moment)
|
||||
endif
|
||||
|
||||
CUR_APP_PATH = $(PRJ_DIR)/$(APP_NAME)
|
||||
|
||||
include $(PRJ_DIR)/platforms.mk
|
||||
include $(PRJ_DIR)/common_libs.mk
|
||||
include $(PRJ_DIR)/toolchains.mk
|
||||
|
||||
# default slot size is 0x10000, 512bytes per row/sector, so 128 sectors
|
||||
MAX_IMG_SECTORS ?= 128
|
||||
|
||||
# Application-specific DEFINES
|
||||
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
|
||||
DEFINES_APP += -DMCUBOOT_MAX_IMG_SECTORS=$(MAX_IMG_SECTORS)
|
||||
# Hardrware acceleration support
|
||||
ifeq ($(USE_CRYPTO_HW), 1)
|
||||
DEFINES_APP += -DMBEDTLS_USER_CONFIG_FILE="\"mcuboot_crypto_acc_config.h\""
|
||||
DEFINES_APP += -DCY_CRYPTO_HAL_DISABLE
|
||||
DEFINES_APP += -DCY_MBEDTLS_HW_ACCELERATION
|
||||
endif
|
||||
# Encrypted image support
|
||||
ifeq ($(ENC_IMG), 1)
|
||||
DEFINES_APP += -DENC_IMG=1
|
||||
endif
|
||||
|
||||
# Collect MCUBoot sourses
|
||||
SOURCES_MCUBOOT := $(wildcard $(CURDIR)/../bootutil/src/*.c)
|
||||
# Collect MCUBoot Application sources
|
||||
SOURCES_APP_SRC := $(wildcard $(CUR_APP_PATH)/*.c)
|
||||
|
||||
# Collect Flash Layer port sources
|
||||
SOURCES_FLASH_PORT := $(wildcard $(CURDIR)/cy_flash_pal/*.c)
|
||||
SOURCES_FLASH_PORT += $(wildcard $(CURDIR)/cy_flash_pal/flash_qspi/*.c)
|
||||
# Collect all the sources
|
||||
SOURCES_APP := $(SOURCES_MCUBOOT)
|
||||
SOURCES_APP += $(SOURCES_APP_SRC)
|
||||
SOURCES_APP += $(SOURCES_FLASH_PORT)
|
||||
|
||||
INCLUDE_DIRS_MCUBOOT := $(addprefix -I, $(CURDIR)/../bootutil/include)
|
||||
INCLUDE_DIRS_MCUBOOT += $(addprefix -I, $(CURDIR)/../bootutil/src)
|
||||
INCLUDE_DIRS_MCUBOOT += $(addprefix -I, $(CURDIR)/..)
|
||||
|
||||
INCLUDE_DIRS_APP := $(addprefix -I, $(CURDIR))
|
||||
INCLUDE_DIRS_APP += $(addprefix -I, $(CURDIR)/cy_flash_pal/flash_qspi)
|
||||
INCLUDE_DIRS_APP += $(addprefix -I, $(CURDIR)/cy_flash_pal/include)
|
||||
INCLUDE_DIRS_APP += $(addprefix -I, $(CURDIR)/cy_flash_pal/include/flash_map_backend)
|
||||
INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH))
|
||||
INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH)/config)
|
||||
INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH)/os)
|
||||
|
||||
ASM_FILES_APP :=
|
||||
ASM_FILES_APP += $(ASM_FILES_STARTUP)
|
||||
|
||||
# Output folder
|
||||
OUT := $(APP_NAME)/out
|
||||
# Output folder to contain build artifacts
|
||||
OUT_TARGET := $(OUT)/$(PLATFORM)
|
||||
|
||||
OUT_CFG := $(OUT_TARGET)/$(BUILDCFG)
|
||||
|
||||
# Overwite path to linker script if custom is required
|
||||
ifeq ($(COMPILER), GCC_ARM)
|
||||
LINKER_SCRIPT := $(subst /cygdrive/c,c:,$(CUR_APP_PATH)/$(APP_NAME).ld)
|
||||
else
|
||||
$(error Only GCC ARM is supported at this moment)
|
||||
endif
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.openocd.launchConfigurationType">
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doContinue" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doGdbServerAllocateConsole" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doGdbServerAllocateTelnetConsole" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doSecondReset" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doStartGdbCLient" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doStartGdbServer" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.enableSemihosting" value="true"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.firstResetType" value="init"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbClientOtherCommands" value="set mem inaccessible-by-default off"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbClientOtherOptions" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerConnectionAddress" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerExecutable" value="${cy_tools_path:openocd}/bin/openocd"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerGdbPortNumber" value="3333"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerLog" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerOther" value="-s "${cy_tools_path:openocd}/scripts" -s "${workspace_loc}/boot/cypress" -c "source [find interface/kitprog3.cfg]" -c "source [find target/psoc6_2m.cfg]" -c "puts stderr {Started by GNU MCU Eclipse}""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerTclPortNumber" value="6666"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerTelnetPortNumber" value="4444"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.otherInitCommands" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.otherRunCommands" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.secondResetType" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.svdPath" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value="./out/PSOC_062_2M/Debug/MCUBootApp.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU MCU OpenOCD"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value="./out/PSOC_062_2M/Debug/MCUBootApp.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${cy_sdk_install_dir}/tools/gcc-7.2.1-1.0/bin/arm-none-eabi-gdb${cy_exe_platform_ext}"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="boot/cypress/MCUBootApp/out/PSOC_062_2M/Debug/MCUBootApp.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="cy_mcuboot"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/cy_mcuboot"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"> <memoryBlockExpression address="268566528" label="0x10020000"/> <memoryBlockExpression address="268632064" label="0x10030000"/> </memoryBlockExpressionList> "/>
|
||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
221
bootloader/mcuboot/boot/cypress/MCUBootApp/README.md
Normal file
221
bootloader/mcuboot/boot/cypress/MCUBootApp/README.md
Normal file
@@ -0,0 +1,221 @@
|
||||
### Port of MCUboot library to be used with Cypress targets
|
||||
|
||||
**Solution Description**
|
||||
|
||||
Given solution demonstrates operation of MCUboot on Cypress' PSoC6 device.
|
||||
|
||||
There are two applications implemented:
|
||||
* MCUBootApp - PSoC6 MCUboot-based bootloading application;
|
||||
* BlinkyApp - simple PSoC6 blinking LED application which is a target of BOOT/UPGRADE;
|
||||
|
||||
Cypress boards, that can be used with this evaluation example:
|
||||
- CY8CPROTO-062-4343W - PSoC 6 2M on board
|
||||
- CY8CKIT-062-WIFI-BT - PSoC 6 1M on board
|
||||
- CY8CPROTO-062S3-4343W - PSoC 6 512K on board
|
||||
The default flash map implemented is the following:
|
||||
|
||||
Single-image mode.
|
||||
|
||||
`[0x10000000, 0x10018000]` - MCUBootApp (bootloader) area;
|
||||
|
||||
`[0x10018000, 0x10028000]` - primary slot for BlinkyApp;
|
||||
|
||||
`[0x10028000, 0x10038000]` - secondary slot for BlinkyApp;
|
||||
|
||||
`[0x10038000, 0x10039000]` - scratch area (not used);
|
||||
|
||||
Size of slots `0x10000` - 64kb
|
||||
|
||||
MCUBootApp checks image integrity with SHA256, image authenticity with EC256 digital signature verification and uses completely SW implementation of cryptographic functions based on Mbed TLS Library.
|
||||
|
||||
**Important**: make sure primary, secondary slot and bootloader app sizes are appropriate and correspond to flash area size defined in Applications' linker files.
|
||||
|
||||
**Important**: make sure RAM areas of CM0p-based MCUBootApp bootloader and CM4-based BlinkyApp do not overlap.
|
||||
Memory (stack) corruption of CM0p application can cause failure if SystemCall-served operations invoked from CM4.
|
||||
|
||||
### Hardware cryptography acceleration
|
||||
|
||||
Cypress PSOC6 MCU family supports hardware acceleration of cryptography based on Mbed TLS Library via shim layer. Implementation of this layer is supplied as separate submodule `cy-mbedtls-acceleration`. HW acceleration of cryptography shortens boot time more then 4 times, comparing to software implementation (observation results).
|
||||
|
||||
To enable hardware acceleration in `MCUBootApp` pass flag `USE_CRYPTO_HW=1` to `make` while build.
|
||||
|
||||
Hardware acceleration of cryptography is enabled for PSOC6 devices by default.
|
||||
|
||||
### How to modify memory map
|
||||
|
||||
__Option 1.__
|
||||
|
||||
Navigate to `sysflash.h` and modify the flash area(s) / slots sizes to meet your needs.
|
||||
|
||||
__Option 2.__
|
||||
|
||||
Navigate to `sysflash.h`, uncomment `CY_FLASH_MAP_EXT_DESC` definition.
|
||||
Now define and initialize `struct flash_area *boot_area_descs[]` with flash memory addresses and sizes you need at the beginning of application, so flash APIs from `cy_flash_map.c` will use it.
|
||||
|
||||
__Note:__ for both options make sure you have updated `MCUBOOT_MAX_IMG_SECTORS` appropriatery with sector size assumed to be 512.
|
||||
|
||||
**How to override the flash map values during build process:**
|
||||
|
||||
Navigate to MCUBootApp.mk, find section `DEFINES_APP +=`
|
||||
Update this line and or add similar for flash map parameters to override.
|
||||
|
||||
The possible list could be:
|
||||
|
||||
* MCUBOOT_MAX_IMG_SECTORS
|
||||
* CY_FLASH_MAP_EXT_DESC
|
||||
* CY_BOOT_SCRATCH_SIZE
|
||||
* CY_BOOT_BOOTLOADER_SIZE
|
||||
* CY_BOOT_PRIMARY_1_SIZE
|
||||
* CY_BOOT_SECONDARY_1_SIZE
|
||||
* CY_BOOT_PRIMARY_2_SIZE
|
||||
* CY_BOOT_SECONDARY_2_SIZE
|
||||
|
||||
As an example in a makefile it should look like following:
|
||||
|
||||
`DEFINES_APP +=-DCY_FLASH_MAP_EXT_DESC`
|
||||
|
||||
`DEFINES_APP +=-DMCUBOOT_MAX_IMG_SECTORS=512`
|
||||
|
||||
`DEFINES_APP +=-DCY_BOOT_PRIMARY_1_SIZE=0x15000`
|
||||
|
||||
**Multi-Image Operation**
|
||||
|
||||
Multi-image operation considers upgrading and verification of more then one image on the device.
|
||||
|
||||
To enable multi-image operation define `MCUBOOT_IMAGE_NUMBER` in `MCUBootApp/config/mcuboot_config.h` file should be set to 2 (only dual-image is supported at the moment). This could also be done on build time by passing `MCUBOOT_IMAGE_NUMBER=2` as parameter to `make`.
|
||||
|
||||
Default value of `MCUBOOT_IMAGE_NUMBER` is 1, which corresponds to single image configuratios.
|
||||
|
||||
In multi-image operation (two images are considered for simplicity) MCUboot Bootloader application operates as following:
|
||||
|
||||
* Verifies Primary_1 and Primary_2 images;
|
||||
* Verifies Secondary_1 and Secondary_2 images;
|
||||
* Upgrades Secondary to Primary if valid images found;
|
||||
* Boots image from Primary_1 slot only;
|
||||
* Boots Primary_1 only if both - Primary_1 and Primary_2 are present and valid;
|
||||
|
||||
This ensures two dependent applications can be accepted by device only in case both images are valid.
|
||||
|
||||
**Default Flash map for Multi-Image operation:**
|
||||
|
||||
`0x10000000 - 0x10018000` - MCUboot Bootloader
|
||||
|
||||
`0x10018000 - 0x10028000` - Primary_1 (BOOT) slot of Bootloader
|
||||
|
||||
`0x10028000 - 0x10038000` - Secondary_1 (UPGRADE) slot of Bootloader
|
||||
|
||||
`0x10038000 - 0x10048000` - Primary_2 (BOOT) slot of Bootloader
|
||||
|
||||
`0x10048000 - 0x10058000` - Secondary_2 (UPGRADE) slot of Bootloader
|
||||
|
||||
`0x10058000 - 0x10059000` - Scratch of Bootloader
|
||||
|
||||
Size of slots `0x10000` - 64kb
|
||||
|
||||
__Note:__ It is also possible to place secondary (upgrade) slots in external memory module so resulting image size can be doubled.
|
||||
For more details about External Memory usage, please refer to separate guiding document `ExternalMemory.md`.
|
||||
|
||||
### Hardware limitations
|
||||
|
||||
Since this application is created to demonstrate MCUboot library features and not as reference examples some considerations are taken.
|
||||
|
||||
1. `SCB5` used to configure serial port for debug prints. This is the most commonly used Serial Communication Block number among available Cypress PSoC 6 kits. If you try to use custom hardware with this application - change definition of `CYBSP_UART_HW` in `main.c` of MCUBootApp to SCB* that correspond to your design.
|
||||
|
||||
2. `CY_SMIF_SLAVE_SELECT_0` is used as definition SMIF driver API. This configuration is used on evaluation kit for this example CY8CPROTO-062-4343W, CY8PROTO-062S3-4343W, CY8CKIT-062-4343W. If you try to use custom hardware with this application - change value of `smif_id` in `main.c` of MCUBootApp to value that corresponds to your design.
|
||||
|
||||
|
||||
### Downloading solution's assets
|
||||
|
||||
There is a set assets required:
|
||||
|
||||
* MCUBooot Library (root repository)
|
||||
* PSoC6 HAL Library
|
||||
* PSoC6 Peripheral Drivers Library (PDL)
|
||||
* Mbed TLS Cryptographic Library
|
||||
|
||||
To get submodules - run the following command:
|
||||
|
||||
git submodule update --init --recursive
|
||||
|
||||
### Building solution
|
||||
|
||||
This folder contains make files infrastructure for building MCUBoot Bootloader. Same approach used in sample BlinkyLedApp application. Example command are provided below for couple different build configurations.
|
||||
|
||||
* Build MCUBootApp in `Debug` for signle image use case.
|
||||
|
||||
make app APP_NAME=MCUBootApp PLATFORM=PSOC_062_2M BUILDCFG=Debug MCUBOOT_IMAGE_NUMBER=1
|
||||
|
||||
* Build MCUBootApp in `Release` for multi image use case.
|
||||
|
||||
make app APP_NAME=MCUBootApp PLATFORM=PSOC_062_2M BUILDCFG=Release MCUBOOT_IMAGE_NUMBER=2
|
||||
|
||||
* To Build MCUBootApp with external memory support - pass `USE_EXTERNAL_FLASH=1` flag to `make` command in examples above. In this case UPGRADE image will be located in external memory. Refer to ExternalMemory.md for additional details.
|
||||
|
||||
Root directory for build is **boot/cypress.**
|
||||
|
||||
**Encrypted Image Support**
|
||||
|
||||
To protect user image from unwanted read - Upgrade Image Encryption can be applied. The ECDH/HKDF with EC256 scheme is used in a given solution as well as Mbed TLS as a crypto provider.
|
||||
|
||||
To enable image encryption support use `ENC_IMG=1` build flag (BlinkyApp should also be built with this flash set 1).
|
||||
|
||||
User is also responsible for providing corresponding binary key data in `enc_priv_key[]` (file `\MCUBootApp\keys.c`). The public part will be used by imgtool when signing and encrypting upgrade image. Signing image with encryption is described in `\BlinkyApp\Readme.md`.
|
||||
|
||||
After MCUBootApp is built with these settings unencrypted and encrypted images will be accepted in secondary (upgrade) slot.
|
||||
|
||||
Example command:
|
||||
|
||||
make app APP_NAME=MCUBootApp PLATFORM=PSOC_062_2M BUILDCFG=Debug MCUBOOT_IMAGE_NUMBER=1 ENC_IMG=1
|
||||
|
||||
**Programming solution**
|
||||
|
||||
There are couple ways of programming hex of MCUBootApp and BlinkyApp. Following instructions assume one of Cypress development kits, for example `CY8CPROTO_062_4343W`.
|
||||
|
||||
1. Direct usage of OpenOCD.
|
||||
OpenOCD package is supplied with ModuToolbox IDE and can be found in installation folder under `./tools_2.1/openocd`.
|
||||
Open terminal application - and execute following command after substitution `PATH_TO_APPLICATION.hex` and `OPENOCD` paths.
|
||||
|
||||
Connect a board to your computer. Switch Kitprog3 to DAP-BULK mode by pressing `SW3 MODE` button until `LED2 STATUS` constantly shines.
|
||||
|
||||
export OPENOCD=/Applications/ModusToolbox/tools_2.1/openocd
|
||||
|
||||
${OPENOCD}/bin/openocd -s ${OPENOCD}/scripts \
|
||||
-f ${OPENOCD}/scripts/interface/kitprog3.cfg \
|
||||
-f ${OPENOCD}/scripts/target/psoc6_2m.cfg \
|
||||
-c "init; reset init; program PATH_TO_APPLICATION.hex" \
|
||||
-c "resume; reset; exit"
|
||||
|
||||
2. Using GUI tool `Cypress Programmer` - follow [link](https://www.cypress.com/products/psoc-programming-solutions) to download.
|
||||
Connect board to your computer. Switch Kitprog3 to DAP-BULK mode by pressing `SW3 MODE` button until `LED2 STATUS` constantly shines. Open `Cypress Programmer` and click `Connect`, then choose hex file: `MCUBootApp.hex` or `BlinkyApp.hex` and click `Program`. Check log to ensure programming success. Reset board.
|
||||
|
||||
3. Using `DAPLINK`.
|
||||
Connect board to your computer. Switch embeded Kitprog3 to `DAPLINK` mode by pressing `SW3 MODE` button until `LED2 STATUS` blinks fast and mass storage device appeared in OS. Drag and drop `hex` files you wish to program to `DAPLINK` drive in your OS.
|
||||
|
||||
|
||||
|
||||
**Currently supported platforms:**
|
||||
|
||||
* PSOC_062_2M
|
||||
* PSOC_062_1M
|
||||
* PSOC_062_512K
|
||||
|
||||
**Build environment troubleshooting:**
|
||||
|
||||
Regular shell/terminal combination on Linux and MacOS.
|
||||
|
||||
On Windows:
|
||||
|
||||
* Cygwin
|
||||
* Msys2
|
||||
|
||||
Also IDE may be used:
|
||||
* Eclipse / ModusToolbox ("makefile project from existing source")
|
||||
|
||||
*Make* - make sure it is added to system's `PATH` variable and correct path is first in the list;
|
||||
|
||||
*Python/Python3* - make sure you have correct path referenced in `PATH`;
|
||||
|
||||
*Msys2* - to use systems PATH navigate to msys2 folder, open `msys2_shell.cmd`, uncomment set `MSYS2_PATH_TYPE=inherit`, restart MSYS2 shell.
|
||||
|
||||
This will iherit system's PATH so should find `python3.7` installed in regular way as well as imgtool and its dependencies.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* mcuboot_assert.h
|
||||
*
|
||||
* Cypress-specific assert() macro redefinition
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MCUBOOT_ASSERT_H
|
||||
#define MCUBOOT_ASSERT_H
|
||||
|
||||
//#include "cy_bootloader_services.h"
|
||||
|
||||
#define CYBL_ASSERT(...) Cy_BLServ_Assert(__VA_ARGS__)
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
#undef assert
|
||||
#define assert(...) CYBL_ASSERT(__VA_ARGS__)
|
||||
#else
|
||||
#define assert
|
||||
#endif
|
||||
|
||||
#endif /* MCUBOOT_ASSERT_H */
|
||||
@@ -0,0 +1,166 @@
|
||||
/* Copyright 2019 Cypress Semiconductor Corporation
|
||||
*
|
||||
* Copyright (c) 2018 Open Source Foundries Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef MCUBOOT_CONFIG_H
|
||||
#define MCUBOOT_CONFIG_H
|
||||
|
||||
/*
|
||||
* Template configuration file for MCUboot.
|
||||
*
|
||||
* When porting MCUboot to a new target, copy it somewhere that your
|
||||
* include path can find it as mcuboot_config/mcuboot_config.h, and
|
||||
* make adjustments to suit your platform.
|
||||
*
|
||||
* For examples, see:
|
||||
*
|
||||
* boot/zephyr/include/mcuboot_config/mcuboot_config.h
|
||||
* boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
|
||||
*/
|
||||
/* Default maximum number of flash sectors per image slot; change
|
||||
* as desirable. */
|
||||
#ifndef MCUBOOT_MAX_IMG_SECTORS
|
||||
#define MCUBOOT_MAX_IMG_SECTORS 2560
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Signature types
|
||||
*
|
||||
* You must choose exactly one signature type.
|
||||
*/
|
||||
|
||||
/* Uncomment for RSA signature support */
|
||||
//#define MCUBOOT_SIGN_RSA
|
||||
|
||||
/* Uncomment for ECDSA signatures using curve P-256. */
|
||||
#define MCUBOOT_SIGN_EC256
|
||||
|
||||
/*
|
||||
* Upgrade mode
|
||||
*
|
||||
* The default is to support A/B image swapping with rollback. A
|
||||
* simpler code path, which only supports overwriting the
|
||||
* existing image with the update image, is also available.
|
||||
*/
|
||||
|
||||
/* Uncomment to enable the overwrite-only code path. */
|
||||
#define MCUBOOT_OVERWRITE_ONLY
|
||||
|
||||
#ifdef MCUBOOT_OVERWRITE_ONLY
|
||||
/* Uncomment to only erase and overwrite those slot 0 sectors needed
|
||||
* to install the new image, rather than the entire image slot. */
|
||||
/* #define MCUBOOT_OVERWRITE_ONLY_FAST */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Cryptographic settings
|
||||
*
|
||||
* You must choose between mbedTLS and Tinycrypt as source of
|
||||
* cryptographic primitives. Other cryptographic settings are also
|
||||
* available.
|
||||
*/
|
||||
|
||||
/* Uncomment to use ARM's mbedTLS cryptographic primitives */
|
||||
#define MCUBOOT_USE_MBED_TLS
|
||||
/* Uncomment to use Tinycrypt's. */
|
||||
/* #define MCUBOOT_USE_TINYCRYPT */
|
||||
|
||||
/*
|
||||
* Always check the signature of the image in slot 0 before booting,
|
||||
* even if no upgrade was performed. This is recommended if the boot
|
||||
* time penalty is acceptable.
|
||||
*/
|
||||
#define MCUBOOT_VALIDATE_PRIMARY_SLOT
|
||||
|
||||
/*
|
||||
* Flash abstraction
|
||||
*/
|
||||
|
||||
/* Uncomment if your flash map API supports flash_area_get_sectors().
|
||||
* See the flash APIs for more details. */
|
||||
// TODO: FWSECURITY-755
|
||||
#define MCUBOOT_USE_FLASH_AREA_GET_SECTORS
|
||||
|
||||
/* Default number of separately updateable images; change in case of
|
||||
* multiple images. */
|
||||
#ifndef MCUBOOT_IMAGE_NUMBER
|
||||
#define MCUBOOT_IMAGE_NUMBER 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Currently there is no configuration option, for this platform,
|
||||
* that enables the system specific mcumgr commands in mcuboot
|
||||
*/
|
||||
#define MCUBOOT_PERUSER_MGMT_GROUP_ENABLED 0
|
||||
|
||||
/*
|
||||
* Logging
|
||||
*/
|
||||
|
||||
/*
|
||||
* If logging is enabled the following functions must be defined by the
|
||||
* platform:
|
||||
*
|
||||
* MCUBOOT_LOG_ERR(...)
|
||||
* MCUBOOT_LOG_WRN(...)
|
||||
* MCUBOOT_LOG_INF(...)
|
||||
* MCUBOOT_LOG_DBG(...)
|
||||
*
|
||||
* The following global logging level configuration macros must also be
|
||||
* defined, each with a unique value. Those will be used to define a global
|
||||
* configuration and will allow any source files to override the global
|
||||
* configuration:
|
||||
*
|
||||
* MCUBOOT_LOG_LEVEL_OFF
|
||||
* MCUBOOT_LOG_LEVEL_ERROR
|
||||
* MCUBOOT_LOG_LEVEL_WARNING
|
||||
* MCUBOOT_LOG_LEVEL_INFO
|
||||
* MCUBOOT_LOG_LEVEL_DEBUG
|
||||
*
|
||||
* The global logging level must be defined, with one of the previously defined
|
||||
* logging levels:
|
||||
*
|
||||
* #define MCUBOOT_LOG_LEVEL MCUBOOT_LOG_LEVEL_(OFF|ERROR|WARNING|INFO|DEBUG)
|
||||
*
|
||||
* MCUBOOT_LOG_LEVEL sets the minimum level that will be logged. The function
|
||||
* priority is:
|
||||
*
|
||||
* MCUBOOT_LOG_ERR > MCUBOOT_LOG_WRN > MCUBOOT_LOG_INF > MCUBOOT_LOG_DBG
|
||||
*
|
||||
* NOTE: Each source file is still able to request its own logging level by
|
||||
* defining BOOT_LOG_LEVEL before #including `bootutil_log.h`
|
||||
*/
|
||||
#define MCUBOOT_HAVE_LOGGING 1
|
||||
/* Define this to support native mcuboot logging system */
|
||||
#define CONFIG_MCUBOOT 1
|
||||
/*
|
||||
* Assertions
|
||||
*/
|
||||
|
||||
/* Uncomment if your platform has its own mcuboot_config/mcuboot_assert.h.
|
||||
* If so, it must provide an ASSERT macro for use by bootutil. Otherwise,
|
||||
* "assert" is used. */
|
||||
//#define MCUBOOT_HAVE_ASSERT_H
|
||||
|
||||
#define MCUBOOT_WATCHDOG_FEED() \
|
||||
do { \
|
||||
/* TODO: to be implemented */ \
|
||||
} while (0)
|
||||
|
||||
/* Uncomment these if support of encrypted upgrade image is needed */
|
||||
#ifdef ENC_IMG
|
||||
#define MCUBOOT_ENC_IMAGES
|
||||
#define MCUBOOT_ENCRYPT_EC256
|
||||
#define NUM_ECC_BYTES (256 / 8)
|
||||
#endif /* ENC_IMG */
|
||||
|
||||
/*
|
||||
* No direct idle call implemented
|
||||
*/
|
||||
#define MCUBOOT_CPU_IDLE() \
|
||||
do { \
|
||||
} while (0)
|
||||
|
||||
#endif /* MCUBOOT_CONFIG_H */
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Nordic Semiconductor ASA
|
||||
* Copyright (c) 2015 Runtime Inc
|
||||
* Copyright (c) 2020 Cypress Semiconductor Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
/*******************************************************************************/
|
||||
|
||||
#ifndef MCUBOOT_LOGGING_H
|
||||
#define MCUBOOT_LOGGING_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define MCUBOOT_LOG_LEVEL_OFF 0
|
||||
#define MCUBOOT_LOG_LEVEL_ERROR 1
|
||||
#define MCUBOOT_LOG_LEVEL_WARNING 2
|
||||
#define MCUBOOT_LOG_LEVEL_INFO 3
|
||||
#define MCUBOOT_LOG_LEVEL_DEBUG 4
|
||||
|
||||
/*
|
||||
* The compiled log level determines the maximum level that can be
|
||||
* printed. Messages at or below this level can be printed, provided
|
||||
* they are also enabled through the Rust logging system, such as by
|
||||
* setting RUST_LOG to bootsim::api=info.
|
||||
*/
|
||||
#ifndef MCUBOOT_LOG_LEVEL
|
||||
#define MCUBOOT_LOG_LEVEL MCUBOOT_LOG_LEVEL_INFO
|
||||
#endif
|
||||
|
||||
int sim_log_enabled(int level);
|
||||
|
||||
#define sim_log_enabled(x) 1
|
||||
|
||||
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_ERROR
|
||||
#define MCUBOOT_LOG_ERR(_fmt, ...) \
|
||||
do { \
|
||||
if (sim_log_enabled(MCUBOOT_LOG_LEVEL_ERROR)) { \
|
||||
fprintf(stderr, "[ERR] " _fmt "\n\r", ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define MCUBOOT_LOG_ERR(...) IGNORE(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_WARNING
|
||||
#define MCUBOOT_LOG_WRN(_fmt, ...) \
|
||||
do { \
|
||||
if (sim_log_enabled(MCUBOOT_LOG_LEVEL_WARNING)) { \
|
||||
fprintf(stderr, "[WRN] " _fmt "\n\r", ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define MCUBOOT_LOG_WRN(...) IGNORE(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_INFO
|
||||
#define MCUBOOT_LOG_INF(_fmt, ...) \
|
||||
do { \
|
||||
if (sim_log_enabled(MCUBOOT_LOG_LEVEL_INFO)) { \
|
||||
fprintf(stderr, "[INF] " _fmt "\n\r", ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define MCUBOOT_LOG_INF(...) IGNORE(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_DEBUG
|
||||
#define MCUBOOT_LOG_DBG(_fmt, ...) \
|
||||
do { \
|
||||
if (sim_log_enabled(MCUBOOT_LOG_LEVEL_DEBUG)) { \
|
||||
fprintf(stderr, "[DBG] " _fmt "\n\r", ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define MCUBOOT_LOG_DBG(...) IGNORE(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define MCUBOOT_LOG_MODULE_DECLARE(...)
|
||||
|
||||
#endif /* MCUBOOT_LOGGING_H */
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* mbed Microcontroller Library
|
||||
* Copyright (c) 2019 Cypress Semiconductor Corporation
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file mcuboot_crypto_acc_config.h
|
||||
* \version 1.1
|
||||
*/
|
||||
|
||||
#ifndef MCUBOOT_MBEDTLS_DEVICE_H
|
||||
#define MCUBOOT_MBEDTLS_DEVICE_H
|
||||
|
||||
/* Currently this target supports SHA1 */
|
||||
// #define MBEDTLS_SHA1_C
|
||||
|
||||
#define MBEDTLS_SHA1_ALT
|
||||
#define MBEDTLS_SHA256_ALT
|
||||
#define MBEDTLS_SHA512_ALT
|
||||
|
||||
/* Currently this target supports CBC, CFB, OFB, CTR and XTS cipher modes */
|
||||
#define MBEDTLS_AES_ALT
|
||||
// #define MBEDTLS_CIPHER_MODE_CBC
|
||||
// #define MBEDTLS_CIPHER_MODE_CFB
|
||||
// #define MBEDTLS_CIPHER_MODE_OFB
|
||||
#ifdef MCUBOOT_ENC_IMAGES
|
||||
#define MBEDTLS_CIPHER_MODE_CTR
|
||||
#endif
|
||||
// #define MBEDTLS_CIPHER_MODE_XTS
|
||||
|
||||
/* Only NIST-P curves are currently supported */
|
||||
#define MBEDTLS_ECP_ALT
|
||||
// #define MBEDTLS_ECP_DP_SECP192R1_ENABLED
|
||||
// #define MBEDTLS_ECP_DP_SECP224R1_ENABLED
|
||||
// #define MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
// #define MBEDTLS_ECP_DP_SECP384R1_ENABLED
|
||||
// #define MBEDTLS_ECP_DP_SECP521R1_ENABLED
|
||||
|
||||
#define MBEDTLS_ECDSA_SIGN_ALT
|
||||
#define MBEDTLS_ECDSA_VERIFY_ALT
|
||||
|
||||
#endif /* MCUBOOT_MBEDTLS_DEVICE_H */
|
||||
File diff suppressed because it is too large
Load Diff
44
bootloader/mcuboot/boot/cypress/MCUBootApp/cy_security_cnt.c
Normal file
44
bootloader/mcuboot/boot/cypress/MCUBootApp/cy_security_cnt.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Arm Limited.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "bootutil/security_cnt.h"
|
||||
#include <stdint.h>
|
||||
|
||||
fih_ret
|
||||
boot_nv_security_counter_init(void)
|
||||
{
|
||||
/* Do nothing. */
|
||||
return FIH_SUCCESS;
|
||||
}
|
||||
|
||||
fih_ret
|
||||
boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
|
||||
{
|
||||
(void)image_id;
|
||||
*security_cnt = 30;
|
||||
|
||||
return FIH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t
|
||||
boot_nv_security_counter_update(uint32_t image_id, uint32_t img_security_cnt)
|
||||
{
|
||||
(void)image_id;
|
||||
(void)img_security_cnt;
|
||||
|
||||
/* Do nothing. */
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/***************************************************************************//**
|
||||
* \file cy_serial_flash_prog.c
|
||||
*
|
||||
* \brief
|
||||
* Provides variables necessary to inform programming tools how to program the
|
||||
* attached serial flash memory. The variables used here must be placed at
|
||||
* specific locations in order to be detected and used by programming tools
|
||||
* to know that there is an attached memory and its characteristics. Uses the
|
||||
* configuration provided as part of BSP.
|
||||
*
|
||||
********************************************************************************
|
||||
* \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.
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* \addtogroup group_serial_flash Serial Flash
|
||||
* \{
|
||||
* Variables for informing programming tools that there is an attached memory device and what
|
||||
* its characteristics are so it can be programmed just like the on-chip memory.
|
||||
*
|
||||
* \defgroup group_serial_flash_variables Variables
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "flash_qspi.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const cy_stc_smif_block_config_t * smifCfg; /* Pointer to SMIF top-level configuration */
|
||||
const uint32_t null_t; /* NULL termination */
|
||||
} stc_smif_ipblocks_arr_t;
|
||||
|
||||
/**
|
||||
* \addtogroup group_serial_flash_variables
|
||||
* \{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This data can be placed anywhere in the internal memory, but it must be at a location that
|
||||
* can be determined and used for the calculation of the CRC16 checksum in the cyToc below. There
|
||||
* are multiple ways this can be accomplished including:
|
||||
* 1) Placing it in a dedicated memory block with a known address. (as done here)
|
||||
* 2) Placing it at an absolute location via a the linker script
|
||||
* 3) Using 'cymcuelftool -S' to recompute the checksum and patch the elf file after linking
|
||||
*/
|
||||
CY_SECTION(".cy_sflash_user_data") __attribute__( (used) )
|
||||
/* const stc_smif_ipblocks_arr_t smifIpBlocksArr = {&smifBlockConfig_sfdp, 0x00000000}; */
|
||||
/* if used zero-pointer to config, DAP link will use hardcoded config for CY8CPROTO-062-4343W */
|
||||
const stc_smif_ipblocks_arr_t smifIpBlocksArr = {0x00000000, 0x00000000};
|
||||
|
||||
/**
|
||||
* This data is used to populate the table of contents part 2. When present, it is used by the boot
|
||||
* process and programming tools to determine key characteristics about the memory usage including
|
||||
* where the boot process should start the application from and what external memories are connected
|
||||
* (if any). This must consume a full row of flash memory row. The last entry is a checksum of the
|
||||
* other values in the ToC which must be updated if any other value changes. This can be done manually
|
||||
* or by running 'cymcuelftool -S' to recompute the checksum.
|
||||
*/
|
||||
CY_SECTION(".cy_toc_part2") __attribute__( (used) )
|
||||
const uint32_t cyToc[128] =
|
||||
{
|
||||
0x200-4, /* Offset=0x0000: Object Size, bytes */
|
||||
0x01211220, /* Offset=0x0004: Magic Number (TOC Part 2, ID) */
|
||||
0, /* Offset=0x0008: Key Storage Address */
|
||||
(int)&smifIpBlocksArr, /* Offset=0x000C: This points to a null terminated array of SMIF structures. */
|
||||
0x10000000u, /* Offset=0x0010: App image start address */
|
||||
/* Offset=0x0014-0x01F7: Reserved */
|
||||
[126] = 0x000002C2, /* Offset=0x01F8: Bits[ 1: 0] CLOCK_CONFIG (0=8MHz, 1=25MHz, 2=50MHz, 3=100MHz)
|
||||
Bits[ 4: 2] LISTEN_WINDOW (0=20ms, 1=10ms, 2=1ms, 3=0ms, 4=100ms)
|
||||
Bits[ 6: 5] SWJ_PINS_CTL (0/1/3=Disable SWJ, 2=Enable SWJ)
|
||||
Bits[ 8: 7] APP_AUTHENTICATION (0/2/3=Enable, 1=Disable)
|
||||
Bits[10: 9] FB_BOOTLOADER_CTL: UNUSED */
|
||||
[127] = 0x3BB30000 /* Offset=0x01FC: CRC16-CCITT (the upper 2 bytes contain the CRC and the lower 2 bytes are 0) */
|
||||
};
|
||||
|
||||
/** \} group_serial_flash_variables */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/** \} group_serial_flash */
|
||||
169
bootloader/mcuboot/boot/cypress/MCUBootApp/keys.c
Normal file
169
bootloader/mcuboot/boot/cypress/MCUBootApp/keys.c
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
/*******************************************************************************
|
||||
*
|
||||
* This software is a port of the open source MCUBoot project.
|
||||
*
|
||||
* This file was modified to fit PSoC6-based MCUBoot applications.
|
||||
*
|
||||
* Portions of this software, including source code, documentation and related
|
||||
* materials ("Software"), are owned by Cypress Semiconductor
|
||||
* Corporation or one of its subsidiaries ("Cypress") and is protected by
|
||||
* and subject to worldwide patent protection (United States and foreign),
|
||||
* United States copyright laws and international treaty provisions.
|
||||
* Therefore, you may use this Software only as provided in the license
|
||||
* agreement accompanying the software package from which you
|
||||
* obtained this Software ("EULA").
|
||||
*
|
||||
* If no EULA applies, Cypress hereby grants you a personal, non-
|
||||
* exclusive, non-transferable license to copy, modify, and compile the
|
||||
* Software source code solely for use in connection with Cypress's
|
||||
* integrated circuit products. Any reproduction, modification, translation,
|
||||
* compilation, or representation of this Software except as specified
|
||||
* above is prohibited without the express written permission of Cypress.
|
||||
*
|
||||
* Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO
|
||||
* WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING,
|
||||
* BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. Cypress reserves the right to make
|
||||
* changes to the Software without notice. Cypress does not assume any
|
||||
* liability arising out of the application or use of the Software or any
|
||||
* product or circuit described in the Software. Cypress does not
|
||||
* authorize its products for use in any products where a malfunction or
|
||||
* failure of the Cypress product may reasonably be expected to result in
|
||||
* significant property damage, injury or death ("High Risk Product"). By
|
||||
* including Cypress's product in a High Risk Product, the manufacturer
|
||||
* of such system or application assumes all risk of such use and in doing
|
||||
* so agrees to indemnify Cypress against all liability.
|
||||
*
|
||||
********************************************************************************/
|
||||
#include <bootutil/sign_key.h>
|
||||
#include <mcuboot_config/mcuboot_config.h>
|
||||
|
||||
#if !defined(MCUBOOT_HW_KEY)
|
||||
#if defined(MCUBOOT_SIGN_RSA)
|
||||
const unsigned char rsa_pub_key[] = {
|
||||
0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd1, 0x06, 0x08,
|
||||
0x1a, 0x18, 0x44, 0x2c, 0x18, 0xe8, 0xfb, 0xfd, 0xf7, 0x0d, 0xa3, 0x4f,
|
||||
0x1f, 0xbb, 0xee, 0x5e, 0xf9, 0xaa, 0xd2, 0x4b, 0x18, 0xd3, 0x5a, 0xe9,
|
||||
0x6d, 0x18, 0x80, 0x19, 0xf9, 0xf0, 0x9c, 0x34, 0x1b, 0xcb, 0xf3, 0xbc,
|
||||
0x74, 0xdb, 0x42, 0xe7, 0x8c, 0x7f, 0x10, 0x53, 0x7e, 0x43, 0x5e, 0x0d,
|
||||
0x57, 0x2c, 0x44, 0xd1, 0x67, 0x08, 0x0f, 0x0d, 0xbb, 0x5c, 0xee, 0xec,
|
||||
0xb3, 0x99, 0xdf, 0xe0, 0x4d, 0x84, 0x0b, 0xaa, 0x77, 0x41, 0x60, 0xed,
|
||||
0x15, 0x28, 0x49, 0xa7, 0x01, 0xb4, 0x3c, 0x10, 0xe6, 0x69, 0x8c, 0x2f,
|
||||
0x5f, 0xac, 0x41, 0x4d, 0x9e, 0x5c, 0x14, 0xdf, 0xf2, 0xf8, 0xcf, 0x3d,
|
||||
0x1e, 0x6f, 0xe7, 0x5b, 0xba, 0xb4, 0xa9, 0xc8, 0x88, 0x7e, 0x47, 0x3c,
|
||||
0x94, 0xc3, 0x77, 0x67, 0x54, 0x4b, 0xaa, 0x8d, 0x38, 0x35, 0xca, 0x62,
|
||||
0x61, 0x7e, 0xb7, 0xe1, 0x15, 0xdb, 0x77, 0x73, 0xd4, 0xbe, 0x7b, 0x72,
|
||||
0x21, 0x89, 0x69, 0x24, 0xfb, 0xf8, 0x65, 0x6e, 0x64, 0x3e, 0xc8, 0x0e,
|
||||
0xd7, 0x85, 0xd5, 0x5c, 0x4a, 0xe4, 0x53, 0x0d, 0x2f, 0xff, 0xb7, 0xfd,
|
||||
0xf3, 0x13, 0x39, 0x83, 0x3f, 0xa3, 0xae, 0xd2, 0x0f, 0xa7, 0x6a, 0x9d,
|
||||
0xf9, 0xfe, 0xb8, 0xce, 0xfa, 0x2a, 0xbe, 0xaf, 0xb8, 0xe0, 0xfa, 0x82,
|
||||
0x37, 0x54, 0xf4, 0x3e, 0xe1, 0x2b, 0xd0, 0xd3, 0x08, 0x58, 0x18, 0xf6,
|
||||
0x5e, 0x4c, 0xc8, 0x88, 0x81, 0x31, 0xad, 0x5f, 0xb0, 0x82, 0x17, 0xf2,
|
||||
0x8a, 0x69, 0x27, 0x23, 0xf3, 0xab, 0x87, 0x3e, 0x93, 0x1a, 0x1d, 0xfe,
|
||||
0xe8, 0xf8, 0x1a, 0x24, 0x66, 0x59, 0xf8, 0x1c, 0xab, 0xdc, 0xce, 0x68,
|
||||
0x1b, 0x66, 0x64, 0x35, 0xec, 0xfa, 0x0d, 0x11, 0x9d, 0xaf, 0x5c, 0x3a,
|
||||
0xa7, 0xd1, 0x67, 0xc6, 0x47, 0xef, 0xb1, 0x4b, 0x2c, 0x62, 0xe1, 0xd1,
|
||||
0xc9, 0x02, 0x03, 0x01, 0x00, 0x01
|
||||
};
|
||||
const unsigned int rsa_pub_key_len = 270;
|
||||
#elif defined(MCUBOOT_SIGN_EC256)
|
||||
/* Format of PEM :
|
||||
* -----BEGIN PUBLIC KEY-----
|
||||
* base64encode(DER)
|
||||
* -----END PUBLIC KEY----- */
|
||||
#if defined(ECC256_KEY_FILE)
|
||||
#include ECC256_KEY_FILE
|
||||
#else
|
||||
#warning "Used default ECC256 ecdsa_pub_key"
|
||||
/* It is OEM_PUB_KEY at this moment for debug purposes */
|
||||
const unsigned char ecdsa_pub_key[] = {
|
||||
0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86,
|
||||
0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a,
|
||||
0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
|
||||
0x42, 0x00, 0x04, 0xbd, 0x59, 0x9d, 0x15, 0xe0,
|
||||
0xff, 0x66, 0x12, 0x37, 0x28, 0xdf, 0x50, 0x38,
|
||||
0xb1, 0x9a, 0x73, 0x9b, 0xbd, 0xd1, 0xb3, 0x8a,
|
||||
0x6f, 0xd2, 0x70, 0xed, 0x7f, 0xdb, 0x57, 0x53,
|
||||
0xde, 0x9e, 0x77, 0x0f, 0x9c, 0x17, 0x22, 0x69,
|
||||
0xa6, 0x75, 0x48, 0x1f, 0xa4, 0xbc, 0x49, 0xe2,
|
||||
0x01, 0xe0, 0x5e, 0x3d, 0xec, 0xa8, 0xc1, 0xca,
|
||||
0xc5, 0x5c, 0xa2, 0xc6, 0xfd, 0xb0, 0x24, 0xb1,
|
||||
0x0a, 0x46, 0xf5,
|
||||
};
|
||||
const unsigned int ecdsa_pub_key_len = 91;
|
||||
#endif
|
||||
#else
|
||||
#warning "No public key available for given signing algorithm."
|
||||
#endif
|
||||
|
||||
#if defined(MCUBOOT_SIGN_RSA) || \
|
||||
defined(MCUBOOT_SIGN_EC256)
|
||||
const struct bootutil_key bootutil_keys[] = {
|
||||
#if defined(MCUBOOT_SIGN_RSA)
|
||||
{
|
||||
.key = rsa_pub_key,
|
||||
.len = &rsa_pub_key_len,
|
||||
},
|
||||
#elif defined(MCUBOOT_SIGN_EC256)
|
||||
{
|
||||
.key = ecdsa_pub_key,
|
||||
.len = &ecdsa_pub_key_len,
|
||||
},
|
||||
#else
|
||||
{
|
||||
.key = NULL,
|
||||
.len = 0x00,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
const int bootutil_key_cnt = 1;
|
||||
#endif
|
||||
#else
|
||||
unsigned int pub_key_len;
|
||||
struct bootutil_key bootutil_keys[1] = {
|
||||
{
|
||||
.key = 0,
|
||||
.len = &pub_key_len,
|
||||
}
|
||||
};
|
||||
const int bootutil_key_cnt = 1;
|
||||
#endif /* !MCUBOOT_HW_KEY */
|
||||
|
||||
unsigned char enc_priv_key[] = {
|
||||
0x30, 0x81, 0x87, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86,
|
||||
0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
|
||||
0x03, 0x01, 0x07, 0x04, 0x6d, 0x30, 0x6b, 0x02, 0x01, 0x01, 0x04, 0x20,
|
||||
0xf6, 0x1e, 0x51, 0x9d, 0xf8, 0xfa, 0xdd, 0xa1, 0xb7, 0xd9, 0xa9, 0x64,
|
||||
0x64, 0x3b, 0x54, 0xd0, 0x3d, 0xd0, 0x1f, 0xe5, 0x78, 0xd9, 0x17, 0x98,
|
||||
0xa5, 0x28, 0xca, 0xcc, 0x6b, 0x67, 0x9e, 0x06, 0xa1, 0x44, 0x03, 0x42,
|
||||
0x00, 0x04, 0x8a, 0x44, 0x73, 0x00, 0x94, 0xc9, 0x80, 0x27, 0x31, 0x0d,
|
||||
0x23, 0x36, 0x6b, 0xe9, 0x69, 0x9f, 0xcb, 0xc5, 0x7c, 0xc8, 0x44, 0x1a,
|
||||
0x93, 0xe6, 0xee, 0x7d, 0x86, 0xa6, 0xae, 0x5e, 0x93, 0x72, 0x74, 0xd9,
|
||||
0xe1, 0x5a, 0x1c, 0x9b, 0x65, 0x1a, 0x2b, 0x61, 0x41, 0x28, 0x02, 0x73,
|
||||
0x84, 0x12, 0x97, 0x3a, 0x2d, 0xa2, 0xa0, 0x67, 0x77, 0x02, 0xda, 0x67,
|
||||
0x1a, 0x4b, 0xdd, 0xd7, 0x71, 0xcc,
|
||||
};
|
||||
static unsigned int enc_priv_key_len = 138;
|
||||
const struct bootutil_key bootutil_enc_key = {
|
||||
.key = enc_priv_key,
|
||||
.len = &enc_priv_key_len,
|
||||
};
|
||||
95
bootloader/mcuboot/boot/cypress/MCUBootApp/libs.mk
Normal file
95
bootloader/mcuboot/boot/cypress/MCUBootApp/libs.mk
Normal file
@@ -0,0 +1,95 @@
|
||||
################################################################################
|
||||
# \file libs.mk
|
||||
# \version 1.0
|
||||
#
|
||||
# \brief
|
||||
# Makefile to describe libraries needed 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.
|
||||
################################################################################
|
||||
|
||||
################################################################################
|
||||
# PDL library
|
||||
################################################################################
|
||||
PDL_VERSION = 121
|
||||
|
||||
THIS_APP_PATH = $(PRJ_DIR)/libs
|
||||
MBEDTLS_PATH = $(PRJ_DIR)/../../ext
|
||||
|
||||
# Add platform folder to build
|
||||
SOURCES_PLATFORM += $(wildcard $(PRJ_DIR)/platforms/*.c)
|
||||
SOURCES_WATCHDOG := $(wildcard $(THIS_APP_PATH)/watchdog/*.c)
|
||||
|
||||
# Add retartget IO implementation using pdl
|
||||
SOURCES_RETARGET_IO_PDL += $(wildcard $(THIS_APP_PATH)/retarget_io_pdl/*.c)
|
||||
|
||||
# Collect dirrectories containing headers for PLATFORM
|
||||
INCLUDE_RETARGET_IO_PDL += $(THIS_APP_PATH)/retarget_io_pdl
|
||||
|
||||
# PSOC6HAL source files
|
||||
SOURCES_HAL += $(THIS_APP_PATH)/psoc6hal/COMPONENT_PSOC6HAL/source/cyhal_crypto_common.c
|
||||
SOURCES_HAL += $(THIS_APP_PATH)/psoc6hal/COMPONENT_PSOC6HAL/source/cyhal_hwmgr.c
|
||||
|
||||
# MbedTLS source files
|
||||
SOURCES_MBEDTLS := $(wildcard $(MBEDTLS_PATH)/mbedtls/library/*.c)
|
||||
|
||||
# Collected source files for libraries
|
||||
SOURCES_LIBS += $(SOURCES_HAL)
|
||||
SOURCES_LIBS += $(SOURCES_MBEDTLS)
|
||||
SOURCES_LIBS += $(SOURCES_WATCHDOG)
|
||||
SOURCES_LIBS += $(SOURCES_PLATFORM)
|
||||
SOURCES_LIBS += $(SOURCES_RETARGET_IO_PDL)
|
||||
|
||||
# Include platforms folder
|
||||
INCLUDE_DIRS_PLATFORM := $(PRJ_DIR)/platforms
|
||||
|
||||
# needed for Crypto HW Acceleration and headers inclusion, do not use for peripherals
|
||||
# peripherals should be accessed
|
||||
INCLUDE_DIRS_HAL := $(THIS_APP_PATH)/psoc6hal/COMPONENT_PSOC6HAL/include
|
||||
INCLUDE_DIRS_HAL += $(THIS_APP_PATH)/psoc6hal/include
|
||||
INCLUDE_DIRS_HAL += $(THIS_APP_PATH)/psoc6hal/COMPONENT_PSOC6HAL/include/pin_packages
|
||||
|
||||
# MbedTLS related include directories
|
||||
INCLUDE_DIRS_MBEDTLS += $(MBEDTLS_PATH)/mbedtls/include
|
||||
INCLUDE_DIRS_MBEDTLS += $(MBEDTLS_PATH)/mbedtls/include/mbedtls
|
||||
INCLUDE_DIRS_MBEDTLS += $(MBEDTLS_PATH)/mbedtls/include/psa
|
||||
INCLUDE_DIRS_MBEDTLS += $(MBEDTLS_PATH)/mbedtls/library
|
||||
|
||||
# Watchdog related includes
|
||||
INCLUDE_DIRS_WATCHDOG := $(THIS_APP_PATH)/watchdog
|
||||
|
||||
# Collected include directories for libraries
|
||||
INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_DIRS_HAL))
|
||||
INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_DIRS_WATCHDOG))
|
||||
INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_DIRS_MBEDTLS))
|
||||
INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_RETARGET_IO_PDL))
|
||||
INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_DIRS_PLATFORM))
|
||||
|
||||
################################################################################
|
||||
# mbedTLS hardware acceleration settings
|
||||
################################################################################
|
||||
ifeq ($(USE_CRYPTO_HW), 1)
|
||||
# cy-mbedtls-acceleration related include directories
|
||||
INCLUDE_DIRS_MBEDTLS_MXCRYPTO := $(THIS_APP_PATH)/cy-mbedtls-acceleration/mbedtls_MXCRYPTO
|
||||
# Collect source files for MbedTLS acceleration
|
||||
SOURCES_MBEDTLS_MXCRYPTO := $(wildcard $(THIS_APP_PATH)/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/*.c)
|
||||
#
|
||||
INCLUDE_DIRS_LIBS += $(addprefix -I,$(INCLUDE_DIRS_MBEDTLS_MXCRYPTO))
|
||||
# Collected source files for libraries
|
||||
SOURCES_LIBS += $(SOURCES_MBEDTLS_MXCRYPTO)
|
||||
endif
|
||||
181
bootloader/mcuboot/boot/cypress/MCUBootApp/main.c
Normal file
181
bootloader/mcuboot/boot/cypress/MCUBootApp/main.c
Normal file
@@ -0,0 +1,181 @@
|
||||
/***************************************************************************//**
|
||||
* \file main.c
|
||||
* \version 1.0
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
/* Cypress pdl headers */
|
||||
#include "cy_pdl.h"
|
||||
#include "cy_retarget_io_pdl.h"
|
||||
#include "cy_result.h"
|
||||
|
||||
#include "cycfg_clocks.h"
|
||||
#include "cycfg_peripherals.h"
|
||||
#include "cycfg_pins.h"
|
||||
|
||||
#include "flash_qspi.h"
|
||||
#include "sysflash/sysflash.h"
|
||||
#include "flash_map_backend/flash_map_backend.h"
|
||||
|
||||
#include "bootutil/image.h"
|
||||
#include "bootutil/bootutil.h"
|
||||
#include "bootutil/sign_key.h"
|
||||
|
||||
#include "bootutil/bootutil_log.h"
|
||||
|
||||
#include "bootutil/fault_injection_hardening.h"
|
||||
|
||||
#include "watchdog.h"
|
||||
|
||||
/* WDT time out for reset mode, in milliseconds. */
|
||||
#define WDT_TIME_OUT_MS 4000
|
||||
|
||||
/* Define pins for UART debug output */
|
||||
#define CYBSP_UART_ENABLED 1U
|
||||
#define CYBSP_UART_HW SCB5
|
||||
#define CYBSP_UART_IRQ scb_5_interrupt_IRQn
|
||||
|
||||
#ifdef CY_BOOT_USE_EXTERNAL_FLASH
|
||||
/* Choose SMIF slot number (slave select).
|
||||
* Acceptable values are:
|
||||
* 0 - SMIF disabled (no external memory);
|
||||
* 1, 2, 3 or 4 - slave select line memory module is connected to.
|
||||
*/
|
||||
uint32_t smif_id = 1; /* Assume SlaveSelect_0 is used for External Memory */
|
||||
#endif
|
||||
|
||||
|
||||
void hw_deinit(void);
|
||||
|
||||
static void do_boot(struct boot_rsp *rsp)
|
||||
{
|
||||
uint32_t app_addr = 0;
|
||||
|
||||
app_addr = (rsp->br_image_off + rsp->br_hdr->ih_hdr_size);
|
||||
|
||||
BOOT_LOG_INF("Starting User Application on CM4 (wait)...");
|
||||
BOOT_LOG_INF("Start Address: 0x%08lx", app_addr);
|
||||
BOOT_LOG_INF("Deinitializing hardware...");
|
||||
|
||||
cy_retarget_io_wait_tx_complete(CYBSP_UART_HW, 10);
|
||||
|
||||
hw_deinit();
|
||||
|
||||
Cy_SysEnableCM4(app_addr);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct boot_rsp rsp;
|
||||
cy_rslt_t rc = CY_RSLT_TYPE_ERROR;
|
||||
bool boot_succeeded = false;
|
||||
FIH_DECLARE(fih_rc, FIH_FAILURE);
|
||||
|
||||
SystemInit();
|
||||
//init_cycfg_clocks();
|
||||
init_cycfg_peripherals();
|
||||
init_cycfg_pins();
|
||||
|
||||
/* Certain PSoC 6 devices enable CM4 by default at startup. It must be
|
||||
* either disabled or enabled & running a valid application for flash write
|
||||
* to work from CM0+. Since flash write may happen in boot_go() for updating
|
||||
* the image before this bootloader app can enable CM4 in do_boot(), we need
|
||||
* to keep CM4 disabled. Note that debugging of CM4 is not supported when it
|
||||
* is disabled.
|
||||
*/
|
||||
#if defined(CY_DEVICE_PSOC6ABLE2)
|
||||
if (CY_SYS_CM4_STATUS_ENABLED == Cy_SysGetCM4Status())
|
||||
{
|
||||
Cy_SysDisableCM4();
|
||||
}
|
||||
#endif /* #if defined(CY_DEVICE_PSOC6ABLE2) */
|
||||
|
||||
/* enable interrupts */
|
||||
__enable_irq();
|
||||
|
||||
/* Initialize retarget-io to use the debug UART port (CYBSP_UART_HW) */
|
||||
rc = cy_retarget_io_pdl_init(115200u);
|
||||
|
||||
if (rc != CY_RSLT_SUCCESS)
|
||||
{
|
||||
CY_ASSERT(0);
|
||||
}
|
||||
|
||||
BOOT_LOG_INF("MCUBoot Bootloader Started");
|
||||
|
||||
#ifdef CY_BOOT_USE_EXTERNAL_FLASH
|
||||
rc = CY_SMIF_CMD_NOT_FOUND;
|
||||
|
||||
#undef MCUBOOT_MAX_IMG_SECTORS
|
||||
/* redefine number of sectors as there 2MB will be
|
||||
* available on PSoC062-2M in case of external
|
||||
* memory usage */
|
||||
#define MCUBOOT_MAX_IMG_SECTORS 4096
|
||||
rc = qspi_init_sfdp(smif_id);
|
||||
if (rc == CY_SMIF_SUCCESS)
|
||||
{
|
||||
BOOT_LOG_INF("External Memory initialized w/ SFDP.");
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOT_LOG_ERR("External Memory initialization w/ SFDP FAILED: 0x%02x", (int)rc);
|
||||
}
|
||||
if (CY_SMIF_SUCCESS == rc)
|
||||
#endif
|
||||
{
|
||||
|
||||
FIH_CALL(boot_go, fih_rc, &rsp);
|
||||
if (FIH_EQ(fih_rc, FIH_SUCCESS))
|
||||
{
|
||||
BOOT_LOG_INF("User Application validated successfully");
|
||||
/* initialize watchdog timer. it should be updated from user app
|
||||
* to mark successful start up of this app. if the watchdog is not updated,
|
||||
* reset will be initiated by watchdog timer and swap revert operation started
|
||||
* to roll back to operable image.
|
||||
*/
|
||||
cy_wdg_init(WDT_TIME_OUT_MS);
|
||||
do_boot(&rsp);
|
||||
boot_succeeded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOT_LOG_INF("MCUBoot Bootloader found none of bootable images");
|
||||
}
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (boot_succeeded) {
|
||||
Cy_SysPm_CpuEnterDeepSleep(CY_SYSPM_WAIT_FOR_INTERRUPT);
|
||||
}
|
||||
else {
|
||||
__WFI();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hw_deinit(void)
|
||||
{
|
||||
cy_retarget_io_pdl_deinit();
|
||||
Cy_GPIO_Port_Deinit(CYBSP_UART_RX_PORT);
|
||||
Cy_GPIO_Port_Deinit(CYBSP_UART_TX_PORT);
|
||||
|
||||
#ifdef CY_BOOT_USE_EXTERNAL_FLASH
|
||||
qspi_deinit(smif_id);
|
||||
#endif
|
||||
}
|
||||
18
bootloader/mcuboot/boot/cypress/MCUBootApp/os/os.h
Normal file
18
bootloader/mcuboot/boot/cypress/MCUBootApp/os/os.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/***************************************************************************//**
|
||||
* \file os.h
|
||||
* \version 1.0
|
||||
*
|
||||
* \brief
|
||||
* Objective:
|
||||
* Heap init prototype
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2017-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||
* You may use this file only in accordance with the license, terms, conditions,
|
||||
* disclaimers, and limitations in the end user license agreement accompanying
|
||||
* the software package with which this file was provided.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
void os_heap_init(void);
|
||||
37
bootloader/mcuboot/boot/cypress/MCUBootApp/os/os_heap.h
Normal file
37
bootloader/mcuboot/boot/cypress/MCUBootApp/os/os_heap.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
|
||||
#ifndef H_OS_HEAP_
|
||||
#define H_OS_HEAP_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void *os_malloc(size_t size);
|
||||
void os_free(void *mem);
|
||||
void *os_realloc(void *ptr, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
42
bootloader/mcuboot/boot/cypress/MCUBootApp/os/os_malloc.h
Normal file
42
bootloader/mcuboot/boot/cypress/MCUBootApp/os/os_malloc.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
|
||||
#ifndef H_OS_MALLOC_
|
||||
#define H_OS_MALLOC_
|
||||
|
||||
#include "os/os_heap.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#undef malloc
|
||||
#define malloc os_malloc
|
||||
|
||||
#undef free
|
||||
#define free os_free
|
||||
|
||||
#undef realloc
|
||||
#define realloc os_realloc
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
/* Manual version of auto-generated version. */
|
||||
|
||||
#ifndef __SYSFLASH_H__
|
||||
#define __SYSFLASH_H__
|
||||
|
||||
#define FLASH_DEVICE_INTERNAL_FLASH (0x7F)
|
||||
|
||||
#define FLASH_AREA_BOOTLOADER 0
|
||||
#define FLASH_AREA_IMAGE_0 1
|
||||
#define FLASH_AREA_IMAGE_1 2
|
||||
#define FLASH_AREA_IMAGE_SCRATCH 3
|
||||
#define FLASH_AREA_IMAGE_2 5
|
||||
#define FLASH_AREA_IMAGE_3 6
|
||||
|
||||
/* Uncomment if external flash is being used */
|
||||
/* #define CY_BOOT_USE_EXTERNAL_FLASH */
|
||||
|
||||
/* use PDL-defined offset or one from SMFI config */
|
||||
#define CY_SMIF_BASE_MEM_OFFSET (0x18000000)
|
||||
|
||||
#define CY_FLASH_ALIGN (CY_FLASH_SIZEOF_ROW)
|
||||
#define CY_FLASH_DEVICE_BASE (CY_FLASH_BASE)
|
||||
|
||||
#ifndef CY_BOOT_SCRATCH_SIZE
|
||||
#define CY_BOOT_SCRATCH_SIZE (0x1000)
|
||||
#endif
|
||||
|
||||
#ifndef CY_BOOT_BOOTLOADER_SIZE
|
||||
#define CY_BOOT_BOOTLOADER_SIZE (0x18000)
|
||||
#endif
|
||||
|
||||
#ifndef CY_BOOT_PRIMARY_1_SIZE
|
||||
#define CY_BOOT_PRIMARY_1_SIZE (0x10000)
|
||||
#endif
|
||||
|
||||
#ifndef CY_BOOT_SECONDARY_1_SIZE
|
||||
#define CY_BOOT_SECONDARY_1_SIZE (0x10000)
|
||||
#endif
|
||||
|
||||
#if (MCUBOOT_IMAGE_NUMBER == 2) /* if dual-image */
|
||||
#ifndef CY_BOOT_PRIMARY_2_SIZE
|
||||
#define CY_BOOT_PRIMARY_2_SIZE (0x10000)
|
||||
#endif
|
||||
|
||||
#ifndef CY_BOOT_SECONDARY_2_SIZE
|
||||
#define CY_BOOT_SECONDARY_2_SIZE (0x10000)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (MCUBOOT_IMAGE_NUMBER == 1)
|
||||
#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \
|
||||
FLASH_AREA_IMAGE_0 : \
|
||||
FLASH_AREA_IMAGE_0)
|
||||
#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \
|
||||
FLASH_AREA_IMAGE_1 : \
|
||||
FLASH_AREA_IMAGE_1)
|
||||
|
||||
#elif (MCUBOOT_IMAGE_NUMBER == 2)
|
||||
|
||||
#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \
|
||||
FLASH_AREA_IMAGE_0 : \
|
||||
((x) == 1) ? \
|
||||
FLASH_AREA_IMAGE_2 : \
|
||||
255)
|
||||
#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \
|
||||
FLASH_AREA_IMAGE_1 : \
|
||||
((x) == 1) ? \
|
||||
FLASH_AREA_IMAGE_3 : \
|
||||
255)
|
||||
|
||||
#else
|
||||
#warning "Image slot and flash area mapping is not defined"
|
||||
#endif
|
||||
#define CY_IMG_HDR_SIZE 0x400
|
||||
|
||||
#ifndef CY_FLASH_MAP_EXT_DESC
|
||||
/* Uncomment in case you want to use separately defined table of flash area descriptors */
|
||||
/* #define CY_FLASH_MAP_EXT_DESC */
|
||||
#endif
|
||||
|
||||
#endif /* __SYSFLASH_H__ */
|
||||
Reference in New Issue
Block a user