From be0a7f000250704bcdbad82aa4ef4d9966fc6307 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 25 Sep 2022 17:31:27 -0700 Subject: [PATCH] ao-tools: Add ao-flash-samd21 script 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 --- ao-tools/ao-flash/Makefile.am | 4 ++-- ao-tools/ao-flash/ao-flash-samd21 | 22 ++++++++++++++++++ ao-tools/ao-flash/ao-flash-samd21.1 | 36 +++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100755 ao-tools/ao-flash/ao-flash-samd21 create mode 100644 ao-tools/ao-flash/ao-flash-samd21.1 diff --git a/ao-tools/ao-flash/Makefile.am b/ao-tools/ao-flash/Makefile.am index ed928439..c9174d6a 100644 --- a/ao-tools/ao-flash/Makefile.am +++ b/ao-tools/ao-flash/Makefile.am @@ -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 index 00000000..1b3dc87b --- /dev/null +++ b/ao-tools/ao-flash/ao-flash-samd21 @@ -0,0 +1,22 @@ +#!/bin/sh +case "$#" in +1) + ;; +*) + echo "usage: $0 ..." + 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 index 00000000..d624fe08 --- /dev/null +++ b/ao-tools/ao-flash/ao-flash-samd21.1 @@ -0,0 +1,36 @@ +.\" +.\" Copyright © 2022 Keith Packard +.\" +.\" 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 -- 2.30.2