From e200b92d88b88cfe9dda41b86f80748dbbe2312c Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 5 May 2026 11:33:06 -0700 Subject: [PATCH] MDMA is a good time (#591) * MDMA is a good time * fast * cleanup --- flash_all.sh | 7 +++++-- flash_kernel.sh | 1 + flash_system.sh | 1 + scripts/mdma.py | 8 ++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/flash_all.sh b/flash_all.sh index 52f8480..36030bc 100755 --- a/flash_all.sh +++ b/flash_all.sh @@ -4,10 +4,13 @@ set -e DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" cd $DIR +scripts/mdma.py reboot-qdl --missing-ok + for part in aop abl xbl xbl_config devcfg; do tools/qdl flash ${part}_a $DIR/firmware/$part.img tools/qdl flash ${part}_b $DIR/firmware/$part.img done -./flash_kernel.sh -./flash_system.sh +tools/qdl flash boot $DIR/output/boot.img +tools/qdl flash system $DIR/output/system.img +tools/qdl reset diff --git a/flash_kernel.sh b/flash_kernel.sh index 5be1c07..18ef0ac 100755 --- a/flash_kernel.sh +++ b/flash_kernel.sh @@ -4,4 +4,5 @@ set -e DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" cd $DIR +scripts/mdma.py reboot-qdl --missing-ok tools/qdl flash boot $DIR/output/boot.img diff --git a/flash_system.sh b/flash_system.sh index 7e88e8f..a982ab6 100755 --- a/flash_system.sh +++ b/flash_system.sh @@ -4,5 +4,6 @@ set -e DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" cd $DIR +scripts/mdma.py reboot-qdl --missing-ok tools/qdl flash system $DIR/output/system.img tools/qdl reset diff --git a/scripts/mdma.py b/scripts/mdma.py index d7369da..4b98305 100755 --- a/scripts/mdma.py +++ b/scripts/mdma.py @@ -51,6 +51,9 @@ class Mdma: raise SystemExit(f"could not find hub {vid:04x}:{pid:04x}") return hub + def available(self): + return os.path.exists(SERIAL_DEV) + def reg(self, addr, value=None, size=4): dev = usb.core.find(idVendor=Pins.HFC_VID, idProduct=Pins.HFC_PID) if value is None: @@ -157,6 +160,7 @@ if __name__ == "__main__": } parser = argparse.ArgumentParser() + parser.add_argument("--missing-ok", action="store_true", help="continue successfully when no MDMA is connected") subparsers = parser.add_subparsers(dest="command", required=True) for cmd, (_, hlp) in cmds.items(): subparsers.add_parser(cmd, help=hlp) @@ -165,4 +169,8 @@ if __name__ == "__main__": raise SystemExit(0) args = parser.parse_args() + if not Mdma().available(): + print("MDMA not found.") + raise SystemExit(0 if args.missing_ok else 1) + cmds[args.command][0]()