Skip to content

Commit 19a5f33

Browse files
committed
Python 3 fixes for scripts.
1 parent a1ae404 commit 19a5f33

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

tools/flash_algo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
"""
33
mbed
4-
Copyright (c) 2017-2017 ARM Limited
4+
Copyright (c) 2017-2019 ARM Limited
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222
import binascii
2323
import argparse
2424
import logging
25-
import StringIO
25+
from six.moves import StringIO
2626
import jinja2
2727
from collections import namedtuple
2828
from itertools import count

tools/post_build_script.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
CHECKSUM_FMT = "<1I"
3333
CHECKSUM_OFFSET = 0x1C
3434
TARGET_INFO_OFFSET = 13*4
35-
ALLIGN_PADS = 4
35+
ALIGN_PADS = 4
3636

3737
def ranges(i):
3838
for _, b in itertools.groupby(enumerate(i), lambda x_y: x_y[1] - x_y[0]):
@@ -115,13 +115,13 @@ def post_build_script(input_file, output_file, board_id=None, family_id=None, bi
115115
blob_header = (0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2)
116116
stack_size = 0x200
117117
region_info_fmt = '5I'
118-
region_info_total = 10
118+
region_info_total = 10
119119
target_cfg_fmt = '3I'+ region_info_fmt*region_info_total*2 + 'IHBB'
120120
sector_info_fmt = '2I'
121121
sector_info_len = len(pack_flash_algo.sector_sizes)
122122
program_target_fmt = '14I'
123123
flash_blob_entry = int(flash_blob_entry, 16)
124-
blob_pad_size = ((len(pack_flash_algo.algo_data) + ALLIGN_PADS -1) // ALLIGN_PADS * ALLIGN_PADS) - len(pack_flash_algo.algo_data)
124+
blob_pad_size = ((len(pack_flash_algo.algo_data) + ALIGN_PADS -1) // ALIGN_PADS * ALIGN_PADS) - len(pack_flash_algo.algo_data)
125125
blob_header_size = len(blob_header) * 4
126126
total_struct_size = blob_header_size + len(pack_flash_algo.algo_data) + blob_pad_size + sector_info_len*struct.calcsize(sector_info_fmt) + struct.calcsize(program_target_fmt) + struct.calcsize(target_cfg_fmt)
127127
flash_blob_addr = end + 1 - 4 - total_struct_size #make room for crc
@@ -141,10 +141,10 @@ def post_build_script(input_file, output_file, board_id=None, family_id=None, bi
141141
new_hex_file.puts(program_target_addr,struct.pack('<' + program_target_fmt,
142142
pack_flash_algo.symbols['Init'] + blob_header_size + flash_blob_entry,
143143
pack_flash_algo.symbols['UnInit'] + blob_header_size + flash_blob_entry,
144-
pack_flash_algo.symbols['EraseChip'] + blob_header_size + flash_blob_entry if pack_flash_algo.symbols['EraseChip'] != 0xffffffffL else 0,
144+
pack_flash_algo.symbols['EraseChip'] + blob_header_size + flash_blob_entry if pack_flash_algo.symbols['EraseChip'] != 0xffffffff else 0,
145145
pack_flash_algo.symbols['EraseSector'] + blob_header_size + flash_blob_entry,
146146
pack_flash_algo.symbols['ProgramPage'] + blob_header_size + flash_blob_entry,
147-
pack_flash_algo.symbols['Verify'] + blob_header_size + flash_blob_entry if pack_flash_algo.symbols['Verify'] != 0xffffffffL else 0,
147+
pack_flash_algo.symbols['Verify'] + blob_header_size + flash_blob_entry if pack_flash_algo.symbols['Verify'] != 0xffffffff else 0,
148148
flash_blob_entry + 1, #BKPT : start of blob + 1
149149
flash_blob_entry + blob_header_size + pack_flash_algo.rw_start, #RSB : blob start + header + rw data offset
150150
stack_pointer, #RSP : stack pointer
@@ -170,7 +170,7 @@ def post_build_script(input_file, output_file, board_id=None, family_id=None, bi
170170
sector_info_len, #Sector start and length list total
171171
*regions_flags
172172
))
173-
board_info_flag = 1 if pack_flash_algo.symbols['EraseSector'] != 0xffffffffL else 0 #kEnablePageErase
173+
board_info_flag = 1 if pack_flash_algo.symbols['EraseSector'] != 0xffffffff else 0 #kEnablePageErase
174174
new_hex_file.puts(target_addr_unpack + 12,struct.pack('<1I', board_info_flag)) #always enable page erase EraseSector is a required symbol in flash algo
175175
new_hex_file.puts(target_addr_unpack + 16,struct.pack('<1I', target_cfg_addr))
176176

tools/pre_build_script.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
# DAPLink Interface Firmware
3-
# Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
3+
# Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
44
# SPDX-License-Identifier: Apache-2.0
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -16,6 +16,9 @@
1616
# limitations under the License.
1717
#
1818

19+
from __future__ import absolute_import
20+
from __future__ import print_function
21+
1922
import sys
2023
import os
2124
import argparse

0 commit comments

Comments
 (0)