Makefile.isp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Makefile.isp for Optiboot
  2. # Bill Westfield (WestfW@yahoo.com) March, 2013
  3. # $Id$
  4. #
  5. # Instructions:
  6. #
  7. # This is a "daughter" Makefile that burns the bootloader using a ISP
  8. # device programmer. It is designed to inherit assorted variables from
  9. # the parent optiboot "Makefile"... Using a daughter makefile makes
  10. # certain variable manipulations more obvious.
  11. #
  12. # To burn bootloader .hex file, invoke the main Makefile using:
  13. # make diecimila_isp
  14. # make lilypad_isp
  15. # make ng_isp
  16. # etc...
  17. #
  18. #
  19. # Note: inherit paths/etc from parent Makefile.
  20. #
  21. #---------------------------------------------------------------------------
  22. #
  23. # * Copyright 2013-2015 by Bill Westfield. Part of Optiboot.
  24. # * This software is licensed under version 2 of the Gnu Public Licence.
  25. # * See optiboot.c for details.
  26. #
  27. #---------------------------------------------------------------------------
  28. # enter the parameters for the avrdude isp tool -b19200
  29. #
  30. # Inherit avrdude paths from top-level makefile
  31. AVRDUDE_ROOT ?= $(GCCROOT)
  32. AVRDUDE_CONF ?= -C$(TOOLROOT)/avr/etc/avrdude.conf
  33. # Default filename for the selected target
  34. FILENAME ?= $(PROGRAM)_$(TARGET).hex
  35. # These are the parameters for a usb-based STK500v2 programmer.
  36. # Exact type unknown. (historical Makefile values.)
  37. #ISPTOOL = stk500v2
  38. #ISPPORT = usb
  39. #ISPSPEED = -b 115200
  40. #
  41. #
  42. # These are parameters for using an Arduino with the ArduinoISP sketch
  43. # as the programmer. On a mac, for a particular Uno as programmer.
  44. ISPTOOL ?= stk500v1
  45. ISPPORT ?= /dev/tty.usbserial-FTD61T6Q
  46. ISPSPEED ?= -b19200
  47. # Not all chips have EFUSE.
  48. ifdef EFUSE
  49. EFUSE_CMD= -U efuse:w:0x$(EFUSE):m
  50. endif
  51. # Default lock fuse configuration (NO lock)
  52. LOCKFUSE ?= 2f# APP protect mode 1, BL protect mode 1
  53. #
  54. # avrdude commands to erase chip, unlock memory, and program fuses.
  55. #
  56. ISPFUSES = -e -u -U lock:w:0x$(LOCKFUSE):m $(EFUSE_CMD) \
  57. -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
  58. #
  59. # avrdude commands to program the new bootloader, and protect the bootloader
  60. # space from accidental SPM writes. Note: "2f" allows boot section to be read
  61. # by the application, which is different than the arduino default.
  62. #
  63. ISPFLASH = -U flash:w:$(FILENAME) -U lock:w:$(LOCKFUSE):m
  64. # There are certain complicated caused by the fact that the default state
  65. # of a fuse is a "1" rather than a "0", especially with respect to fuse bits
  66. # that have not been implemented. Those would normally not be included, but
  67. # unimplemented fuses still default to being "1"
  68. #
  69. # the efuse should really be 0xf8; since, however, only the lower
  70. # three bits of that byte are used on the atmega168, avrdude gets
  71. # confused if you specify 1's for the higher bits, see:
  72. # http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
  73. #
  74. # similarly, the lock bits should be 0xff instead of 0x3f (to
  75. # unlock the bootloader section) and 0xcf instead of 0x2f (to
  76. # lock it), but since the high two bits of the lock byte are
  77. # unused, avrdude would get confused.
  78. isp: $(FILENAME)
  79. $(AVRDUDE_ROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
  80. -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
  81. $(ISPFUSES) \
  82. $(ISPFLASH)