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_HAVE_LOGGING) 86 #define MCUBOOT_HAVE_LOGGING 1 87 #endif 88 #if MYNEWT_VAL(BOOTUTIL_BOOTSTRAP) 89 #define MCUBOOT_BOOTSTRAP 1 90 #endif 91 #if MYNEWT_VAL_CHOICE(BOOTUTIL_DOWNGRADE_PREVENTION, version) 92 #define MCUBOOT_DOWNGRADE_PREVENTION 1 93 /* MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER is used later as bool value so it is 94 * always defined, (unlike MCUBOOT_DOWNGRADE_PREVENTION which is only used in 95 * preprocessor condition and my be not defined) */ 96 #define MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER 0 97 #elif MYNEWT_VAL_CHOICE(BOOTUTIL_DOWNGRADE_PREVENTION, security_counter) 98 #define MCUBOOT_DOWNGRADE_PREVENTION 1 99 #define MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER 1 100 #endif 101 #if MYNEWT_VAL(BOOTUTIL_HW_DOWNGRADE_PREVENTION) 102 #define MCUBOOT_HW_ROLLBACK_PROT 1 103 #endif 104 105 #if MYNEWT_VAL(MCUBOOT_MEASURED_BOOT) 106 #define MCUBOOT_MEASURED_BOOT 1 107 #endif 108 109 #if MYNEWT_VAL(MCUBOOT_MEASURED_BOOT_MAX_RECORD_SZ) 110 #define MAX_BOOT_RECORD_SZ MYNEWT_VAL(MCUBOOT_MEASURED_BOOT_MAX_RECORD_SZ) 111 #endif 112 113 #if MYNEWT_VAL(MCUBOOT_DATA_SHARING) 114 #define MCUBOOT_DATA_SHARING 1 115 #endif 116 117 #if MYNEWT_VAL(MCUBOOT_SHARED_DATA_BASE) 118 #define MCUBOOT_SHARED_DATA_BASE MYNEWT_VAL(MCUBOOT_SHARED_DATA_BASE) 119 #endif 120 121 #if MYNEWT_VAL(MCUBOOT_SHARED_DATA_SIZE) 122 #define MCUBOOT_SHARED_DATA_SIZE MYNEWT_VAL(MCUBOOT_SHARED_DATA_SIZE) 123 #endif 124 125 /* 126 * Currently there is no configuration option, for this platform, 127 * that enables the system specific mcumgr commands in mcuboot 128 */ 129 #define MCUBOOT_PERUSER_MGMT_GROUP_ENABLED 0 130 131 #define MCUBOOT_MAX_IMG_SECTORS MYNEWT_VAL(BOOTUTIL_MAX_IMG_SECTORS) 132 133 #if MYNEWT_VAL(MCU_FLASH_MIN_WRITE_SIZE) > 8 134 #define MCUBOOT_BOOT_MAX_ALIGN MYNEWT_VAL(MCU_FLASH_MIN_WRITE_SIZE) 135 #endif 136 137 #if MYNEWT_VAL(BOOTUTIL_FEED_WATCHDOG) && MYNEWT_VAL(WATCHDOG_INTERVAL) 138 #include <hal/hal_watchdog.h> 139 #define MCUBOOT_WATCHDOG_FEED() \ 140 do { \ 141 hal_watchdog_tickle(); \ 142 } while (0) 143 #else 144 #define MCUBOOT_WATCHDOG_FEED() do {} while (0) 145 #endif 146 147 /* 148 * No direct idle call implemented 149 */ 150 #define MCUBOOT_CPU_IDLE() \ 151 do { \ 152 } while (0) 153 154 #endif /* __MCUBOOT_CONFIG_H__ */ 155