Merge tag 'u-boot-rockchip-20200501' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / tools / binman / etype / text.py
index 9ee04d7..3577135 100644 (file)
@@ -5,9 +5,9 @@
 
 from collections import OrderedDict
 
-from entry import Entry, EntryArg
-import fdt_util
-import tools
+from binman.entry import Entry, EntryArg
+from dtoc import fdt_util
+from patman import tools
 
 
 class Entry_text(Entry):
@@ -22,6 +22,8 @@ class Entry_text(Entry):
             that contains the string to place in the entry
         <xxx> (actual name is the value of text-label): contains the string to
             place in the entry.
+        <text>: The text to place in the entry (overrides the above mechanism).
+            This is useful when the text is constant.
 
     Example node:
 
@@ -44,15 +46,28 @@ class Entry_text(Entry):
             message = "a message directly in the node"
         };
 
+    or just:
+
+        text {
+            size = <8>;
+            text = "some text 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)
-        label, = self.GetEntryArgsOrProps([EntryArg('text-label', str)])
-        self.text_label = tools.ToStr(label) if type(label) != str else label
-        value, = self.GetEntryArgsOrProps([EntryArg(self.text_label, str)])
-        value = tools.ToBytes(value) if value is not None else value
+        value = fdt_util.GetString(self._node, 'text')
+        if value:
+            value = tools.ToBytes(value)
+        else:
+            label, = self.GetEntryArgsOrProps([EntryArg('text-label', str)])
+            self.text_label = label
+            if self.text_label:
+                value, = self.GetEntryArgsOrProps([EntryArg(self.text_label,
+                                                            str)])
+                value = tools.ToBytes(value) if value is not None else value
         self.value = value
 
     def ObtainContents(self):