X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/1c9852b334371604476e95e9745978401941f056..HEAD:/firmware/Makefile diff --git a/firmware/Makefile b/firmware/Makefile old mode 100644 new mode 100755 index 4757c02b4..d80018f92 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -1,18 +1,57 @@ -SERIAL = `echo /dev/tty.USA19QI*` -UISP = uisp -dprog=avr910 -dserial=$(SERIAL) -dpart=auto -TARGET = atmega8 -#TARGET = at90s2313 -# The two lines above are for "uisp" and the AVR910 serial programmer connected -# to a Keyspan USB to serial converter to a Mac running Mac OS X. -# Choose your favorite programmer and interface. - -COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=$(TARGET) # -DDEBUG_LEVEL=2 - -OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o isp.o clock.o main.o - - -# symbolic targets: -all: main.hex +# +# Makefile for usbasp +# 20061119 Thomas Fischl original +# 20061120 Hanns-Konrad Unger help: and TARGET=atmega48 added +# 20140308 Peter Henn TARGET=atmega328 added +# 20140329 Peter Henn F_CPU parameter added +# + +# TARGET=atmega8 HFUSE=0xc9 LFUSE=0xef F_CPU=12000000 +# TARGET=atmega8 HFUSE=0xc9 LFUSE=0xef F_CPU=16000000 +# TARGET=atmega48 HFUSE=0xdd LFUSE=0xff +# TARGET=atmega168 HFUSE=0xdd LFUSE=0xef EFUSE=0x01 F_CPU=12000000 +# TARGET=atmega168 HFUSE=0xdd LFUSE=0xef EFUSE=0x01 F_CPU=16000000 +# TARGET=atmega168 HFUSE=0xdd LFUSE=0xe7 EFUSE=0x01 F_CPU=18000000 +# TARGET=atmega328 HFUSE=0xd9 LFUSE=0xef EFUSE=0x05 F_CPU=12000000 +# TARGET=atmega328 HFUSE=0xd9 LFUSE=0xef EFUSE=0x05 F_CPU=16000000 +# TARGET=atmega328 HFUSE=0xd9 LFUSE=0xe7 EFUSE=0x05 F_CPU=18000000 +# TARGET=at90s2313 +TARGET=atmega8 +HFUSE=0xc9 +LFUSE=0xef +F_CPU=12000000 + +# ISP=bsd PORT=/dev/parport0 +# ISP=ponyser PORT=/dev/ttyS1 +# ISP=stk500 PORT=/dev/ttyS1 +# ISP=usbasp PORT=/dev/usb/ttyUSB0 +# ISP=stk500v2 PORT=/dev/ttyUSB0 +ISP=usbasp +PORT=/dev/usb/ttyUSB0 + +help: + @echo "Usage: make same as make help" + @echo " make help same as make" + @echo " make main.hex create main.hex" + @echo " make clean remove redundant data" + @echo " make disasm disasm main" + @echo " make flash upload main.hex into flash" + @echo " make fuses program fuses" + @echo " make avrdude test avrdude" + @echo "Current values:" + @echo " TARGET=${TARGET}" + @echo " LFUSE=${LFUSE}" + @echo " HFUSE=${HFUSE}" +ifdef EFUSE + @echo " EFUSE=${EFUSE}" +endif + @echo " CLOCK=${F_CPU}" + @echo " ISP=${ISP}" + @echo " PORT=${PORT}" + +COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=$(TARGET) -DF_CPU=$(F_CPU)L # -DDEBUG_LEVEL=2 + +OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o isp.o clock.o tpi.o main.o .c.o: $(COMPILE) -c $< -o $@ @@ -48,13 +87,23 @@ disasm: main.bin cpp: $(COMPILE) -E main.c -avrdude: - avrdude -c butterfly -p $(TARGET) -U flash:w:main.hex +flash: + avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -U flash:w:main.hex fuses: - avrdude -c avr910 -p m8 -u -U hfuse:w:0xc9:m -U lfuse:w:0x9f:m +ifdef EFUSE + avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -u -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m -U efuse:w:$(EFUSE):m +else + avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -u -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m +endif + +avrdude: + avrdude -c ${ISP} -p ${TARGET} -P ${PORT} -v + -# Fuse high byte: +# Fuse setting, see http://www.engbedded.com/fusecalc +# +# Fuse atmega8 high byte HFUSE: # 0xc9 = 1 1 0 0 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 # | | | | | +-------- BOOTSZ1 @@ -63,14 +112,94 @@ fuses: # | | +---------------- SPIEN (allow serial programming) # | +------------------ WDTON (WDT not always on) # +-------------------- RSTDISBL (reset pin is enabled) -# Fuse low byte: +# Fuse atmega8 low byte LFUSE: # 0x9f = 1 0 0 1 1 1 1 1 # ^ ^ \ / \--+--/ # | | | +------- CKSEL 3..0 (external >8M crystal) # | | +--------------- SUT 1..0 (crystal osc, BOD enabled) # | +------------------ BODEN (BrownOut Detector enabled) # +-------------------- BODLEVEL (2.7V) +# +# Fuse atmega48 high byte hfuse: +# 0xdf = 1 1 0 1 1 1 1 1 factory setting +# ^ ^ ^ ^ ^ \-+-/ +# | | | | | +------ BODLEVEL (Brown out disabled) +# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) +# | | | +-------------- WDTON (WDT not always on) +# | | +---------------- SPIEN (allow serial programming) +# | +------------------ DWEN (debug wire is disabled) +# +-------------------- RSTDISBL (reset pin is enabled) +# 0xdd = ext.reset, no DW, SPI, no watchdog, no save eeprom, BOD 2.7V +# Fuse atmega48 low byte lfuse: +# 0x62 = 0 1 1 0 0 0 1 0 factory setting +# ^ ^ \ / \--+--/ +# | | | +------- CKSEL 3..0 (internal 8Mhz Oszillator) +# | | +--------------- SUT 1..0 (start-up time) +# | +------------------ CKOUT (no clock output) +# +-------------------- CKDIV8 (divide clock by 8) +# 0xdc = divide/1,no clock output,fast raising power,low Pw Oszil. 3..8 Mhz +# 0xe0 = divide/1,no clock output,fast raising power,external Oszil. +# 0xff = divide/1,no clock output,slow raising power,low Pw Oszil 8.. Mhz +# +# Fuse atmega168p high byte hfuse: +# 0xdf = 1 1 0 1 1 1 1 1 factory setting +# ^ ^ ^ ^ ^ \-+-/ +# | | | | | +------ BODLEVEL (Brown out disabled) +# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) +# | | | +-------------- WDTON (WDT not always on) +# | | +---------------- SPIEN (allow serial programming) +# | +------------------ DWEN (debug wire is disabled) +# +-------------------- RSTDISBL (reset pin is enabled) +# 0xdd = ext.reset, no DW, SPI, no watchdog, no save eeprom, BOD 2.7V +# Fuse atmega168p low byte lfuse: +# 0x62 = 0 1 1 0 0 0 1 0 factory setting +# ^ ^ \ / \--+--/ +# | | | +------- CKSEL 3..0 (internal 8Mhz Oszillator) +# | | +--------------- SUT 1..0 (start-up time) +# | +------------------ CKOUT (no clock output) +# +-------------------- CKDIV8 (divide clock by 8) +# 0xef = divide/1,no clock output,fast raising power,low Pw Oszil 8.. Mhz +# Fuse atmega168p extended byte efuse: +# 0xf9 = 1 1 1 1 1 0 0 1 factory setting +# \-+-+-+---/ ^ ^ ^---- BOOTRST (boot reset vector at 0x0000) +# ^ | +------ BOOTSZ0 +# | +-------- BOOTSZ1 +# +-------------- not used +# Note: avrdude masks not used fuse bits to zero. Therefore use only +# the lower three bits to define the BOOTSZx and BOOTRST +# +# Fuse atmega328p high byte hfuse: +# 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) +# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 +# | | | | | +-------- BOOTSZ1 +# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) +# | | | +-------------- WDTON (WDT not always on) +# | | +---------------- SPIEN (allow serial programming) +# | +------------------ DWEN (debug wire is disabled) +# +-------------------- RSTDISBL (reset pin is enabled) +# 0xd9 = ext.reset, no DW, SPI, no watchdog, no save eeprom, reset vector 0x0000 +# Fuse atmega328p low byte lfuse: +# 0x6d = 0 1 1 0 0 0 1 0 factory setting +# ^ ^ \ / \--+--/ +# | | | +------- CKSEL 3..0 (internal 8Mhz Oszillator) +# | | +--------------- SUT 1..0 (start-up time) +# | +------------------ CKOUT (no clock output) +# +-------------------- CKDIV8 (divide clock by 8) +# 0xef = divide/1,no clock output,fast raising power,low Pw Oszil 8.. Mhz +# Fuse atmega328p extended byte efuse: +# 0xff = 1 1 1 1 1 1 1 1 factory setting +# \-+-+-+---/ \-+-/ +# | +------ BODLEVEL (Brown out disabled) +# +-------------- not used +# 0xfd = BOD 2,7V +# Note: avrdude masks not used fuse bits to zero. Therefore use only +# the lower three bits to define the BOD level, here 0x05 +SERIAL = `echo /dev/tty.USA19QI*` +UISP = uisp -dprog=$S -dserial=$(SERIAL) -dpart=auto +# The two lines above are for "uisp" and the AVR910 serial programmer connected +# to a Keyspan USB to serial converter to a Mac running Mac OS X. +# Choose your favorite programmer and interface. uisp: all $(UISP) --erase