soc/tools/litex_term: replace get_file_data with f.read()

This commit is contained in:
Florent Kermarrec 2016-02-18 23:55:41 +01:00
parent 68c2d3b7a0
commit 5b8566d20f
1 changed files with 3 additions and 13 deletions

View File

@ -122,17 +122,6 @@ class SFLFrame:
self.raw.append(d) self.raw.append(d)
def get_file_data(filename):
with open(filename, "rb") as f:
data = []
while True:
w = f.read(1)
if not w:
break
data.append(int.from_bytes(w, "big"))
return data
class LiteXTerm: class LiteXTerm:
def __init__(self, kernel_image, kernel_address): def __init__(self, kernel_image, kernel_address):
self.kernel_image = kernel_image self.kernel_image = kernel_image
@ -183,13 +172,14 @@ class LiteXTerm:
return 1 return 1
def upload(self, filename, address): def upload(self, filename, address):
data = get_file_data(filename) with open(filename, "rb") as f:
data = f.read()
print("[TERM] Uploading {} ({} bytes)...".format(filename, len(data))) print("[TERM] Uploading {} ({} bytes)...".format(filename, len(data)))
current_address = address current_address = address
position = 0 position = 0
length = len(data) length = len(data)
start = time.time() start = time.time()
while len(data) != 0: while len(data):
print("{}%\r".format(100*position//length), end="") print("{}%\r".format(100*position//length), end="")
frame = SFLFrame() frame = SFLFrame()
frame_data = data[:251] frame_data = data[:251]