From 80291131a8c461a8c89acd9d6e44d9c1c9ea4bab Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 13 Dec 2018 17:22:17 +0100 Subject: [PATCH] flash/loader: fix python3 compatibility issue with hex files --- pyocd/flash/loader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyocd/flash/loader.py b/pyocd/flash/loader.py index a8eab0097..a000b04ef 100755 --- a/pyocd/flash/loader.py +++ b/pyocd/flash/loader.py @@ -122,7 +122,11 @@ def program(self, file_or_path, format=None, **kwargs): try: # Open the file if a path was provided. if isPath: - file_obj = open(file_or_path, "rb") + mode = 'rb' + if format == 'hex': + # hex file must be read as plain text file + mode = 'r' + file_obj = open(file_or_path, mode) else: file_obj = file_or_path