diff --git a/board/README.md b/board/README.md index 4434d28af..ad9091411 100644 --- a/board/README.md +++ b/board/README.md @@ -4,18 +4,15 @@ Programming **Panda** ``` -./recover.sh # flash bootstub -``` - -``` -./flash.sh # flash application +./recover.py # flash bootstub +./flash.py # flash application ``` Troubleshooting ---- -If your panda will not flash and green LED is on, use `recover.sh`. -If panda is blinking fast with green LED, use `flash.sh`. +If your panda will not flash and green LED is on, use `recover.py`. +If panda is blinking fast with green LED, use `flash.py`. Otherwise if LED is off and panda can't be seen with `lsusb` command, use [panda paw](https://comma.ai/shop/products/panda-paw) to go into DFU mode. diff --git a/board/flash.py b/board/flash.py new file mode 100755 index 000000000..d1a78e2c5 --- /dev/null +++ b/board/flash.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +import os +import subprocess + +from panda import Panda + +board_path = os.path.dirname(os.path.realpath(__file__)) + +if __name__ == "__main__": + subprocess.check_call(f"scons -C {board_path}/.. -j$(nproc) {board_path}", shell=True) + + serials = Panda.list() + print(f"found {len(serials)} panda(s) - {serials}") + for s in serials: + print("flashing", s) + with Panda(serial=s) as p: + p.flash() diff --git a/board/flash.sh b/board/flash.sh deleted file mode 100755 index cdb8f1be6..000000000 --- a/board/flash.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh -set -e - -scons -u -j$(nproc) -printf %b 'from python import Panda\nfor serial in Panda.list(): Panda(serial).flash()' | PYTHONPATH=.. python3 diff --git a/board/recover.py b/board/recover.py new file mode 100755 index 000000000..5284a4e29 --- /dev/null +++ b/board/recover.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +import os +import time +import subprocess + +from panda import Panda, PandaDFU + +board_path = os.path.dirname(os.path.realpath(__file__)) + +if __name__ == "__main__": + subprocess.check_call(f"scons -C {board_path}/.. -j$(nproc) {board_path}", shell=True) + + for s in Panda.list(): + print("putting", s, "in DFU mode") + with Panda(serial=s) as p: + p.reset(enter_bootstub=True) + p.reset(enter_bootloader=True) + + # wait for reset pandas to come back up + time.sleep(1) + + dfu_serials = PandaDFU.list() + print(f"found {len(dfu_serials)} panda(s) in DFU - {dfu_serials}") + for s in dfu_serials: + print("flashing", s) + PandaDFU(s).recover() diff --git a/board/recover.sh b/board/recover.sh deleted file mode 100755 index f003cba67..000000000 --- a/board/recover.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env sh -set -e - -scons -u -j$(nproc) -# Recovers panda from DFU mode only, use flash.sh after power cycling panda -printf %b 'from python import Panda\nfor serial in Panda.list(): Panda(serial).reset(enter_bootstub=True); Panda(serial).reset(enter_bootloader=True)' | PYTHONPATH=.. python3 -sleep 1 -printf %b 'from python import PandaDFU\nfor serial in PandaDFU.list(): PandaDFU(serial).recover()' | PYTHONPATH=.. python3