Skip to content

Commit 56bb772

Browse files
cfrantzpamaury
authored andcommitted
[rom_ext] Clear power-on-reset in self-requested reboots
Signed-off-by: Chris Frantz <[email protected]> (cherry picked from commit 4295c6f)
1 parent 7d9087e commit 56bb772

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

sw/device/silicon_creator/lib/drivers/rstmgr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,8 @@ bool rstmgr_is_hw_reset_reason(dt_rstmgr_t dt, uint32_t reasons,
168168

169169
return false;
170170
}
171+
172+
void rstmgr_reboot(void) {
173+
rstmgr_reason_clear(1 << kRstmgrReasonPowerOn);
174+
rstmgr_reset();
175+
}

sw/device/silicon_creator/lib/drivers/rstmgr.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ noreturn
115115
void
116116
rstmgr_reset(void);
117117

118+
/**
119+
* Reboot the chip.
120+
*
121+
* This function clears the power-on-reset reason and then resets the chip.
122+
*/
123+
#ifdef OT_PLATFORM_RV32
124+
// Omit `noreturn` to be able to test this function in off-target tests.
125+
noreturn
126+
#endif
127+
void
128+
rstmgr_reboot(void);
129+
118130
/**
119131
* Verifies that info collection is initialized properly.
120132
*

sw/device/silicon_creator/lib/rescue/dfu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ void dfu_protocol_handler(void *_ctx, uint8_t ep, usb_transfer_flags_t flags,
318318
if (flags & kUsbTransferFlagsReset) {
319319
// A USB reset after we've been enumerated means software reset.
320320
if (ctx->ep0.device_address && ctx->ep0.configuration) {
321-
rstmgr_reset();
321+
rstmgr_reboot();
322322
}
323323
}
324324

sw/device/silicon_creator/lib/rescue/rescue_spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ rom_error_t rescue_protocol(boot_data_t *bootdata, boot_log_t *boot_log,
130130
} break;
131131

132132
case kSpiDeviceOpcodeReset:
133-
rstmgr_reset();
133+
rstmgr_reboot();
134134
break;
135135
default:
136136
dfu_transport_result(&ctx, kErrorUsbBadSetup);

sw/device/silicon_creator/lib/rescue/rescue_xmodem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ rom_error_t rescue_protocol(boot_data_t *bootdata, boot_log_t *boot_log,
156156
rescue_state_init(&rescue_state, bootdata, boot_log, config);
157157
rom_error_t result = protocol(&rescue_state);
158158
if (result == kErrorRescueReboot) {
159-
rstmgr_reset();
159+
rstmgr_reboot();
160160
}
161161
return result;
162162
}

sw/device/silicon_creator/rom_ext/rom_ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ static rom_error_t rom_ext_start(boot_data_t *boot_data, boot_log_t *boot_log) {
767767
if (error == kErrorRescueInactivity &&
768768
boot_attempted == kHardenedBoolFalse) {
769769
rescue_skip_next_boot();
770-
rstmgr_reset();
770+
rstmgr_reboot();
771771
}
772772
}
773773

0 commit comments

Comments
 (0)