From 5118d67508da50de41bd845c321191de3b98caea Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Sat, 29 Jan 2022 17:40:46 +0800 Subject: [PATCH] config_tools: gracefully skip invalid or ignored BARs The board configuration generator assumes all PCI BARs are programmed when the board inspector runs, which is sometimes not the case. Unprogrammed BARs will be reported using plain texts wrapped by angle brackets in the output of `lspci`. This patch gracefully skips the unprogrammed BARs and continues when parsing the output of `lspci`, in order to avoid build-time failures due to unprogrammed BARs. Tracked-On: #6355 Signed-off-by: Junjie Mao --- misc/config_tools/library/board_cfg_lib.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/misc/config_tools/library/board_cfg_lib.py b/misc/config_tools/library/board_cfg_lib.py index 00d9e599b..8629953d4 100644 --- a/misc/config_tools/library/board_cfg_lib.py +++ b/misc/config_tools/library/board_cfg_lib.py @@ -435,7 +435,11 @@ def parser_pci(): if "size=" not in line: continue - bar_addr = int(get_value_after_str(line, "at"), 16) + try: + bar_addr = int(get_value_after_str(line, "at"), 16) + except ValueError: + continue + bar_num = line.split()[1].strip(':') if bar_addr >= common.SIZE_4G or bar_addr < common.SIZE_2G: if not tmp_bar_attr.remappable: