-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converted to git, reformatted code and made it compatible with recent…
… versions of avr-gcc and avr-libc Signed-off-by: Christian Kroll <[email protected]>
- Loading branch information
Showing
3 changed files
with
335 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.o | ||
*.d | ||
*.swp | ||
image.bin | ||
image_eeprom.bin | ||
image_eeprom.hex | ||
image_eeprom.srec | ||
image.elf | ||
image.hex | ||
image.lst | ||
image.map | ||
image.srec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,81 @@ | ||
MCU_TARGET=atmega8 | ||
DEFS = -DF_CPU=8000000 -DATMEGA8 | ||
# Default values | ||
OBJ = main.o | ||
OUT ?= image | ||
MCU_TARGET ?= atmega8 | ||
MCU_CC ?= avr-gcc | ||
OPTIMIZE ?= -Os | ||
WARNINGS ?= -Wall | ||
DEFS ?= -DF_CPU=16000000 | ||
CFLAGS += -MMD -g -std=c99 -mmcu=$(MCU_TARGET) $(OPTIMIZE) $(WARNINGS) $(DEFS) | ||
ASFLAGS ?= -g $(DEFS) | ||
LDFLAGS ?= -Wl,-Map,$(OUT).map | ||
|
||
OBJ = main.o | ||
# External Tools | ||
OBJCOPY ?= avr-objcopy | ||
OBJDUMP ?= avr-objdump | ||
FLASH ?= avrdude -c usbasp -p $(MCU_TARGET) -U flash:w:image.hex | ||
|
||
include ../../make/avr.mk | ||
############################################################################# | ||
# Rules | ||
all: $(OUT).elf lst text eeprom | ||
|
||
clean: | ||
rm -rf $(OUT) *.o *.d *.lst *.map $(OUT).hex $(OUT)_eeprom.hex *.bin *.srec | ||
rm -rf *.srec $(OUT).elf | ||
|
||
flash: $(OUT).hex | ||
$(FLASHCMD) | ||
|
||
############################################################################# | ||
# Building Rules | ||
$(OUT).elf: $(OBJ) | ||
$(MCU_CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) | ||
|
||
%.o: %.c | ||
$(MCU_CC) $(CFLAGS) -c $< | ||
|
||
%.o: %.S | ||
$(MCU_CC) -mmcu=$(MCU_TARGET) $(ASFLAGS) -c $< | ||
|
||
lst: $(OUT).lst | ||
|
||
%.lst: %.elf | ||
$(OBJDUMP) -h -S $< > $@ | ||
|
||
# Rules for building the .text rom images | ||
text: hex bin srec | ||
|
||
hex: $(OUT).hex | ||
bin: $(OUT).bin | ||
srec: $(OUT).srec | ||
|
||
%.hex: %.elf | ||
$(OBJCOPY) -j .text -j .data -O ihex $< $@ | ||
|
||
%.srec: %.elf | ||
$(OBJCOPY) -j .text -j .data -O srec $< $@ | ||
|
||
%.bin: %.elf | ||
$(OBJCOPY) -j .text -j .data -O binary $< $@ | ||
|
||
# Rules for building the .eeprom rom images | ||
|
||
eeprom: ehex ebin esrec | ||
|
||
ehex: $(OUT)_eeprom.hex | ||
ebin: $(OUT)_eeprom.bin | ||
esrec: $(OUT)_eeprom.srec | ||
|
||
%_eeprom.hex: %.elf | ||
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ | ||
|
||
%_eeprom.srec: %.elf | ||
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ | ||
|
||
%_eeprom.bin: %.elf | ||
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ | ||
|
||
DEPS := $(wildcard *.d) | ||
ifneq ($(DEPS),) | ||
include $(DEPS) | ||
endif |
Oops, something went wrong.