Skip to content

Commit d24a0bd

Browse files
cfrantzpamaury
authored andcommitted
[rescue] Print the rescue protocol type
1. Print the type of rescue protocol linked into the ROM_EXT. 2. Emit a warning if the owner config protocol is inconsistent with the type of protocol linked into the ROM_EXT. Signed-off-by: Chris Frantz <[email protected]> (cherry picked from commit 3185b58)
1 parent c0b52d8 commit d24a0bd

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,20 @@ hardened_bool_t rescue_detect_entry(const owner_rescue_config_t *config) {
332332
if (rescue_requested == kHardenedBoolTrue) {
333333
return kHardenedBoolTrue;
334334
}
335+
rescue_protocol_t protocol = kRescueProtocolXmodem;
335336
rescue_detect_t detect = kRescueDetectBreak;
336337
uint32_t index = 0;
337338
uint32_t gpio_val = 0;
338339
if ((hardened_bool_t)config != kHardenedBoolFalse) {
340+
protocol = config->protocol;
339341
detect = bitfield_field32_read(config->detect, RESCUE_DETECT);
340342
index = bitfield_field32_read(config->detect, RESCUE_DETECT_INDEX);
341343
gpio_val = bitfield_bit32_read(config->gpio, RESCUE_GPIO_VALUE_BIT);
342344
}
345+
dbg_printf("info: rescue protocol %c\r\n", rescue_type);
346+
if (protocol != rescue_type) {
347+
dbg_printf("warning: rescue configured for protocol %c\r\n", protocol);
348+
}
343349
switch (detect) {
344350
case kRescueDetectNone:
345351
break;

sw/device/silicon_creator/lib/rescue/rescue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ typedef struct RescueState {
9696
uint8_t data[2048];
9797
} rescue_state_t;
9898

99+
extern const uint32_t rescue_type;
100+
99101
/**
100102
* Handle rescue modes that involve sending data to the host.
101103
*

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h"
2323

24+
const uint32_t rescue_type = kRescueProtocolSpiDfu;
25+
2426
enum {
2527
/**
2628
* Base address of the spi_device registers.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h"
2121

22+
const uint32_t rescue_type = kRescueProtocolUsbDfu;
23+
2224
static const usb_device_descriptor_t device_desc = {
2325
.length = (uint8_t)sizeof(usb_device_descriptor_t),
2426
.descriptor_type = kUsbDescTypeDevice,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "sw/device/silicon_creator/lib/rescue/rescue.h"
1212
#include "sw/device/silicon_creator/lib/rescue/xmodem.h"
1313

14+
const uint32_t rescue_type = kRescueProtocolXmodem;
15+
1416
// All of the xmodem functions accept an opaque iohandle pointer.
1517
// The iohandle is used to facilitate unit tests and doesn't have
1618
// any function in real firmware.

0 commit comments

Comments
 (0)