Skip to content

Commit

Permalink
ports/*328*: Add -mcu option to all of the m328/m328p install scripts
Browse files Browse the repository at this point in the history
It seems that some of these boards have m328 and others have m328p;
allow the user to select which their board has on the command line.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Mar 27, 2022
1 parent 9bd4e47 commit cb2fc3c
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 15 deletions.
5 changes: 5 additions & 0 deletions ports/duemilanove-big/snek-duemilanove-big-install.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ and 'avrisp2'. The default is 'usbtiny'.
\-hex <snek.hex>
Specifies the hex file to load to the board. The default is the
currently installed version of Snek.
.TP
\-mcu <MCU name>
Specifies which micro controller to expect to find on the board. Some
boards have m328 while others have m328p. The default is @MCU@, but if
you get an error message indicating a mismatch, you can try the other.
.SH COMMANDS
.TP
fuseload
Expand Down
27 changes: 18 additions & 9 deletions ports/duemilanove-big/snek-duemilanove-big-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ mode=arg

verify=""

MCU="@MCU@"

for i in "$@"; do
case "$mode" in
arg)
Expand All @@ -27,11 +29,14 @@ for i in "$@"; do
-hex|--hex)
mode=hex
;;
-mcu|--mcu)
mode=mcu
;;
-quick)
verify="-V"
;;
*)
echo "Usage: $0 {-isp usbtiny} {-isp avrisp2} {-hex snek-uduino.hex} {fuseload|load|fuse}" 1>&2
echo "Usage: $0 {-isp usbtiny} {-isp avrisp2} {-hex snek-uduino.hex} {-mcu 328} {fuseload|load|fuse}" 1>&2
exit 1
;;
esac
Expand All @@ -44,19 +49,23 @@ for i in "$@"; do
SNEKBIG="$i"
mode=arg
;;
mcu)
MCU="$i"
mode=arg;
;;
esac
done

FUSES="-U lfuse:w:0xff:m -U hfuse:w:0x91:m -U efuse:w:0xfd:m"
FUSES="-U hfuse:w:0xd1:m"

case "$action" in
fuse)
avrdude -V -c $ISP -p m328 -u $FUSES
;;
fuseload)
avrdude -V -c $ISP -p m328 -u $FUSES && avrdude $verify -c $ISP -p m328 -U flash:w:"${SNEKBIG}"
fuse|fuseload)
avrdude -V -c $ISP -p $MCU -u $FUSES || exit 1
;;
load)
avrdude $verify -c $ISP -p m328 -U flash:w:"${SNEKBIG}"
esac

case "$action" in
fuseload|load)
avrdude $verify -c $ISP -p $MCU -U flash:w:"${SNEKBIG}" || exit 1
;;
esac
4 changes: 3 additions & 1 deletion ports/duemilanove/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ CLOCK?=16000000
BAUD?=115200
INSTALLER?=1
ATMEGA_FLASH_SIZE?=0x7e00
MCU?=m328

include $(SNEK_ATMEGA)/snek-atmega.defs

Expand All @@ -50,7 +51,8 @@ SNEK_ATMEGA_SED=$(SNEK_SED) \
-e 's;@UBOARD@;$(UBOARD);g' \
-e 's;@CBOARD@;$(CBOARD);g' \
-e 's;@BAUD@;$(BAUD);g' \
-e 's;@PORT@;$(PORT);g'
-e 's;@PORT@;$(PORT);g' \
-e 's;@MCU@;$(MCU);g'

SNEK_CFLAGS = $(SNEK_MOST_WARNINGS) $(SNEK_BASE_CFLAGS)

Expand Down
5 changes: 5 additions & 0 deletions ports/duemilanove/snek-duemilanove-install.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ currently installed version of Snek.
.TP
\-port <port>
Specifies the serial port to use. The default is @PORT@.
.TP
\-mcu <MCU name>
Specifies which micro controller to expect to find on the board. Some
boards have m328 while others have m328p. The default is @MCU@, but if
you get an error message indicating a mismatch, you can try the other.
.SH OPTIBOOT
Snek for the @CBOARD@ requires Optiboot. If your board does not
already have Optiboot, you can use the Arduino IDE to install Optiboot
Expand Down
14 changes: 12 additions & 2 deletions ports/duemilanove/snek-duemilanove-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ PORT="@PORT@"

mode=arg

MCU="@MCU@"

for i in "$@"; do
case "$mode" in
arg)
Expand All @@ -20,8 +22,11 @@ for i in "$@"; do
-port|--port)
mode=port
;;
-mcu|--mcu)
mode=mcu
;;
*)
echo "Usage: $0 {-hex snek-@BOARD@.hex} {-port @PORT@}" 1>&2
echo "Usage: $0 {-hex snek-@BOARD@.hex} {-port @PORT@} {-mcu @MCU@}" 1>&2
exit 1
;;
esac
Expand All @@ -33,7 +38,12 @@ for i in "$@"; do
port)
PORT="$i"
mode=arg
;;
mcu)
MCU="$i"
mode=arg
;;
esac
done

avrdude -P $PORT -c arduino -b @BAUD@ -p ATMEGA328P -D -U flash:w:"${SNEKHEX}"
avrdude -P $PORT -c arduino -b @BAUD@ -p "$MCU" -D -U flash:w:"${SNEKHEX}"
13 changes: 11 additions & 2 deletions ports/grove/snek-grove-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ PORT=/dev/ttyUSB0

mode=arg

MCU=m328

for i in "$@"; do
case "$mode" in
arg)
Expand All @@ -17,8 +19,11 @@ for i in "$@"; do
-hex|--hex)
mode=hex
;;
-mcu|--mcu)
mode=mcu
;;
*)
echo "Usage: $0 {-port $PORT} {-hex snek-grove.hex}" 1>&2
echo "Usage: $0 {-port $PORT} {-hex snek-grove.hex} {-mcu $MCU}" 1>&2
exit 1
;;
esac
Expand All @@ -31,7 +36,11 @@ for i in "$@"; do
HEX="$i"
mode=arg
;;
mcu)
MCU="$i"
mode=arg
;;
esac
done

avrdude -pATMEGA328P -carduino -P$PORT -b115200 -D -U flash:w:"${HEX}":i
avrdude -p"$MCU" -carduino -P$PORT -b115200 -D -U flash:w:"${HEX}":i
2 changes: 1 addition & 1 deletion ports/lilypad/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#

SNEK_NO_DICT=1
SNEK_NO_SLICE=1
BOARD=lilypad
CBOARD=LilyPad
UBOARD=LILYPAD
PORT=/dev/ttyUSB0
BAUD=57600
CLOCK=8000000
MCU=m328p

SNEK_ATMEGA_BUILTINS_EXTRA = \
snek-tone.builtin
Expand Down
1 change: 1 addition & 0 deletions ports/uno-big/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ BOARD?=uno-big
CBOARD?=Uno-big
UBOARD?=UNO-BIG
PORT?=/dev/ttyACM0
MCU?=m328p

include ../duemilanove-big/Makefile
1 change: 1 addition & 0 deletions ports/uno/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ BOARD=uno
CBOARD=Uno
UBOARD=UNO
PORT=/dev/ttyACM0
MCU?=m328p

include ../duemilanove/Makefile

0 comments on commit cb2fc3c

Please sign in to comment.