2011-02-11 14:42:21 +02:00
|
|
|
#
|
|
|
|
# Makefile - Makefile of the ATUSB firmware
|
|
|
|
#
|
|
|
|
# Written 2010-2011 by Werner Almesberger
|
|
|
|
# Copyright 2010-2011 by Werner Almesberger
|
|
|
|
#
|
|
|
|
# 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 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
|
|
|
|
SHELL = /bin/bash
|
|
|
|
|
2011-02-09 00:32:15 +02:00
|
|
|
NAME = atusb
|
2011-02-11 14:10:53 +02:00
|
|
|
|
2011-02-09 00:32:15 +02:00
|
|
|
CFLAGS = -g -Wall -Wextra -Wshadow -Werror -Wno-unused \
|
|
|
|
-Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes
|
|
|
|
|
|
|
|
CHIP=atmega32u2
|
|
|
|
|
|
|
|
AVR_PREFIX = $(BIN_PATH) avr-
|
|
|
|
CC = $(AVR_PREFIX)gcc
|
|
|
|
OBJCOPY = $(AVR_PREFIX)objcopy
|
|
|
|
#OBJDUMP = $(AVR_PREFIX)objdump
|
|
|
|
|
|
|
|
FreakUSB = usb
|
2011-02-11 14:10:53 +02:00
|
|
|
USB_OBJS = usb.o ctrl.o usb_buf.o ep.o hw.o isr.o
|
2011-02-10 12:19:55 +02:00
|
|
|
OBJS = atusb.o board.o spi.o descr.o ep0.o $(USB_OBJS)
|
2011-02-09 00:32:15 +02:00
|
|
|
|
2011-02-11 14:10:53 +02:00
|
|
|
vpath %.c $(FreakUSB)/usb/
|
|
|
|
vpath %.c $(FreakUSB)/hw/at90usbxx2/
|
|
|
|
|
2011-02-09 00:32:15 +02:00
|
|
|
CFLAGS += -I../fw/include \
|
|
|
|
-I$(FreakUSB)/usb -I$(FreakUSB)/hw/at90usbxx2 \
|
|
|
|
-DNUM_EPS=1
|
|
|
|
|
2011-02-11 14:42:21 +02:00
|
|
|
# ----- Verbosity control -----------------------------------------------------
|
|
|
|
|
|
|
|
CC_normal := $(CC)
|
|
|
|
BUILD_normal :=
|
|
|
|
DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
|
|
|
|
|
|
|
|
CC_quiet = @echo " CC " $@ && $(CC_normal)
|
|
|
|
BUILD_quiet = @echo " BUILD " $@ && $(BUILD_normal)
|
|
|
|
DEPEND_quiet = @$(DEPEND_normal)
|
|
|
|
|
|
|
|
ifeq ($(V),1)
|
|
|
|
CC = $(CC_normal)
|
|
|
|
BUILD = $(BUILD_normal)
|
|
|
|
DEPEND = $(DEPEND_normal)
|
|
|
|
else
|
|
|
|
CC = $(CC_quiet)
|
|
|
|
BUILD = $(BUILD_quiet)
|
|
|
|
DEPEND = $(DEPEND_quiet)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# ----- Rules -----------------------------------------------------------------
|
2011-02-11 14:10:53 +02:00
|
|
|
|
2011-02-09 00:32:15 +02:00
|
|
|
.PHONY: all clean upload prog
|
|
|
|
|
|
|
|
all: $(NAME).bin
|
|
|
|
|
|
|
|
$(NAME).elf: $(OBJS)
|
2011-02-11 14:10:53 +02:00
|
|
|
$(CC) $(CFLAGS) -mmcu=$(CHIP) -o $@ $(OBJS)
|
2011-02-09 00:32:15 +02:00
|
|
|
|
|
|
|
%.bin: %.elf
|
2011-02-11 14:42:21 +02:00
|
|
|
$(BUILD) $(OBJCOPY) -j .text -j .data -O binary $< $@
|
|
|
|
|
|
|
|
# ----- Cleanup ---------------------------------------------------------------
|
2011-02-09 00:32:15 +02:00
|
|
|
|
|
|
|
clean:
|
2011-02-11 14:42:21 +02:00
|
|
|
rm -f $(NAME).bin $(NAME).elf $(OBJS) $(OBJS:.o=.d)
|
|
|
|
|
|
|
|
# ----- Dependencies ----------------------------------------------------------
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -mmcu=$(CHIP) -Os -c $<
|
|
|
|
$(DEPEND) $< | \
|
|
|
|
sed -e \
|
|
|
|
'/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
|
|
|
|
-e '$${g;p;}' -e d >$*.d; \
|
|
|
|
[ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; }
|
|
|
|
|
|
|
|
-include $(OBJS:.o=.d)
|
|
|
|
|
|
|
|
# ----- Programming and device control ----------------------------------------
|
2011-02-09 00:32:15 +02:00
|
|
|
|
|
|
|
upload: $(NAME).bin
|
|
|
|
scp $(NAME).bin jlime:
|
|
|
|
|
|
|
|
prog:
|
2011-02-11 13:53:11 +02:00
|
|
|
ssh jlime avrdude -F -p $(CHIP) -c nanonote_atusb -e \
|
2011-02-09 00:32:15 +02:00
|
|
|
-U flash:w:$(NAME).bin:r \
|
|
|
|
-U lfuse:w:0x60:m # external clock, slow start-up
|
|
|
|
|
|
|
|
on:
|
|
|
|
ssh jlime poke 0x10010318 4
|
|
|
|
|
|
|
|
off:
|
|
|
|
ssh jlime poke 0x10010314 4
|