mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-08-20 08:58:52 +09:00
![Simon Glass](/assets/img/avatar_default.png)
Sometimes it is useful to pass binman the value of an entry property from the command line. For example some entries need access to files and it is not always convenient to put these filenames in the image definition (device tree). Add a -a option which can be used like this: -a<prop>=<value> where <prop> is the property to set <value> is the value to set it to Signed-off-by: Simon Glass <sjg@chromium.org>
72 lines
2.7 KiB
Python
72 lines
2.7 KiB
Python
# SPDX-License-Identifier: GPL-2.0+
|
|
# Copyright (c) 2016 Google, Inc
|
|
# Written by Simon Glass <sjg@chromium.org>
|
|
#
|
|
# Entry-type module for testing purposes. Not used in real images.
|
|
#
|
|
|
|
from collections import OrderedDict
|
|
|
|
from entry import Entry, EntryArg
|
|
import fdt_util
|
|
import tools
|
|
|
|
|
|
class Entry__testing(Entry):
|
|
"""A fake entry used for testing
|
|
|
|
Properties:
|
|
return_invalid_entry: Return an invalid entry from GetOffsets()
|
|
"""
|
|
def __init__(self, section, etype, node):
|
|
Entry.__init__(self, section, etype, node)
|
|
self.return_invalid_entry = fdt_util.GetBool(self._node,
|
|
'return-invalid-entry')
|
|
self.return_unknown_contents = fdt_util.GetBool(self._node,
|
|
'return-unknown-contents')
|
|
self.bad_update_contents = fdt_util.GetBool(self._node,
|
|
'bad-update-contents')
|
|
self.process_fdt_ready = False
|
|
self.never_complete_process_fdt = fdt_util.GetBool(self._node,
|
|
'never-complete-process-fdt')
|
|
self.require_args = fdt_util.GetBool(self._node, 'require-args')
|
|
|
|
# This should be picked up by GetEntryArgsOrProps()
|
|
self.test_existing_prop = 'existing'
|
|
self.force_bad_datatype = fdt_util.GetBool(self._node,
|
|
'force-bad-datatype')
|
|
(self.test_str_fdt, self.test_str_arg, self.test_int_fdt,
|
|
self.test_int_arg, existing) = self.GetEntryArgsOrProps([
|
|
EntryArg('test-str-fdt', str),
|
|
EntryArg('test-str-arg', str),
|
|
EntryArg('test-int-fdt', int),
|
|
EntryArg('test-int-arg', int),
|
|
EntryArg('test-existing-prop', str)], self.require_args)
|
|
if self.force_bad_datatype:
|
|
self.GetEntryArgsOrProps([EntryArg('test-bad-datatype-arg', bool)])
|
|
|
|
def ObtainContents(self):
|
|
if self.return_unknown_contents:
|
|
return False
|
|
self.data = 'a'
|
|
self.contents_size = len(self.data)
|
|
return True
|
|
|
|
def GetOffsets(self):
|
|
if self.return_invalid_entry :
|
|
return {'invalid-entry': [1, 2]}
|
|
return {}
|
|
|
|
def ProcessContents(self):
|
|
if self.bad_update_contents:
|
|
# Request to update the conents with something larger, to cause a
|
|
# failure.
|
|
self.ProcessContentsUpdate('aa')
|
|
|
|
def ProcessFdt(self, fdt):
|
|
"""Force reprocessing the first time"""
|
|
ready = self.process_fdt_ready
|
|
if not self.never_complete_process_fdt:
|
|
self.process_fdt_ready = True
|
|
return ready
|