From: Kevin Rosenberg Date: Sat, 29 Mar 2008 00:21:39 +0000 (-0600) Subject: add makefile to repository; add -Wl,-relax to linker flags X-Git-Url: http://git.kpe.io/?p=avr_bc100.git;a=commitdiff_plain;h=e69ce471b5201b021291e8a406d371fc451a2ace add makefile to repository; add -Wl,-relax to linker flags --- diff --git a/BaseTinyFirmware/GCC/ChangeLog b/BaseTinyFirmware/GCC/ChangeLog index f36d807..07131e9 100644 --- a/BaseTinyFirmware/GCC/ChangeLog +++ b/BaseTinyFirmware/GCC/ChangeLog @@ -1,19 +1,25 @@ +2008-03-12 Kevin Rosenberg + * BaseTinyFirmware/GCC/avr463/Makefile: Added -Wl,-relax to linker + flags. On my system this crashes avr-ld.exe, but others have reported + a large reduction in firmware size with this option. I added this + option for others to try. + 2008-03-14 Martin Thomas - * added "volatile" to structure object and array declarations for objects - sed in main-thread and ISRs. I'm not sure about the current state of - implicitly "guaranteed" accesses in (avr-)gcc but it should be a "better - safe than sorry" extension. - * enveloped access to timer-values in timer.c to make them "atomic" since - they are unsigned long + * added "volatile" to structure object and array declarations for + objects sed in main-thread and ISRs. I'm not sure about the + current state of implicitly "guaranteed" accesses in (avr-)gcc but + it should be a "better safe than sorry" extension. + * enveloped access to timer-values in timer.c to make them + "atomic" since they are unsigned long * "atomic" access to singned int and unsigned int members of ADCS - * it maybe better to have one place to globally enable interrupts ("sei"). - Done in "initialize" now and not several times in the driver - init-functions. + * it maybe better to have one place to globally enable + interrupts ("sei"). Done in "initialize" now and not several + times in the driver init-functions. * changed some space to tab as in the original code * added header files to the AVR-Studio project workspace - * added -lm to the linker-options in the AVR Studio gcc-plugin, not - important for the basic application but might be good if someone uses the - code as a base for own developments + * added -lm to the linker-options in the AVR Studio gcc-plugin, + not important for the basic application but might be good if + someone uses the ode as a base for own developments 2008-03-12 Kevin Rosenberg * Initial GCC port performed and compiles without error diff --git a/BaseTinyFirmware/GCC/avr463/Makefile b/BaseTinyFirmware/GCC/avr463/Makefile new file mode 100644 index 0000000..44c49e4 --- /dev/null +++ b/BaseTinyFirmware/GCC/avr463/Makefile @@ -0,0 +1,108 @@ +############################################################################### +# Makefile for the project avr463 +############################################################################### + +## General Flags +PROJECT = avr463 +MCU = attiny861 +TARGET = avr463.elf +CC = avr-gcc.exe + +## Options common to compile, link and assembly rules +COMMON = -mmcu=$(MCU) + +## Compile options common for all C compilation units. +CFLAGS = $(COMMON) +CFLAGS += -Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -DNIMH +CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d + +## Assembly specific flags +ASMFLAGS = $(COMMON) +ASMFLAGS += $(CFLAGS) +ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2 + +## Linker flags +LDFLAGS = $(COMMON) +LDFLAGS += -Wl,-Map=avr463.map -Wl,-relax + + +## Intel Hex file production flags +HEX_FLASH_FLAGS = -R .eeprom + +HEX_EEPROM_FLAGS = -j .eeprom +HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load" +HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings + + +## Libraries +LIBS = -lm + +## Objects that must be built in order to link +OBJECTS = ADC.o battery.o chargefunc.o main.o menu.o NIMHcharge.o OWI.o PWM.o statefunc.o time.o USI.o + +## Objects explicitly added by the user +LINKONLYOBJECTS = + +## Build +all: $(TARGET) avr463.hex avr463.eep avr463.lss size + +## Compile +ADC.o: ../ADC.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +battery.o: ../battery.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +chargefunc.o: ../chargefunc.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +main.o: ../main.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +menu.o: ../menu.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +NIMHcharge.o: ../NIMHcharge.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +OWI.o: ../OWI.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +PWM.o: ../PWM.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +statefunc.o: ../statefunc.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +time.o: ../time.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +USI.o: ../USI.c + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +##Link +$(TARGET): $(OBJECTS) + $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET) + +%.hex: $(TARGET) + avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@ + +%.eep: $(TARGET) + -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0 + +%.lss: $(TARGET) + avr-objdump -h -S $< > $@ + +size: ${TARGET} + @echo + @avr-size -C --mcu=${MCU} ${TARGET} + +## Clean target +.PHONY: clean +clean: + -rm -rf $(OBJECTS) avr463.elf dep avr463.hex avr463.eep avr463.lss avr463.map + + +## Other dependencies +-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*) +