summaryrefslogtreecommitdiff
path: root/tools/binman/etype/text.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-07-17 22:25:33 +0300
committerSimon Glass <sjg@chromium.org>2018-08-02 01:30:47 +0300
commitbb74837c9a32e51187d843c2469f0176d674c5f9 (patch)
treeb7597444221cb13594090527ff54ee5f0dad8d12 /tools/binman/etype/text.py
parent53af22a9958ca93c89056ad2750ad0d46a51b6c8 (diff)
downloadu-boot-bb74837c9a32e51187d843c2469f0176d674c5f9.tar.xz
binman: Support an entry that holds text
It is useful to able to write an identifying string to the image within an entry. Add a 'text' entry type to handle this. The actual text is typically passed to binman on the command line. The text is not itself nul-terminated but this can be achieved if required by setting the size of the entry to something larger than the text. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/etype/text.py')
-rw-r--r--tools/binman/etype/text.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tools/binman/etype/text.py b/tools/binman/etype/text.py
new file mode 100644
index 0000000000..1c69afa72e
--- /dev/null
+++ b/tools/binman/etype/text.py
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass <sjg@chromium.org>
+#
+
+from collections import OrderedDict
+
+from entry import Entry, EntryArg
+import fdt_util
+
+
+class Entry_text(Entry):
+ """An entry which contains text
+
+ The text can be provided either in the node itself or by a command-line
+ argument.
+
+ Example node:
+
+ text {
+ size = <50>;
+ text-label = "message";
+ };
+
+ You can then use:
+
+ binman -amessage="this is my message"
+
+ and binman will insert that string into the entry.
+
+ It is also possible to put the string directly in the node:
+
+ text {
+ size = <8>;
+ text-label = "message";
+ message = "a message directly in the node"
+ };
+
+ The text is not itself nul-terminated. This can be achieved, if required,
+ by setting the size of the entry to something larger than the text.
+ """
+ def __init__(self, section, etype, node):
+ Entry.__init__(self, section, etype, node)
+ self.text_label, = self.GetEntryArgsOrProps(
+ [EntryArg('text-label', str)])
+ self.value, = self.GetEntryArgsOrProps([EntryArg(self.text_label, str)])
+
+ def ObtainContents(self):
+ self.SetContents(self.value)
+ return True