174 lines
7.5 KiB
Plaintext
174 lines
7.5 KiB
Plaintext
##############################################################################
|
|
# #
|
|
# Teacup - Lean and efficient firmware for RepRap printers #
|
|
# #
|
|
# by Triffid Hunter, Traumflug, jakepoz, many others. #
|
|
# #
|
|
# This firmware is Copyright (c) ... #
|
|
# 2009 - 2010 Michael Moon aka Triffid_Hunter #
|
|
# 2010 - 2013 Markus "Traumflug" Hitter <mah@jump-ing.de> #
|
|
# #
|
|
# 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. #
|
|
# #
|
|
# This program is distributed in the hope that it will be useful, #
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
# GNU General Public License for more details. #
|
|
# #
|
|
# You should have received a copy of the GNU General Public License #
|
|
# along with this program; if not, write to the Free Software #
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
|
|
# #
|
|
##############################################################################
|
|
|
|
##############################################################################
|
|
# #
|
|
# Makefile for ARM targets. Use it with #
|
|
# #
|
|
# make -f Makefile-ARM #
|
|
# #
|
|
# or copy/link it to Makefile for convenience. #
|
|
# #
|
|
##############################################################################
|
|
|
|
##############################################################################
|
|
# #
|
|
# Change these to suit your hardware #
|
|
# #
|
|
##############################################################################
|
|
|
|
MCU ?= lpc1114
|
|
# MCU ?= atmega328p
|
|
# MCU ?= atmega644
|
|
# MCU ?= atmega1284p
|
|
# MCU ?= atmega1280
|
|
# MCU ?= atmega2560
|
|
# MCU ?= at90usb1286
|
|
# MCU ?= atmega32u4
|
|
|
|
# CPU clock rate not defined here, but in the CMSIS headers.
|
|
|
|
##############################################################################
|
|
# #
|
|
# Where to find your compiler and linker. Later, this is completed like #
|
|
# CC = $(TOOLCHAIN)gcc #
|
|
# #
|
|
##############################################################################
|
|
|
|
TOOLCHAIN = arm-none-eabi-
|
|
# TOOLCHAIN = <path-to-arduino-folder>/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-
|
|
|
|
##############################################################################
|
|
# #
|
|
# Programmer settings for "make program" #
|
|
# #
|
|
##############################################################################
|
|
|
|
# Unlike with AVR, there is no one tool for uploading to all chips. Some
|
|
# need 'lpc21isp', others (e.g. Arduinos) need 'bossac'.
|
|
#
|
|
# To deal with this, we simply define the port here and do the rest directly
|
|
# in the rules for the 'program' target.
|
|
|
|
# Frequency of the on-chip R/C oscillator or the on-board quartz crystal.
|
|
F_CRYSTAL ?= 12000000
|
|
|
|
# Serial port the electronics is connected to.
|
|
UPLOADER_PORT ?= /dev/ttyUSB0
|
|
#UPLOADER_PORT ?= /dev/ttyACM0
|
|
#UPLOADER_PORT ?= com1
|
|
|
|
##############################################################################
|
|
# #
|
|
# Below here, defaults should be ok. #
|
|
# #
|
|
##############################################################################
|
|
|
|
PROGRAM = teacup
|
|
|
|
# The thing we build by default, and also the thing we clean.
|
|
TARGET = $(PROGRAM).hex
|
|
|
|
# Arduino IDE takes the "compile everything available"-approach, so we have
|
|
# to keep this working and can take a shortcut:
|
|
#SOURCES = $(wildcard *.c)
|
|
# Until the generic ARM port is completed, we'd have to wrap all sources
|
|
# in #ifdef __AVR__. To avoid this, build only a selection for now:
|
|
SOURCES = mendel.c cpu.c serial.c
|
|
SOURCES += mbed-serial_api.c mbed-pinmap.c mbed-pinmap_common.c mbed-error.c
|
|
ifeq ($(MCU), lpc1114)
|
|
SOURCES += mbed-system_LPC11xx.c
|
|
endif
|
|
|
|
# Other target MCU specific adjustments:
|
|
|
|
# Startup definitions. Not target MCU specific.
|
|
CFLAGS = -D__STARTUP_CLEAR_BSS -D__START=main
|
|
ifeq ($(MCU), lpc1114)
|
|
CFLAGS += -mthumb -mcpu=cortex-m0
|
|
CFLAGS += -mtune=cortex-m0
|
|
CFLAGS += -D__ARM_LPC1114__
|
|
endif
|
|
# Other options ...
|
|
CFLAGS += -Wall
|
|
CFLAGS += -Wstrict-prototypes
|
|
CFLAGS += -Os
|
|
CFLAGS += -flto
|
|
CFLAGS += -ffunction-sections
|
|
CFLAGS += -fdata-sections
|
|
# Until we're done with basic porting ...
|
|
CFLAGS += -D__ARMEL_NOTYET__
|
|
|
|
LDFLAGS = --specs=nano.specs
|
|
LDFLAGS += --specs=nosys.specs
|
|
ifeq ($(MCU), lpc1114)
|
|
LDFLAGS += -T arm-lpc1114.ld
|
|
endif
|
|
LDFLAGS += -Wl,--as-needed
|
|
LDFLAGS += -Wl,--gc-sections
|
|
|
|
LIBS = -lm
|
|
|
|
-include Makefile-common
|
|
|
|
# Architecture specific targets
|
|
|
|
.PHONY: all program size
|
|
|
|
all: $(PROGRAM).hex $(BUILDDIR)/$(PROGRAM).lst $(BUILDDIR)/$(PROGRAM).sym size
|
|
|
|
program: $(PROGRAM).hex config.h
|
|
@echo
|
|
@echo "To let the bootloader complete his work, connect now PIO0_1 to GND,"
|
|
@echo "then press Reset for a moment. The bootloader should begin uploading."
|
|
@echo "After being done, disconnect PIO0_1 and press reset again. On a"
|
|
@echo "Gen7-ARM, PIO0_1 is the Step pin of the Z stepper driver."
|
|
@echo
|
|
lpc21isp -control $< $(UPLOADER_PORT) 115200 $(F_CRYSTAL)
|
|
|
|
$(BUILDDIR)/teacup.elf: $(BUILDDIR)/startup.o
|
|
|
|
$(BUILDDIR)/startup.o: arm-startup_lpc11xx.s | $(BUILDDIR)
|
|
@echo " CC $@"
|
|
@$(CC) -c $(CFLAGS) -o $@ $<
|
|
|
|
## Interpret TARGET section sizes wrt different ARM chips
|
|
## Usage: $(call show_size,section-name,section-regex,lpc1114-size-in-k)
|
|
define show_size
|
|
@$(OBJDUMP) -h $^ | \
|
|
perl -MPOSIX -ne \
|
|
'/.($2)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; \
|
|
END { printf " %-7s: %5d bytes %3d%%\n", "$1", $$a, \
|
|
ceil($$a * 100 / ($3 * 1024)), \
|
|
}'
|
|
endef
|
|
|
|
size: $(BUILDDIR)/$(PROGRAM).elf
|
|
@echo " SIZES ARM... lpc1114"
|
|
$(call show_size,FLASH,text,32)
|
|
$(call show_size,RAM,data|bss,4)
|
|
$(call show_size,EEPROM,eeprom,0.0001)
|