diff --git a/core/embed/prodtest/.changelog.d/3932.added b/core/embed/prodtest/.changelog.d/3932.added new file mode 100644 index 000000000..696afa782 --- /dev/null +++ b/core/embed/prodtest/.changelog.d/3932.added @@ -0,0 +1 @@ +Added REBOOT command diff --git a/core/embed/prodtest/README.md b/core/embed/prodtest/README.md index 1ff4dd433..ca551b68e 100644 --- a/core/embed/prodtest/README.md +++ b/core/embed/prodtest/README.md @@ -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. diff --git a/core/embed/prodtest/main.c b/core/embed/prodtest/main.c index 2712703d1..61a746e50 100644 --- a/core/embed/prodtest/main.c +++ b/core/embed/prodtest/main.c @@ -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"); } diff --git a/core/embed/trezorhal/stm32f4/supervise.c b/core/embed/trezorhal/stm32f4/supervise.c index d4a72df17..e3190a391 100644 --- a/core/embed/trezorhal/stm32f4/supervise.c +++ b/core/embed/trezorhal/stm32f4/supervise.c @@ -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; diff --git a/core/embed/trezorhal/stm32f4/supervise.h b/core/embed/trezorhal/stm32f4/supervise.h index c4a70650e..9affd8b77 100644 --- a/core/embed/trezorhal/stm32f4/supervise.h +++ b/core/embed/trezorhal/stm32f4/supervise.h @@ -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 #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");