1 /* Copyright 2019 Cypress Semiconductor Corporation
2  *
3  * Copyright (c) 2018 Open Source Foundries Limited
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 #ifndef MCUBOOT_CONFIG_H
8 #define MCUBOOT_CONFIG_H
9 
10 /*
11  * Template configuration file for MCUboot.
12  *
13  * When porting MCUboot to a new target, copy it somewhere that your
14  * include path can find it as mcuboot_config/mcuboot_config.h, and
15  * make adjustments to suit your platform.
16  *
17  * For examples, see:
18  *
19  * boot/zephyr/include/mcuboot_config/mcuboot_config.h
20  * boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
21  */
22 /* Default maximum number of flash sectors per image slot; change
23  * as desirable. */
24 #ifndef MCUBOOT_MAX_IMG_SECTORS
25 #define MCUBOOT_MAX_IMG_SECTORS 2560
26 #endif
27 
28 /*
29  * Signature types
30  *
31  * You must choose exactly one signature type.
32  */
33 
34 /* Uncomment for RSA signature support */
35 //#define MCUBOOT_SIGN_RSA
36 
37 /* Uncomment for ECDSA signatures using curve P-256. */
38 #define MCUBOOT_SIGN_EC256
39 
40 /*
41  * Upgrade mode
42  *
43  * The default is to support A/B image swapping with rollback.  A
44  * simpler code path, which only supports overwriting the
45  * existing image with the update image, is also available.
46  */
47 
48 /* Uncomment to enable the overwrite-only code path. */
49 #define MCUBOOT_OVERWRITE_ONLY
50 
51 #ifdef MCUBOOT_OVERWRITE_ONLY
52 /* Uncomment to only erase and overwrite those slot 0 sectors needed
53  * to install the new image, rather than the entire image slot. */
54 /* #define MCUBOOT_OVERWRITE_ONLY_FAST */
55 #endif
56 
57 /*
58  * Cryptographic settings
59  *
60  * You must choose between mbedTLS and Tinycrypt as source of
61  * cryptographic primitives. Other cryptographic settings are also
62  * available.
63  */
64 
65 /* Uncomment to use ARM's mbedTLS cryptographic primitives */
66 #define MCUBOOT_USE_MBED_TLS
67 /* Uncomment to use Tinycrypt's. */
68 /* #define MCUBOOT_USE_TINYCRYPT */
69 
70 /*
71  * Always check the signature of the image in slot 0 before booting,
72  * even if no upgrade was performed. This is recommended if the boot
73  * time penalty is acceptable.
74  */
75 #define MCUBOOT_VALIDATE_PRIMARY_SLOT
76 
77 /*
78  * Flash abstraction
79  */
80 
81 /* Uncomment if your flash map API supports flash_area_get_sectors().
82  * See the flash APIs for more details. */
83 // TODO: FWSECURITY-755
84 #define MCUBOOT_USE_FLASH_AREA_GET_SECTORS
85 
86 /* Default number of separately updateable images; change in case of
87  * multiple images. */
88 #ifndef MCUBOOT_IMAGE_NUMBER
89 #define MCUBOOT_IMAGE_NUMBER 1
90 #endif
91 
92 /*
93  * Currently there is no configuration option, for this platform,
94  * that enables the system specific mcumgr commands in mcuboot
95  */
96 #define MCUBOOT_PERUSER_MGMT_GROUP_ENABLED 0
97 
98 /*
99  * Logging
100  */
101 
102 /*
103  * If logging is enabled the following functions must be defined by the
104  * platform:
105  *
106  *    MCUBOOT_LOG_ERR(...)
107  *    MCUBOOT_LOG_WRN(...)
108  *    MCUBOOT_LOG_INF(...)
109  *    MCUBOOT_LOG_DBG(...)
110  *
111  * The following global logging level configuration macros must also be
112  * defined, each with a unique value. Those will be used to define a global
113  * configuration and will allow any source files to override the global
114  * configuration:
115  *
116  *    MCUBOOT_LOG_LEVEL_OFF
117  *    MCUBOOT_LOG_LEVEL_ERROR
118  *    MCUBOOT_LOG_LEVEL_WARNING
119  *    MCUBOOT_LOG_LEVEL_INFO
120  *    MCUBOOT_LOG_LEVEL_DEBUG
121  *
122  * The global logging level must be defined, with one of the previously defined
123  * logging levels:
124  *
125  *    #define MCUBOOT_LOG_LEVEL MCUBOOT_LOG_LEVEL_(OFF|ERROR|WARNING|INFO|DEBUG)
126  *
127  * MCUBOOT_LOG_LEVEL sets the minimum level that will be logged. The function
128  * priority is:
129  *
130  *    MCUBOOT_LOG_ERR > MCUBOOT_LOG_WRN > MCUBOOT_LOG_INF > MCUBOOT_LOG_DBG
131  *
132  * NOTE: Each source file is still able to request its own logging level by
133  * defining BOOT_LOG_LEVEL before #including `bootutil_log.h`
134  */
135 #define MCUBOOT_HAVE_LOGGING 1
136 /* Define this to support native mcuboot logging system */
137 #define CONFIG_MCUBOOT 1
138 /*
139  * Assertions
140  */
141 
142 /* Uncomment if your platform has its own mcuboot_config/mcuboot_assert.h.
143  * If so, it must provide an ASSERT macro for use by bootutil. Otherwise,
144  * "assert" is used. */
145 //#define MCUBOOT_HAVE_ASSERT_H
146 
147 #define MCUBOOT_WATCHDOG_FEED()         \
148     do {                                \
149         /* TODO: to be implemented */   \
150     } while (0)
151 
152 /* Uncomment these if support of encrypted upgrade image is needed */
153 #ifdef ENC_IMG
154 #define MCUBOOT_ENC_IMAGES
155 #define MCUBOOT_ENCRYPT_EC256
156 #define NUM_ECC_BYTES (256 / 8)
157 #endif /* ENC_IMG */
158 
159 /*
160  * No direct idle call implemented
161  */
162 #define MCUBOOT_CPU_IDLE() \
163     do {                   \
164     } while (0)
165 
166 #endif /* MCUBOOT_CONFIG_H */
167