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(BOOT_SERIAL)
30 #define MCUBOOT_SERIAL 1
31 #endif
32 #if MYNEWT_VAL(BOOTUTIL_VALIDATE_SLOT0)
33 #define MCUBOOT_VALIDATE_PRIMARY_SLOT 1
34 #endif
35 #if MYNEWT_VAL(BOOTUTIL_USE_MBED_TLS)
36 #define MCUBOOT_USE_MBED_TLS 1
37 #endif
38 #if MYNEWT_VAL(BOOTUTIL_USE_TINYCRYPT)
39 #define MCUBOOT_USE_TINYCRYPT 1
40 #endif
41 #if MYNEWT_VAL(BOOTUTIL_SIGN_EC256)
42 #define MCUBOOT_SIGN_EC256 1
43 #endif
44 #if MYNEWT_VAL(BOOTUTIL_SIGN_RSA)
45 #define MCUBOOT_SIGN_RSA 1
46 #define MCUBOOT_SIGN_RSA_LEN MYNEWT_VAL(BOOTUTIL_SIGN_RSA_LEN)
47 #endif
48 #if MYNEWT_VAL(BOOTUTIL_SIGN_ED25519)
49 #define MCUBOOT_SIGN_ED25519 1
50 #endif
51 #if MYNEWT_VAL(BOOTUTIL_ENCRYPT_RSA)
52 #define MCUBOOT_ENCRYPT_RSA 1
53 #endif
54 #if MYNEWT_VAL(BOOTUTIL_ENCRYPT_KW)
55 #define MCUBOOT_ENCRYPT_KW 1
56 #endif
57 #if MYNEWT_VAL(BOOTUTIL_ENCRYPT_EC256)
58 #define MCUBOOT_ENCRYPT_EC256 1
59 #endif
60 #if MYNEWT_VAL(BOOTUTIL_ENCRYPT_X25519)
61 #define MCUBOOT_ENCRYPT_X25519 1
62 #endif
63 #if MYNEWT_VAL(BOOTUTIL_ENCRYPT_RSA) || MYNEWT_VAL(BOOTUTIL_ENCRYPT_KW) || \
64     MYNEWT_VAL(BOOTUTIL_ENCRYPT_EC256) || MYNEWT_VAL(BOOTUTIL_ENCRYPT_X25519)
65 #define MCUBOOT_ENC_IMAGES 1
66 #endif
67 #if MYNEWT_VAL(BOOTUTIL_SWAP_USING_MOVE)
68 #define MCUBOOT_SWAP_USING_MOVE 1
69 #endif
70 #if MYNEWT_VAL(BOOTUTIL_SWAP_SAVE_ENCTLV)
71 #define MCUBOOT_SWAP_SAVE_ENCTLV 1
72 #endif
73 #if MYNEWT_VAL(BOOTUTIL_OVERWRITE_ONLY)
74 #define MCUBOOT_OVERWRITE_ONLY 1
75 #endif
76 #if MYNEWT_VAL(BOOTUTIL_OVERWRITE_ONLY_FAST)
77 #define MCUBOOT_OVERWRITE_ONLY_FAST 1
78 #endif
79 #if MYNEWT_VAL(BOOTUTIL_HAVE_LOGGING)
80 #define MCUBOOT_HAVE_LOGGING 1
81 #endif
82 #if MYNEWT_VAL(BOOTUTIL_BOOTSTRAP)
83 #define MCUBOOT_BOOTSTRAP 1
84 #endif
85 #if MYNEWT_VAL_CHOICE(BOOTUTIL_DOWNGRADE_PREVENTION, version)
86 #define MCUBOOT_DOWNGRADE_PREVENTION                     1
87 /* MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER is used later as bool value so it is
88  * always defined, (unlike MCUBOOT_DOWNGRADE_PREVENTION which is only used in
89  * preprocessor condition and my be not defined) */
90 #define MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER    0
91 #elif MYNEWT_VAL_CHOICE(BOOTUTIL_DOWNGRADE_PREVENTION, security_counter)
92 #define MCUBOOT_DOWNGRADE_PREVENTION                     1
93 #define MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER    1
94 #endif
95 #if MYNEWT_VAL(BOOTUTIL_HW_DOWNGRADE_PREVENTION)
96 #define MCUBOOT_HW_ROLLBACK_PROT 1
97 #endif
98 
99 #if MYNEWT_VAL(MCUBOOT_MEASURED_BOOT)
100 #define MCUBOOT_MEASURED_BOOT       1
101 #endif
102 
103 #if MYNEWT_VAL(MCUBOOT_MEASURED_BOOT_MAX_RECORD_SZ)
104 #define MAX_BOOT_RECORD_SZ          MYNEWT_VAL(MCUBOOT_MEASURED_BOOT_MAX_RECORD_SZ)
105 #endif
106 
107 #if MYNEWT_VAL(MCUBOOT_DATA_SHARING)
108 #define MCUBOOT_DATA_SHARING        1
109 #endif
110 
111 #if MYNEWT_VAL(MCUBOOT_SHARED_DATA_BASE)
112 #define MCUBOOT_SHARED_DATA_BASE    MYNEWT_VAL(MCUBOOT_SHARED_DATA_BASE)
113 #endif
114 
115 #if MYNEWT_VAL(MCUBOOT_SHARED_DATA_SIZE)
116 #define MCUBOOT_SHARED_DATA_SIZE    MYNEWT_VAL(MCUBOOT_SHARED_DATA_SIZE)
117 #endif
118 
119 /*
120  * Currently there is no configuration option, for this platform,
121  * that enables the system specific mcumgr commands in mcuboot
122  */
123 #define MCUBOOT_PERUSER_MGMT_GROUP_ENABLED 0
124 
125 #define MCUBOOT_MAX_IMG_SECTORS       MYNEWT_VAL(BOOTUTIL_MAX_IMG_SECTORS)
126 
127 #if MYNEWT_VAL(BOOTUTIL_FEED_WATCHDOG) && MYNEWT_VAL(WATCHDOG_INTERVAL)
128 #include <hal/hal_watchdog.h>
129 #define MCUBOOT_WATCHDOG_FEED()    \
130     do {                           \
131         hal_watchdog_tickle();     \
132     } while (0)
133 #else
134 #define MCUBOOT_WATCHDOG_FEED()    do {} while (0)
135 #endif
136 
137 /*
138  * No direct idle call implemented
139  */
140 #define MCUBOOT_CPU_IDLE() \
141     do {                   \
142     } while (0)
143 
144 #endif /* __MCUBOOT_CONFIG_H__ */
145