Finally, a Makefile to run: make && make upload && make serial

This commit is contained in:
Masakazu OHTSUKA
2015-07-27 18:13:56 +09:00
parent 534bb96018
commit f80e8374bb
4 changed files with 32 additions and 35 deletions

View File

@@ -7,17 +7,44 @@ CSOURCES = $(wildcard $(SOURCEDIR)/*.c)
CPPLISTS = $(patsubst %.cpp,$(BUILDDIR)/%.lst,$(CPPSOURCES))
CLISTS = $(patsubst %.c,$(BUILDDIR)/%.lst,$(CSOURCES))
INO = ~/src/ino/bin/ino
.PHONY: assembly
assembly: $(CPPLISTS) $(CLISTS)
# Use Arduino-1.0.5 on /Applications/Arduino.app
AVRBIN = /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin
DATASIZE = $(shell $(AVRBIN)/avr-size -B .build/irkit/firmware.hex | tail -n 1 | cut -b 11-15)
VERSION = $(shell git describe --tags --long | sed -e "s/^v//" | sed -e "s/\-/./g")
build:
$(INO) build -m irkit --ldflags="-Os --gc-sections -Map=.build/irkit/firmware.map"
$(AVRBIN)/avr-nm --size-sort .build/irkit/firmware.elf > .build/irkit/firmware.nm.size.log
$(AVRBIN)/avr-nm --numeric-sort .build/irkit/firmware.elf > .build/irkit/firmware.nm.numeric.log
version:
sed -e s/__VERSION__/$(VERSION)/ src/IRKit/version.template > src/IRKit/version.c
upload:
@if [ $(DATASIZE) -gt 28672 ] ; then \
echo "size is $(DATASIZE), NG" ; \
else \
echo "size is $(DATASIZE), OK" ; \
$(INO) upload -m irkit ; \
fi
serial:
sleep 2
$(INO) serial -b 115200
# remove Arduino IDE build files
clean:
rm -rf src/IRKit/build-uno/
$(BUILDDIR)/$(SOURCEDIR)/%.lst : $(SOURCEDIR)/%.cpp
@mkdir -p $(BUILDDIR)/$(SOURCEDIR)
/Applications/Arduino-1.0.5.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=105 -I/Applications/Arduino-1.0.5.app/Contents/Resources/Java/hardware/arduino/cores/arduino -ffunction-sections -fdata-sections -g -Os -w -DUSB_VID=0x1d50 -DUSB_PID=0x6085 -I/Applications/Arduino-1.0.5.app/Contents/Resources/Java/hardware/arduino/variants/leonardo -I/Applications/Arduino-1.0.5.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Applications/Arduino-1.0.5.app/Contents/Resources/Java/hardware/arduino/cores/arduino/avr-libc -Wa,-aln=$@ -fno-exceptions -o $(subst .lst,.o,$@) -c $<
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=105 -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -ffunction-sections -fdata-sections -g -Os -w -DUSB_VID=0x1d50 -DUSB_PID=0x6085 -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/leonardo -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/avr-libc -Wa,-aln=$@ -fno-exceptions -o $(subst .lst,.o,$@) -c $<
$(BUILDDIR)/$(SOURCEDIR)/%.lst : $(SOURCEDIR)/%.c
@mkdir -p $(BUILDDIR)/$(SOURCEDIR)
/Applications/Arduino-1.0.5.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=105 -I/Applications/Arduino-1.0.5.app/Contents/Resources/Java/hardware/arduino/cores/arduino -ffunction-sections -fdata-sections -g -Os -w -DUSB_VID=0x1d50 -DUSB_PID=0x6085 -I/Applications/Arduino-1.0.5.app/Contents/Resources/Java/hardware/arduino/variants/leonardo -I/Applications/Arduino-1.0.5.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Applications/Arduino-1.0.5.app/Contents/Resources/Java/hardware/arduino/cores/arduino/avr-libc -Wa,-aln=$@ -o $(subst .lst,.o,$@) -c $<
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=105 -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -ffunction-sections -fdata-sections -g -Os -w -DUSB_VID=0x1d50 -DUSB_PID=0x6085 -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/leonardo -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/avr-libc -Wa,-aln=$@ -o $(subst .lst,.o,$@) -c $<
.PHONY: assembly build version clean
assembly: $(CPPLISTS) $(CLISTS)

View File

@@ -1,14 +0,0 @@
#!/bin/sh
set -xe
# Use Arduino-1.0.5 on /Applications/Arduino.app
AVRBIN=/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin
# remove Arduino IDE build files
rm -rf src/IRKit/build-uno/
VERSION=`git describe --tags --long | sed -e "s/^v//" | sed -e "s/\-/./g"`
sed -e "s/__VERSION__/$VERSION/" src/IRKit/version.template > src/IRKit/version.c
~/src/ino/bin/ino build -m irkit --ldflags="-Os --gc-sections -Map=.build/irkit/firmware.map"
${AVRBIN}/avr-nm --size-sort .build/irkit/firmware.elf > .build/irkit/firmware.nm.size.log
${AVRBIN}/avr-nm --numeric-sort .build/irkit/firmware.elf > .build/irkit/firmware.nm.numeric.log

View File

@@ -1,2 +0,0 @@
#!/bin/sh
~/src/ino/bin/ino serial -b 115200

View File

@@ -1,14 +0,0 @@
#!/bin/sh
set -e
# don't want to write boot loader area of leonardo
AVRBIN=/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin
DATASIZE=`$AVRBIN/avr-size -B .build/irkit/firmware.hex | tail -n 1 | cut -b 11-15`
if [ "$DATASIZE" -gt 28672 ]; then
echo "size is $DATASIZE > 28672, NG"
exit 1
else
echo "size is $DATASIZE < 28672, OK"
fi
~/src/ino/bin/ino upload -m irkit