Skip to content

Commit c3de0ca

Browse files
committed
tools: sof_ri_info: dump all CSS/CSE header fields
Extend CSS and CSE parsing/dump paths to include fields that were previously skipped or only partially represented. Cover version-specific CSE fields and expose additional CSS header members so output better matches the current rimage headers. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 4027943 commit c3de0ca

1 file changed

Lines changed: 43 additions & 15 deletions

File tree

tools/sof_ri_info/sof_ri_info.py

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -846,14 +846,22 @@ def parse_cse_manifest(reader):
846846
nb_entries = reader.read_dw()
847847
reader.info('# of entries {}'.format(nb_entries))
848848
hdr.add_a(Adec('nb_entries', nb_entries))
849-
# read version (1byte for header ver and 1 byte for entry ver)
850-
ver = reader.read_w()
851-
hdr.add_a(Ahex('header_version', ver))
849+
# read version bytes
850+
hdr.add_a(Ahex('header_version', reader.read_b()))
851+
hdr.add_a(Ahex('entry_version', reader.read_b()))
852852
header_length = reader.read_b()
853853
hdr.add_a(Ahex('header_length', header_length))
854-
hdr.add_a(Ahex('checksum', reader.read_b()))
854+
legacy_or_unused = reader.read_b()
855+
if header_length > 12:
856+
hdr.add_a(Ahex('not_used', legacy_or_unused))
857+
else:
858+
hdr.add_a(Ahex('checksum', legacy_or_unused))
855859
hdr.add_a(Astring('partition_name', reader.read_string(4)))
856860

861+
# CSE v2.5 extends header with a CRC32 checksum dword
862+
if header_length > 12:
863+
hdr.add_a(Ahex('checksum32', reader.read_dw()))
864+
857865
reader.set_offset(cse_mft.file_offset + header_length)
858866
# Read entries
859867
nb_index = 0
@@ -862,13 +870,13 @@ def parse_cse_manifest(reader):
862870
entry_name = reader.read_string(12)
863871
entry_offset = reader.read_dw()
864872
entry_length = reader.read_dw()
865-
# reserved field
866-
reader.read_dw()
873+
entry_reserved = reader.read_dw()
867874

868875
hdr_entry = Component('cse_hdr_entry', 'Entry', reader.get_offset())
869876
hdr_entry.add_a(Astring('entry_name', entry_name))
870877
hdr_entry.add_a(Ahex('entry_offset', entry_offset))
871878
hdr_entry.add_a(Ahex('entry_length', entry_length))
879+
hdr_entry.add_a(Ahex('entry_reserved', entry_reserved))
872880
hdr.add_comp(hdr_entry)
873881

874882
assert cse_mft.file_offset == reader.ext_mft_length
@@ -916,12 +924,16 @@ def parse_css_manifest_4(css_mft, reader, size_limit):
916924
hdr = Component('css_mft_hdr', 'Header', reader.get_offset())
917925
css_mft.add_comp(hdr)
918926

919-
hdr.add_a(Auint('type', reader.read_dw()))
927+
header_type = reader.read_dw()
928+
hdr.add_a(Auint('type', header_type))
929+
hdr.add_a(Auint('header_type', header_type))
920930
header_len_dw = reader.read_dw()
921931
hdr.add_a(Auint('header_len_dw', header_len_dw))
922932
hdr.add_a(Auint('header_version', reader.read_dw()))
923933
hdr.add_a(Auint('reserved0', reader.read_dw(), 'red'))
924-
hdr.add_a(Ahex('mod_vendor', reader.read_dw()))
934+
module_vendor = reader.read_dw()
935+
hdr.add_a(Ahex('mod_vendor', module_vendor))
936+
hdr.add_a(Ahex('module_vendor', module_vendor))
925937
date_start = reader.get_offset()
926938
hdr.add_a(Auint('date_start', date_start))
927939
hdr.add_a(Adate('date', hex(reader.read_dw())))
@@ -930,10 +942,17 @@ def parse_css_manifest_4(css_mft, reader, size_limit):
930942
hdr.add_a(Auint('size', size))
931943
hdr.add_a(Astring('header_id', reader.read_string(4)))
932944
hdr.add_a(Auint('padding', reader.read_dw()))
933-
hdr.add_a(Aversion('fw_version', reader.read_w(), reader.read_w(),
934-
reader.read_w(), reader.read_w()))
945+
fw_major = reader.read_w()
946+
fw_minor = reader.read_w()
947+
fw_hotfix = reader.read_w()
948+
fw_build = reader.read_w()
949+
hdr.add_a(Auint('fw_major_version', fw_major))
950+
hdr.add_a(Auint('fw_minor_version', fw_minor))
951+
hdr.add_a(Auint('fw_hotfix_version', fw_hotfix))
952+
hdr.add_a(Auint('fw_build_version', fw_build))
953+
hdr.add_a(Aversion('fw_version', fw_major, fw_minor, fw_hotfix, fw_build))
935954
hdr.add_a(Auint('svn', reader.read_dw()))
936-
reader.read_bytes(18*4)
955+
hdr.add_a(Abytes('reserved1', reader.read_bytes(18*4)))
937956
modulus_size = reader.read_dw()
938957
hdr.add_a(Adec('modulus_size', modulus_size))
939958
exponent_size = reader.read_dw()
@@ -1456,10 +1475,19 @@ def __init__(self, offset):
14561475

14571476
def dump_info(self, pref, comp_filter):
14581477
hdr = self.cdir['cse_mft_hdr']
1459-
print('{}{} ver {} checksum {} partition name {}'.
1460-
format(pref,
1461-
self.name, hdr.adir['header_version'],
1462-
hdr.adir['checksum'], hdr.adir['partition_name']))
1478+
out = '{}{} header_ver {} entry_ver {} partition name {}'.format(
1479+
pref,
1480+
self.name,
1481+
hdr.adir['header_version'],
1482+
hdr.adir['entry_version'],
1483+
hdr.adir['partition_name'])
1484+
if 'checksum' in hdr.adir:
1485+
out += ' checksum {}'.format(hdr.adir['checksum'])
1486+
if 'not_used' in hdr.adir:
1487+
out += ' not_used {}'.format(hdr.adir['not_used'])
1488+
if 'checksum32' in hdr.adir:
1489+
out += ' checksum32 {}'.format(hdr.adir['checksum32'])
1490+
print(out)
14631491
self.dump_comp_info(pref, comp_filter + ['Header'])
14641492

14651493
class CssManifest(Component):

0 commit comments

Comments
 (0)