Skip to content

Commit 55226e2

Browse files
committed
Check if security keys are configured before loading MCUboot block device table
1 parent ecec111 commit 55226e2

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

default_bd.cpp

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "ota.h"
2222
#include "rtc.h"
23+
#include "target.h"
2324
#include "bootutil/bootutil_log.h"
2425

2526
#include "SlicingBlockDevice.h"
@@ -361,30 +362,36 @@ static void initBlockTable(void) {
361362

362363
mbed::BlockDevice* get_secondary_bd(void) {
363364

364-
if(!BlockTableLoaded) {
365-
initBlockTable();
366-
BlockTableLoaded = true;
367-
}
365+
if(!target_empty_keys()) {
366+
if(!BlockTableLoaded) {
367+
initBlockTable();
368+
BlockTableLoaded = true;
369+
}
368370

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+
}
373376
}
377+
return nullptr;
374378
}
375379

376380
mbed::BlockDevice* get_scratch_bd(void) {
377381

378-
if(!BlockTableLoaded) {
379-
initBlockTable();
380-
BlockTableLoaded = true;
381-
}
382+
if(!target_empty_keys()) {
383+
if(!BlockTableLoaded) {
384+
initBlockTable();
385+
BlockTableLoaded = true;
386+
}
382387

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+
}
387393
}
394+
return nullptr;
388395
}
389396

390397
mbed::BlockDevice* BlockDevice::get_default_instance()

0 commit comments

Comments
 (0)