|
20 | 20 |
|
21 | 21 | #include "ota.h" |
22 | 22 | #include "rtc.h" |
| 23 | +#include "target.h" |
23 | 24 | #include "bootutil/bootutil_log.h" |
24 | 25 |
|
25 | 26 | #include "SlicingBlockDevice.h" |
@@ -361,30 +362,36 @@ static void initBlockTable(void) { |
361 | 362 |
|
362 | 363 | mbed::BlockDevice* get_secondary_bd(void) { |
363 | 364 |
|
364 | | - if(!BlockTableLoaded) { |
365 | | - initBlockTable(); |
366 | | - BlockTableLoaded = true; |
367 | | - } |
| 365 | + if(!target_empty_keys()) { |
| 366 | + if(!BlockTableLoaded) { |
| 367 | + initBlockTable(); |
| 368 | + BlockTableLoaded = true; |
| 369 | + } |
368 | 370 |
|
369 | | - if(block_info[SECONDARY_BLOCK_DEVICE].raw_flag) { |
370 | | - return block_info[SECONDARY_BLOCK_DEVICE].log_bd; |
371 | | - } else { |
372 | | - return block_info[SECONDARY_BLOCK_DEVICE].file_bd; |
| 371 | + if(block_info[SECONDARY_BLOCK_DEVICE].raw_flag) { |
| 372 | + return block_info[SECONDARY_BLOCK_DEVICE].log_bd; |
| 373 | + } else { |
| 374 | + return block_info[SECONDARY_BLOCK_DEVICE].file_bd; |
| 375 | + } |
373 | 376 | } |
| 377 | + return nullptr; |
374 | 378 | } |
375 | 379 |
|
376 | 380 | mbed::BlockDevice* get_scratch_bd(void) { |
377 | 381 |
|
378 | | - if(!BlockTableLoaded) { |
379 | | - initBlockTable(); |
380 | | - BlockTableLoaded = true; |
381 | | - } |
| 382 | + if(!target_empty_keys()) { |
| 383 | + if(!BlockTableLoaded) { |
| 384 | + initBlockTable(); |
| 385 | + BlockTableLoaded = true; |
| 386 | + } |
382 | 387 |
|
383 | | - if(block_info[SCRATCH_BLOCK_DEVICE].raw_flag) { |
384 | | - return block_info[SCRATCH_BLOCK_DEVICE].log_bd;; |
385 | | - } else { |
386 | | - return block_info[SCRATCH_BLOCK_DEVICE].file_bd; |
| 388 | + if(block_info[SCRATCH_BLOCK_DEVICE].raw_flag) { |
| 389 | + return block_info[SCRATCH_BLOCK_DEVICE].log_bd;; |
| 390 | + } else { |
| 391 | + return block_info[SCRATCH_BLOCK_DEVICE].file_bd; |
| 392 | + } |
387 | 393 | } |
| 394 | + return nullptr; |
388 | 395 | } |
389 | 396 |
|
390 | 397 | mbed::BlockDevice* BlockDevice::get_default_instance() |
|
0 commit comments