Files
ninlight-w600/tools/flash.sh
T

24 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Flashes app image (ninlight_<device>_gz.img) over the serial port (runs natively on the Mac).
# For blank/erased chips only: pass "full" as third argument to flash ninlight_<device>.fls instead.
# Usage: tools/flash.sh <device> <port-name as listed by `build/host-tools/wm_tool -l`> [full]
set -euo pipefail
DEV=${1:?usage: tools/flash.sh <device> <port> [full]}
PORT=${2:?usage: tools/flash.sh <device> <port> [full]}
MODE=${3:-app}
# wm_tool prepends /dev/ itself - accept either spelling.
PORT=${PORT#/dev/}
ROOT=$(cd "$(dirname "$0")/.." && pwd)
TOOL="$ROOT/build/host-tools/wm_tool"
if [ ! -x "$TOOL" ] || [ "$ROOT/sdk/tools/wm_tool.c" -nt "$TOOL" ]; then
mkdir -p "$(dirname "$TOOL")"
cc -O2 -w -o "$TOOL" "$ROOT/sdk/tools/wm_tool.c" -lpthread
fi
if [ "$MODE" = "full" ]; then
echo "Bitte bei \"please manually reset the device\" die Reset-Taste drücken."
"$TOOL" -c "$PORT" -ds 460800 -rs none -eo secboot -dl "$ROOT/build/$DEV/ninlight_$DEV.fls"
else
echo "Bitte bei \"please manually reset the device\" die Reset-Taste drücken."
"$TOOL" -c "$PORT" -ds 460800 -rs none -dl "$ROOT/build/$DEV/ninlight_${DEV}_gz.img"
fi