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
|
#ifdef USE_TOUCH
|
||||||
#include <io/touch.h>
|
#include <io/touch.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_BACKUP_RAM
|
||||||
|
#include <sys/backup_ram.h>
|
||||||
|
#endif
|
||||||
#ifdef USE_BUTTON
|
#ifdef USE_BUTTON
|
||||||
#include <io/button.h>
|
#include <io/button.h>
|
||||||
#endif
|
#endif
|
||||||
@ -113,6 +116,9 @@ static void drivers_init(secbool *touch_initialized) {
|
|||||||
#ifdef USE_OPTIGA
|
#ifdef USE_OPTIGA
|
||||||
optiga_hal_init();
|
optiga_hal_init();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_BACKUP_RAM
|
||||||
|
backup_ram_init();
|
||||||
|
#endif
|
||||||
#ifdef USE_BUTTON
|
#ifdef USE_BUTTON
|
||||||
button_init();
|
button_init();
|
||||||
#endif
|
#endif
|
||||||
@ -126,6 +132,9 @@ static void drivers_init(secbool *touch_initialized) {
|
|||||||
|
|
||||||
static void drivers_deinit(void) {
|
static void drivers_deinit(void) {
|
||||||
#ifdef FIXED_HW_DEINIT
|
#ifdef FIXED_HW_DEINIT
|
||||||
|
#ifdef USE_BACKUP_RAM
|
||||||
|
backup_ram_deinit();
|
||||||
|
#endif
|
||||||
#ifdef USE_BUTTON
|
#ifdef USE_BUTTON
|
||||||
button_deinit();
|
button_deinit();
|
||||||
#endif
|
#endif
|
||||||
|
@ -58,6 +58,10 @@
|
|||||||
#include <sec/optiga_config.h>
|
#include <sec/optiga_config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_BACKUP_RAM
|
||||||
|
#include <sys/backup_ram.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_TROPIC
|
#ifdef USE_TROPIC
|
||||||
#include <sec/tropic.h>
|
#include <sec/tropic.h>
|
||||||
#endif
|
#endif
|
||||||
@ -95,6 +99,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void drivers_init() {
|
void drivers_init() {
|
||||||
|
|
||||||
|
#ifdef USE_BACKUP_RAM
|
||||||
|
backup_ram_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_POWERCTL
|
#ifdef USE_POWERCTL
|
||||||
powerctl_init();
|
powerctl_init();
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,31 +41,18 @@ static void prodtest_backup_ram_write(cli_t* cli) {
|
|||||||
return;
|
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;
|
backup_ram_power_manager_data_t pm_data;
|
||||||
|
|
||||||
pm_data.soc = ((float)soc / 100);
|
pm_data.soc = ((float)soc / 100);
|
||||||
pm_data.last_capture_timestamp = systick_cycles();
|
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) {
|
if (status != BACKUP_RAM_OK) {
|
||||||
cli_error(cli, CLI_ERROR, "Failed to write backup RAM");
|
cli_error(cli, CLI_ERROR, "Failed to write backup RAM");
|
||||||
backup_ram_deinit();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_ram_deinit();
|
|
||||||
|
|
||||||
cli_ok(cli, "");
|
cli_ok(cli, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,27 +62,14 @@ static void prodtest_backup_ram_read(cli_t* cli) {
|
|||||||
return;
|
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;
|
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) {
|
if (status != BACKUP_RAM_OK) {
|
||||||
cli_error(cli, CLI_ERROR, "Failed to read backup RAM");
|
cli_error(cli, CLI_ERROR, "Failed to read backup RAM");
|
||||||
backup_ram_deinit();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_ram_deinit();
|
|
||||||
|
|
||||||
cli_ok(cli, "SOC: %d\%", (int)(pm_data.soc * 100));
|
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_erase();
|
||||||
|
|
||||||
backup_ram_deinit();
|
|
||||||
|
|
||||||
cli_ok(cli, "");
|
cli_ok(cli, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,8 +112,6 @@ static void prodtest_backup_ram_erase_unused(cli_t* cli) {
|
|||||||
|
|
||||||
backup_ram_erase_unused();
|
backup_ram_erase_unused();
|
||||||
|
|
||||||
backup_ram_deinit();
|
|
||||||
|
|
||||||
cli_ok(cli, "");
|
cli_ok(cli, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,10 @@
|
|||||||
#include <io/sdcard.h>
|
#include <io/sdcard.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_BACKUP_RAM
|
||||||
|
#include <sys/backup_ram.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_TOUCH
|
#ifdef USE_TOUCH
|
||||||
#include <io/touch.h>
|
#include <io/touch.h>
|
||||||
#endif
|
#endif
|
||||||
@ -207,6 +211,9 @@ static void drivers_init(void) {
|
|||||||
#ifdef USE_SD_CARD
|
#ifdef USE_SD_CARD
|
||||||
sdcard_init();
|
sdcard_init();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_BACKUP_RAM
|
||||||
|
backup_ram_init();
|
||||||
|
#endif
|
||||||
#ifdef USE_BUTTON
|
#ifdef USE_BUTTON
|
||||||
button_init();
|
button_init();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user