#!/bin/bash
# Flash SaltyLab — auto-reboot to DFU if serial port exists
PORT=/dev/cu.usbmodemSALTY0011
FW=.pio/build/f722/firmware.bin

if [ -e "$PORT" ]; then
    echo "Sending reboot-to-DFU..."
    echo -n 'R' > "$PORT"
    sleep 2
fi

echo "Flashing..."
/opt/homebrew/bin/dfu-util -a 0 -s 0x08000000:leave -D "$FW"
