Skip to content

Commit

Permalink
ports/uno: Use duemilanove files to build this target
Browse files Browse the repository at this point in the history
Uno is identical to duemilanove except for the name and the default
tty port used when installing.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Feb 3, 2021
1 parent 94814cd commit fbd90a1
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 723 deletions.
2 changes: 1 addition & 1 deletion ports/duemilanove/.gitignore
@@ -1,4 +1,4 @@
snek-duemilanove-*
snek-duemilanove-*.elf
snek-duemilanove-*.hex
snek-duemilanove-*.map
snek-duemilanove-install
63 changes: 22 additions & 41 deletions ports/duemilanove/Makefile
Expand Up @@ -14,6 +14,10 @@

SNEK_ROOT = ../..
SNEK_ATMEGA = $(SNEK_ROOT)/chips/atmega
BOARD?=duemilanove
CBOARD?=Duemilanove
UBOARD?=DUEMILANOVE
PORT?=/dev/ttyUSB0

include $(SNEK_ATMEGA)/snek-atmega.defs

Expand All @@ -33,9 +37,15 @@ SNEK_LOCAL_BUILTINS = \

include $(SNEK_ROOT)/snek-install.defs

SNEK_ATMEGA_SED=$(SNEK_SED) \
-e 's;@BOARD@;$(BOARD);g' \
-e 's;@UBOARD@;$(UBOARD);g' \
-e 's;@CBOARD@;$(CBOARD);g' \
-e 's;@PORT@;$(PORT);g'

SNEK_CFLAGS = $(SNEK_MOST_WARNINGS) $(SNEK_BASE_CFLAGS)

BASE=snek-duemilanove-$(SNEK_VERSION)
BASE=snek-$(BOARD)-$(SNEK_VERSION)
ELF=$(BASE).elf
HEX=$(BASE).hex
MAP=$(BASE).map
Expand All @@ -52,34 +62,7 @@ LDFLAGS=$(SNEK_LDFLAGS) \
-Wl,--defsym -Wl,__EEPROM_REGION_LENGTH__=0x400 \
-Wl,-Map=$(MAP)

ISP = usbtiny
#ISP = avrisp2

#
# lfuse: 0xff
# CKDIV8: 1 no divide by 8
# CKOUT: 1 no clock output
# SUT1: 1 crystal osc, slow startup
# SUT0: 1 crystal osc, slow startup
# CKSEL3: 1 low swing osc, 8-16MHz
# CKSEL2: 1 low swing osc, 8-16MHz
# CKSEL1: 1 low swing osc, 8-16MHz
# CKSEL0: 1 crystal osc
# hfuse:
# RSTDISBL: 1 reset enabled
# DWEN: 1 debug wire disabled
# SPIEN: 0 SPI program enabled
# WDTON: 1 watch dog disabled
# EESAVE: 0 EEPROM saved across chip erase
# BOOTSZ1: 1 256 words
# BOOTSZ0: 1 256 words
# BOOTRST: 1 boot to address 0
# efuse:
# BODLEVEL2 1 brown out 2.5-2.9V
# BODLEVEL1 0 brown out 2.5-2.9V
# BODLEVEL0 1 brown out 2.5-2.9V

all: $(HEX) snek-duemilanove-install
all: $(HEX) snek-$(BOARD)-install snek-$(BOARD)-install.1

$(HEX): $(ELF)
avr-objcopy -O ihex -R .eeprom $^ $@
Expand All @@ -88,25 +71,23 @@ $(ELF): $(SNEK_OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
@gawk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)

snek-duemilanove-install: snek-duemilanove-install.in
$(SNEK_SED) $^ > $@
snek-$(BOARD)-install: snek-duemilanove-install.in
$(SNEK_ATMEGA_SED) $^ > $@
chmod +x $@

set-fuse:
avrdude -F -V -c $(ISP) -p ATMEGA328P -U lfuse:w:0xff:m
avrdude -F -V -c $(ISP) -p ATMEGA328P -U hfuse:w:0xd7:m
avrdude -F -V -c $(ISP) -p ATMEGA328P -U efuse:w:0xfd:m
load: $(HEX) snek-$(BOARD)-install
./snek-$(BOARD)-install -hex $(HEX)

load: $(HEX) snek-duemilanove-install
./snek-duemilanove-install -hex $(HEX)
snek-$(BOARD)-install.1: snek-duemilanove-install.1.in
$(SNEK_ATMEGA_SED) $^ > $@

install: snek-duemilanove-install $(HEX) snek-duemilanove-install.1
install: snek-$(BOARD)-install $(HEX) snek-$(BOARD)-install.1
install -d $(DESTDIR)$(BINDIR)
install snek-duemilanove-install $(DESTDIR)$(BINDIR)
install snek-$(BOARD)-install $(DESTDIR)$(BINDIR)
install -d $(DESTDIR)$(SHAREDIR)
install -m 0644 $(HEX) $(DESTDIR)$(SHAREDIR)
install -d $(DESTDIR)$(MANDIR)/man1
install -m 0644 snek-duemilanove-install.1 $(DESTDIR)$(MANDIR)/man1
install -m 0644 snek-$(BOARD)-install.1 $(DESTDIR)$(MANDIR)/man1

clean::
rm -f *.elf *.hex *.map snek-duemilanove-install
rm -f *.elf *.hex *.map snek-$(BOARD)-install
Expand Up @@ -11,28 +11,27 @@
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" General Public License for more details.
.\"
.TH SNEK-DUEMILANOVE-INSTALL 1 "snek-duemilanove-install" ""
.TH SNEK-@UBOARD@-INSTALL 1 "snek-@BOARD@-install" ""
.SH NAME
snek-duemilanove-instal \- Install Snek to Duemilanove
snek-@BOARD@-instal \- Install Snek to @CBOARD@
.SH SYNOPSIS
.B "snek-duemilanove-install" [OPTION]... [COMMAND]
.B "snek-@BOARD@-install" [OPTION]... [COMMAND]
.SH DESCRIPTION
.I snek-duemilanove-install
installs the Snek programming language on an ATmega328P Arduemilanove
Duemilanove board using the Optiboot boot loader.
.I snek-@BOARD@-install
installs the Snek programming language on an ATmega328P
@CBOARD@ board using the Optiboot boot loader.
.SH OPTIONS
.TP
\-hex <snek.hex>
Specifies the hex file to load to the board. The default is the
currently installed version of Snek.
.TP
\-port <port>
Specifies the serial port to use. The default is /dev/ttyUSB0.
Specifies the serial port to use. The default is @PORT@.
.SH OPTIBOOT
Snek for the Duemilanove requires you to first install Optiboot on
your device.
You can use the Arduino IDE to install Optiboot on your
Duemilanove. Follow the instructions on the Optiboot web site:
Snek for the @CBOARD@ requires Optiboot. If your board does not
already have Optiboot, you can use the Arduino IDE to install Optiboot
on your @CBOARD@. Follow the instructions on the Optiboot web site:
https://github.com/Optiboot/optiboot to learn how to do that.
.SH AUTHOR
Keith Packard

0 comments on commit fbd90a1

Please sign in to comment.