From c9921182ab4b1f83e3e5c671446dca5ffdf45b90 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 10 Aug 2020 16:20:51 +0200 Subject: [PATCH] chipset: update helper scripts to python3 --- chipset/cc256x/convert_bts_init_scripts.py | 2 +- chipset/csr/convert_psr.py | 4 ++-- chipset/da14581/convert_hex_files.py | 11 ++++++----- chipset/em9301/convert_emp.py | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/chipset/cc256x/convert_bts_init_scripts.py b/chipset/cc256x/convert_bts_init_scripts.py index 245532632..b1038a21f 100755 --- a/chipset/cc256x/convert_bts_init_scripts.py +++ b/chipset/cc256x/convert_bts_init_scripts.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # BlueKitchen GmbH (c) 2012-2014 # documentation for TI Vendor Specific commands: diff --git a/chipset/csr/convert_psr.py b/chipset/csr/convert_psr.py index e648d4f81..21317cd77 100755 --- a/chipset/csr/convert_psr.py +++ b/chipset/csr/convert_psr.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # BlueKitchen GmbH (c) 2019 import sys @@ -66,7 +66,7 @@ if len(sys.argv) != 2: prs_file = sys.argv[1] fout = sys.stdout -with open (prs_file, 'rb') as fin: +with open (prs_file, 'rt') as fin: for line_with_nl in fin: line = line_with_nl.strip() if line.startswith('&'): diff --git a/chipset/da14581/convert_hex_files.py b/chipset/da14581/convert_hex_files.py index 2d718e32d..f036198fc 100755 --- a/chipset/da14581/convert_hex_files.py +++ b/chipset/da14581/convert_hex_files.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # BlueKitchen GmbH (c) 2012-2014 # avr-objcopy -I ihex -O binary hci_581_active_uart.hex hci_581_active_uart.bin @@ -8,6 +8,7 @@ from intelhex import IntelHex import glob +import sys usage = '''This script converts the HCI Firmware in .hex format for Dialog Semiconductor into C files to be used with BTstack. @@ -49,14 +50,14 @@ const uint32_t da14581_fw_size = sizeof(da14581_fw_data); def convert_hex(basename): hex_name = basename + '.hex' - print ('Reading %s' % hex_name) + print('Reading %s' % hex_name) ih = IntelHex(hex_name) # f = open(basename + '.txt', 'w') # open file for writing # ih.dump(f) # dump to file object # f.close() # close file size = ih.maxaddr() - ih.minaddr() + 1 - print '- Start: %x' % ih.minaddr() - print '- End: %x' % ih.maxaddr() + print('- Start: %x' % ih.minaddr()) + print('- End: %x' % ih.maxaddr()) with open(basename + '.h', 'w') as fout: fout.write(header.replace('BASENAME',basename)); @@ -66,7 +67,7 @@ def convert_hex(basename): fout.write(' ') for i in range(0,size): if i % 1000 == 0: - print ('- Write %05u/%05u' % (i, size)) + print('- Write %05u/%05u' % (i, size)) byte = ih[ih.minaddr() + i] fout.write("0x{0:02x}, ".format(byte)) if (i & 0x0f) == 0x0f: diff --git a/chipset/em9301/convert_emp.py b/chipset/em9301/convert_emp.py index 2dbe403f2..ee9c181ed 100755 --- a/chipset/em9301/convert_emp.py +++ b/chipset/em9301/convert_emp.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # BlueKitchen GmbH (c) 2018 import sys @@ -70,7 +70,7 @@ def convert_emp(basename): for i in range(0,size): if i % 1000 == 0: print ('- Write %05u/%05u' % (i, size)) - byte = ord(firm[i]) + byte = firm[i] fout.write("0x{0:02x}, ".format(byte)) if (i & 0x0f) == 0x0f: fout.write('\n ')