Skip to content

Commit bcf6af8

Browse files
authored
Merge pull request #22 from toniebox-reverse-engineering/develop
v1.2.2
2 parents e2c2810 + b1c5f83 commit bcf6af8

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ cc3200tool/logging
1414
cc3200tool/json
1515
test/
1616
.vscode/
17+
tmp/*

cc3200tool/cc.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ def __call__(self, string):
242242
help="local path to store the file contents in")
243243
parser_read_file.add_argument(
244244
"--file-id", type=auto_int, default=-1, help="if filename not available you can read a file by its id")
245+
parser_read_file.add_argument(
246+
"--inactive", action="store_true",
247+
help="read from inactive FAT copy")
245248

246249
parser_write_flash = subparsers.add_parser(
247250
"write_flash", help="Write a Gang image on the flash")
@@ -290,6 +293,9 @@ def __call__(self, string):
290293
parser_read_all_files.add_argument(
291294
"--all-by-file-id", action="store_true",
292295
help="Read all filenames by its id")
296+
parser_read_all_files.add_argument(
297+
"--inactive", action="store_true",
298+
help="read from inactive FAT copy")
293299

294300
parser_write_all_files = subparsers.add_parser(
295301
"write_all_files",
@@ -894,7 +900,7 @@ def _raw_read(self, offset, size, storage_id=STORAGE_ID_SRAM, sinfo=None):
894900
def _exec_from_ram(self):
895901
self._send_packet(OPCODE_EXEC_FROM_RAM)
896902

897-
def _get_file_info(self, filename, file_id=-1):
903+
def _get_file_info(self, filename, file_id=-1, inactive=False):
898904
if not self.port is None and file_id == -1:
899905
command = OPCODE_GET_FILE_INFO \
900906
+ struct.pack(">I", len(filename)) \
@@ -905,7 +911,7 @@ def _get_file_info(self, filename, file_id=-1):
905911
raise CC3200Error()
906912
return CC3x00FileInfo.from_packet(finfo)
907913

908-
fat_info = self.get_fat_info(inactive=False)
914+
fat_info = self.get_fat_info(inactive=inactive)
909915
finfo = CC3x00FileInfo(exists=False, size=0)
910916
for file in fat_info.files:
911917
if file_id == -1:
@@ -1154,8 +1160,8 @@ def _write_file_api(self, local_file, cc_filename, sign_data, fs_flags, size, fi
11541160
log.debug("Closing file ...")
11551161
return self._close_file(sign_data)
11561162

1157-
def read_file(self, cc_fname, local_file, file_id=-1):
1158-
finfo = self._get_file_info(cc_fname, file_id)
1163+
def read_file(self, cc_fname, local_file, file_id=-1, inactive=False):
1164+
finfo = self._get_file_info(cc_fname, file_id, inactive)
11591165
if not finfo.exists:
11601166
raise CC3200Error(f"{cc_fname} does not exist on target")
11611167

@@ -1179,7 +1185,7 @@ def read_file(self, cc_fname, local_file, file_id=-1):
11791185
self._close_file()
11801186
return
11811187

1182-
fat_info = self.get_fat_info(inactive=False, extended=True)
1188+
fat_info = self.get_fat_info(inactive=inactive, extended=True)
11831189
filefinfo = None
11841190
for file in fat_info.files:
11851191
if file_id == -1:
@@ -1284,8 +1290,8 @@ def list_filesystem(self, json_output=False, inactive=False, extended=False):
12841290
if json_output:
12851291
fat_info.print_sffs_info_json()
12861292

1287-
def read_all_files(self, local_dir, by_file_id=False, all_by_file_id=False):
1288-
fat_info = self.get_fat_info(inactive=False)
1293+
def read_all_files(self, local_dir, by_file_id=False, all_by_file_id=False, inactive=False):
1294+
fat_info = self.get_fat_info(inactive=inactive)
12891295
fat_info.print_sffs_info()
12901296
for f in fat_info.files:
12911297
ccname = f.fname
@@ -1304,9 +1310,9 @@ def read_all_files(self, local_dir, by_file_id=False, all_by_file_id=False):
13041310

13051311
try:
13061312
if all_by_file_id or ( by_file_id and f.fname == '' ):
1307-
self.read_file(ccname, open(target_file, 'wb', -1), f.index)
1313+
self.read_file(ccname, open(target_file, 'wb', -1), f.index, inactive=inactive)
13081314
else:
1309-
self.read_file(f.fname, open(target_file, 'wb', -1))
1315+
self.read_file(f.fname, open(target_file, 'wb', -1), inactive=inactive)
13101316
except Exception as ex:
13111317
log.error("File %s could not be read, %s" % (f.fname, str (ex)))
13121318

@@ -1414,7 +1420,7 @@ def main():
14141420
check_fat = True
14151421

14161422
if command.cmd == "read_file":
1417-
cc.read_file(command.cc_filename, command.local_file, command.file_id)
1423+
cc.read_file(command.cc_filename, command.local_file, command.file_id, command.inactive)
14181424

14191425
if command.cmd == "erase_file":
14201426
log.info("Erasing file %s", command.filename)
@@ -1430,7 +1436,7 @@ def main():
14301436
cc.list_filesystem(command.json_output, command.inactive, command.extended)
14311437

14321438
if command.cmd == "read_all_files":
1433-
cc.read_all_files(command.local_dir, command.by_file_id, command.all_by_file_id)
1439+
cc.read_all_files(command.local_dir, command.by_file_id, command.all_by_file_id, command.inactive)
14341440

14351441
if command.cmd == "write_all_files":
14361442
use_api = True

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="cc3200tool",
5-
version="1.2.1",
5+
version="1.2.2",
66
description="A tool to down-/upload files form/to TI CC3200",
77
author="Kiril Zyapkov, 0xbadbee",
88
author_email="k.zyapkov@allterco.com",

0 commit comments

Comments
 (0)