diff options
author | Simon Glass <sjg@chromium.org> | 2020-10-03 11:31:27 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-10-29 14:42:17 -0600 |
commit | e144cafe43c8298bd41c044329857c3068cd845b (patch) | |
tree | 0c671dc9826b0ca6569294c438597fcc89f78039 /tools/dtoc/fdt.py | |
parent | abb9cd30b23858125ce015c1dffdae4d7895bae8 (diff) | |
download | u-boot-e144cafe43c8298bd41c044329857c3068cd845b.zip u-boot-e144cafe43c8298bd41c044329857c3068cd845b.tar.gz u-boot-e144cafe43c8298bd41c044329857c3068cd845b.tar.bz2 |
dtoc: Fix widening of int to bytes
At present an integer is converted to bytes incorrectly. The whole 32-bit
integer is inserted as the first element of the byte array, and the other
three bytes are skipped. This was not noticed because the unit test did
not check it, and the functional test was checking for wrong values.
Update the code to handle this as a special case. Add one more test to
cover all code paths.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/fdt.py')
-rw-r--r-- | tools/dtoc/fdt.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index d058c59..03b8677 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -129,6 +129,15 @@ class Prop: specific. """ if newprop.type < self.type: + # Special handling to convert an int into bytes + if self.type == TYPE_INT and newprop.type == TYPE_BYTE: + if type(self.value) == list: + new_value = [] + for val in self.value: + new_value += [tools.ToChar(by) for by in val] + else: + new_value = [tools.ToChar(by) for by in self.value] + self.value = new_value self.type = newprop.type if type(newprop.value) == list and type(self.value) != list: |