Skip to content

Commit cc2b5b4

Browse files
projectgusespressif-bot
authored andcommitted
tool: Fix 'idf.py bootloader' error if Secure Boot is enabled
If Secure Boot is enabled, there's no bootloader flasher arguments in the project (to encourage careful manual flashing), so this command would fail with a KeyError.
1 parent 35007bd commit cc2b5b4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/idf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,15 +461,17 @@ def _print_closing_message(self, args, actions):
461461
# Otherwise, if we built any binaries print a message about
462462
# how to flash them
463463
def print_flashing_message(title, key):
464-
print("\n%s build complete. To flash, run this command:" % title)
465-
466464
with open(os.path.join(args.build_dir, "flasher_args.json")) as f:
467465
flasher_args = json.load(f)
468466

469467
def flasher_path(f):
470468
return _safe_relpath(os.path.join(args.build_dir, f))
471469

472470
if key != "project": # flashing a single item
471+
if key not in flasher_args:
472+
# This is the case for 'idf.py bootloader' if Secure Boot is on, need to follow manual flashing steps
473+
print("\n%s build complete." % title)
474+
return
473475
cmd = ""
474476
if (key == "bootloader"): # bootloader needs --flash-mode, etc to be passed in
475477
cmd = " ".join(flasher_args["write_flash_args"]) + " "
@@ -485,6 +487,8 @@ def flasher_path(f):
485487
for o, f in flash_items:
486488
cmd += o + " " + flasher_path(f) + " "
487489

490+
print("\n%s build complete. To flash, run this command:" % title)
491+
488492
print(
489493
"%s %s -p %s -b %s --before %s --after %s --chip %s %s write_flash %s" % (
490494
PYTHON,

0 commit comments

Comments
 (0)