From efddab6c365439b9084ef1ac4750eacb7ba9e889 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 7 Jan 2023 14:07:08 -0700 Subject: binman: Allow writing section contents to a file At present only the image (which is a section) has a filename. Move this implementation to the entry_Section class so that any section can have a filename. With this, the section data is written to a file. This allows parts of an image to be written, along with the entire image. Make a note that this can be used to include the contents of a section in one image in another (later) image. Signed-off-by: Simon Glass --- tools/binman/ftest.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tools/binman/ftest.py') diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 62ee86b9b7..c3cb32dca2 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6077,5 +6077,19 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'Cannot write symbols to an ELF file without Python elftools', str(exc.exception)) + def testSectionFilename(self): + """Check writing of section contents to a file""" + data = self._DoReadFile('261_section_fname.dts') + expected = (b'&&' + U_BOOT_DATA + b'&&&' + + tools.get_bytes(ord('!'), 7) + + U_BOOT_DATA + tools.get_bytes(ord('&'), 12)) + self.assertEqual(expected, data) + + sect_fname = tools.get_output_filename('outfile.bin') + self.assertTrue(os.path.exists(sect_fname)) + sect_data = tools.read_file(sect_fname) + self.assertEqual(U_BOOT_DATA, sect_data) + + if __name__ == "__main__": unittest.main() -- cgit v1.2.3