blob: 720683d979109cd2e435a0f8bfe88ed28a1ee45a [file] [log] [blame] [view]
Roman Okhrimenko977b3752022-03-31 14:40:48 +03001## PSoC™ 6 platform description
2
3### MCUBootApp specifics
4
5### Default memory map
6
Roman Okhrimenkodc0ca082023-06-21 20:49:51 +03007This repository provides a set of predefined memory maps in JSON files. They are located in `platforms/memory/PSOC6/flashmap`. One can use the predefined flash map or define its own using the predefined file as a template.
Roman Okhrimenko977b3752022-03-31 14:40:48 +03008
9### JSON flash map
10As absolute addresses are used in JSON flash maps, the placement of flash area in internal or external memory is derived from its address. For instance:
Roman Okhrimenkodc0ca082023-06-21 20:49:51 +030011
Roman Okhrimenko977b3752022-03-31 14:40:48 +030012```
13 "application_1": {
14 "address": {
15 "description": "Address of the application primary slot",
16 "value": "0x10018000"
17 },
18 "size": {
19 "description": "Size of the application primary slot",
20 "value": "0x10000"
21 },
22 "upgrade_address": {
23 "description": "Address of the application secondary slot",
24 "value": "0x18030200"
25 },
26 "upgrade_size": {
27 "description": "Size of the application secondary slot",
28 "value": "0x10000"
29 }
30 }
31```
32declares primary slot in the internal Flash, and secondary slot in the external Flash.
33
34##### Shared secondary slot
35Some Flash ICs have large erase block. For SEMPER Secure NOR Flash it is 256 kilobytes, so placing each image trailer in a separate erase block seems a waste.
36
37Specific technique is needed to place all trailers of the shared secondary slot in the single erase block. Since the whole erase block with trailer is occasionally cleared by MCUBoot, image padding is required to place trailers at different addresses and to avoid unintended erasing of image bytes.
Roman Okhrimenkodc0ca082023-06-21 20:49:51 +030038
Roman Okhrimenko977b3752022-03-31 14:40:48 +030039```
40 /| |-----------| |
41 / | | | |
42 / |-----------| | |
43 / | | | |
44 / | | Image 2 |-----------|
45 / | Image 1 | | |
46 / : : : Image 3 :
47 / | | | |
48 / |-----------|-----------|-----------|
49 Shared | Trailer | Padding | |\
50Secondary |0x200 bytes|0x200 bytes| Padding | \
51 Slot |-----------|-----------| | \
52 \ | | Trailer |0x400 bytes| \
53 \ | |0x200 bytes| | Erase
54 \ | |-----------|-----------| block
55 \ | | | Trailer | 256 K
56 \ | | |0x200 bytes| /
57 \ | | |-----------| /
58 \ : : : : /
59 \ | | | |/
60 \|-----------|-----------|-----------|
61```
62The pre-build script issues messages, such as
63```
64Note: application_2 (secondary slot) requires 512 padding bytes before trailer
65```
66to remind about the necessary padding.
67
68### Encrypted Image Support
69
70To protect the user's image from unwanted read, Upgrade Image Encryption can be applied. The ECDH/HKDF with the EC256 scheme is used in a given solution as well as mbedTLS as a crypto provider.
71
72To enable the image encryption support, use the `ENC_IMG=1` build flag (BlinkyApp should also be built with this flash set 1).
73
74The 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.md](../../BlinkyApp/BlinkyApp.md).
75
76After MCUBootApp is built with these settings, unencrypted and encrypted images will be accepted in the secondary (upgrade) slot.
77
78An example of the command:
79
Roman Okhrimenkodc0ca082023-06-21 20:49:51 +030080 make app APP_NAME=MCUBootApp PLATFORM=PSOC_062_2M BUILDCFG=Debug FLASH_MAP=platforms/memory/PSOC6/flashmap/psoc6_swap_single.json ENC_IMG=1
Roman Okhrimenko977b3752022-03-31 14:40:48 +030081
82NOTE: Debug configuration of MCUBootApp with Multi-image encrypted upgrades in external flash (built with flags `BUILDCFG=Debug` `MCUBOOT_IMG_NUMBER=2 USE_EXTERNAL_FLASH=1 ENC_IMG=1`) is set to use optimization level `-O2 -g3` to fit into `0x18000` allocated for `MCUBootApp`.
83
84### Programming applications
85
86#### Using OpenOCD from command line
87
88The following instructions assume the usage of one of Cypress development kits `CY8CPROTO_062_4343W`.
89
90Connect the board to your computer. Switch Kitprog3 to DAP-BULK mode by clicking the `SW3 MODE` button until `LED2 STATUS` constantly shines.
91
92Open the terminal application and execute the following command after substitution of the `PATH_TO_APPLICATION.hex` and `OPENOCD` paths:
93
94 export OPENOCD=/Applications/ModusToolbox/tools_2.4/openocd
95
96 ${OPENOCD}/bin/openocd -s ${OPENOCD}/scripts \
97 -f ${OPENOCD}/scripts/interface/kitprog3.cfg \
98 -f ${OPENOCD}/scripts/target/psoc6_2m.cfg \
99 -c "init; reset init; program PATH_TO_APPLICATION.hex" \
100 -c "resume; reset; exit"