Add reboot extra command.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include "mbedtls/ecdh.h"
|
#include "mbedtls/ecdh.h"
|
||||||
#ifdef PICO_PLATFORM
|
#ifdef PICO_PLATFORM
|
||||||
#include "pico/aon_timer.h"
|
#include "pico/aon_timer.h"
|
||||||
|
#include "hardware/watchdog.h"
|
||||||
#else
|
#else
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
#define CMD_DATETIME 0xA
|
#define CMD_DATETIME 0xA
|
||||||
#define CMD_DYNOPS 0x6
|
#define CMD_DYNOPS 0x6
|
||||||
#define CMD_SECURE_LOCK 0x3A
|
#define CMD_SECURE_LOCK 0x3A
|
||||||
|
#define CMD_REBOOT 0xFB
|
||||||
#define SECURE_LOCK_KEY_AGREEMENT 0x1
|
#define SECURE_LOCK_KEY_AGREEMENT 0x1
|
||||||
#define SECURE_LOCK_ENABLE 0x2
|
#define SECURE_LOCK_ENABLE 0x2
|
||||||
#define SECURE_LOCK_MASK 0x3
|
#define SECURE_LOCK_MASK 0x3
|
||||||
@@ -287,6 +289,14 @@ int cmd_extras() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef PICO_PLATFORM
|
||||||
|
else if (P1(apdu) == CMD_REBOOT) {
|
||||||
|
if (apdu.nc != 0) {
|
||||||
|
return SW_WRONG_LENGTH();
|
||||||
|
}
|
||||||
|
watchdog_reboot(0, 0, 100);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
return SW_INCORRECT_P1P2();
|
return SW_INCORRECT_P1P2();
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ def parse_args():
|
|||||||
parser_otp.add_argument('--lock', help='Lock & protect (no other firmwares can be loaded)', action='store_true')
|
parser_otp.add_argument('--lock', help='Lock & protect (no other firmwares can be loaded)', action='store_true')
|
||||||
parser_otp.add_argument('--index', help='Bootkey index [0-3]', type=int, default=0, choices=[0, 1, 2, 3])
|
parser_otp.add_argument('--index', help='Bootkey index [0-3]', type=int, default=0, choices=[0, 1, 2, 3])
|
||||||
|
|
||||||
|
parser_reboot = subparser.add_parser('reboot', help='Reboots the Pico HSM.')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@@ -507,6 +509,9 @@ def otp(picohsm, args):
|
|||||||
elif (args.subcommand == 'secure_boot'):
|
elif (args.subcommand == 'secure_boot'):
|
||||||
picohsm.secure_boot(BOOTKEY, bootkey_index=args.index, lock=args.lock)
|
picohsm.secure_boot(BOOTKEY, bootkey_index=args.index, lock=args.lock)
|
||||||
|
|
||||||
|
def reboot(picohsm, args):
|
||||||
|
picohsm.reboot()
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
sys.stderr.buffer.write(b'Pico HSM Tool v2.0\n')
|
sys.stderr.buffer.write(b'Pico HSM Tool v2.0\n')
|
||||||
sys.stderr.buffer.write(b'Author: Pol Henarejos\n')
|
sys.stderr.buffer.write(b'Author: Pol Henarejos\n')
|
||||||
@@ -537,6 +542,8 @@ def main(args):
|
|||||||
phy(picohsm, args)
|
phy(picohsm, args)
|
||||||
elif (args.command == 'otp'):
|
elif (args.command == 'otp'):
|
||||||
otp(picohsm, args)
|
otp(picohsm, args)
|
||||||
|
elif (args.command == 'reboot'):
|
||||||
|
reboot(picohsm, args)
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|||||||
Reference in New Issue
Block a user