diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2017-06-08 21:49:00 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-06-13 21:23:59 -0700 |
commit | 68079d94a66830ae25bb0c6d6b5ac53555e05fd9 (patch) | |
tree | 7304fe8b7b8b9fbd243808f1e7b189014a99ec75 | |
parent | 01213a574f4d8ebe6cc295d1dc614feeb3a79adb (diff) | |
download | chrome-ec-68079d94a66830ae25bb0c6d6b5ac53555e05fd9.tar.gz |
g: show RW headers' Board ID fields in 'version' output
The contents of the board ID fields of the Cr50 image headers is an
important piece of information which determines if an image can run on
a particular H1 chip.
This patch adds this information to the output of the 'version'
command, printing both the contents of the fields of the RW images and
if the image would run with the current INFO1 board ID contents (Yes
or NO).
The board_id feature is in fact g chipset specific, this is why
board_id support files are being moved from the cr50 board scope to
the g chip scope.
BRANCH=cr50
BUG=b:35587387,b:35587053
TEST=observed expected output in the version command:
> bid
Board ID: 000000fa, flags 000000ff
> vers
Chip: g cr50 B2-C
Board: 0
RO_A: * 0.0.10/29d77172
RO_B: 0.0.10/c2a3f8f9
RW_A: * 0.0.20/DBG/cr50_v1.1.6542-856c3aff4
RW_B: 0.0.20/DBG/cr50_v1.1.6543-2c68a2630+
BID A: 00000000:00000000:00000000 Yes
BID B: 000000ea:0000fffc:000000ff No
Build: 0.0.20/DBG/cr50_v1.1.6542-856c3aff4
tpm2:v0.0.289-cb2de5a
cryptoc:v0.0.8-6283eee
2017-06-09 15:34:19 vbendeb@eskimo.mtv.corp.google.com
>
Change-Id: I5b283abf304a7408ca8f424407044fca238185e1
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/530033
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | board/cr50/board.h | 3 | ||||
-rw-r--r-- | board/cr50/build.mk | 1 | ||||
-rw-r--r-- | chip/g/board_id.c (renamed from board/cr50/board_id.c) | 26 | ||||
-rw-r--r-- | chip/g/board_id.h (renamed from board/cr50/board_id.h) | 28 | ||||
-rw-r--r-- | chip/g/build.mk | 3 | ||||
-rw-r--r-- | chip/g/system.c | 31 | ||||
-rw-r--r-- | common/system.c | 1 | ||||
-rw-r--r-- | include/config.h | 12 | ||||
-rw-r--r-- | include/system.h | 7 |
9 files changed, 85 insertions, 27 deletions
diff --git a/board/cr50/board.h b/board/cr50/board.h index a8606131ea..0e1f5e4b2f 100644 --- a/board/cr50/board.h +++ b/board/cr50/board.h @@ -247,6 +247,9 @@ enum nvmem_users { #define CONFIG_I2C_SLAVE #define CONFIG_TPM_I2CS +#define CONFIG_BOARD_ID_SUPPORT +#define CONFIG_EXTENDED_VERSION_INFO + #define I2C_PORT_MASTER 0 #endif /* __CROS_EC_BOARD_H */ diff --git a/board/cr50/build.mk b/board/cr50/build.mk index f51297bcff..ef2299dccd 100644 --- a/board/cr50/build.mk +++ b/board/cr50/build.mk @@ -30,7 +30,6 @@ dirs-y += $(BDIR)/tpm2 # Objects that we need to build board-y = board.o -board-y += board_id.o board-${CONFIG_RDD} += rdd.o board-${CONFIG_USB_SPI} += usb_spi.o board-${CONFIG_USB_I2C} += usb_i2c.o diff --git a/board/cr50/board_id.c b/chip/g/board_id.c index f6f3202a96..fb3fb8755e 100644 --- a/board/cr50/board_id.c +++ b/chip/g/board_id.c @@ -8,12 +8,11 @@ #include "endian.h" #include "extension.h" #include "flash_info.h" -#include "signed_header.h" #include "system.h" #include "util.h" -#define CPRINTS(format, args...) cprints(CC_RBOX, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_RBOX, format, ## args) +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args) /** * Return the image header for the current image copy @@ -24,16 +23,8 @@ const struct SignedHeader *get_current_image_header(void) get_program_memory_addr(system_get_image_copy()); } -/** - * Check the current header vs. the supplied Board ID - * - * @param board_id Pointer to a Board ID structure to check - * @param h Pointer to the currently running image's header - * - * @return 0 if no mismatch, non-zero if mismatch - */ -static uint32_t check_board_id_vs_header(const struct board_id *id, - const struct SignedHeader *h) +uint32_t check_board_id_vs_header(const struct board_id *id, + const struct SignedHeader *h) { uint32_t mismatch; uint32_t header_board_id_type; @@ -72,14 +63,7 @@ static uint32_t check_board_id_vs_header(const struct board_id *id, return mismatch; } -/** - * Check board ID from the flash INFO1 space. - * - * @param id Pointer to a Board ID structure to fill - * - * @return EC_SUCCESS of an error code in cases of vairous failures to read. - */ -static int read_board_id(struct board_id *id) +int read_board_id(struct board_id *id) { uint32_t *id_p; int i; diff --git a/board/cr50/board_id.h b/chip/g/board_id.h index fefcd4c36b..2599060d79 100644 --- a/board/cr50/board_id.h +++ b/chip/g/board_id.h @@ -4,9 +4,11 @@ * found in the LICENSE file. */ -#ifndef __EC_BOARD_CR50_BOARD_ID__H -#define __EC_BOARD_CR50_BOARD_ID__H +#ifndef __EC_CHIP_G_BOARD_ID_H +#define __EC_CHIP_G_BOARD_ID_H +#include "common.h" +#include "signed_header.h" #include "util.h" /* Structure holding Board ID */ @@ -24,8 +26,28 @@ struct info1_board_space { #define INFO_BOARD_ID_SIZE sizeof(struct board_id) #define INFO_BOARD_SPACE_PROTECT_SIZE 16 +/** + * Check the current header vs. the supplied Board ID + * + * @param board_id Pointer to a Board ID structure to check + * @param h Pointer to the currently running image's header + * + * @return 0 if no mismatch, non-zero if mismatch + */ +uint32_t check_board_id_vs_header(const struct board_id *id, + const struct SignedHeader *h); + +/** + * Check board ID from the flash INFO1 space. + * + * @param id Pointer to a Board ID structure to fill + * + * @return EC_SUCCESS of an error code in cases of vairous failures to read. + */ +int read_board_id(struct board_id *id); + BUILD_ASSERT((offsetof(struct info1_board_space, bid) & 3) == 0); BUILD_ASSERT((INFO_BOARD_ID_SIZE & 3) == 0); BUILD_ASSERT(sizeof(struct info1_board_space) <= INFO_BOARD_SPACE_PROTECT_SIZE); -#endif /* ! __EC_BOARD_CR50_BOARD_ID_H */ +#endif /* ! __EC_CHIP_G_BOARD_ID_H */ diff --git a/chip/g/build.mk b/chip/g/build.mk index 69c22c27f3..91d6808058 100644 --- a/chip/g/build.mk +++ b/chip/g/build.mk @@ -20,7 +20,8 @@ CPPFLAGS += -I$(CRYPTOCLIB)/include endif # Required chip modules -chip-y=clock.o gpio.o hwtimer.o jtag.o system.o +chip-y = clock.o gpio.o hwtimer.o jtag.o system.o +chip-$(CONFIG_BOARD_ID_SUPPORT) += board_id.o ifeq ($(CONFIG_POLLING_UART),y) chip-y += polling_uart.o else diff --git a/chip/g/system.c b/chip/g/system.c index 9fa5385907..625bde28a5 100644 --- a/chip/g/system.c +++ b/chip/g/system.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "config.h" +#include "board_id.h" #include "console.h" #include "cpu.h" #include "cpu.h" @@ -687,3 +687,32 @@ void system_get_rollback_bits(char *value, size_t value_size) snprintf(value, value_size, "%d/%d/%d", info_count, headers[0].count, headers[1].count); } + +#ifdef CONFIG_EXTENDED_VERSION_INFO + +void system_print_extended_version_info(void) +{ + int i; + struct board_id bid; + enum system_image_copy_t rw_images[] = { + SYSTEM_IMAGE_RW, SYSTEM_IMAGE_RW_B + }; + + if (read_board_id(&bid) != EC_SUCCESS) { + ccprintf("Board ID read failure!\n"); + return; + } + + for (i = 0; i < ARRAY_SIZE(rw_images); i++) { + struct SignedHeader *ss = (struct SignedHeader *) + get_program_memory_addr(rw_images[i]); + + ccprintf("BID %c: %08x:%08x:%08x %s\n", 'A' + i, + ss->board_id_type ^ SIGNED_HEADER_PADDING, + ss->board_id_type_mask ^ SIGNED_HEADER_PADDING, + ss->board_id_flags ^ SIGNED_HEADER_PADDING, + check_board_id_vs_header(&bid, ss) ? " No" : "Yes"); + } +} + +#endif /* CONFIG_EXTENDED_VERSION_INFO */ diff --git a/common/system.c b/common/system.c index b9e444c71c..8e1a123b39 100644 --- a/common/system.c +++ b/common/system.c @@ -960,6 +960,7 @@ static int command_version(int argc, char **argv) ccprintf("RW: %s\n", system_get_version(SYSTEM_IMAGE_RW)); #endif + system_print_extended_version_info(); print_build_string(); return EC_SUCCESS; diff --git a/include/config.h b/include/config.h index cff891a433..26bf0fb8f2 100644 --- a/include/config.h +++ b/include/config.h @@ -2764,6 +2764,18 @@ */ #undef CONFIG_PWR_STATE_DISCHARGE_FULL +/* + * Define this if a chip needs to add some information to the common 'version' + * command output. + */ +#undef CONFIG_EXTENDED_VERSION_INFO + +/* + * Define this if board ID support is required. For g chip based boards it + * allows to nail different images to different boards. + */ +#undef CONFIG_BOARD_ID_SUPPORT + /*****************************************************************************/ /* * Include board and core configs, since those hold the CONFIG_ constants for a diff --git a/include/system.h b/include/system.h index 0f01907574..f40feb0e37 100644 --- a/include/system.h +++ b/include/system.h @@ -522,4 +522,11 @@ uintptr_t system_get_fw_reset_vector(uintptr_t base); */ int system_is_reboot_warm(void); +#ifdef CONFIG_EXTENDED_VERSION_INFO +void system_print_extended_version_info(void); +#else +static inline void system_print_extended_version_info(void) +{ +} +#endif #endif /* __CROS_EC_SYSTEM_H */ |