# # Makefile for the Embedded Controller Firmware of the XIOH board # # Note that there are multiple board variants: BOARD=XIOH_V5 or BOARD=XIOH_V6. # One "make" invocation only builds for one variant. # The build result files include $(BOARD) in their names. # # "make" generates the following files: # ECF-$(BOARD).elf # ECF-$(BOARD).lst # ECF-$(BOARD).map # ECF-$(BOARD).txt # # Note that "make clean" removes files for all board targets. # # Note that the .txt is what must be flashed and is not 100% equivalent # to the .elf: the .txt includes additionnal safety features in the form # of filling of unused areas, done by the fill_titxt.py program. # default board variant: you can override by the command line, # e.g.: "make BOARD=XIOH_V6" BOARD = XIOH_V5 BASE_TARGET = ECF TARGET = $(BASE_TARGET)-$(BOARD) MCU = msp430f2274 SOURCES = main.c serial.c ####################################################################################### CFLAGS = -mmcu=$(MCU) -D$(BOARD) -funsigned-char -g3 -O2 -Wall -Wextra ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp -Wa,-gstabs LDFLAGS = -mmcu=$(MCU) -Wl,-Map=$(TARGET).map ######################################################################################## CC = msp430-gcc LD = msp430-ld AR = msp430-ar AS = msp430-gcc GASP = msp430-gasp NM = msp430-nm OBJCOPY = msp430-objcopy OBJDUMP = msp430-objdump RANLIB = msp430-ranlib STRIP = msp430-strip SIZE = msp430-size READELF = msp430-readelf MAKETXT = srec_cat CP = cp -p RM = rm -f MV = mv ######################################################################################## # the file which will include dependencies DEPEND = $(SOURCES:.c=.$(BOARD).d) # all the object files OBJECTS = $(SOURCES:.c=.$(BOARD).o) build: $(TARGET).elf $(TARGET).txt $(TARGET).lst $(TARGET).elf: $(OBJECTS) echo "Linking $@" $(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@ echo echo ">>>> Size of Firmware <<<<" $(SIZE) $(TARGET).elf echo %.hex: %.elf $(OBJCOPY) -O ihex $< $@ %.unsafe: %.hex $(MAKETXT) -O $@ -TITXT $< -I unix2dos $@ # 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. # ./fill_titxt.py: # -n 4 -x 0xff3f: Put 4 words 3fff just before the vectors. # Each decodes as an infinite loop instruction. # -d 0x82432001: Put aligned 4382 0120 instructions # (reboot using WD) everywhere it is possible. # -w 0x0020: If word gaps remain, put 0200 instructions # there (jump next instruction). # # The goal is to make a firmware more robust in case the PC gets # corrupted. We fill most of the unprogrammed area with instructions # that will trigger a reboot (write of a bad value to WDTCTL). Just # before the vector, we put 4 single word infinite loop instructions: # this is better than double words instructions because we can't put # arbitrary words in the vector area, so if PC/2 is odd the result # will still be completely defined if we land there, 3fff is an # acceptable BSLSKEY, and the application provides a watchdog timeout. # In remaining single word spaces, we put "jmp next" instructions to # hopefully get to the next 4382 0120 instruction. # %.txt: %.unsafe ./fill_titxt.py -n 4 -x 0xff3f -d 0x82432001 -w 0x0020 -o $@ $< echo echo '>>>' echo '>>>>>>' FINAL RESULT IS IN $@ '<<<<<<' echo '>>>' echo %.lst: %.elf $(OBJDUMP) -S -d $< > $@ && $(OBJDUMP) -s -j .rodata $< >> $@ %.$(BOARD).o: %.c echo "Compiling $<" $(CC) -c $(CFLAGS) -o $@ $< # 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) %.$(BOARD).d: %.c echo "Generating dependencies $@ from $<" $(CC) -M ${CFLAGS} $< >$@ .SILENT: .PHONY: clean clean: -$(RM) *.o *.d *.elf *.hex *.map *.unsafe -$(RM) $(BASE_TARGET)*.txt $(BASE_TARGET)*.lst -$(RM) path.txt include.txt source.txt file.r43 *.dep