## Makefile for msp430## 'make' builds everything# 'make clean' deletes everything except source files and Makefile# 'make install' builds everything, and programs the MSP430 using MSPFLASHER# You need to set TARGET, MCU and SOURCES for your project.# TARGET is the name of the executable file to be produced# $(TARGET).elf $(TARGET).hex and $(TARGET).txt nad $(TARGET).map are all generated.# The TXT file is used for BSL loading, the ELF can be used for JTAG use#TARGET= project0
MCU= msp430f5529
# MSP430Flasher nameMSPFLASHER= MSP430Flasher
# List all the source files here# eg if you have a source file foo.c then list it hereSOURCES= main.c delay.c
# Include are located in the Include directoryINCLUDES= -IInclude
# Add or subtract whatever MSPGCC flags you want. There are plenty more#######################################################################################CFLAGS= -mmcu=$(MCU) -g -Os -Wall -Wunused $(INCLUDES)ASFLAGS= -mmcu=$(MCU) -x assembler-with-cpp -Wa,-gstabs
LDFLAGS= -mmcu=$(MCU) -Wl,-Map=$(TARGET).map
########################################################################################CC= msp430-elf-gcc
LD= msp430-elf-ld
AR= msp430-elf-ar
AS= msp430-elf-gcc
NM= msp430-elf-nm
OBJCOPY= msp430-elf-objcopy
RANLIB= msp430-elf-ranlib
STRIP= msp430-elf-strip
SIZE= msp430-elf-size
READELF= msp430-elf-readelf
MAKETXT= srec_cat
CP= cp -p
RM= rm -f
MV= mv
######################################################################################### the file which will include dependenciesDEPEND=$(SOURCES:.c=.d)# all the object filesOBJECTS=$(SOURCES:.c=.o)all:$(TARGET).elf$(TARGET).hex$(TARGET).txt$(TARGET).elf:$(OBJECTS)echo"Linking $@"$(CC)$(OBJECTS)$(LDFLAGS)$(LIBS) -o $@echoecho">>>> Size of Firmware <<<<"$(SIZE)$(TARGET).elf
echo%.hex: %.elf$(OBJCOPY) -O ihex $< $@%.txt: %.hex$(MAKETXT) -O $@ -TITXT $< -I
unix2dos $(TARGET).txt
# The above line is required for the DOS based TI BSL tool to be able to read the txt file generated from linux/unix systems.%.o: %.cecho"Compiling $<"$(CC) -c $(CFLAGS) -o $@ $<
# rule for making assembler source listing, to see the code%.lst: %.c$(CC) -c $(ASFLAGS) -Wa,-anlhd $< > $@# include the dependencies unless we're going to clean, then forget about them.ifneq ($(MAKECMDGOALS), clean)-include $(DEPEND)endif# dependencies file# includes also considered, since some of these are our own# (otherwise use -MM instead of -M)%.d: %.cecho"Generating dependencies $@ from $<"$(CC) -M ${CFLAGS} $< >$@.SILENT:.PHONY:cleanclean: -$(RM)$(OBJECTS) -$(RM)$(TARGET).*
-$(RM)$(SOURCES:.c=.lst) -$(RM)$(DEPEND)install:$(TARGET).txt$(MSPFLASHER) -n $(MCU) -w "$(TARGET).txt" -v -z [VCC]
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.