Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 1 | ### Port Of Mcuboot Library For Evaluation With Cypress PSoC 6 Chips |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 2 | |
Roman Okhrimenko | 6ea44be | 2020-09-24 17:20:15 +0300 | [diff] [blame] | 3 | ### Disclaimer |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 4 | |
Roman Okhrimenko | 6ea44be | 2020-09-24 17:20:15 +0300 | [diff] [blame] | 5 | Given solution is included in `mcuboot` repository with purpose to demonstrate basic consepts and features of MCUBoot library on Cypress PSoC 6 device. Applications are created per mcuboot library maintainers requirements. Implemetation differs from conventional and recomended by Cypress Semiconductors development flow for PSoC 6 devices. These applications are not recomended as a starting point for development and should not be considered as supported examples for PSoC 6 devices. |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 6 | |
Roman Okhrimenko | 6ea44be | 2020-09-24 17:20:15 +0300 | [diff] [blame] | 7 | Examples provided to use with **ModusToolbox® Software Environment** are a recommended reference point to start development of MCUBoot based bootloaders for PSoC 6 devices. |
| 8 | |
| 9 | Refer to **Cypress Semiconductors** [github](https://github.com/cypresssemiconductorco) page to find examples. |
| 10 | |
| 11 | 1. MCUboot-Based Basic Bootloader [mtb-example-psoc6-mcuboot-basic](https://github.com/cypresssemiconductorco/mtb-example-psoc6-mcuboot-basic) |
| 12 | 2. MCUboot-Based Bootloader with Rollback to Factory App in External Flash [mtb-example-anycloud-mcuboot-rollback](https://github.com/cypresssemiconductorco/mtb-example-anycloud-mcuboot-rollback) |
| 13 | |
| 14 | ### Solution Description |
| 15 | |
| 16 | There are two applications implemented: |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 17 | * MCUBootApp - PSoC 6 MCUBoot-based bootloading application; |
| 18 | * BlinkyApp - simple PSoC 6 blinking LED application which is a target of BOOT/UPGRADE; |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 19 | |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 20 | #### MCUBootApp |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 21 | |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 22 | * There are two types of upgrade operation supported: |
| 23 | * **Overwrite only** - secondady image is only copied to primary slot after validation |
| 24 | * **Swap** - seconrady and primary slots images are swapped in process of upgrade. Upgrade operation can be reverted in case of bad secondary image. |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 25 | |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 26 | * There are two types of operation modes supported: |
| 27 | * single image |
| 28 | * multi image |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 29 | |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 30 | * Secondary (upgrade) slot(s) can be placed in external memory. For more details about External Memory usage refer to separate guiding document `MCUBootApp/ExternalMemory.md`. |
| 31 | |
| 32 | * MCUBootApp checks image integrity with SHA256, image authenticity with EC256 digital signature verification |
| 33 | * Cryptographic functions can be based on completely software implementation or be hardware accelerated. mbedTLS library is used in both cases. |
| 34 | |
| 35 | Detailed description of **MCUBootApp** is provided in `MCUBootApp/MCUBootApp.md` |
Bohdan Kovalchuk | a333a45 | 2020-07-09 16:55:58 +0300 | [diff] [blame] | 36 | |
Roman Okhrimenko | 579b30c | 2021-03-24 13:35:59 +0200 | [diff] [blame] | 37 | MCUBootApp checks image integrity with SHA256, image authenticity with EC256 digital signature verification and uses either completely software implementation of cryptographic functions or accelerated by hardware - both based on mbedTLS Library. |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 38 | |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 39 | #### BlinkyApp |
| 40 | * Can be built to use as primary or secondary image for both internal and external flash memory |
| 41 | * Primary and secondary images differ in text printed to serial terminal and led blinking frequency. |
| 42 | * Watchdog timer functionality is supported to confirm successful start/upgrade of application |
| 43 | * User application side of mcuboot swap operation is demonstrated for secondary image build. |
| 44 | |
| 45 | Detailed description of **BlinkyApp** is provided in `BlinkyApp/BlinkyApp.md` |
| 46 | |
Roman Okhrimenko | 6ea44be | 2020-09-24 17:20:15 +0300 | [diff] [blame] | 47 | ### Downloading Solution's Assets |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 48 | |
| 49 | There is a set assets required: |
| 50 | |
| 51 | * MCUBooot Library (root repository) |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 52 | * PSoC 6 Peripheral Drivers Library (PDL) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 53 | * mbedTLS Cryptographic Library |
| 54 | |
| 55 | Those are represented as submodules. |
| 56 | |
| 57 | To retrieve source code with subsequent submodules pull: |
| 58 | |
Fabio Utzig | de1d72d | 2020-11-10 12:35:04 -0300 | [diff] [blame] | 59 | git clone --recursive https://github.com/mcu-tools/mcuboot.git |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 60 | |
| 61 | Submodules can also be updated and initialized separately: |
| 62 | |
Christian Daudt | e1960a9 | 2020-03-04 14:20:33 -0800 | [diff] [blame] | 63 | cd mcuboot |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 64 | git submodule update --init --recursive |
| 65 | |
Roman Okhrimenko | 6ea44be | 2020-09-24 17:20:15 +0300 | [diff] [blame] | 66 | ### Building Solution |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 67 | |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 68 | Root directory for build is `boot/cypress`. |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 69 | |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 70 | Root folder contains make files infrastructure for building both MCUBootApp bootloading application and BlinkyApp user application. |
Roman Okhrimenko | aa7c021 | 2020-03-24 23:33:00 +0200 | [diff] [blame] | 71 | |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 72 | Instructions on how to build and upload MCUBootApp bootloading application and sample user application are located in `MCUBootApp.md` and `BlinkyApp.md` files in corresponding folders. |
| 73 | |
| 74 | **Toolchain** |
| 75 | |
| 76 | **GCC_ARM** is the only supported (built and verified on GCC 7.2.1). |
| 77 | |
| 78 | It is inluded with [ModusToolbox® Software Environment](https://www.cypress.com/products/modustoolbox-software-environment) and can be found in folder `./ModusToolbox/tools_2.1/gcc-7.2.1`. |
| 79 | |
| 80 | Default installation folder is expected by makefile build system. |
| 81 | |
| 82 | In case of using another installation folder, version of **ModusToolbox IDE** or another GCC Compiler - path to a toolchain should be specified to a build system using **TOOLCHAIN_PATH** flag. |
| 83 | |
| 84 | **Example:** |
| 85 | |
| 86 | make app APP_NAME=BlinkyApp PLATFORM=PSOC_062_2M IMG_TYPE=BOOT TOOLCHAIN_PATH=/home/fw-security/ModusToolbox/tools_2.0/gcc-7.2.1 |
Roman Okhrimenko | aa7c021 | 2020-03-24 23:33:00 +0200 | [diff] [blame] | 87 | |
Roman Okhrimenko | 579b30c | 2021-03-24 13:35:59 +0200 | [diff] [blame] | 88 | Supported platforms for `MCUBoot`, `BlinkyApp`: |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 89 | |
Roman Okhrimenko | 579b30c | 2021-03-24 13:35:59 +0200 | [diff] [blame] | 90 | * PSOC_062_2M |
| 91 | * PSOC_062_1M |
| 92 | * PSOC_062_512K |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 93 | |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame^] | 94 | ### Build Environment Troubleshooting |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 95 | |
| 96 | Following CLI / IDE are supported for project build: |
| 97 | |
| 98 | * Cygwin on Windows systems |
Christian Daudt | e1960a9 | 2020-03-04 14:20:33 -0800 | [diff] [blame] | 99 | * unix style shells on *nix systems |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 100 | * Eclipse / ModusToolbox ("makefile project from existing source") |
| 101 | |
| 102 | *Make* - make sure it is added to system's `PATH` variable and correct path is first in the list; |
| 103 | |
| 104 | *Python/Python3* - make sure you have correct path referenced in `PATH`; |
| 105 | |
| 106 | *Msys2* - to use systems PATH navigate to msys2 folder, open `msys2_shell.cmd`, uncomment set `MSYS2_PATH_TYPE=inherit`, restart MSYS2 shell. |
| 107 | |
| 108 | This will inherit system's PATH so should find `python3.7` installed in regular way as well as imgtool and its dependencies. |
| 109 | |