scripts: use python's hex() in ta_bin_to_c.py
- Python has a built in function to turn a byte into its respective hex
value that can be used instead of string formatting the values
directly.
- Using the built in function instead of the previous string formatting
method fixed an issue where bytes were failing to be written when
we used an archaic yocto bsp from broadcom.
- The built in function also has the benefit of being easier to read and
understand.
Signed-off-by: Dhananjay Phadke <dphadke@linux.microsoft.com>
Signed-off-by: Andrew Mustea <andrew.mustea@microsoft.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/scripts/bin_to_c.py b/scripts/bin_to_c.py
index d35cc68..8ac6d30 100755
--- a/scripts/bin_to_c.py
+++ b/scripts/bin_to_c.py
@@ -60,7 +60,7 @@
if args.text and i != size - 1 and bytes[i] == b'\0':
print('Error: null byte encountered in text file')
sys.exit(1)
- f.write('0x' + '{:02x}'.format(bytes[i]) + ',')
+ f.write(hex(bytes[i]) + ',')
i = i + 1
if i % 8 == 0 or i == size:
f.write('\n')