From 54eb42d903aa4cd88f034fcbf812279a2522caef Mon Sep 17 00:00:00 2001 From: Igor Biletskyy Date: Mon, 15 Aug 2022 20:11:38 -0700 Subject: [PATCH] one flash.sh for both H7 and F4 (#1032) * flash one * edit readme --- board/README.md | 4 +--- board/flash.sh | 2 +- board/flash_h7.sh | 5 ----- python/__init__.py | 7 ++++--- 4 files changed, 6 insertions(+), 12 deletions(-) delete mode 100755 board/flash_h7.sh diff --git a/board/README.md b/board/README.md index 5afb7289..d2ab341f 100644 --- a/board/README.md +++ b/board/README.md @@ -21,9 +21,7 @@ Programming **Panda** ``` -scons -u -j$(nproc) # Compile -./flash_h7.sh # for red panda -./flash.sh # for other pandas +./flash.sh # for any pandas ``` Troubleshooting diff --git a/board/flash.sh b/board/flash.sh index 54a1d56c..cdb8f1be 100755 --- a/board/flash.sh +++ b/board/flash.sh @@ -2,4 +2,4 @@ set -e scons -u -j$(nproc) -PYTHONPATH=.. python3 -c "from python import Panda; Panda().flash('obj/panda.bin.signed')" +printf %b 'from python import Panda\nfor serial in Panda.list(): Panda(serial).flash()' | PYTHONPATH=.. python3 diff --git a/board/flash_h7.sh b/board/flash_h7.sh deleted file mode 100755 index 6fb28d2b..00000000 --- a/board/flash_h7.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh -set -e - -scons -u -j$(nproc) -PYTHONPATH=.. python3 -c "from python import Panda; Panda().flash('obj/panda_h7.bin.signed')" diff --git a/python/__init__.py b/python/__init__.py index 3c23a553..3ab83d09 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -340,9 +340,10 @@ class Panda: except Exception: pass - def flash(self, fn=DEFAULT_FW_FN, code=None, reconnect=True): - if self._mcu_type == MCU_TYPE_H7 and fn == DEFAULT_FW_FN: - fn = DEFAULT_H7_FW_FN + def flash(self, fn=None, code=None, reconnect=True): + if not fn: + fn = DEFAULT_H7_FW_FN if self._mcu_type == MCU_TYPE_H7 else DEFAULT_FW_FN + assert os.path.isfile(fn) print("flash: main version is " + self.get_version()) if not self.bootstub: self.reset(enter_bootstub=True)