#!/bin/bash

DBG_IF=`ls -lh /dev/ttyA* | grep adm | awk '{print $10}'`

if [ -z $DBG_IF ]; then
    echo "Couldn't find debug interface. Is the uC in the bootloader mode?"
    exit
else
    echo "Found $DBG_IF as the debug interface."
fi

until bossac -i -d --port $DBG_IF -U -w -o0x2000 test_master.bin -R; do
    sleep 5;
done

echo "Flashed device at $DBG_IF."
