#!/usr/bin/env bash # Flashes app image (ninlight__gz.img) over the serial port (runs natively on the Mac). # For blank/erased chips only: pass "full" as third argument to flash ninlight_.fls instead. # Usage: tools/flash.sh [full] set -euo pipefail DEV=${1:?usage: tools/flash.sh [full]} PORT=${2:?usage: tools/flash.sh [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