Skip to content

Commit cca6de5

Browse files
committed
Add venv wrapper and reset notice for GD32 flasher
Add an executable bash wrapper at common/scripts/gd32/flash that bootstraps a Python venv (using python3), installs/updates pip and pyserial, and execs flash.py; includes checks and a helpful error if python/venv is missing. Also add a brief print in common/scripts/gd32/flash.py to instruct users to manually reset the MCU before the next bootloader session.
1 parent b8b077b commit cca6de5

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

common/scripts/gd32/flash

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4+
5+
PYTHON="${PYTHON:-python3}"
6+
command -v "$PYTHON" >/dev/null 2>&1 || PYTHON=python
7+
command -v "$PYTHON" >/dev/null 2>&1 || { echo "No python found (need python3)"; exit 1; }
8+
9+
if [[ ! -x "$DIR/venv/bin/python" ]]; then
10+
"$PYTHON" -m venv "$DIR/venv" || {
11+
echo "Failed to create venv. On Debian/Ubuntu install: python3-venv" >&2
12+
exit 1
13+
}
14+
"$DIR/venv/bin/python" -m pip install -q -U pip
15+
"$DIR/venv/bin/python" -m pip install -q pyserial
16+
fi
17+
18+
exec "$DIR/venv/bin/python" "$DIR/flash.py" "$@"
19+

common/scripts/gd32/flash.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def close(self):
4545
time.sleep(0.1)
4646
self.port.rts = False
4747
self.port.close()
48+
print("Done. Reset the MCU manually before the next bootloader session.")
4849

4950
def enter_bootloader(self):
5051
"""Enter ROM bootloader mode using DTR/RTS"""

0 commit comments

Comments
 (0)