Guest User

Untitled

a guest
Jun 19th, 2012
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.23 KB | None | 0 0
  1. # Name: Makefile
  2. # Project: bootloadHID
  3. # Author: Christian Starkjohann
  4. # Creation Date: 2007-03-19
  5. # Tabsize: 4
  6. # Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
  7. # License: GNU GPL v2 (see License.txt)
  8. # This Revision: $Id: Makefile 788 2010-05-30 20:54:41Z cs $
  9.  
  10. ###############################################################################
  11. # Configure the following variables according to your AVR. The example below
  12. # is for an ATMega8. Program the device with
  13. #     make fuse    # to set the clock generator, boot section size etc.
  14. #     make flash   # to load the boot loader into flash
  15. #     make lock    # to protect the boot loader from overwriting
  16.  
  17. DEVICE = atmega168p
  18. BOOTLOADER_ADDRESS = 0x3800
  19. F_CPU = 16000000
  20. #FUSEH = 0xc0
  21. #FUSEL = 0x9f
  22. # Fuse high byte:
  23. # 0xc0 = 1 1 0 0   0 0 0 0 <-- BOOTRST (boot reset vector at 0x1800)
  24. #        ^ ^ ^ ^   ^ ^ ^------ BOOTSZ0
  25. #        | | | |   | +-------- BOOTSZ1
  26. #        | | | |   + --------- EESAVE (preserve EEPROM over chip erase)
  27. #        | | | +-------------- CKOPT (full output swing)
  28. #        | | +---------------- SPIEN (allow serial programming)
  29. #        | +------------------ WDTON (WDT not always on)
  30. #        +-------------------- RSTDISBL (reset pin is enabled)
  31. # Fuse low byte:
  32. # 0x9f = 1 0 0 1   1 1 1 1
  33. #        ^ ^ \ /   \--+--/
  34. #        | |  |       +------- CKSEL 3..0 (external >8M crystal)
  35. #        | |  +--------------- SUT 1..0 (crystal osc, BOD enabled)
  36. #        | +------------------ BODEN (BrownOut Detector enabled)
  37. #        +-------------------- BODLEVEL (2.7V)
  38.  
  39. ###############################################################################
  40.  
  41. AVRDUDE = avrdude -c stk500v2 -P avrdoper -p $(DEVICE)
  42.  
  43. LDFLAGS += -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS)
  44.  
  45. # Omit -fno-* options when using gcc 3, it does not support them.
  46. COMPILE = avr-gcc -Wall -Os -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -Iusbdrv -I. -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) -DDEBUG_LEVEL=0 # -DTEST_MODE
  47. # NEVER compile the final product with debugging! Any debug output will
  48. # distort timing so that the specs can't be met.
  49.  
  50. OBJECTS =  usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
  51.  
  52.  
  53. # symbolic targets:
  54. all:    main.hex
  55.  
  56. .c.o:
  57.     $(COMPILE) -c $< -o $@
  58.  
  59. .S.o:
  60.     $(COMPILE) -x assembler-with-cpp -c $< -o $@
  61. # "-x assembler-with-cpp" should not be necessary since this is the default
  62. # file type for the .S (with capital S) extension. However, upper case
  63. # characters are not always preserved on Windows. To ensure WinAVR
  64. # compatibility define the file type manually.
  65.  
  66. .c.s:
  67.     $(COMPILE) -S $< -o $@
  68.  
  69. flash:  all
  70.     $(AVRDUDE) -U flash:w:main.hex:i
  71.  
  72. readflash:
  73.     $(AVRDUDE) -U flash:r:read.hex:i
  74.  
  75. fuse:
  76.     $(AVRDUDE) -U hfuse:w:$(FUSEH):m -U lfuse:w:$(FUSEL):m
  77.  
  78. lock:
  79.     $(AVRDUDE) -U lock:w:0x2f:m
  80.  
  81. read_fuses:
  82.     $(UISP) --rd_fuses
  83.  
  84. clean:
  85.     rm -f main.hex main.bin *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s
  86.  
  87. # file targets:
  88. main.bin:   $(OBJECTS)
  89.     $(COMPILE) -o main.bin $(OBJECTS) $(LDFLAGS)
  90.  
  91. main.hex:   main.bin
  92.     rm -f main.hex main.eep.hex
  93.     avr-objcopy -j .text -j .data -O ihex main.bin main.hex
  94.     avr-size main.hex
  95.  
  96. disasm: main.bin
  97.     avr-objdump -d main.bin
  98.  
  99. cpp:
  100.     $(COMPILE) -E main.c
Advertisement
Add Comment
Please, Sign In to add comment