feat(core/bootloader_emu): add option to wipe firmware image on start
What changed, and why it matters
This commit adds a new command-line option (-w) to the Trezor bootloader emulator, a software-only testing tool. When used, it erases any simulated firmware image before the emulator starts booting. It is a development/testing convenience and does not change real hardware behavior or fix a security problem.
No security action required. Treat as a normal feature addition for emulator testing workflows.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is confined to core/embed/projects/bootloader/emulator.c. It adds a ‘w’ option to the getopt string and a handler that calls flash_area_erase(&FIRMWARE_AREA, NULL) on the emulator’s simulated flash. This only affects the bootloader_emu build used for local emulation/testing, not physical devices. No production bootloader or firmware logic is modified.
Changed components
core/embed/projects/bootloader/emulator.cbootloader_emu (emulator build only)Inspect captured patch +8 / −1
diff --git a/core/embed/projects/bootloader/emulator.c b/core/embed/projects/bootloader/emulator.c
index a4b5f7b4..0768ad5f 100644
--- a/core/embed/projects/bootloader/emulator.c
+++ b/core/embed/projects/bootloader/emulator.c
@@ -40,6 +40,7 @@ void usage(void) {
printf("Usage: ./build/bootloader/bootloader_emu [options]\n");
printf("Options:\n");
printf(" -s stay in bootloader\n");
+ printf(" -w wipe any firmware before booting\n");
printf(" -e MESSAGE [TITLE [FOOTER]] display error screen and stop\n");
printf(" -c COLOR_VARIANT set color variant\n");
printf(" -b BITCOIN_ONLY set bitcoin only flag\n");
@@ -148,7 +149,7 @@ int main(int argc, char **argv) {
uint8_t set_variant = 0xff;
uint8_t color_variant = 0;
uint8_t bitcoin_only = 0;
- while ((opt = getopt(argc, argv, "hslec:b:f:i:")) != -1) {
+ while ((opt = getopt(argc, argv, "hslewc:b:f:i:")) != -1) {
switch (opt) {
case 's':
bootargs_set(BOOT_COMMAND_STOP_AND_WAIT, NULL, 0);
@@ -169,6 +170,11 @@ int main(int argc, char **argv) {
exit(1);
}
} break;
+ case 'w': {
+ if (sectrue != flash_area_erase(&FIRMWARE_AREA, NULL)) {
+ exit(1);
+ }
+ } break;
case 'f': {
uint8_t hash[BLAKE2S_DIGEST_LENGTH];
if (!load_firmware(optarg, hash)) {
@@ -176,6 +182,7 @@ int main(int argc, char **argv) {
}
bootargs_set(BOOT_COMMAND_INSTALL_UPGRADE, hash, sizeof(hash));
} break;
+
#ifdef LOCKABLE_BOOTLOADER
case 'l':
secret_lock_bootloader();
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.