Skip to content

Commit eb90aa1

Browse files
committed
libs/flash_image: allow for flashing on AMD via -x flag
Signed-off-by: Maciej Pijanowski <[email protected]>
1 parent 900051d commit eb90aa1

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

osfv_cli/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ robotframework = "^7.2"
1010

1111
[tool.poetry]
1212
name = "osfv"
13-
version = "0.7.2"
13+
version = "0.7.3"
1414
description = "Open Source Firmware Validation Command Line Interface Tool"
1515
authors = ["Maciej Pijanowski <[email protected]>"]
1616
include = ["src/models/*.yml"]

osfv_cli/src/osfv/cli/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,10 @@ def flash_write(rte, args):
677677
== False
678678
):
679679
exit(
680-
"FATAL: Some image's regions are empty, despite being defined in the flash descriptor. "
681-
"Flashing full image in this form will result in a bricked platform. "
682-
"If you wish to continue anyway, pass the -x option to skip the check. "
683-
"You probably also want to pass the -b option to flash BIOS region only, "
680+
"FATAL: Image could not be loaded, or some image's regions are empty, despite being defined in the flash descriptor. "
681+
"Flashing full image in this form on Intel platform will result in a bricked platform. "
682+
"If you wish to continue anyway (e.g. when using AMD platform), pass the -x option to skip the check. "
683+
"When using Intel platform, you probably also want to pass the -b option to flash BIOS region only, "
684684
"leaving other regions in platform's flash (such as ME) intact."
685685
)
686686
print(f"Writing {args.rom} to flash...")

osfv_cli/src/osfv/libs/flash_image.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ def __init__(self):
6060

6161
def load_image_file(self, image_path):
6262
if not os.path.isfile(image_path):
63-
print(f"FATAL: file does not exist: {image_path}")
64-
sys.exit(1)
63+
print(f"File does not exist: {image_path}")
64+
self.EXIT_CODE = False
65+
return False
6566
with open(
6667
image_path,
6768
mode="rb",
@@ -76,8 +77,9 @@ def load_image_file(self, image_path):
7677
self.imageData[valsig_offset : (valsig_offset + 0x04)],
7778
)[0x00]
7879
if valsig != self.FLVALSIG:
79-
print("FATAL: Invalid image, no FLVALSIG found!")
80-
sys.exit(1)
80+
print("Invalid image, no FLVALSIG found!")
81+
self.EXIT_CODE = False
82+
return False
8183
if self.VERBOSITY > 0:
8284
print("FLVALSIG: {0:#0{1}x}".format(valsig, 0x0A))
8385

@@ -100,6 +102,7 @@ def load_image_file(self, image_path):
100102
FRBA : (FRBA + (0x04 * self.NUMBER_OF_REGIONS))
101103
],
102104
)
105+
return True
103106

104107
def get_region_data(self, pIndex, pName):
105108
if self.REGIONS[pIndex] == 0x00007FFF:
@@ -151,5 +154,5 @@ def dump_region(self, pIndex, pName):
151154
print('Region "' + pName + '" dumped to: ' + pName + "_dump.bin")
152155
else:
153156
if self.VERBOSITY > 0:
154-
print("FATAL: region dump failed.")
157+
print("Region dump failed.")
155158
self.EXIT_CODE = 1

osfv_cli/src/osfv/libs/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ def check_flash_image_regions(
6767
flash_image.set_verbosity(1)
6868

6969
print(f"Verifying flash image completeness of {rom} ...")
70-
flash_image.load_image_file(rom)
70+
if not flash_image.load_image_file(rom):
71+
print(
72+
"Failed to load image file. Cannot verify the presence of Intel regions."
73+
)
74+
if dry_run:
75+
return True
76+
return False
7177

7278
for check_region_name in regions:
7379
check_region_index = flash_image.get_region_index(check_region_name)

0 commit comments

Comments
 (0)