/make/arduino-mk

To get this branch, use:
bzr branch http://bzr.ed.am/make/arduino-mk

« back to all changes in this revision

Viewing changes to arduino.mk

  • Committer: edam
  • Date: 2013-01-02 19:55:16 UTC
  • Revision ID: tim@ed.am-20130102195516-0dn4obb92007gqth
added support for burning bootloaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
257
257
LIBRARYDIRS := $(foreach lib, $(LIBRARIES), \
258
258
        $(firstword $(wildcard $(addsuffix /$(lib), $(LIBRARYPATH)))))
259
259
LIBRARYDIRS += $(addsuffix /utility, $(LIBRARYDIRS))
 
260
BOOTLOADERDIR := \
 
261
        $(ARDUINODIR)/hardware/arduino/bootloaders/$(BOARD_BOOTLOADER_PATH)
260
262
 
261
263
# files
262
264
TARGET := $(if $(TARGET),$(TARGET),a.out)
265
267
ARDUINOLIB := .lib/arduino.a
266
268
ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(LIBRARYDIRS), \
267
269
        $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp))))
268
 
BOOTLOADERHEX := $(addprefix \
269
 
        $(ARDUINODIR)/hardware/arduino/bootloaders/$(BOARD_BOOTLOADER_PATH)/, \
270
 
        $(BOARD_BOOTLOADER_FILE))
 
270
BOOTLOADERHEX := $(wildcard $(BOOTLOADERDIR)/$(BOARD_BOOTLOADER_FILE))
271
271
 
272
272
# avrdude confifuration
273
273
ifeq "$(AVRDUDECONF)" ""
358
358
 
359
359
bootloader:
360
360
        @echo "Burning bootloader to board..."
 
361
        @test -n "$(BOOTLOADERHEX)" || { \
 
362
                echo "error: bootloader file could not be determined." >&2; \
 
363
                exit 1; }
361
364
        @test -n "$(SERIALDEV)" || { \
362
365
                echo "error: SERIALDEV could not be determined automatically." >&2; \
363
366
                exit 1; }
366
369
                echo; }
367
370
        stty $(STTYFARG) $(SERIALDEV) hupcl
368
371
        $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_UNLOCK):m
369
 
        $(AVRDUDE) $(AVRDUDEFLAGS) -eU lfuse:w:$(BOARD_BOOTLOADER_LFUSES):m
370
 
        $(AVRDUDE) $(AVRDUDEFLAGS) -U hfuse:w:$(BOARD_BOOTLOADER_HFUSES):m
371
 
ifneq "$(BOARD_BOOTLOADER_EFUSES)" ""
372
 
        $(AVRDUDE) $(AVRDUDEFLAGS) -U efuse:w:$(BOARD_BOOTLOADER_EFUSES):m
373
 
endif
374
 
ifneq "$(BOOTLOADERHEX)" ""
 
372
        $(AVRDUDE) $(AVRDUDEFLAGS) -e -U lfuse:w:$(BOARD_BOOTLOADER_LFUSES):m \
 
373
                -U hfuse:w:$(BOARD_BOOTLOADER_HFUSES):m \
 
374
                $(patsubst %, -U efuse:w:%:m, $(BOARD_BOOTLOADER_EFUSES))
375
375
        $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(BOOTLOADERHEX):i
376
 
endif
377
376
        $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_LOCK):m
378
377
 
379
378
# building the target