mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-07-06 06:21:51 +00:00
binman: Allow use of help and entry-docs without libfdt
At present if libfdt is not available binman can't do anything much. Improve the situation a little. Ideally there should be a test to cover this, but I'm not quite sure how to fake this. Signed-off-by: Simon Glass <sjg@chromium.org> (fixed up missing ReadChildData() enty test)
This commit is contained in:
parent
b986b3bb19
commit
8dbb7444eb
9 changed files with 44 additions and 13 deletions
|
@ -15,8 +15,6 @@ import tools
|
||||||
import cbfs_util
|
import cbfs_util
|
||||||
import command
|
import command
|
||||||
import elf
|
import elf
|
||||||
from image import Image
|
|
||||||
import state
|
|
||||||
import tout
|
import tout
|
||||||
|
|
||||||
# List of images we plan to create
|
# List of images we plan to create
|
||||||
|
@ -113,6 +111,9 @@ def ReadEntry(image_fname, entry_path, decomp=True):
|
||||||
Returns:
|
Returns:
|
||||||
data extracted from the entry
|
data extracted from the entry
|
||||||
"""
|
"""
|
||||||
|
global Image
|
||||||
|
from image import Image
|
||||||
|
|
||||||
image = Image.FromFile(image_fname)
|
image = Image.FromFile(image_fname)
|
||||||
entry = image.FindEntryPath(entry_path)
|
entry = image.FindEntryPath(entry_path)
|
||||||
return entry.ReadData(decomp)
|
return entry.ReadData(decomp)
|
||||||
|
@ -459,6 +460,9 @@ def Binman(args):
|
||||||
Args:
|
Args:
|
||||||
args: Command line arguments Namespace object
|
args: Command line arguments Namespace object
|
||||||
"""
|
"""
|
||||||
|
global Image
|
||||||
|
global state
|
||||||
|
|
||||||
if args.full_help:
|
if args.full_help:
|
||||||
pager = os.getenv('PAGER')
|
pager = os.getenv('PAGER')
|
||||||
if not pager:
|
if not pager:
|
||||||
|
@ -468,6 +472,10 @@ def Binman(args):
|
||||||
command.Run(pager, fname)
|
command.Run(pager, fname)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
# Put these here so that we can import this module without libfdt
|
||||||
|
from image import Image
|
||||||
|
import state
|
||||||
|
|
||||||
if args.cmd in ['ls', 'extract', 'replace']:
|
if args.cmd in ['ls', 'extract', 'replace']:
|
||||||
try:
|
try:
|
||||||
tout.Init(args.verbosity)
|
tout.Init(args.verbosity)
|
||||||
|
|
|
@ -21,7 +21,6 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import fdt_util
|
import fdt_util
|
||||||
import state
|
|
||||||
import tools
|
import tools
|
||||||
from tools import ToHex, ToHexSize
|
from tools import ToHex, ToHexSize
|
||||||
import tout
|
import tout
|
||||||
|
@ -71,6 +70,10 @@ class Entry(object):
|
||||||
orig_size: Original size value read from node
|
orig_size: Original size value read from node
|
||||||
"""
|
"""
|
||||||
def __init__(self, section, etype, node, name_prefix=''):
|
def __init__(self, section, etype, node, name_prefix=''):
|
||||||
|
# Put this here to allow entry-docs and help to work without libfdt
|
||||||
|
global state
|
||||||
|
import state
|
||||||
|
|
||||||
self.section = section
|
self.section = section
|
||||||
self.etype = etype
|
self.etype = etype
|
||||||
self._node = node
|
self._node = node
|
||||||
|
|
|
@ -97,6 +97,11 @@ class TestEntry(unittest.TestCase):
|
||||||
base = entry.Entry.Create(None, self.GetNode(), 'blob-dtb')
|
base = entry.Entry.Create(None, self.GetNode(), 'blob-dtb')
|
||||||
self.assertTrue(base.WriteChildData(base))
|
self.assertTrue(base.WriteChildData(base))
|
||||||
|
|
||||||
|
def testReadChildData(self):
|
||||||
|
"""Test the ReadChildData() method of the base class"""
|
||||||
|
base = entry.Entry.Create(None, self.GetNode(), 'blob-dtb')
|
||||||
|
self.assertIsNone(base.ReadChildData(base))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
from entry import Entry
|
from entry import Entry
|
||||||
import fdt_util
|
import fdt_util
|
||||||
import state
|
|
||||||
import tools
|
import tools
|
||||||
import tout
|
import tout
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
# Entry-type module for U-Boot device tree files
|
# Entry-type module for U-Boot device tree files
|
||||||
#
|
#
|
||||||
|
|
||||||
import state
|
|
||||||
|
|
||||||
from entry import Entry
|
from entry import Entry
|
||||||
from blob import Entry_blob
|
from blob import Entry_blob
|
||||||
|
|
||||||
|
@ -18,6 +16,10 @@ class Entry_blob_dtb(Entry_blob):
|
||||||
'state' module.
|
'state' module.
|
||||||
"""
|
"""
|
||||||
def __init__(self, section, etype, node):
|
def __init__(self, section, etype, node):
|
||||||
|
# Put this here to allow entry-docs and help to work without libfdt
|
||||||
|
global state
|
||||||
|
import state
|
||||||
|
|
||||||
Entry_blob.__init__(self, section, etype, node)
|
Entry_blob.__init__(self, section, etype, node)
|
||||||
|
|
||||||
def ObtainContents(self):
|
def ObtainContents(self):
|
||||||
|
|
|
@ -11,7 +11,6 @@ import cbfs_util
|
||||||
from cbfs_util import CbfsWriter
|
from cbfs_util import CbfsWriter
|
||||||
from entry import Entry
|
from entry import Entry
|
||||||
import fdt_util
|
import fdt_util
|
||||||
import state
|
|
||||||
|
|
||||||
class Entry_cbfs(Entry):
|
class Entry_cbfs(Entry):
|
||||||
"""Entry containing a Coreboot Filesystem (CBFS)
|
"""Entry containing a Coreboot Filesystem (CBFS)
|
||||||
|
@ -164,6 +163,10 @@ class Entry_cbfs(Entry):
|
||||||
both of size 1MB.
|
both of size 1MB.
|
||||||
"""
|
"""
|
||||||
def __init__(self, section, etype, node):
|
def __init__(self, section, etype, node):
|
||||||
|
# Put this here to allow entry-docs and help to work without libfdt
|
||||||
|
global state
|
||||||
|
import state
|
||||||
|
|
||||||
Entry.__init__(self, section, etype, node)
|
Entry.__init__(self, section, etype, node)
|
||||||
self._cbfs_arg = fdt_util.GetString(node, 'cbfs-arch', 'x86')
|
self._cbfs_arg = fdt_util.GetString(node, 'cbfs-arch', 'x86')
|
||||||
self._cbfs_entries = OrderedDict()
|
self._cbfs_entries = OrderedDict()
|
||||||
|
|
|
@ -8,11 +8,7 @@ This handles putting an FDT into the image with just the information about the
|
||||||
image.
|
image.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import libfdt
|
|
||||||
|
|
||||||
from entry import Entry
|
from entry import Entry
|
||||||
from fdt import Fdt
|
|
||||||
import state
|
|
||||||
import tools
|
import tools
|
||||||
import tout
|
import tout
|
||||||
|
|
||||||
|
@ -80,6 +76,15 @@ class Entry_fdtmap(Entry):
|
||||||
added as necessary. See the binman README.
|
added as necessary. See the binman README.
|
||||||
"""
|
"""
|
||||||
def __init__(self, section, etype, node):
|
def __init__(self, section, etype, node):
|
||||||
|
# Put these here to allow entry-docs and help to work without libfdt
|
||||||
|
global libfdt
|
||||||
|
global state
|
||||||
|
global Fdt
|
||||||
|
|
||||||
|
import libfdt
|
||||||
|
import state
|
||||||
|
from fdt import Fdt
|
||||||
|
|
||||||
Entry.__init__(self, section, etype, node)
|
Entry.__init__(self, section, etype, node)
|
||||||
|
|
||||||
def _GetFdtmap(self):
|
def _GetFdtmap(self):
|
||||||
|
|
|
@ -11,7 +11,6 @@ import os
|
||||||
|
|
||||||
from section import Entry_section
|
from section import Entry_section
|
||||||
import fdt_util
|
import fdt_util
|
||||||
import state
|
|
||||||
import tools
|
import tools
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +28,10 @@ class Entry_files(Entry_section):
|
||||||
at run-time so you can obtain the file positions.
|
at run-time so you can obtain the file positions.
|
||||||
"""
|
"""
|
||||||
def __init__(self, section, etype, node):
|
def __init__(self, section, etype, node):
|
||||||
|
# Put this here to allow entry-docs and help to work without libfdt
|
||||||
|
global state
|
||||||
|
import state
|
||||||
|
|
||||||
Entry_section.__init__(self, section, etype, node)
|
Entry_section.__init__(self, section, etype, node)
|
||||||
self._pattern = fdt_util.GetString(self._node, 'pattern')
|
self._pattern = fdt_util.GetString(self._node, 'pattern')
|
||||||
if not self._pattern:
|
if not self._pattern:
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
from entry import Entry
|
from entry import Entry
|
||||||
from blob_dtb import Entry_blob_dtb
|
from blob_dtb import Entry_blob_dtb
|
||||||
import state
|
|
||||||
import tools
|
import tools
|
||||||
|
|
||||||
class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb):
|
class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb):
|
||||||
|
@ -25,6 +24,10 @@ class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb):
|
||||||
it available to u_boot_ucode.
|
it available to u_boot_ucode.
|
||||||
"""
|
"""
|
||||||
def __init__(self, section, etype, node):
|
def __init__(self, section, etype, node):
|
||||||
|
# Put this here to allow entry-docs and help to work without libfdt
|
||||||
|
global state
|
||||||
|
import state
|
||||||
|
|
||||||
Entry_blob_dtb.__init__(self, section, etype, node)
|
Entry_blob_dtb.__init__(self, section, etype, node)
|
||||||
self.ucode_data = b''
|
self.ucode_data = b''
|
||||||
self.collate = False
|
self.collate = False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue