Skip to content

Commit

Permalink
ports/uno: Add missing snek-uno-install files
Browse files Browse the repository at this point in the history
The .gitignore caused these files to not get added.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Jun 15, 2020
1 parent 01a19e4 commit 67c7a68
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ports/uno/.gitignore
@@ -1,4 +1,4 @@
snek-uno-*
snek-uno-*.elf
snek-uno-*.hex
snek-uno-*.map
snek-uno-install
54 changes: 54 additions & 0 deletions ports/uno/snek-uno-install.1
@@ -0,0 +1,54 @@
.\"
.\" Copyright © 2020 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 3 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.
.\"
.TH SNEK-MEGA-INSTALL 1 "snek-uno-install" ""
.SH NAME
snek-uno-install \- Install Snek to Arduino Uno
.SH SYNOPSIS
.B "snek-uno-install" [OPTION]... [COMMAND]
.SH DESCRIPTION
.I snek-uno-install
installs the Snek programming language on an ATmega328P Arduino Uno
board, including the ability to re-program the ATmega16u2 chip used as
a usbserial converter.
.SH OPTIONS
.TP
\-port <port>
Specifies the serial port to use when programming the ATmega328p chip,
the default is '/dev/ttyACM0'.
.TP
\-isp <ISP model>
Specifies the programmer to use when programming the ATmega16u2 chip
used as a usb to serial converter, common options are 'usbtiny'
and 'avrisp2'. The default is 'usbtiny'.
.TP
\-hex <snek.hex>
Specifies the hex file to load to the board. The default is the
currently installed version of Snek when programming the ATmega328p, and the
currently installed version of the usbserial program when programming
the ATmega16u2.
.SH COMMANDS
.TP
snek
Loads Snek to the target device. This is the default command. Note
that snekde will not be able to get/put programs to the device without
also reprogramming the ATmega16u2 device used as a usb to serial
converter on the Arduino Uno board.
.TP
usbserial
Loads the updated usbserial converter firmware to the ATmega16u2
device on the Arduino Uno board. This version supports the XON/XOFF
flow control required for SnekDE to be able to successfully
communicate with Snek running on the ATmega328p processor.
.SH AUTHOR
Keith Packard
76 changes: 76 additions & 0 deletions ports/uno/snek-uno-install.in
@@ -0,0 +1,76 @@
#!/bin/sh

SHAREDIR="@SHAREDIR@"

SNEKMEGA="$SHAREDIR/snek-uno-@SNEK_VERSION@.hex"
USBSERIAL="$SHAREDIR/Arduino-usbserial-atmega16u2-Uno-Rev3.hex"
PORT=/dev/ttyACM0
ISP=usbtiny
HEX=default

action="snek"

mode=arg

for i in "$@"; do
case "$mode" in
arg)
case "$i" in
snek|usbserial)
action="$i"
;;
-port|--port)
mode=port
;;
-isp|--isp)
mode=isp
;;
-hex|--hex)
mode=hex
;;
*)
echo "Usage: $0 {-port /dev/ttyACM0} {-isp avrisp2} {-hex snek-uno.hex} {snek|usbserial}" 1>&2
exit 1
;;
esac
;;
isp)
ISP="$i"
mode=arg
;;
port)
PORT="$i"
mode=arg
;;
hex)
HEX="$i"
mode=arg
;;
esac
done

case "$HEX" in
default)
case "$action" in
snek)
HEX="${SNEKMEGA}"
;;
usbserial)
HEX="${USBSERIAL}"
;;
esac
;;
esac

case "$action" in
snek)
avrdude -pATMEGA328P -carduino -P$PORT -b115200 -D -U flash:w:"${HEX}":i
;;
usbserial)
avrdude -pm16u2 -c$ISP -U flash:w:"${HEX}":i
;;
*)
echo "Usage: $0 {-port /dev/ttyACM0} {-isp avrisp2} {-hex snek-uno.hex} {snek|usbserial}" 1>&2
exit 1
;;
esac

0 comments on commit 67c7a68

Please sign in to comment.