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:
parent
000aa4ed21
commit
b0b2ffd38f
1
core/embed/prodtest/.changelog.d/3932.added
Normal file
1
core/embed/prodtest/.changelog.d/3932.added
Normal file
@ -0,0 +1 @@
|
||||
Added REBOOT command
|
@ -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.
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user