1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-19 05:58:09 +00:00

feat(core/prodtest): add reboot command

This commit is contained in:
tychovrahe 2024-06-09 18:23:40 +02:00 committed by matejcik
parent 000aa4ed21
commit b0b2ffd38f
5 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1 @@
Added REBOOT command

View File

@ -250,6 +250,13 @@ WIPE
OK
```
### REBOOT
This command initiates device reboot. No response, as the device reboots immediately after receiving the command.
Example:
```
REBOOT
```
### OPTIGAID READ
Returns the coprocessor UID of the Optiga chip as a 27 byte hexadecimal string.

View File

@ -604,6 +604,8 @@ static void test_otp_write_device_variant(const char *args) {
vcp_println("OK");
}
static void test_reboot(void) { svc_reboot(); }
void cpuid_read(void) {
uint32_t cpuid[3];
cpuid[0] = LL_GetUID_Word0();
@ -762,7 +764,8 @@ int main(void) {
} else if (startswith(line, "WIPE")) {
test_wipe();
} else if (startswith(line, "REBOOT")) {
test_reboot();
} else {
vcp_println("UNKNOWN");
}

View File

@ -41,6 +41,14 @@ void svc_reboot_to_bootloader(void) {
}
}
void svc_reboot(void) {
if (is_mode_unprivileged() && !is_mode_handler()) {
__asm__ __volatile__("svc %0" ::"i"(SVC_REBOOT) : "memory");
} else {
NVIC_SystemReset();
}
}
void SVC_C_Handler(uint32_t *stack) {
uint8_t svc_number = ((uint8_t *)stack[6])[-2];
switch (svc_number) {
@ -85,6 +93,9 @@ void SVC_C_Handler(uint32_t *stack) {
case SVC_GET_SYSTICK_VAL:
systick_val_copy = SysTick->VAL;
break;
case SVC_REBOOT:
NVIC_SystemReset();
break;
default:
stack[0] = 0xffffffff;
break;

View File

@ -6,6 +6,7 @@
#define SVC_SHUTDOWN 4
#define SVC_REBOOT_TO_BOOTLOADER 5
#define SVC_GET_SYSTICK_VAL 6
#define SVC_REBOOT 7
#include <string.h>
#include "boot_args.h"
@ -70,6 +71,8 @@ static inline void svc_shutdown(void) {
void svc_reboot_to_bootloader(void);
void svc_reboot(void);
static inline uint32_t svc_get_systick_val(void) {
if (is_mode_unprivileged() && !is_mode_handler()) {
__asm__ __volatile__("svc %0" ::"i"(SVC_GET_SYSTICK_VAL) : "memory");