ao-tools: Add ao-flash-samd21 script
authorKeith Packard <keithp@keithp.com>
Mon, 26 Sep 2022 00:31:27 +0000 (17:31 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 26 Sep 2022 00:31:27 +0000 (17:31 -0700)
This takes an .elf or .ihx file and flashes that to a SAMD21 based
board using openocd. Note that you must have a hacked version of
OpenOCD for this to work via the ST-link device.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/ao-flash/Makefile.am
ao-tools/ao-flash/ao-flash-samd21 [new file with mode: 0755]
ao-tools/ao-flash/ao-flash-samd21.1 [new file with mode: 0644]

index ed9284397dc3a817b4dad9139ffdb33a242b5633..c9174d6a8d520ef6be1ca50af6d9e95b010b3641 100644 (file)
@@ -1,3 +1,3 @@
-bin_SCRIPTS=ao-flash-stm ao-flash-lpc ao-flash-stm32f0x ao-reset-lpc
+bin_SCRIPTS=ao-flash-stm ao-flash-lpc ao-flash-stm32f0x ao-reset-lpc ao-flash-samd21
 
-man_MANS = ao-flash-stm.1 ao-flash-lpc.1 ao-flash-stm32f0x.1 ao-reset-lpc.1
+man_MANS = ao-flash-stm.1 ao-flash-lpc.1 ao-flash-stm32f0x.1 ao-reset-lpc.1 ao-flash-samd21.1
diff --git a/ao-tools/ao-flash/ao-flash-samd21 b/ao-tools/ao-flash/ao-flash-samd21
new file mode 100755 (executable)
index 0000000..1b3dc87
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+case "$#" in
+1)
+    ;;
+*)
+    echo "usage: $0 <filename> ..."
+    exit 1
+    ;;
+esac
+
+openocd \
+    -f interface/stlink.cfg \
+    -c 'transport select hla_swd' \
+    -c 'set CPUTAPID 0x0bc11477' \
+    -f target/at91samdXX.cfg \
+    -c 'adapter speed 10' \
+    -c init \
+    -c 'reset init' \
+    -c 'at91samd bootloader 0' \
+    -c 'reset init' \
+    -c "program $1" \
+    -c "shutdown"
diff --git a/ao-tools/ao-flash/ao-flash-samd21.1 b/ao-tools/ao-flash/ao-flash-samd21.1
new file mode 100644 (file)
index 0000000..d624fe0
--- /dev/null
@@ -0,0 +1,36 @@
+.\"
+.\" Copyright © 2022 Keith Packard <keithp@keithp.com>
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful, but
+.\" WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+.\" General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License along
+.\" with this program; if not, write to the Free Software Foundation, Inc.,
+.\" 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+.\"
+.\"
+.TH AO-FLASH-LPC 1 "ao-flash-samd21" ""
+.SH NAME
+ao-flash-samd21 \- flash a program to an SAMD21-based AltOS device using openocd
+.SH SYNOPSIS
+.B "ao-flash-samd21"
+\fIfile.elf\fP
+.SH DESCRIPTION
+.I ao-flash-samd21
+loads the specified .elf file into the target device flash memory.
+.SH USAGE
+.I ao-flash-samd21
+is a simple script that passes the correct arguments to openocd to
+load a file into the target device via a connected STlink
+debugging dongle.
+.SH "SEE ALSO"
+openocd(1)
+.SH AUTHOR
+Keith Packard