summaryrefslogtreecommitdiff
path: root/tools/binman/ftest.py
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-10-31 14:43:04 -0400
committerTom Rini <trini@konsulko.com>2022-10-31 14:43:04 -0400
commita90afc6730e6c67ad37f4c98a02891a93b4ff971 (patch)
tree724c085433631e142a56c052d667139cba29b4a6 /tools/binman/ftest.py
parent6f38d91158e7e4199753b79e0a25c1a65175aba4 (diff)
parent77bec9e3d8bd2dc307447b92a3d5cefd693a62ad (diff)
Merge branch '2022-10-31-vbe-implement-the-full-firmware-flow'
To quote Simon: This series provides an implementation of VBE from TPL through to U-Boot proper, using VBE to load the relevant firmware stages. It buils a single image.bin file containing all the phases: TPL - initial phase, loads VPL using binman symbols VPL - main firmware phase, loads SPL using VBE parameters SPL - loads U-Boot proper using VBE parameters U-Boot - final firmware phase, where OS booting is processed This series does not include the OS-booting phase. That will be the subject of a future series. The implementation is entirely handled by sandbox. It should be possible to enable this on a real board without much effort, but that is also the subject of a future series.
Diffstat (limited to 'tools/binman/ftest.py')
-rw-r--r--tools/binman/ftest.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 232ac2cf185..e849d96587c 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -6005,5 +6005,62 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
self.assertTrue(os.path.islink(sname))
self.assertEqual(os.readlink(sname), fname)
+ def testSymbolsElf(self):
+ """Test binman can assign symbols embedded in an ELF file"""
+ if not elf.ELF_TOOLS:
+ self.skipTest('Python elftools not available')
+ self._SetupTplElf('u_boot_binman_syms')
+ self._SetupVplElf('u_boot_binman_syms')
+ self._SetupSplElf('u_boot_binman_syms')
+ data = self._DoReadFileDtb('260_symbols_elf.dts')[0]
+ image_fname = tools.get_output_filename('image.bin')
+
+ image = control.images['image']
+ entries = image.GetEntries()
+
+ for entry in entries.values():
+ # No symbols in u-boot and it has faked contents anyway
+ if entry.name == 'u-boot':
+ continue
+ edata = data[entry.image_pos:entry.image_pos + entry.size]
+ efname = tools.get_output_filename(f'edata-{entry.name}')
+ tools.write_file(efname, edata)
+
+ syms = elf.GetSymbolFileOffset(efname, ['_binman_u_boot'])
+ re_name = re.compile('_binman_(u_boot_(.*))_prop_(.*)')
+ for name, sym in syms.items():
+ msg = 'test'
+ val = elf.GetSymbolValue(sym, edata, msg)
+ entry_m = re_name.match(name)
+ if entry_m:
+ ename, prop = entry_m.group(1), entry_m.group(3)
+ entry, entry_name, prop_name = image.LookupEntry(entries,
+ name, msg)
+ if prop_name == 'offset':
+ expect_val = entry.offset
+ elif prop_name == 'image_pos':
+ expect_val = entry.image_pos
+ elif prop_name == 'size':
+ expect_val = entry.size
+ self.assertEqual(expect_val, val)
+
+ def testSymbolsElfBad(self):
+ """Check error when trying to write symbols without the elftools lib"""
+ if not elf.ELF_TOOLS:
+ self.skipTest('Python elftools not available')
+ self._SetupTplElf('u_boot_binman_syms')
+ self._SetupVplElf('u_boot_binman_syms')
+ self._SetupSplElf('u_boot_binman_syms')
+ try:
+ elf.ELF_TOOLS = False
+ with self.assertRaises(ValueError) as exc:
+ self._DoReadFileDtb('260_symbols_elf.dts')
+ finally:
+ elf.ELF_TOOLS = True
+ self.assertIn(
+ "Section '/binman': entry '/binman/u-boot-spl-elf': "
+ 'Cannot write symbols to an ELF file without Python elftools',
+ str(exc.exception))
+
if __name__ == "__main__":
unittest.main()