"Das U-Boot" Source Tree

binman: Allow text directly in the node

At present text entries use an indirect method to specify the text to use,
with a label pointing to the text itself.

Allow the text to be directly written into the node. This is more
convenient in cases where the text is constant.

Signed-off-by: Simon Glass <sjg@chromium.org>

+34 -5
+9
tools/binman/README.entries
··· 312 312 that contains the string to place in the entry 313 313 <xxx> (actual name is the value of text-label): contains the string to 314 314 place in the entry. 315 + <text>: The text to place in the entry (overrides the above mechanism). 316 + This is useful when the text is constant. 315 317 316 318 Example node: 317 319 ··· 332 334 size = <8>; 333 335 text-label = "message"; 334 336 message = "a message directly in the node" 337 + }; 338 + 339 + or just: 340 + 341 + text { 342 + size = <8>; 343 + text = "some text directly in the node" 335 344 }; 336 345 337 346 The text is not itself nul-terminated. This can be achieved, if required,
+19 -4
tools/binman/etype/text.py
··· 22 22 that contains the string to place in the entry 23 23 <xxx> (actual name is the value of text-label): contains the string to 24 24 place in the entry. 25 + <text>: The text to place in the entry (overrides the above mechanism). 26 + This is useful when the text is constant. 25 27 26 28 Example node: 27 29 ··· 44 46 message = "a message directly in the node" 45 47 }; 46 48 49 + or just: 50 + 51 + text { 52 + size = <8>; 53 + text = "some text directly in the node" 54 + }; 55 + 47 56 The text is not itself nul-terminated. This can be achieved, if required, 48 57 by setting the size of the entry to something larger than the text. 49 58 """ 50 59 def __init__(self, section, etype, node): 51 60 Entry.__init__(self, section, etype, node) 52 - label, = self.GetEntryArgsOrProps([EntryArg('text-label', str)]) 53 - self.text_label = tools.ToStr(label) if type(label) != str else label 54 - value, = self.GetEntryArgsOrProps([EntryArg(self.text_label, str)]) 55 - value = tools.ToBytes(value) if value is not None else value 61 + value = fdt_util.GetString(self._node, 'text') 62 + if value: 63 + value = tools.ToBytes(value) 64 + else: 65 + label, = self.GetEntryArgsOrProps([EntryArg('text-label', str)]) 66 + self.text_label = label 67 + if self.text_label: 68 + value, = self.GetEntryArgsOrProps([EntryArg(self.text_label, 69 + str)]) 70 + value = tools.ToBytes(value) if value is not None else value 56 71 self.value = value 57 72 58 73 def ObtainContents(self):
+1 -1
tools/binman/ftest.py
··· 1286 1286 expected = (tools.ToBytes(TEXT_DATA) + 1287 1287 tools.GetBytes(0, 8 - len(TEXT_DATA)) + 1288 1288 tools.ToBytes(TEXT_DATA2) + tools.ToBytes(TEXT_DATA3) + 1289 - b'some text') 1289 + b'some text' + b'more text') 1290 1290 self.assertEqual(expected, data) 1291 1291 1292 1292 def testEntryDocs(self):
+5
tools/binman/test/066_text.dts
··· 24 24 text-label = "test-id4"; 25 25 test-id4 = "some text"; 26 26 }; 27 + /* Put text directly in the node */ 28 + text5 { 29 + type = "text"; 30 + text = "more text"; 31 + }; 27 32 }; 28 33 };