summaryrefslogtreecommitdiff
path: root/chip/g
diff options
context:
space:
mode:
Diffstat (limited to 'chip/g')
-rw-r--r--chip/g/board_id.c43
-rw-r--r--chip/g/build.mk13
-rw-r--r--chip/g/upgrade_fw.c4
3 files changed, 49 insertions, 11 deletions
diff --git a/chip/g/board_id.c b/chip/g/board_id.c
index 18b7be1ffb..b871f8b6ca 100644
--- a/chip/g/board_id.c
+++ b/chip/g/board_id.c
@@ -129,7 +129,7 @@ uint32_t board_id_mismatch(const struct SignedHeader *sh)
* @return EC_SUCCESS or an error code in cases of various failures to read or
* if the space has been already initialized.
*/
-static int write_board_id(const struct board_id *id)
+static int write_board_id(const struct board_id *id, int clear_flags)
{
struct board_id id_test;
uint32_t rv;
@@ -151,7 +151,7 @@ static int write_board_id(const struct board_id *id)
return rv;
}
- if (!board_id_is_blank(&id_test)) {
+ if (!clear_flags && !board_id_is_blank(&id_test)) {
CPRINTS("%s: Board ID already programmed", __func__);
return EC_ERROR_ACCESS_DENIED;
}
@@ -201,7 +201,7 @@ static enum vendor_cmd_rc vc_set_board_id(enum vendor_cmd_cc code,
id.flags = be32toh(id.flags);
/* We care about the LSB only. */
- *pbuf = write_board_id(&id);
+ *pbuf = write_board_id(&id, 0);
return *pbuf;
}
@@ -239,17 +239,42 @@ static int command_board_id(int argc, char **argv)
id.flags = strtoi(argv[2], &e, 0);
if (*e)
return EC_ERROR_PARAM2;
+ rv = write_board_id(&id, 0);
+ }
+#endif
+#ifdef CR50_RELAXED
+ else if (argc == 2) {
+ int clear_flags;
+
+ if (strcasecmp(argv[1], "force_pvt"))
+ return EC_ERROR_PARAM2;
+
+ clear_flags = 1;
+ rv = read_board_id(&id);
+ if (rv != EC_SUCCESS) {
+ CPRINTS("%s: error reading Board ID", __func__);
+ return rv;
+ }
+ if (board_id_is_blank(&id)) {
+ CPRINTS("%s: Board ID isn't set", __func__);
+ return EC_ERROR_INVAL;
+ }
+ id.flags = 0;
+ rv = write_board_id(&id, clear_flags);
- rv = write_board_id(&id);
- } else {
- ccprintf("specify board type and flags\n");
- rv = EC_ERROR_PARAM_COUNT;
}
#endif
return rv;
}
-DECLARE_SAFE_CONSOLE_COMMAND(bid,
- command_board_id, NULL, "Set/Get Board ID");
+DECLARE_SAFE_CONSOLE_COMMAND(bid, command_board_id,
+#ifdef CR50_DEV
+ "[force_pvt | bid flags]",
+#elif defined(CR50_RELAXED)
+ "[force_pvt]",
+#else
+ NULL,
+#endif
+ "Set/Get Board ID");
static enum vendor_cmd_rc vc_get_board_id(enum vendor_cmd_cc code,
void *buf,
diff --git a/chip/g/build.mk b/chip/g/build.mk
index d0ff756ac5..d4633748eb 100644
--- a/chip/g/build.mk
+++ b/chip/g/build.mk
@@ -126,8 +126,21 @@ ifneq ($(CONFIG_RW_B),)
$(out)/$(PROJECT).obj: $(out)/RW/ec.RW_B.flat
endif
+CR50_OPTS=
+
ifneq ($(CR50_DEV),)
CPPFLAGS += -DCR50_DEV=$(CR50_DEV)
+CR50_OPTS+=CR50_DEV
+endif
+
+ifneq ($(CR50_SQA),)
+CPPFLAGS += -DCR50_SQA=$(CR50_SQA)
+CR50_OPTS+=CR50_SQA
+endif
+
+# Test if more than one Cr50 build option is specified
+ifneq ($(wordlist 2,3,$(CR50_OPTS)),)
+$(error Incompatible CR50 build options specified: $(CR50_OPTS))
endif
MANIFEST := util/signer/ec_RW-manifest-dev.json
diff --git a/chip/g/upgrade_fw.c b/chip/g/upgrade_fw.c
index b796184a08..9138e6b498 100644
--- a/chip/g/upgrade_fw.c
+++ b/chip/g/upgrade_fw.c
@@ -162,7 +162,7 @@ int usb_pdu_valid(struct upgrade_command *cmd_body, size_t cmd_size)
return 1;
}
-#ifdef CR50_DEV
+#ifdef CR50_RELAXED
#ifndef CONFIG_IGNORE_G_UPDATE_CHECKS
#define CONFIG_IGNORE_G_UPDATE_CHECKS
#endif
@@ -318,7 +318,7 @@ static int contents_allowed(uint32_t block_offset,
size_t body_size, void *upgrade_data,
uint8_t *error_code)
{
-#ifndef CR50_DEV
+#ifdef CR50_RELAXED
#ifdef CONFIG_BOARD_ID_SUPPORT
if (block_offset == valid_sections.rw_base_offset) {
/* This block is a rw header of the new image. */