#!/bin/bash set -euo pipefail usage() { echo "Usage: arduino-sim [platform]" echo "" echo "Launch Renode with a GDB server for debugging firmware." echo "Connect nvim-dap or gdb to localhost:3333" echo "" echo "Platforms:" {{range .Platforms}} echo " {{.Name}} {{.Machine}}" {{end}} exit 1 } [[ $# -lt 1 ]] && usage ELF="$1" PLATFORM="${2:-{{(index .Platforms 0).Name}}}" [[ ! -f "$ELF" ]] && echo "Error: $ELF not found" && exit 1 case "$PLATFORM" in {{range .Platforms}} {{.Name}}) RENODE_PLATFORM="{{.ReplPath}}" MACHINE="{{.Machine}}" ;; {{end}} *) echo "Unknown platform: $PLATFORM" usage ;; esac RESC=$(mktemp /tmp/renode-XXXXXX.resc) cat >"$RESC" <ds or gdb → target remote :3333" echo "" renode --disable-xwt "$RESC" rm -f "$RESC"