Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 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 | |
| 20 | #ifndef H_BOOTUTIL_PRIV_ |
| 21 | #define H_BOOTUTIL_PRIV_ |
| 22 | |
Marti Bolivar | cca28a9 | 2017-06-12 16:52:22 -0400 | [diff] [blame] | 23 | #include "sysflash/sysflash.h" |
Andrzej Puzdrowski | b788c71 | 2018-04-12 12:42:49 +0200 | [diff] [blame] | 24 | |
| 25 | #include <flash_map_backend/flash_map_backend.h> |
| 26 | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 27 | #include "bootutil/image.h" |
Marti Bolivar | f91bca5 | 2018-04-12 12:40:46 -0400 | [diff] [blame] | 28 | #include "mcuboot_config/mcuboot_config.h" |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 29 | |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 30 | #ifdef MCUBOOT_ENC_IMAGES |
| 31 | #include "bootutil/enc_key.h" |
| 32 | #endif |
| 33 | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 34 | #ifdef __cplusplus |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
Marti Bolivar | 248da08 | 2018-04-24 15:11:39 -0400 | [diff] [blame] | 38 | #ifdef MCUBOOT_HAVE_ASSERT_H |
| 39 | #include "mcuboot_config/mcuboot_assert.h" |
Fabio Utzig | 57c40f7 | 2017-12-12 21:48:30 -0200 | [diff] [blame] | 40 | #else |
| 41 | #define ASSERT assert |
| 42 | #endif |
| 43 | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 44 | struct flash_area; |
| 45 | |
| 46 | #define BOOT_EFLASH 1 |
| 47 | #define BOOT_EFILE 2 |
| 48 | #define BOOT_EBADIMAGE 3 |
| 49 | #define BOOT_EBADVECT 4 |
| 50 | #define BOOT_EBADSTATUS 5 |
| 51 | #define BOOT_ENOMEM 6 |
| 52 | #define BOOT_EBADARGS 7 |
| 53 | |
| 54 | #define BOOT_TMPBUF_SZ 256 |
| 55 | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 56 | /* |
| 57 | * Maintain state of copy progress. |
| 58 | */ |
| 59 | struct boot_status { |
Fabio Utzig | 2473ac0 | 2017-05-02 12:45:02 -0300 | [diff] [blame] | 60 | uint32_t idx; /* Which area we're operating on */ |
| 61 | uint8_t state; /* Which part of the swapping process are we at */ |
| 62 | uint8_t use_scratch; /* Are status bytes ever written to scratch? */ |
Fabio Utzig | 4649072 | 2017-09-04 15:34:32 -0300 | [diff] [blame] | 63 | uint32_t swap_size; /* Total size of swapped image */ |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 64 | #ifdef MCUBOOT_ENC_IMAGES |
| 65 | uint8_t enckey[2][BOOT_ENC_KEY_SIZE]; |
| 66 | #endif |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 67 | }; |
| 68 | |
Fabio Utzig | 3900001 | 2018-07-30 12:40:20 -0300 | [diff] [blame] | 69 | #define BOOT_MAGIC_GOOD 1 |
| 70 | #define BOOT_MAGIC_BAD 2 |
| 71 | #define BOOT_MAGIC_UNSET 3 |
| 72 | #define BOOT_MAGIC_ANY 4 /* NOTE: control only, not dependent on sector */ |
| 73 | |
| 74 | /* |
| 75 | * NOTE: leave BOOT_FLAG_SET equal to one, this is written to flash! |
| 76 | */ |
| 77 | #define BOOT_FLAG_SET 1 |
| 78 | #define BOOT_FLAG_BAD 2 |
| 79 | #define BOOT_FLAG_UNSET 3 |
| 80 | #define BOOT_FLAG_ANY 4 /* NOTE: control only, not dependent on sector */ |
| 81 | |
| 82 | #define BOOT_STATUS_IDX_0 1 |
| 83 | |
| 84 | #define BOOT_STATUS_STATE_0 1 |
| 85 | #define BOOT_STATUS_STATE_1 2 |
| 86 | #define BOOT_STATUS_STATE_2 3 |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * End-of-image slot structure. |
| 90 | * |
| 91 | * 0 1 2 3 |
| 92 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 93 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 94 | * ~ ~ |
| 95 | * ~ Swap status (variable, aligned) ~ |
| 96 | * ~ ~ |
| 97 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Fabio Utzig | 4649072 | 2017-09-04 15:34:32 -0300 | [diff] [blame] | 98 | * | Swap size | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 99 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Fabio Utzig | 3900001 | 2018-07-30 12:40:20 -0300 | [diff] [blame] | 100 | * ~ padding with erased val (MAX ALIGN - 4) ~ |
Fabio Utzig | 4649072 | 2017-09-04 15:34:32 -0300 | [diff] [blame] | 101 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Fabio Utzig | 3900001 | 2018-07-30 12:40:20 -0300 | [diff] [blame] | 102 | * | Copy done | padding with erased val (MAX ALIGN - 1) ~ |
Fabio Utzig | 4649072 | 2017-09-04 15:34:32 -0300 | [diff] [blame] | 103 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Fabio Utzig | 3900001 | 2018-07-30 12:40:20 -0300 | [diff] [blame] | 104 | * | Image OK | padding with erased val (MAX ALIGN - 1) ~ |
Fabio Utzig | 4649072 | 2017-09-04 15:34:32 -0300 | [diff] [blame] | 105 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 106 | * ~ MAGIC (16 octets) ~ |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 107 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 108 | */ |
| 109 | |
| 110 | extern const uint32_t boot_img_magic[4]; |
| 111 | |
| 112 | struct boot_swap_state { |
| 113 | uint8_t magic; /* One of the BOOT_MAGIC_[...] values. */ |
| 114 | uint8_t copy_done; |
| 115 | uint8_t image_ok; |
| 116 | }; |
| 117 | |
Marti Bolivar | f9bfddd | 2018-04-24 14:28:33 -0400 | [diff] [blame] | 118 | #define BOOT_MAX_IMG_SECTORS MCUBOOT_MAX_IMG_SECTORS |
Fabio Utzig | a1fae67 | 2018-03-30 10:52:38 -0300 | [diff] [blame] | 119 | |
| 120 | /* |
| 121 | * The current flashmap API does not check the amount of space allocated when |
| 122 | * loading sector data from the flash device, allowing for smaller counts here |
| 123 | * would most surely incur in overruns. |
| 124 | * |
| 125 | * TODO: make flashmap API receive the current sector array size. |
| 126 | */ |
| 127 | #if BOOT_MAX_IMG_SECTORS < 32 |
| 128 | #error "Too few sectors, please increase BOOT_MAX_IMG_SECTORS to at least 32" |
| 129 | #endif |
| 130 | |
| 131 | /** Number of image slots in flash; currently limited to two. */ |
| 132 | #define BOOT_NUM_SLOTS 2 |
| 133 | |
| 134 | /** Maximum number of image sectors supported by the bootloader. */ |
| 135 | #define BOOT_STATUS_STATE_COUNT 3 |
| 136 | #define BOOT_STATUS_MAX_ENTRIES BOOT_MAX_IMG_SECTORS |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 137 | |
| 138 | #define BOOT_STATUS_SOURCE_NONE 0 |
| 139 | #define BOOT_STATUS_SOURCE_SCRATCH 1 |
| 140 | #define BOOT_STATUS_SOURCE_SLOT0 2 |
| 141 | |
Fabio Utzig | 2473ac0 | 2017-05-02 12:45:02 -0300 | [diff] [blame] | 142 | #define BOOT_FLAG_IMAGE_OK 0 |
| 143 | #define BOOT_FLAG_COPY_DONE 1 |
| 144 | |
Fabio Utzig | 7ebb7c2 | 2017-04-26 10:59:31 -0300 | [diff] [blame] | 145 | extern const uint32_t BOOT_MAGIC_SZ; |
| 146 | |
Marti Bolivar | c50926f | 2017-06-14 09:35:40 -0400 | [diff] [blame] | 147 | /** |
| 148 | * Compatibility shim for flash sector type. |
| 149 | * |
| 150 | * This can be deleted when flash_area_to_sectors() is removed. |
| 151 | */ |
| 152 | #ifdef MCUBOOT_USE_FLASH_AREA_GET_SECTORS |
| 153 | typedef struct flash_sector boot_sector_t; |
| 154 | #else |
| 155 | typedef struct flash_area boot_sector_t; |
| 156 | #endif |
| 157 | |
Marti Bolivar | 9b1f8bb | 2017-06-12 15:24:13 -0400 | [diff] [blame] | 158 | /** Private state maintained during boot. */ |
| 159 | struct boot_loader_state { |
| 160 | struct { |
| 161 | struct image_header hdr; |
Marti Bolivar | c0b4791 | 2017-06-13 17:18:09 -0400 | [diff] [blame] | 162 | const struct flash_area *area; |
Marti Bolivar | c50926f | 2017-06-14 09:35:40 -0400 | [diff] [blame] | 163 | boot_sector_t *sectors; |
Marti Bolivar | 8489865 | 2017-06-13 17:20:22 -0400 | [diff] [blame] | 164 | size_t num_sectors; |
Marti Bolivar | 9b1f8bb | 2017-06-12 15:24:13 -0400 | [diff] [blame] | 165 | } imgs[BOOT_NUM_SLOTS]; |
| 166 | |
Fabio Utzig | 2bd980a | 2018-11-26 10:38:17 -0200 | [diff] [blame^] | 167 | struct { |
| 168 | const struct flash_area *area; |
| 169 | boot_sector_t *sectors; |
| 170 | size_t num_sectors; |
| 171 | } scratch; |
Marti Bolivar | 9b1f8bb | 2017-06-12 15:24:13 -0400 | [diff] [blame] | 172 | |
| 173 | uint8_t write_sz; |
| 174 | }; |
| 175 | |
Fabio Utzig | 1a927dd | 2017-12-05 10:30:26 -0200 | [diff] [blame] | 176 | int bootutil_verify_sig(uint8_t *hash, uint32_t hlen, uint8_t *sig, |
| 177 | size_t slen, uint8_t key_id); |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 178 | |
Fabio Utzig | 7ebb7c2 | 2017-04-26 10:59:31 -0300 | [diff] [blame] | 179 | uint32_t boot_slots_trailer_sz(uint8_t min_write_sz); |
Fabio Utzig | 4cee4f7 | 2017-05-22 10:59:57 -0400 | [diff] [blame] | 180 | int boot_status_entries(const struct flash_area *fap); |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 181 | uint32_t boot_status_off(const struct flash_area *fap); |
| 182 | int boot_read_swap_state(const struct flash_area *fap, |
| 183 | struct boot_swap_state *state); |
Fabio Utzig | 2473ac0 | 2017-05-02 12:45:02 -0300 | [diff] [blame] | 184 | int boot_read_swap_state_by_id(int flash_area_id, |
| 185 | struct boot_swap_state *state); |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 186 | int boot_write_magic(const struct flash_area *fap); |
| 187 | int boot_write_status(struct boot_status *bs); |
| 188 | int boot_schedule_test_swap(void); |
| 189 | int boot_write_copy_done(const struct flash_area *fap); |
| 190 | int boot_write_image_ok(const struct flash_area *fap); |
Fabio Utzig | 4649072 | 2017-09-04 15:34:32 -0300 | [diff] [blame] | 191 | int boot_write_swap_size(const struct flash_area *fap, uint32_t swap_size); |
| 192 | int boot_read_swap_size(uint32_t *swap_size); |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 193 | #ifdef MCUBOOT_ENC_IMAGES |
| 194 | int boot_write_enc_key(const struct flash_area *fap, uint8_t slot, |
| 195 | const uint8_t *enckey); |
| 196 | int boot_read_enc_key(uint8_t slot, uint8_t *enckey); |
| 197 | #endif |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 198 | |
Marti Bolivar | f804f62 | 2017-06-12 15:41:48 -0400 | [diff] [blame] | 199 | /* |
| 200 | * Accessors for the contents of struct boot_loader_state. |
| 201 | */ |
| 202 | |
Marti Bolivar | c0b4791 | 2017-06-13 17:18:09 -0400 | [diff] [blame] | 203 | /* These are macros so they can be used as lvalues. */ |
| 204 | #define BOOT_IMG_AREA(state, slot) ((state)->imgs[(slot)].area) |
Fabio Utzig | 2bd980a | 2018-11-26 10:38:17 -0200 | [diff] [blame^] | 205 | #define BOOT_SCRATCH_AREA(state) ((state)->scratch.area) |
Marti Bolivar | e10a739 | 2017-06-14 16:20:07 -0400 | [diff] [blame] | 206 | #define BOOT_WRITE_SZ(state) ((state)->write_sz) |
Marti Bolivar | c0b4791 | 2017-06-13 17:18:09 -0400 | [diff] [blame] | 207 | |
Marti Bolivar | f804f62 | 2017-06-12 15:41:48 -0400 | [diff] [blame] | 208 | static inline struct image_header* |
| 209 | boot_img_hdr(struct boot_loader_state *state, size_t slot) |
| 210 | { |
| 211 | return &state->imgs[slot].hdr; |
| 212 | } |
| 213 | |
Marti Bolivar | d3269fd | 2017-06-12 16:31:12 -0400 | [diff] [blame] | 214 | static inline size_t |
| 215 | boot_img_num_sectors(struct boot_loader_state *state, size_t slot) |
| 216 | { |
| 217 | return state->imgs[slot].num_sectors; |
| 218 | } |
| 219 | |
Fabio Utzig | 2bd980a | 2018-11-26 10:38:17 -0200 | [diff] [blame^] | 220 | static inline size_t |
| 221 | boot_scratch_num_sectors(struct boot_loader_state *state) |
| 222 | { |
| 223 | return state->scratch.num_sectors; |
| 224 | } |
| 225 | |
Marti Bolivar | 135b8f6 | 2017-06-13 17:22:13 -0400 | [diff] [blame] | 226 | /* |
| 227 | * Offset of the slot from the beginning of the flash device. |
| 228 | */ |
| 229 | static inline uint32_t |
| 230 | boot_img_slot_off(struct boot_loader_state *state, size_t slot) |
| 231 | { |
| 232 | return state->imgs[slot].area->fa_off; |
| 233 | } |
| 234 | |
| 235 | static inline size_t boot_scratch_area_size(struct boot_loader_state *state) |
| 236 | { |
Fabio Utzig | 2bd980a | 2018-11-26 10:38:17 -0200 | [diff] [blame^] | 237 | return BOOT_SCRATCH_AREA(state)->fa_size; |
Marti Bolivar | 135b8f6 | 2017-06-13 17:22:13 -0400 | [diff] [blame] | 238 | } |
| 239 | |
Marti Bolivar | c50926f | 2017-06-14 09:35:40 -0400 | [diff] [blame] | 240 | #ifndef MCUBOOT_USE_FLASH_AREA_GET_SECTORS |
| 241 | |
Marti Bolivar | d3269fd | 2017-06-12 16:31:12 -0400 | [diff] [blame] | 242 | static inline size_t |
| 243 | boot_img_sector_size(struct boot_loader_state *state, |
| 244 | size_t slot, size_t sector) |
| 245 | { |
| 246 | return state->imgs[slot].sectors[sector].fa_size; |
| 247 | } |
| 248 | |
Marti Bolivar | ea08887 | 2017-06-12 17:10:49 -0400 | [diff] [blame] | 249 | /* |
| 250 | * Offset of the sector from the beginning of the image, NOT the flash |
| 251 | * device. |
| 252 | */ |
| 253 | static inline uint32_t |
| 254 | boot_img_sector_off(struct boot_loader_state *state, size_t slot, |
| 255 | size_t sector) |
| 256 | { |
| 257 | return state->imgs[slot].sectors[sector].fa_off - |
| 258 | state->imgs[slot].sectors[0].fa_off; |
| 259 | } |
| 260 | |
Marti Bolivar | cca28a9 | 2017-06-12 16:52:22 -0400 | [diff] [blame] | 261 | static inline int |
| 262 | boot_initialize_area(struct boot_loader_state *state, int flash_area) |
| 263 | { |
Marti Bolivar | cca28a9 | 2017-06-12 16:52:22 -0400 | [diff] [blame] | 264 | int num_sectors = BOOT_MAX_IMG_SECTORS; |
Marti Bolivar | cca28a9 | 2017-06-12 16:52:22 -0400 | [diff] [blame] | 265 | int rc; |
| 266 | |
| 267 | switch (flash_area) { |
| 268 | case FLASH_AREA_IMAGE_0: |
Fabio Utzig | 2bd980a | 2018-11-26 10:38:17 -0200 | [diff] [blame^] | 269 | rc = flash_area_to_sectors(flash_area, &num_sectors, state->imgs[0].sectors); |
| 270 | state->imgs[0].num_sectors = (size_t)num_sectors; |
Marti Bolivar | cca28a9 | 2017-06-12 16:52:22 -0400 | [diff] [blame] | 271 | break; |
| 272 | case FLASH_AREA_IMAGE_1: |
Fabio Utzig | 2bd980a | 2018-11-26 10:38:17 -0200 | [diff] [blame^] | 273 | rc = flash_area_to_sectors(flash_area, &num_sectors, state->imgs[1].sectors); |
| 274 | state->imgs[1].num_sectors = (size_t)num_sectors; |
| 275 | break; |
| 276 | case FLASH_AREA_IMAGE_SCRATCH: |
| 277 | rc = flash_area_to_sectors(flash_area, &num_sectors, state->scratch.sectors); |
| 278 | state->scratch.num_sectors = (size_t)num_sectors; |
Marti Bolivar | cca28a9 | 2017-06-12 16:52:22 -0400 | [diff] [blame] | 279 | break; |
Marti Bolivar | cca28a9 | 2017-06-12 16:52:22 -0400 | [diff] [blame] | 280 | default: |
| 281 | return BOOT_EFLASH; |
| 282 | } |
| 283 | |
Fabio Utzig | 2bd980a | 2018-11-26 10:38:17 -0200 | [diff] [blame^] | 284 | return rc; |
Marti Bolivar | cca28a9 | 2017-06-12 16:52:22 -0400 | [diff] [blame] | 285 | } |
| 286 | |
Marti Bolivar | c50926f | 2017-06-14 09:35:40 -0400 | [diff] [blame] | 287 | #else /* defined(MCUBOOT_USE_FLASH_AREA_GET_SECTORS) */ |
| 288 | |
| 289 | static inline size_t |
| 290 | boot_img_sector_size(struct boot_loader_state *state, |
| 291 | size_t slot, size_t sector) |
| 292 | { |
| 293 | return state->imgs[slot].sectors[sector].fs_size; |
| 294 | } |
| 295 | |
| 296 | static inline uint32_t |
| 297 | boot_img_sector_off(struct boot_loader_state *state, size_t slot, |
| 298 | size_t sector) |
| 299 | { |
| 300 | return state->imgs[slot].sectors[sector].fs_off - |
| 301 | state->imgs[slot].sectors[0].fs_off; |
| 302 | } |
| 303 | |
| 304 | static inline int |
| 305 | boot_initialize_area(struct boot_loader_state *state, int flash_area) |
| 306 | { |
| 307 | uint32_t num_sectors; |
| 308 | struct flash_sector *out_sectors; |
| 309 | size_t *out_num_sectors; |
| 310 | int rc; |
| 311 | |
| 312 | switch (flash_area) { |
| 313 | case FLASH_AREA_IMAGE_0: |
| 314 | num_sectors = BOOT_MAX_IMG_SECTORS; |
| 315 | out_sectors = state->imgs[0].sectors; |
| 316 | out_num_sectors = &state->imgs[0].num_sectors; |
| 317 | break; |
| 318 | case FLASH_AREA_IMAGE_1: |
| 319 | num_sectors = BOOT_MAX_IMG_SECTORS; |
| 320 | out_sectors = state->imgs[1].sectors; |
| 321 | out_num_sectors = &state->imgs[1].num_sectors; |
| 322 | break; |
Fabio Utzig | 2bd980a | 2018-11-26 10:38:17 -0200 | [diff] [blame^] | 323 | case FLASH_AREA_IMAGE_SCRATCH: |
| 324 | num_sectors = BOOT_MAX_IMG_SECTORS; |
| 325 | out_sectors = state->scratch.sectors; |
| 326 | out_num_sectors = &state->scratch.num_sectors; |
| 327 | break; |
Marti Bolivar | c50926f | 2017-06-14 09:35:40 -0400 | [diff] [blame] | 328 | default: |
| 329 | return -1; |
| 330 | } |
| 331 | |
| 332 | rc = flash_area_get_sectors(flash_area, &num_sectors, out_sectors); |
| 333 | if (rc != 0) { |
| 334 | return rc; |
| 335 | } |
| 336 | *out_num_sectors = num_sectors; |
| 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | #endif /* !defined(MCUBOOT_USE_FLASH_AREA_GET_SECTORS) */ |
| 341 | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 342 | #ifdef __cplusplus |
| 343 | } |
| 344 | #endif |
| 345 | |
| 346 | #endif |