add makefile to repository; add -Wl,-relax to linker flags
authorKevin Rosenberg <kevin@rosenberg.net>
Sat, 29 Mar 2008 00:21:39 +0000 (18:21 -0600)
committerKevin Rosenberg <kevin@rosenberg.net>
Sat, 29 Mar 2008 00:21:39 +0000 (18:21 -0600)
BaseTinyFirmware/GCC/ChangeLog
BaseTinyFirmware/GCC/avr463/Makefile [new file with mode: 0644]

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