1
0
mirror of https://github.com/raphnet/4nes4snes synced 2024-12-22 06:58:51 -05:00
4nes4snes/Makefile.atmega168

86 lines
2.0 KiB
Makefile
Raw Normal View History

CC=avr-gcc
AS=$(CC)
LD=$(CC)
PROGNAME=4nes4snes-m168
CPU=atmega168
CFLAGS=-Wall -Os -Iusbdrv -I. -mmcu=$(CPU) -DF_CPU=12000000L #-DDEBUG_LEVEL=1
LDFLAGS=-Wl,-Map=$(PROGNAME).map -mmcu=$(CPU)
AVRDUDE=avrdude -p m168 -P usb -c avrispmkII
OBJS=usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o fournsnes.o devdesc.o
HEXFILE=$(PROGNAME).hex
ELFFILE=$(PROGNAME).elf
# symbolic targets:
all: $(HEXFILE)
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
.S.o:
$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
# "-x assembler-with-cpp" should not be necessary since this is the default
# file type for the .S (with capital S) extension. However, upper case
# characters are not always preserved on Windows. To ensure WinAVR
# compatibility define the file type manually.
.c.s:
$(CC) $(CFLAGS) -S $< -o $@
clean:
rm -f $(HEXFILE) main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s
# file targets:
$(ELFFILE): $(OBJS)
$(LD) $(LDFLAGS) -o $(ELFFILE) $(OBJS)
$(HEXFILE): $(ELFFILE)
rm -f $(HEXFILE)
avr-objcopy -j .text -j .data -O ihex $(ELFFILE) $(HEXFILE)
./checksize $(ELFFILE)
flash: $(HEXFILE)
$(AVRDUDE) -Uflash:w:$(HEXFILE) -B 1.0
2013-04-26 08:23:38 -04:00
# Extended fuse byte (Datasheet Table 28-5)
#
# - - - - - BOOTSZ1 BOOTSZ0 BOOTRST
# 0 0 0 0 0 0 0 1
2013-04-26 08:23:38 -04:00
#
EFUSE=0x01
2013-04-26 08:23:38 -04:00
# Fuse high byte (Datasheet Table 28-6)
#
# RSTDISBL DWEN SPIEN WDTON EESAVE BODLEVEL2 BODLEVEL1 BODLEVEL0
2013-04-26 08:23:38 -04:00
# 1 1 0 1 0 1 0 1
#
HFUSE=0xd5
2013-04-26 08:23:38 -04:00
# Fuse low byte (Datasheet Table 28-7)
#
# CKDIV8 CKOUT SUT1 SUT0 CKSEL3 CKSEL2 CKSEL1 CKSEL0
# 1 1 0 1 0 1 1 1
#
2013-04-26 08:23:38 -04:00
# Full swing crystal oscillator
# 0.4 - 20 MHz : CKSEL3..1 011
#
# Crystal Oscillator, BOD enabled (Table 9-6)
# CKSEL0 : 1
# SUT1..0 : 01
#
LFUSE=0xD7
fuse:
$(AVRDUDE) -e -Uefuse:w:$(EFUSE):m -Uhfuse:w:$(HFUSE):m -Ulfuse:w:$(LFUSE):m -B 20.0 -v
chip_erase:
$(AVRDUDE) -e -B 1.0 -F
reset:
$(AVRDUDE) -B 1.0 -F