Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial, UNTESTED commit of vga-fade-in.
- Loading branch information
Marti Bolivar
committed
Sep 21, 2010
1 parent
ec2d45f
commit be5f1ba
Showing
3 changed files
with
488 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
.DEFAULT_GOAL := sketch | ||
|
||
# Valid BOARDs: maple, maple_native, ... | ||
BOARD ?= maple | ||
MEMORY_TARGET ?= flash | ||
|
||
# USB ID for DFU upload | ||
VENDOR_ID := 1EAF | ||
PRODUCT_ID := 0003 | ||
|
||
# Guess the MCU based on the BOARD (can be overridden ) | ||
ifeq ($(BOARD), maple) | ||
MCU := STM32F103RB | ||
PRODUCT_ID := 0003 | ||
endif | ||
ifeq ($(BOARD), maple_native) | ||
MCU := STM32F103ZE | ||
PRODUCT_ID := 0003 | ||
endif | ||
|
||
# Useful paths | ||
ifeq ($(LIB_MAPLE_HOME),) | ||
SRCROOT := . | ||
else | ||
SRCROOT := $(LIB_MAPLE_HOME) | ||
endif | ||
BUILD_PATH = build | ||
LIBMAPLE_PATH := $(SRCROOT)/libmaple | ||
SUPPORT_PATH := $(SRCROOT)/support | ||
|
||
# Useful variables | ||
GLOBAL_CFLAGS := -Os -g -mcpu=cortex-m3 -mthumb -march=armv7-m -nostdlib \ | ||
-ffunction-sections -fdata-sections -Wl,--gc-sections \ | ||
-DBOARD_$(BOARD) -DMCU_$(MCU) | ||
GLOBAL_CXXFLAGS := -fno-rtti -fno-exceptions -Wall -DBOARD_$(BOARD) -DMCU_$(MCU) | ||
GLOBAL_ASFLAGS := -mcpu=cortex-m3 -march=armv7-m -mthumb -DBOARD_$(BOARD) \ | ||
-DMCU_$(MCU) -x assembler-with-cpp | ||
|
||
LDDIR := $(SUPPORT_PATH)/ld | ||
LDFLAGS = -T$(LDDIR)/$(LDSCRIPT) -L$(LDDIR) \ | ||
-mcpu=cortex-m3 -mthumb -Xlinker \ | ||
--gc-sections --print-gc-sections --march=armv7-m -Wall | ||
|
||
# Set up build rules and some useful templates | ||
include $(SUPPORT_PATH)/make/build-rules.mk | ||
include $(SUPPORT_PATH)/make/build-templates.mk | ||
|
||
# Some target specific things | ||
ifeq ($(MEMORY_TARGET), ram) | ||
LDSCRIPT := $(BOARD)/ram.ld | ||
VECT_BASE_ADDR := VECT_TAB_RAM | ||
endif | ||
ifeq ($(MEMORY_TARGET), flash) | ||
LDSCRIPT := $(BOARD)/flash.ld | ||
VECT_BASE_ADDR := VECT_TAB_FLASH | ||
endif | ||
ifeq ($(MEMORY_TARGET), jtag) | ||
LDSCRIPT := $(BOARD)/jtag.ld | ||
VECT_BASE_ADDR := VECT_TAB_BASE | ||
endif | ||
|
||
# Set all submodules here | ||
LIBMAPLE_MODULES := $(SRCROOT)/libmaple | ||
LIBMAPLE_MODULES += $(SRCROOT)/wirish | ||
|
||
# call each module rules.mk | ||
$(foreach m,$(LIBMAPLE_MODULES),$(eval $(call LIBMAPLE_MODULE_template,$(m)))) | ||
|
||
# Main target | ||
include build-targets.mk | ||
|
||
.PHONY: install sketch clean help debug cscope tags ctags ram flash jtag | ||
|
||
# Target upload commands | ||
UPLOAD_ram := $(SUPPORT_PATH)/scripts/reset.py && \ | ||
sleep 1 && \ | ||
$(DFU) -a0 -d $(VENDOR_ID):$(PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R | ||
UPLOAD_flash := $(SUPPORT_PATH)/scripts/reset.py && \ | ||
sleep 1 && \ | ||
$(DFU) -a1 -d $(VENDOR_ID):$(PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R | ||
UPLOAD_jtag := $(OPENOCD) -f support/openocd/flash.cfg | ||
|
||
# conditionally upload to whatever the last build was | ||
install: INSTALL_TARGET = $(shell cat $(BUILD_PATH)/build-type 2>/dev/null) | ||
install: $(BUILD_PATH)/$(BOARD).bin | ||
@echo Install target: $(INSTALL_TARGET) | ||
$(UPLOAD_$(INSTALL_TARGET)) | ||
|
||
# Force a rebuild if the maple target changed | ||
PREV_BUILD_TYPE = $(shell cat $(BUILD_PATH)/build-type 2>/dev/null) | ||
build-check: | ||
ifneq ($(PREV_BUILD_TYPE), $(MEMORY_TARGET)) | ||
$(shell rm -rf $(BUILD_PATH)) | ||
endif | ||
|
||
sketch: build-check MSG_INFO $(BUILD_PATH)/$(BOARD).bin | ||
|
||
clean: | ||
rm -rf build | ||
|
||
help: | ||
@echo "" | ||
@echo " libmaple Makefile help" | ||
@echo " ----------------------" | ||
@echo " Compile targets (default MEMORY_TARGET=flash):" | ||
@echo " ram: Compile sketch code to ram" | ||
@echo " flash: Compile sketch code to flash" | ||
@echo " jtag: Compile sketch code to jtag" | ||
@echo " sketch: Compile sketch code to target MEMORY_TARGET" | ||
@echo " " | ||
@echo " Programming targets:" | ||
@echo " install: Upload code to target" | ||
@echo " " | ||
@echo " Other targets:" | ||
@echo " debug: Start an openocd gdb server, port 3333" | ||
@echo " clean: Remove all build and object files" | ||
@echo " help: Show this message" | ||
@echo " " | ||
|
||
debug: | ||
$(OPENOCD) -f support/openocd/run.cfg | ||
|
||
cscope: | ||
rm -rf *.cscope | ||
find . -name '*.[hcs]' -o -name '*.cpp' | xargs cscope -b | ||
|
||
tags: | ||
etags `find . -name "*.c" -o -name "*.cpp" -o -name "*.h"` | ||
@echo "Made TAGS file for EMACS code browsing" | ||
|
||
ctags: | ||
ctags-exuberant -R . | ||
@echo "Made tags file for VIM code browsing" | ||
|
||
ram: | ||
@$(MAKE) MEMORY_TARGET=ram --no-print-directory sketch | ||
|
||
flash: | ||
@$(MAKE) MEMORY_TARGET=flash --no-print-directory sketch | ||
|
||
jtag: | ||
@$(MAKE) MEMORY_TARGET=jtag --no-print-directory sketch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# main project target | ||
$(BUILD_PATH)/main.o: main.cpp | ||
$(SILENT_CXX) $(CXX) $(CFLAGS) $(CXXFLAGS) $(LIBMAPLE_INCLUDES) $(WIRISH_INCLUDES) -o $@ -c $< | ||
|
||
$(BUILD_PATH)/$(BOARD).elf: $(BUILDDIRS) $(TGT_BIN) $(BUILD_PATH)/main.o | ||
$(SILENT_LD) $(CXX) $(LDFLAGS) -o $@ $(TGT_BIN) $(BUILD_PATH)/main.o | ||
|
||
$(BUILD_PATH)/$(BOARD).bin: $(BUILD_PATH)/$(BOARD).elf | ||
$(SILENT_OBJCOPY) $(OBJCOPY) -v -Obinary $(BUILD_PATH)/$(BOARD).elf $@ 1>/dev/null | ||
$(SILENT_DISAS) $(DISAS) -d $(BUILD_PATH)/$(BOARD).elf > $(BUILD_PATH)/$(BOARD).disas | ||
@echo " " | ||
@echo "Object file sizes:" | ||
@find $(BUILD_PATH) -iname *.o | xargs $(SIZE) -t > $(BUILD_PATH)/$(BOARD).sizes | ||
@cat $(BUILD_PATH)/$(BOARD).sizes | ||
@echo " " | ||
@echo "Final Size:" | ||
@$(SIZE) $< | ||
@echo $(MEMORY_TARGET) > $(BUILD_PATH)/build-type | ||
|
||
$(BUILDDIRS): | ||
@mkdir -p $@ | ||
|
||
MSG_INFO: | ||
@echo "================================================================================" | ||
@echo "" | ||
@echo " Build info:" | ||
@echo " BOARD: " $(BOARD) | ||
@echo " MCU: " $(MCU) | ||
@echo " MEMORY_TARGET: " $(MEMORY_TARGET) | ||
@echo "" | ||
@echo " See 'make help' for all possible targets" | ||
@echo "" | ||
@echo "================================================================================" | ||
@echo | ||
|
Oops, something went wrong.