Makefile.isp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. # These are the parameters for a usb-based STK500v2 programmer.
  34. # Exact type unknown. (historical Makefile values.)
  35. #ISPTOOL = stk500v2
  36. #ISPPORT = usb
  37. #ISPSPEED = -b 115200
  38. #
  39. #
  40. # These are parameters for using an Arduino with the ArduinoISP sketch
  41. # as the programmer. On a mac, for a particular Uno as programmer.
  42. ISPTOOL ?= stk500v1
  43. ISPPORT ?= /dev/tty.usbserial-FTD61T6Q
  44. ISPSPEED ?= -b19200
  45. # Not all chips have EFUSE.
  46. ifdef EFUSE
  47. EFUSE_CMD= -U efuse:w:0x$(EFUSE):m
  48. endif
  49. #
  50. # avrdude commands to erase chip, unlock memory, and program fuses.
  51. #
  52. ISPFUSES = -e -u -U lock:w:0x3f:m $(EFUSE_CMD) \
  53. -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
  54. #
  55. # avrdude commands to program the new bootloader, and protect the bootloader
  56. # space from accidental SPM writes. Note: "2f" allows boot section to be read
  57. # by the application, which is different than the arduino default.
  58. #
  59. ISPFLASH = -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x2f:m
  60. # There are certain complicated caused by the fact that the default state
  61. # of a fuse is a "1" rather than a "0", especially with respect to fuse bits
  62. # that have not been implemented. Those would normally not be included, but
  63. # unimplemented fuses still default to being "1"
  64. #
  65. # the efuse should really be 0xf8; since, however, only the lower
  66. # three bits of that byte are used on the atmega168, avrdude gets
  67. # confused if you specify 1's for the higher bits, see:
  68. # http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
  69. #
  70. # similarly, the lock bits should be 0xff instead of 0x3f (to
  71. # unlock the bootloader section) and 0xcf instead of 0x2f (to
  72. # lock it), but since the high two bits of the lock byte are
  73. # unused, avrdude would get confused.
  74. isp: $(PROGRAM)_$(TARGET).hex
  75. $(AVRDUDE_ROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
  76. -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
  77. $(ISPFUSES) \
  78. $(ISPFLASH)