mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-09 10:28:46 +00:00
feat(core): add backup ram global initialization in bootloader, prodtest and kernel
[no changelog]
This commit is contained in:
parent
dec252df77
commit
ae02677ca2
@ -44,6 +44,9 @@
|
||||
#ifdef USE_TOUCH
|
||||
#include <io/touch.h>
|
||||
#endif
|
||||
#ifdef USE_BACKUP_RAM
|
||||
#include <sys/backup_ram.h>
|
||||
#endif
|
||||
#ifdef USE_BUTTON
|
||||
#include <io/button.h>
|
||||
#endif
|
||||
@ -113,6 +116,9 @@ static void drivers_init(secbool *touch_initialized) {
|
||||
#ifdef USE_OPTIGA
|
||||
optiga_hal_init();
|
||||
#endif
|
||||
#ifdef USE_BACKUP_RAM
|
||||
backup_ram_init();
|
||||
#endif
|
||||
#ifdef USE_BUTTON
|
||||
button_init();
|
||||
#endif
|
||||
@ -126,6 +132,9 @@ static void drivers_init(secbool *touch_initialized) {
|
||||
|
||||
static void drivers_deinit(void) {
|
||||
#ifdef FIXED_HW_DEINIT
|
||||
#ifdef USE_BACKUP_RAM
|
||||
backup_ram_deinit();
|
||||
#endif
|
||||
#ifdef USE_BUTTON
|
||||
button_deinit();
|
||||
#endif
|
||||
|
@ -58,6 +58,10 @@
|
||||
#include <sec/optiga_config.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_BACKUP_RAM
|
||||
#include <sys/backup_ram.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_TROPIC
|
||||
#include <sec/tropic.h>
|
||||
#endif
|
||||
@ -95,6 +99,11 @@
|
||||
#endif
|
||||
|
||||
void drivers_init() {
|
||||
|
||||
#ifdef USE_BACKUP_RAM
|
||||
backup_ram_init();
|
||||
#endif
|
||||
|
||||
#ifdef USE_POWERCTL
|
||||
powerctl_init();
|
||||
#endif
|
||||
|
@ -41,31 +41,18 @@ static void prodtest_backup_ram_write(cli_t* cli) {
|
||||
return;
|
||||
}
|
||||
|
||||
backup_ram_status_t status = backup_ram_init();
|
||||
if (status != BACKUP_RAM_OK) {
|
||||
if (status == BACKUP_RAM_OK_STORAGE_INITIALIZED) {
|
||||
cli_trace(cli, "Backup storage had to be initialized");
|
||||
} else {
|
||||
cli_error(cli, CLI_ERROR, "Failed to initialize backup RAM");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
backup_ram_power_manager_data_t pm_data;
|
||||
|
||||
pm_data.soc = ((float)soc / 100);
|
||||
pm_data.last_capture_timestamp = systick_cycles();
|
||||
|
||||
status = backup_ram_store_power_manager_data(&pm_data);
|
||||
backup_ram_status_t status = backup_ram_store_power_manager_data(&pm_data);
|
||||
|
||||
if (status != BACKUP_RAM_OK) {
|
||||
cli_error(cli, CLI_ERROR, "Failed to write backup RAM");
|
||||
backup_ram_deinit();
|
||||
return;
|
||||
}
|
||||
|
||||
backup_ram_deinit();
|
||||
|
||||
cli_ok(cli, "");
|
||||
}
|
||||
|
||||
@ -75,27 +62,14 @@ static void prodtest_backup_ram_read(cli_t* cli) {
|
||||
return;
|
||||
}
|
||||
|
||||
backup_ram_status_t status = backup_ram_init();
|
||||
if (status != BACKUP_RAM_OK) {
|
||||
if (status == BACKUP_RAM_OK_STORAGE_INITIALIZED) {
|
||||
cli_trace(cli, "Backup storage had to be initialized");
|
||||
} else {
|
||||
cli_error(cli, CLI_ERROR, "Failed to initialize backup RAM");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
backup_ram_power_manager_data_t pm_data;
|
||||
status = backup_ram_read_power_manager_data(&pm_data);
|
||||
backup_ram_status_t status = backup_ram_read_power_manager_data(&pm_data);
|
||||
|
||||
if (status != BACKUP_RAM_OK) {
|
||||
cli_error(cli, CLI_ERROR, "Failed to read backup RAM");
|
||||
backup_ram_deinit();
|
||||
return;
|
||||
}
|
||||
|
||||
backup_ram_deinit();
|
||||
|
||||
cli_ok(cli, "SOC: %d\%", (int)(pm_data.soc * 100));
|
||||
}
|
||||
|
||||
@ -117,8 +91,6 @@ static void prodtest_backup_ram_erase(cli_t* cli) {
|
||||
|
||||
backup_ram_erase();
|
||||
|
||||
backup_ram_deinit();
|
||||
|
||||
cli_ok(cli, "");
|
||||
}
|
||||
|
||||
@ -140,8 +112,6 @@ static void prodtest_backup_ram_erase_unused(cli_t* cli) {
|
||||
|
||||
backup_ram_erase_unused();
|
||||
|
||||
backup_ram_deinit();
|
||||
|
||||
cli_ok(cli, "");
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,10 @@
|
||||
#include <io/sdcard.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_BACKUP_RAM
|
||||
#include <sys/backup_ram.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_TOUCH
|
||||
#include <io/touch.h>
|
||||
#endif
|
||||
@ -207,6 +211,9 @@ static void drivers_init(void) {
|
||||
#ifdef USE_SD_CARD
|
||||
sdcard_init();
|
||||
#endif
|
||||
#ifdef USE_BACKUP_RAM
|
||||
backup_ram_init();
|
||||
#endif
|
||||
#ifdef USE_BUTTON
|
||||
button_init();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user