Skip to content

Commit

Permalink
Merge pull request #149 from robin-nitrokey/nk3-reboot-bootloader
Browse files Browse the repository at this point in the history
nk3: Add --bootloader option to reboot command
  • Loading branch information
robin-nitrokey committed Jan 17, 2022
2 parents 418c4af + c42a24b commit fd670b1
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions pynitrokey/cli/nk3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,33 @@ def list() -> None:


@nk3.command()
@click.option(
"--bootloader",
is_flag=True,
help="Reboot a Nitrokey 3 device into bootloader mode",
)
@click.pass_obj
def reboot(ctx: Context) -> None:
"""Reboot the key."""
def reboot(ctx: Context, bootloader: bool) -> None:
"""
Reboot the key.
Per default, the key will reboot into regular firmware mode. If the --bootloader option
is set, a key can boot from firmware mode to bootloader mode. Booting into
bootloader mode has to be confirmed by pressing the touch button.
"""
with ctx.connect() as device:
device.reboot()
if bootloader:
if isinstance(device, Nitrokey3Device):
local_print(
"Please press the touch button to reboot the device into bootloader mode ..."
)
device.reboot(BootMode.BOOTROM)
else:
local_critical(
"A Nitrokey 3 device in bootloader mode can only reboot into firmware mode."
)
else:
device.reboot()


@nk3.command()
Expand Down

0 comments on commit fd670b1

Please sign in to comment.