X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=rules.mk;h=83c9da5f84cd4917ff8d5908a1d3598e7b7e3893;hb=1f96edaed60def1f513ddd8adcdfa3e12b971006;hp=104031fbb27bc4568ecfd84213d2d10c817789fc;hpb=63d82fcaeb78d0764f39667b937262ed4a692c17;p=tmk_firmware.git diff --git a/rules.mk b/rules.mk index 104031f..83c9da5 100644 --- a/rules.mk +++ b/rules.mk @@ -25,8 +25,23 @@ # # make extcoff = Convert ELF to AVR Extended COFF. # -# make program = Download the hex file to the device, using avrdude. -# Please customize the avrdude settings below first! +# make program = Download the hex file to the device. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). # # make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. @@ -109,8 +124,10 @@ CFLAGS += -O$(OPT) CFLAGS += -funsigned-char CFLAGS += -funsigned-bitfields CFLAGS += -ffunction-sections +CFLAGS += -fno-inline-small-functions CFLAGS += -fpack-struct CFLAGS += -fshort-enums +CFLAGS += -fno-strict-aliasing CFLAGS += -Wall CFLAGS += -Wstrict-prototypes #CFLAGS += -mshort-calls @@ -141,6 +158,10 @@ CPPFLAGS += -funsigned-bitfields CPPFLAGS += -fpack-struct CPPFLAGS += -fshort-enums CPPFLAGS += -fno-exceptions +CPPFLAGS += -ffunction-sections +CPPFLAGS += -fdata-sections +# to supress "warning: only initialized variables can be placed into program memory area" +CPPFLAGS += -w CPPFLAGS += -Wall CPPFLAGS += -Wundef #CPPFLAGS += -mshort-calls @@ -166,6 +187,7 @@ endif # -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 +ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) ifdef CONFIG_H ASFLAGS += -include $(CONFIG_H) endif @@ -318,15 +340,16 @@ LST = $(patsubst %.c,$(OBJDIR)/%.lst,$(patsubst %.cpp,$(OBJDIR)/%.lst,$(patsubst # Compiler flags to generate dependency files. -GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d +#GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d +GENDEPFLAGS = -MMD -MP -MF .dep/$(subst /,_,$@).d # Combine all necessary flags and optional flags. # Add target processor to flags. # You can give extra flags at 'make' command line like: make EXTRAFLAGS=-DFOO=bar -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS) -ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) +ALL_CFLAGS = -mmcu=$(MCU) $(CFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) @@ -387,6 +410,34 @@ gccversion : program: $(TARGET).hex $(TARGET).eep $(PROGRAM_CMD) +teensy: $(TARGET).hex + teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex + +flip: $(TARGET).hex + batchisp -hardware usb -device $(MCU) -operation erase f + batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program + batchisp -hardware usb -device $(MCU) -operation start reset 0 + +dfu: $(TARGET).hex + dfu-programmer $(MCU) erase + dfu-programmer $(MCU) flash $(TARGET).hex + dfu-programmer $(MCU) reset + +dfu-start: + dfu-programmer $(MCU) reset + dfu-programmer $(MCU) start + +flip-ee: $(TARGET).hex $(TARGET).eep + $(COPY) $(TARGET).eep $(TARGET)eep.hex + batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase + batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program + batchisp -hardware usb -device $(MCU) -operation start reset 0 + $(REMOVE) $(TARGET)eep.hex + +dfu-ee: $(TARGET).hex $(TARGET).eep + dfu-programmer $(MCU) eeprom-flash $(TARGET).eep + dfu-programmer $(MCU) reset + # Generate avr-gdb config/init file which does the following: # define the reset signal, load the target file, connect to target, and set @@ -488,6 +539,7 @@ extcoff: $(TARGET).elf # Compile: create object files from C source files. $(OBJDIR)/%.o : %.c @echo + mkdir -p $(@D) @echo $(MSG_COMPILING) $< $(CC) -c $(ALL_CFLAGS) $< -o $@ @@ -495,6 +547,7 @@ $(OBJDIR)/%.o : %.c # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo + mkdir -p $(@D) @echo $(MSG_COMPILING_CPP) $< $(CC) -c $(ALL_CPPFLAGS) $< -o $@ @@ -512,13 +565,14 @@ $(OBJDIR)/%.o : %.cpp # Assemble: create object files from assembler source files. $(OBJDIR)/%.o : %.S @echo + mkdir -p $(@D) @echo $(MSG_ASSEMBLING) $< $(CC) -c $(ALL_ASFLAGS) $< -o $@ # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@ # Target: clean project. @@ -538,7 +592,11 @@ clean_list : $(REMOVE) $(OBJ:.o=.s) $(REMOVE) $(OBJ:.o=.i) $(REMOVE) -r .dep - $(REMOVEDIR) $(OBJDIR) + $(REMOVE) -r $(OBJDIR) + +show_path: + @echo VPATH=$(VPATH) + @echo SRC=$(SRC) # Create object files directory @@ -552,5 +610,5 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) # Listing of phony targets. .PHONY : all begin finish end sizebefore sizeafter gccversion \ build elf hex eep lss sym coff extcoff \ -clean clean_list program debug gdb-config - +clean clean_list debug gdb-config show_path \ +program teensy dfu flip dfu-ee flip-ee dfu-start