Skip to content

Commit e5580d3

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 d6c1f63 commit e5580d3

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
@@ -294,14 +294,20 @@ hardened_bool_t rescue_detect_entry(const owner_rescue_config_t *config) {
294294
if (rescue_requested == kHardenedBoolTrue) {
295295
return kHardenedBoolTrue;
296296
}
297+
rescue_protocol_t protocol = kRescueProtocolXmodem;
297298
rescue_detect_t detect = kRescueDetectBreak;
298299
uint32_t index = 0;
299300
uint32_t gpio_val = 0;
300301
if ((hardened_bool_t)config != kHardenedBoolFalse) {
302+
protocol = config->protocol;
301303
detect = bitfield_field32_read(config->detect, RESCUE_DETECT);
302304
index = bitfield_field32_read(config->detect, RESCUE_DETECT_INDEX);
303305
gpio_val = bitfield_bit32_read(config->gpio, RESCUE_GPIO_VALUE_BIT);
304306
}
307+
dbg_printf("info: rescue protocol %c\r\n", rescue_type);
308+
if (protocol != rescue_type) {
309+
dbg_printf("warning: rescue configured for protocol %c\r\n", protocol);
310+
}
305311
switch (detect) {
306312
case kRescueDetectNone:
307313
break;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ typedef struct RescueState {
8686
uint8_t data[2048];
8787
} rescue_state_t;
8888

89+
extern const uint32_t rescue_type;
90+
8991
/**
9092
* Handle rescue modes that involve sending data to the host.
9193
*

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)