mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-20 22:21:41 +00:00
binman: Add support for calling mkimage
As a first step to integrating mkimage into binman, add a new entry type that feeds data into mkimage for processing and incorporates that output into the image. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
ce774e94de
commit
3e8fba4cd4
5 changed files with 120 additions and 0 deletions
|
@ -587,6 +587,29 @@ See README.x86 for information about Intel binary blobs.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Entry: mkimage: Entry containing a binary produced by mkimage
|
||||||
|
-------------------------------------------------------------
|
||||||
|
|
||||||
|
Properties / Entry arguments:
|
||||||
|
- datafile: Filename for -d argument
|
||||||
|
- args: Other arguments to pass
|
||||||
|
|
||||||
|
The data passed to mkimage is collected from subnodes of the mkimage node,
|
||||||
|
e.g.:
|
||||||
|
|
||||||
|
mkimage {
|
||||||
|
args = "-n test -T imximage";
|
||||||
|
|
||||||
|
u-boot-spl {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
This calls mkimage to create an imximage with u-boot-spl.bin as the input
|
||||||
|
file. The output from mkimage then becomes part of the image produced by
|
||||||
|
binman.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Entry: powerpc-mpc85xx-bootpg-resetvec: PowerPC mpc85xx bootpg + resetvec code for U-Boot
|
Entry: powerpc-mpc85xx-bootpg-resetvec: PowerPC mpc85xx bootpg + resetvec code for U-Boot
|
||||||
-----------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@ class Entry__testing(Entry):
|
||||||
'return-contents-once')
|
'return-contents-once')
|
||||||
self.bad_update_contents_twice = fdt_util.GetBool(self._node,
|
self.bad_update_contents_twice = fdt_util.GetBool(self._node,
|
||||||
'bad-update-contents-twice')
|
'bad-update-contents-twice')
|
||||||
|
self.return_contents_later = fdt_util.GetBool(self._node,
|
||||||
|
'return-contents-later')
|
||||||
|
|
||||||
# Set to True when the entry is ready to process the FDT.
|
# Set to True when the entry is ready to process the FDT.
|
||||||
self.process_fdt_ready = False
|
self.process_fdt_ready = False
|
||||||
|
@ -83,6 +85,9 @@ class Entry__testing(Entry):
|
||||||
def ObtainContents(self):
|
def ObtainContents(self):
|
||||||
if self.return_unknown_contents or not self.return_contents:
|
if self.return_unknown_contents or not self.return_contents:
|
||||||
return False
|
return False
|
||||||
|
if self.return_contents_later:
|
||||||
|
self.return_contents_later = False
|
||||||
|
return False
|
||||||
self.data = self.contents
|
self.data = self.contents
|
||||||
self.contents_size = len(self.data)
|
self.contents_size = len(self.data)
|
||||||
if self.return_contents_once:
|
if self.return_contents_once:
|
||||||
|
|
62
tools/binman/etype/mkimage.py
Normal file
62
tools/binman/etype/mkimage.py
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
# SPDX-License-Identifier: GPL-2.0+
|
||||||
|
# Copyright (c) 2016 Google, Inc
|
||||||
|
# Written by Simon Glass <sjg@chromium.org>
|
||||||
|
#
|
||||||
|
# Entry-type module for producing an image using mkimage
|
||||||
|
#
|
||||||
|
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
from binman.entry import Entry
|
||||||
|
from dtoc import fdt_util
|
||||||
|
from patman import tools
|
||||||
|
|
||||||
|
class Entry_mkimage(Entry):
|
||||||
|
"""Entry containing a binary produced by mkimage
|
||||||
|
|
||||||
|
Properties / Entry arguments:
|
||||||
|
- datafile: Filename for -d argument
|
||||||
|
- args: Other arguments to pass
|
||||||
|
|
||||||
|
The data passed to mkimage is collected from subnodes of the mkimage node,
|
||||||
|
e.g.:
|
||||||
|
|
||||||
|
mkimage {
|
||||||
|
args = "-n test -T imximage";
|
||||||
|
|
||||||
|
u-boot-spl {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
This calls mkimage to create an imximage with u-boot-spl.bin as the input
|
||||||
|
file. The output from mkimage then becomes part of the image produced by
|
||||||
|
binman.
|
||||||
|
"""
|
||||||
|
def __init__(self, section, etype, node):
|
||||||
|
Entry.__init__(self, section, etype, node)
|
||||||
|
self._args = fdt_util.GetString(self._node, 'args').split(' ')
|
||||||
|
self._mkimage_entries = OrderedDict()
|
||||||
|
self._ReadSubnodes()
|
||||||
|
|
||||||
|
def ObtainContents(self):
|
||||||
|
data = b''
|
||||||
|
for entry in self._mkimage_entries.values():
|
||||||
|
# First get the input data and put it in a file. If not available,
|
||||||
|
# try later.
|
||||||
|
if not entry.ObtainContents():
|
||||||
|
return False
|
||||||
|
data += entry.GetData()
|
||||||
|
uniq = self.GetUniqueName()
|
||||||
|
input_fname = tools.GetOutputFilename('mkimage.%s' % uniq)
|
||||||
|
tools.WriteFile(input_fname, data)
|
||||||
|
output_fname = tools.GetOutputFilename('mkimage-out.%s' % uniq)
|
||||||
|
tools.Run('mkimage', '-d', input_fname, *self._args, output_fname)
|
||||||
|
self.SetContents(tools.ReadFile(output_fname))
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _ReadSubnodes(self):
|
||||||
|
"""Read the subnodes to find out what should go in this image"""
|
||||||
|
for node in self._node.subnodes:
|
||||||
|
entry = Entry.Create(self, node)
|
||||||
|
entry.ReadNode()
|
||||||
|
self._mkimage_entries[entry.name] = entry
|
|
@ -3357,6 +3357,13 @@ class TestFunctional(unittest.TestCase):
|
||||||
data = self._DoReadFile('154_intel_fsp_t.dts')
|
data = self._DoReadFile('154_intel_fsp_t.dts')
|
||||||
self.assertEqual(FSP_T_DATA, data[:len(FSP_T_DATA)])
|
self.assertEqual(FSP_T_DATA, data[:len(FSP_T_DATA)])
|
||||||
|
|
||||||
|
def testMkimage(self):
|
||||||
|
"""Test using mkimage to build an image"""
|
||||||
|
data = self._DoReadFile('156_mkimage.dts')
|
||||||
|
|
||||||
|
# Just check that the data appears in the file somewhere
|
||||||
|
self.assertIn(U_BOOT_SPL_DATA, data)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
23
tools/binman/test/156_mkimage.dts
Normal file
23
tools/binman/test/156_mkimage.dts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
|
/ {
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
|
||||||
|
binman {
|
||||||
|
size = <0x80>;
|
||||||
|
|
||||||
|
mkimage {
|
||||||
|
args = "-n test -T script";
|
||||||
|
|
||||||
|
u-boot-spl {
|
||||||
|
};
|
||||||
|
|
||||||
|
_testing {
|
||||||
|
return-contents-later;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
Loading…
Add table
Reference in a new issue