1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *  http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied.  See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 #ifndef __MCUBOOT_CONFIG_H__
20 #define __MCUBOOT_CONFIG_H__
21 
22 #include <syscfg/syscfg.h>
23 
24 #if MYNEWT_VAL(BOOTUTIL_IMAGE_NUMBER)
25 #define MCUBOOT_IMAGE_NUMBER MYNEWT_VAL(BOOTUTIL_IMAGE_NUMBER)
26 #else
27 #define MCUBOOT_IMAGE_NUMBER 1
28 #endif
29 #if MYNEWT_VAL(BOOTUTIL_VERSION_CMP_USE_BUILD_NUMBER)
30 #define MCUBOOT_VERSION_CMP_USE_BUILD_NUMBER
31 #endif
32 #if MYNEWT_VAL(BOOT_SERIAL)
33 #define MCUBOOT_SERIAL 1
34 #endif
35 #if MYNEWT_VAL(BOOT_SERIAL_MGMT_ECHO)
36 #define MCUBOOT_BOOT_MGMT_ECHO 1
37 #endif
38 #if MYNEWT_VAL(BOOTUTIL_VALIDATE_SLOT0)
39 #define MCUBOOT_VALIDATE_PRIMARY_SLOT 1
40 #endif
41 #if MYNEWT_VAL(BOOTUTIL_USE_MBED_TLS)
42 #define MCUBOOT_USE_MBED_TLS 1
43 #endif
44 #if MYNEWT_VAL(BOOTUTIL_USE_TINYCRYPT)
45 #define MCUBOOT_USE_TINYCRYPT 1
46 #endif
47 #if MYNEWT_VAL(BOOTUTIL_SIGN_EC256)
48 #define MCUBOOT_SIGN_EC256 1
49 #endif
50 #if MYNEWT_VAL(BOOTUTIL_SIGN_RSA)
51 #define MCUBOOT_SIGN_RSA 1
52 #define MCUBOOT_SIGN_RSA_LEN MYNEWT_VAL(BOOTUTIL_SIGN_RSA_LEN)
53 #endif
54 #if MYNEWT_VAL(BOOTUTIL_SIGN_ED25519)
55 #define MCUBOOT_SIGN_ED25519 1
56 #endif
57 #if MYNEWT_VAL(BOOTUTIL_ENCRYPT_RSA)
58 #define MCUBOOT_ENCRYPT_RSA 1
59 #endif
60 #if MYNEWT_VAL(BOOTUTIL_ENCRYPT_KW)
61 #define MCUBOOT_ENCRYPT_KW 1
62 #endif
63 #if MYNEWT_VAL(BOOTUTIL_ENCRYPT_EC256)
64 #define MCUBOOT_ENCRYPT_EC256 1
65 #endif
66 #if MYNEWT_VAL(BOOTUTIL_ENCRYPT_X25519)
67 #define MCUBOOT_ENCRYPT_X25519 1
68 #endif
69 #if MYNEWT_VAL(BOOTUTIL_ENCRYPT_RSA) || MYNEWT_VAL(BOOTUTIL_ENCRYPT_KW) || \
70     MYNEWT_VAL(BOOTUTIL_ENCRYPT_EC256) || MYNEWT_VAL(BOOTUTIL_ENCRYPT_X25519)
71 #define MCUBOOT_ENC_IMAGES 1
72 #endif
73 #if MYNEWT_VAL(BOOTUTIL_SWAP_USING_MOVE)
74 #define MCUBOOT_SWAP_USING_MOVE 1
75 #endif
76 #if MYNEWT_VAL(BOOTUTIL_SWAP_SAVE_ENCTLV)
77 #define MCUBOOT_SWAP_SAVE_ENCTLV 1
78 #endif
79 #if MYNEWT_VAL(BOOTUTIL_OVERWRITE_ONLY)
80 #define MCUBOOT_OVERWRITE_ONLY 1
81 #endif
82 #if MYNEWT_VAL(BOOTUTIL_OVERWRITE_ONLY_FAST)
83 #define MCUBOOT_OVERWRITE_ONLY_FAST 1
84 #endif
85 #if MYNEWT_VAL(BOOTUTIL_SINGLE_APPLICATION_SLOT)
86 #define MCUBOOT_SINGLE_APPLICATION_SLOT 1
87 #endif
88 #if MYNEWT_VAL(BOOTUTIL_HAVE_LOGGING)
89 #define MCUBOOT_HAVE_LOGGING 1
90 #endif
91 #if MYNEWT_VAL(BOOTUTIL_BOOTSTRAP)
92 #define MCUBOOT_BOOTSTRAP 1
93 #endif
94 #if MYNEWT_VAL_CHOICE(BOOTUTIL_DOWNGRADE_PREVENTION, version)
95 #define MCUBOOT_DOWNGRADE_PREVENTION                     1
96 /* MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER is used later as bool value so it is
97  * always defined, (unlike MCUBOOT_DOWNGRADE_PREVENTION which is only used in
98  * preprocessor condition and my be not defined) */
99 #define MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER    0
100 #elif MYNEWT_VAL_CHOICE(BOOTUTIL_DOWNGRADE_PREVENTION, security_counter)
101 #define MCUBOOT_DOWNGRADE_PREVENTION                     1
102 #define MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER    1
103 #endif
104 #if MYNEWT_VAL(BOOTUTIL_HW_DOWNGRADE_PREVENTION)
105 #define MCUBOOT_HW_ROLLBACK_PROT 1
106 #endif
107 
108 #if MYNEWT_VAL(MCUBOOT_MEASURED_BOOT)
109 #define MCUBOOT_MEASURED_BOOT       1
110 #endif
111 
112 #if MYNEWT_VAL(MCUBOOT_MEASURED_BOOT_MAX_RECORD_SZ)
113 #define MAX_BOOT_RECORD_SZ          MYNEWT_VAL(MCUBOOT_MEASURED_BOOT_MAX_RECORD_SZ)
114 #endif
115 
116 #if MYNEWT_VAL(MCUBOOT_DATA_SHARING)
117 #define MCUBOOT_DATA_SHARING        1
118 #endif
119 
120 #if MYNEWT_VAL(MCUBOOT_SHARED_DATA_BASE)
121 #define MCUBOOT_SHARED_DATA_BASE    MYNEWT_VAL(MCUBOOT_SHARED_DATA_BASE)
122 #endif
123 
124 #if MYNEWT_VAL(MCUBOOT_SHARED_DATA_SIZE)
125 #define MCUBOOT_SHARED_DATA_SIZE    MYNEWT_VAL(MCUBOOT_SHARED_DATA_SIZE)
126 #endif
127 
128 /*
129  * Currently there is no configuration option, for this platform,
130  * that enables the system specific mcumgr commands in mcuboot
131  */
132 #define MCUBOOT_PERUSER_MGMT_GROUP_ENABLED 0
133 
134 #define MCUBOOT_MAX_IMG_SECTORS       MYNEWT_VAL(BOOTUTIL_MAX_IMG_SECTORS)
135 
136 #if MYNEWT_VAL(MCU_FLASH_MIN_WRITE_SIZE) > 8
137 #define MCUBOOT_BOOT_MAX_ALIGN  MYNEWT_VAL(MCU_FLASH_MIN_WRITE_SIZE)
138 #endif
139 
140 #if MYNEWT_VAL(BOOTUTIL_FEED_WATCHDOG) && MYNEWT_VAL(WATCHDOG_INTERVAL)
141 #include <hal/hal_watchdog.h>
142 #define MCUBOOT_WATCHDOG_FEED()    \
143     do {                           \
144         hal_watchdog_tickle();     \
145     } while (0)
146 #else
147 #define MCUBOOT_WATCHDOG_FEED()    do {} while (0)
148 #endif
149 
150 /*
151  * No direct idle call implemented
152  */
153 #define MCUBOOT_CPU_IDLE() \
154     do {                   \
155     } while (0)
156 
157 #endif /* __MCUBOOT_CONFIG_H__ */
158