Makefile 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. # Makefile for ATmegaBOOT
  2. # E.Lins, 18.7.2005
  3. # $Id$
  4. #
  5. # Instructions
  6. #
  7. # To make bootloader .hex file:
  8. # make diecimila
  9. # make lilypad
  10. # make ng
  11. # etc...
  12. #
  13. # To burn bootloader .hex file:
  14. # make diecimila_isp
  15. # make lilypad_isp
  16. # make ng_isp
  17. # etc...
  18. #
  19. # Edit History
  20. # 201406xx: WestfW: More Makefile restructuring.
  21. # Split off Makefile.1284, Makefile.extras, Makefile.custom
  22. # So that in theory, the main Makefile contains only the
  23. # official platforms, and does not need to be modified to
  24. # add "less supported" chips and boards.
  25. # 201303xx: WestfW: Major Makefile restructuring.
  26. # Allows options on Make command line "make xx LED=B3"
  27. # (see also pin_defs.h)
  28. # Divide into "chip" targets and "board" targets.
  29. # Most boards are (recursive) board targets with options.
  30. # Move isp target to separate makefile (fixes m8 EFUSE)
  31. # Some (many) targets will now be rebuilt when not
  32. # strictly necessary, so that options will be included.
  33. # (any "make" with options will always compile.)
  34. # Set many variables with ?= so they can be overridden
  35. # Use arduinoISP settings as default for ISP targets
  36. #
  37. #
  38. # * Copyright 2013-2015 by Bill Westfield. Part of Optiboot.
  39. # * This software is licensed under version 2 of the Gnu Public Licence.
  40. # * See optiboot.c for details.
  41. HELPTEXT = "\n"
  42. #----------------------------------------------------------------------
  43. #
  44. # program name should not be changed...
  45. PROGRAM = optiboot
  46. # The default behavior is to build using tools that are in the users
  47. # current path variables, but we can also build using an installed
  48. # Arduino user IDE setup, or the Arduino source tree.
  49. # Uncomment this next lines to build within the arduino environment,
  50. # using the arduino-included avrgcc toolset (mac and pc)
  51. # ENV ?= arduino
  52. # ENV ?= arduinodev
  53. # OS ?= macosx
  54. # OS ?= windows
  55. # export symbols to recursive makes (for ISP)
  56. export
  57. # defaults
  58. MCU_TARGET = atmega644p
  59. BIGBOOT = 0
  60. BOOT_ON_POR = 1
  61. #APP_ON_EXTR = 0
  62. TIMEOUT = 4
  63. UART = 1
  64. SINGLESPEED = 0
  65. BAUD_RATE = 230400
  66. LED_DATA_FLASH = 0
  67. AVR_FREQ = 7372800L
  68. LED = A6
  69. LED_START_ON = 1
  70. LED_START_FLASHES = 0
  71. LDSECTIONS = -Wl,-Tlink_optiboot.ld
  72. all: atmega644p
  73. # Build environments
  74. # Start of some ugly makefile-isms to allow optiboot to be built
  75. # in several different environments. See the README.TXT file for
  76. # details.
  77. # default
  78. fixpath = $(1)
  79. SH := bash
  80. ifeq ($(ENV), arduino)
  81. # For Arduino, we assume that we're connected to the optiboot directory
  82. # included with the arduino distribution, which means that the full set
  83. # of avr-tools are "right up there" in standard places.
  84. # (except that in 1.5.x, there's an additional level of "up")
  85. TESTDIR := $(firstword $(wildcard ../../../tools/*))
  86. ifeq (,$(TESTDIR))
  87. # Arduino 1.5.x tool location compared to optiboot dir
  88. TOOLROOT = ../../../../tools
  89. else
  90. # Arduino 1.0 (and earlier) tool location
  91. TOOLROOT = ../../../tools
  92. endif
  93. GCCROOT = $(TOOLROOT)/avr/bin/
  94. ifeq ($(OS), windows)
  95. # On windows, SOME of the tool paths will need to have backslashes instead
  96. # of forward slashes (because they use windows cmd.exe for execution instead
  97. # of a unix/mingw shell?) We also have to ensure that a consistent shell
  98. # is used even if a unix shell is installed (ie as part of WINAVR)
  99. fixpath = $(subst /,\,$1)
  100. SHELL = cmd.exe
  101. SH = sh
  102. endif
  103. else ifeq ($(ENV), arduinodev)
  104. # Arduino IDE source code environment. Use the unpacked compilers created
  105. # by the build (you'll need to do "ant build" first.)
  106. ifeq ($(OS), macosx)
  107. TOOLROOT = ../../../../build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools
  108. endif
  109. ifeq ($(OS), windows)
  110. TOOLROOT = ../../../../build/windows/work/hardware/tools
  111. endif
  112. GCCROOT = $(TOOLROOT)/avr/bin/
  113. AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
  114. else
  115. GCCROOT =
  116. AVRDUDE_CONF =
  117. endif
  118. STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
  119. STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
  120. -lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
  121. STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
  122. #
  123. # End of build environment code.
  124. OBJ = $(PROGRAM).o
  125. OPTIMIZE = -Os -fno-split-wide-types -mrelax
  126. # GCC 15+ needs -mno-call-main, otherwise linking fails against newer
  127. # binutils: main is placed directly in .init9 (optiboot never returns from
  128. # it), so the libc __call_main/exit startup sequence this flag suppresses
  129. # is neither needed nor safely relocatable here.
  130. ifeq ($(shell echo 'int main(void){return 0;}' | $(GCCROOT)avr-gcc -mmcu=atmega328p -mno-call-main -x c -c -o /dev/null - 2>/dev/null; echo $$?),0)
  131. OPTIMIZE += -mno-call-main
  132. endif
  133. DEFS =
  134. CC = $(GCCROOT)avr-gcc
  135. # Override is only needed by avr-lib build system.
  136. HELPTEXT += "Option AVR_FREQ=<n> - Clock rate of AVR CPU\n"
  137. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
  138. override LDFLAGS = $(LDSECTIONS) -Wl,--relax -nostartfiles
  139. OBJCOPY = $(GCCROOT)avr-objcopy
  140. OBJDUMP = $(call fixpath,$(GCCROOT)avr-objdump)
  141. SIZE = $(GCCROOT)avr-size
  142. #
  143. # Make command-line Options.
  144. # Permit commands like "make atmega328 LED_START_FLASHES=10" to pass the
  145. # appropriate parameters ("-DLED_START_FLASHES=10") to gcc
  146. #
  147. ifdef PRODUCTION
  148. ifneq ($(PRODUCTION),0)
  149. VERSION_CMD = -DPRODUCTION=1
  150. endif
  151. dummy = FORCE
  152. endif
  153. HELPTEXT += "Option CUSTOM_VERSION=nn - set a customer version number\n"
  154. ifdef CUSTOM_VERSION
  155. ifneq ($(CUSTOM_VERSION), 0)
  156. VERSION_CMD = -DOPTIBOOT_CUSTOMVER=$(CUSTOM_VERSION)
  157. else
  158. VERSION_CMD = -DPRODUCTION=1
  159. endif
  160. dummy = FORCE
  161. endif
  162. HELPTEXT += "Option BAUD_RATE=nnnn - set the bit rate for communications\n"
  163. ifdef BAUD_RATE
  164. BAUD_RATE_CMD = -DBAUD_RATE=$(BAUD_RATE)
  165. dummy = FORCE
  166. else
  167. BAUD_RATE_CMD = -DBAUD_RATE=115200
  168. endif
  169. HELPTEXT += "Option LED=B3 - set LED pin to particular port/bit\n"
  170. ifdef LED
  171. LED_CMD = -DLED=$(LED)
  172. dummy = FORCE
  173. endif
  174. HELPTEXT += "Option LED_START_FLASHES=n - set number of LED flashes when bootloader starts\n"
  175. ifdef LED_START_FLASHES
  176. LED_START_FLASHES_CMD = -DLED_START_FLASHES=$(LED_START_FLASHES)
  177. dummy = FORCE
  178. else
  179. LED_START_FLASHES_CMD = -DLED_START_FLASHES=3
  180. endif
  181. HELPTEXT += "Option LED_DATA_FLASH=1 - flash the LED each time data is received.\n"
  182. ifdef LED_DATA_FLASH
  183. ifneq ($(LED_DATA_FLASH), 0)
  184. LED_DATA_FLASH_CMD = -DLED_DATA_FLASH=1
  185. dummy = FORCE
  186. endif
  187. endif
  188. HELPTEXT += "Option LED_START_ON=1 - Turn the LED on at bootload start\n"
  189. ifdef LED_START_ON
  190. ifneq ($(LED_START_ON), 0)
  191. LED_START_ON_CMD = -DLED_START_ON=1
  192. endif
  193. dummy = FORCE
  194. endif
  195. HELPTEXT += "Option BIGBOOT=1 - enable extra features up to 1kbytes\n"
  196. # BIGBOOT: Include extra features, up to 1K.
  197. ifdef BIGBOOT
  198. ifneq ($(BIGBOOT), 0)
  199. BIGBOOT_CMD = -DBIGBOOT=1
  200. dummy = FORCE
  201. endif
  202. endif
  203. HELPTEXT += "Option SUPPORT_EEPROM=1 - Include code to read/write EEPROM\n"
  204. ifdef SUPPORT_EEPROM
  205. ifneq ($(SUPPORT_EEPROM), 0)
  206. SUPPORT_EEPROM_CMD = -DSUPPORT_EEPROM
  207. dummy = FORCE
  208. endif
  209. endif
  210. HELPTEXT += "Option SOFT_UART=1 - use a software (bit-banged) UART\n"
  211. ifdef SOFT_UART
  212. ifneq ($(SOFT_UART), 0)
  213. SOFT_UART_CMD = -DSOFT_UART=1
  214. dummy = FORCE
  215. endif
  216. endif
  217. HELPTEXT += "Option SOFTTX=B5 - pin for software UART xmit \n"
  218. ifdef SOFTTX
  219. SOFT_UART_CMD += -DSOFTTX=$(SOFTTX)
  220. dummy = FORCE
  221. endif
  222. HELPTEXT += "Option SOFTRX=B6 - pin for software UART receive\n"
  223. ifdef SOFTRX
  224. SOFT_UART_CMD += -DSOFTRX=$(SOFTRX)
  225. dummy = FORCE
  226. endif
  227. HELPTEXT += "Option SINGLESPEED=1 - do not use U2X mode on UART\n"
  228. ifdef SINGLESPEED
  229. ifneq ($(SINGLESPEED), 0)
  230. SS_CMD = -DSINGLESPEED=1
  231. endif
  232. endif
  233. HELPTEXT += "Option RS485=B0 - Pin for optional rs485 tx enable\n"
  234. ifdef RS485
  235. RS485_CMD = -DRS485=$(RS485)
  236. dummy = FORCE
  237. endif
  238. HELPTEXT += "Option NO_APP_SPM=1 - disallow application call of do_spm\n"
  239. ifdef NO_APP_SPM
  240. ifneq ($(NO_APP_SPM),0)
  241. APPSPM_CMD = -DAPP_NOSPM=1
  242. endif
  243. endif
  244. HELPTEXT += "Option OSCCAL_VALUE=nnn - set set OSCCAL_VALUE in bootloader\n"
  245. ifdef OSCCAL_VALUE
  246. OSCCAL_VALUE_CMD = -DOSCCAL_VALUE=$(OSCCAL_VALUE)
  247. dummy = FORCE
  248. endif
  249. HELPTEXT += "Option BOOT_ON_POR - Run bootloader on power-on\n"
  250. ifdef NO_START_APP_ON_POR
  251. ifneq ($(NO_START_APP_ON_POR),0)
  252. POR_CMD = -DNO_START_APP_ON_POR=1
  253. dummy = FORCE
  254. endif
  255. endif
  256. ifdef BOOT_ON_POR
  257. ifneq ($(NO_START_APP_ON_POR),0)
  258. POR_CMD = -DNO_START_APP_ON_POR=1
  259. dummy = FORCE
  260. endif
  261. endif
  262. HELPTEXT += "Option APP_ON_EXTR - Run App on External Reset\n"
  263. ifdef START_APP_ON_EXTR
  264. ifneq ($(START_APP_ON_EXTR),0)
  265. EXTR_CMD = -DSTART_APP_ON_EXTR=1
  266. dummy = FORCE
  267. endif
  268. endif
  269. ifdef APP_ON_EXTR
  270. ifneq ($(START_APP_ON_EXTR),0)
  271. EXTR_CMD = -DSTART_APP_ON_EXTR=1
  272. dummy = FORCE
  273. endif
  274. endif
  275. COMMON_OPTIONS = $(BAUD_RATE_CMD) $(LED_START_FLASHES_CMD) $(BIGBOOT_CMD)
  276. COMMON_OPTIONS += $(SOFT_UART_CMD) $(LED_DATA_FLASH_CMD) $(LED_CMD) $(SS_CMD)
  277. COMMON_OPTIONS += $(SUPPORT_EEPROM_CMD) $(LED_START_ON_CMD) $(APPSPM_CMD)
  278. COMMON_OPTIONS += $(OSCCAL_VALUE_CMD) $(VERSION_CMD) $(TIMEOUT_CMD)
  279. COMMON_OPTIONS += $(POR_CMD) $(EXTR_CMD) $(RS485_CMD)
  280. #UART is handled separately and only passed for devices with more than one.
  281. HELPTEXT += "Option UART=n - use UARTn for communications\n"
  282. ifdef UART
  283. UART_CMD = -DUART=$(UART)
  284. endif
  285. ifdef UARTTX
  286. UART_CMD = -DUARTTX=$(UARTTX)
  287. endif
  288. HELPTEXT += "Option TIMEOUT=n - set WDT to 1, 2, 4, or 8 seconds\n"
  289. ifdef TIMEOUT
  290. TIMEOUT_CMD = -DWDTTIME=$(TIMEOUT)
  291. dummy = FORCE
  292. endif
  293. .PRECIOUS: %.elf
  294. #---------------------------------------------------------------------------
  295. # "Chip-level Platform" targets.
  296. # A "Chip-level Platform" compiles for a particular chip, but probably does
  297. # not have "standard" values for things like clock speed, LED pin, etc.
  298. # Makes for chip-level platforms should usually explicitly define their
  299. # options like: "make atmega1285 AVR_FREQ=16000000L LED=D0"
  300. #---------------------------------------------------------------------------
  301. #
  302. # Note about fuses:
  303. # the efuse should really be 0xf8; since, however, only the lower
  304. # three bits of that byte are used on the atmega168, avrdude gets
  305. # confused if you specify 1's for the higher bits, see:
  306. # http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
  307. #
  308. # similarly, the lock bits should be 0xff instead of 0x3f (to
  309. # unlock the bootloader section) and 0xcf instead of 0x2f (to
  310. # lock it), but since the high two bits of the lock byte are
  311. # unused, avrdude would get confused.
  312. #---------------------------------------------------------------------------
  313. #
  314. HELPTEXT += "\n-------------\n\n"
  315. # Test platforms
  316. # Virtual boot block test
  317. HELPTEXT += "target virboot8 - ATmega8 with virtual boot partition\n"
  318. virboot8: TARGET = atmega8
  319. virboot8: MCU_TARGET = atmega8
  320. virboot8: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-Dsave_vect_num=EE_RDY_vect_num'
  321. virboot8: AVR_FREQ ?= 16000000L
  322. virboot8: $(PROGRAM)_virboot8.hex
  323. ifndef PRODUCTION
  324. virboot8: $(PROGRAM)_virboot8.lst
  325. endif
  326. HELPTEXT += "target virboot328p - ATmega328 with virtual boot partition\n"
  327. virboot328: TARGET = atmega328
  328. virboot328: MCU_TARGET = atmega328p
  329. virboot328: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION'
  330. virboot328: AVR_FREQ ?= 16000000L
  331. virboot328: $(PROGRAM)_virboot328.hex
  332. ifndef PRODUCTION
  333. virboot328: $(PROGRAM)_virboot328.lst
  334. endif
  335. virboot328_isp: virboot328
  336. virboot328_isp: TARGET = virboot328
  337. virboot328_isp: MCU_TARGET = atmega328p
  338. # no boot section, SPIEN
  339. virboot328_isp: HFUSE ?= DF
  340. # Low power xtal (16MHz) 16KCK/14CK+65ms
  341. virboot328_isp: LFUSE ?= FF
  342. # 2.7V brownout
  343. virboot328_isp: EFUSE ?= FD
  344. virboot328_isp: isp
  345. virboot8_isp: virboot8
  346. virboot8_isp: TARGET = virboot8
  347. virboot8_isp: MCU_TARGET = atmega8
  348. # SPIEN, CKOPT (for full swing xtal), boot section 1k
  349. # Note that we need boot section to include our SPM instructions,
  350. # even though we do not enable BOOTRST
  351. virboot8_isp: HFUSE ?= CB
  352. # 2.7V brownout, 16MHz Xtal, 16KCK/14CK+65ms
  353. virboot8_isp: LFUSE ?= BF
  354. virboot8_isp: isp
  355. # Diecimila, Duemilanove with m168, and NG use identical bootloaders
  356. # Call it "atmega168" for generality and clarity, keep "diecimila" for
  357. # backward compatibility of makefile
  358. # ATmega8
  359. #
  360. HELPTEXT += "target atmega8 - ATmega8, ATmega8A, ATmega8L\n"
  361. atmega8: TARGET = atmega8
  362. atmega8: MCU_TARGET = atmega8
  363. atmega8: CFLAGS += $(COMMON_OPTIONS)
  364. atmega8: AVR_FREQ ?= 16000000L
  365. atmega8: $(PROGRAM)_atmega8.hex
  366. ifndef PRODUCTION
  367. atmega8: $(PROGRAM)_atmega8.lst
  368. endif
  369. atmega8_isp: atmega8
  370. atmega8_isp: TARGET = atmega8
  371. atmega8_isp: MCU_TARGET = atmega8
  372. ifndef BIGBOOT
  373. # SPIEN, CKOPT (for full swing xtal), Bootsize=512B
  374. atmega8_isp: HFUSE ?= CC
  375. else
  376. # SPIEN, CKOPT (for full swing xtal), Bootsize=1024B
  377. atmega8_isp: HFUSE ?= CA
  378. endif
  379. # 2.7V brownout, 16MHz Xtal, 16KCK/14CK+65ms
  380. atmega8_isp: LFUSE ?= BF
  381. atmega8_isp: isp
  382. HELPTEXT += "target atmega168* - ATmega168/A, ATmega168P, ATMEGA1268PB\n"
  383. atmega168: TARGET = atmega168
  384. atmega168: MCU_TARGET = atmega168
  385. atmega168: CFLAGS += $(COMMON_OPTIONS)
  386. atmega168: AVR_FREQ ?= 16000000L
  387. atmega168: $(PROGRAM)_atmega168.hex
  388. ifndef PRODUCTION
  389. atmega168: $(PROGRAM)_atmega168.lst
  390. endif
  391. atmega168_isp: atmega168
  392. atmega168_isp: TARGET = atmega168
  393. # 2.7V brownout
  394. atmega168_isp: HFUSE ?= DD
  395. # Full swing (16MHz) 16KCK/14CK+65ms
  396. atmega168_isp: LFUSE ?= F7
  397. ifndef BIGBOOT
  398. # 512 byte boot
  399. atmega168_isp: EFUSE ?= FC
  400. else
  401. # 1024byte boot
  402. atmega168_isp: EFUSE ?= FA
  403. endif
  404. atmega168_isp: isp
  405. HELPTEXT += "target atmega328* - ATmega328, ATmega328p, ATmega328pb\n"
  406. atmega328: TARGET = atmega328
  407. atmega328: MCU_TARGET = atmega328p
  408. atmega328: CFLAGS += $(COMMON_OPTIONS)
  409. atmega328: AVR_FREQ ?= 16000000L
  410. atmega328: $(PROGRAM)_atmega328.hex
  411. ifndef PRODUCTION
  412. atmega328: $(PROGRAM)_atmega328.lst
  413. endif
  414. atmega328_isp: atmega328
  415. atmega328_isp: TARGET = atmega328
  416. atmega328_isp: MCU_TARGET = atmega328p
  417. ifndef BIGBOOT
  418. # 512 byte boot, SPIEN
  419. atmega328_isp: HFUSE ?= DE
  420. else
  421. # 1k byte boot, SPIEN
  422. atmega328_isp: HFUSE ?= DC
  423. endif
  424. # Low power xtal (16MHz) 16KCK/14CK+65ms
  425. atmega328_isp: LFUSE ?= FF
  426. # 2.7V brownout
  427. atmega328_isp: EFUSE ?= FD
  428. atmega328_isp: isp
  429. #Atmega1280
  430. #HELPTEXT += "target atmega1280 - ATmega1280 (100pin, 128k)\n"
  431. atmega1280: MCU_TARGET = atmega1280
  432. atmega1280: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
  433. atmega1280: AVR_FREQ ?= 16000000L
  434. atmega1280: $(PROGRAM)_atmega1280.hex
  435. ifndef PRODUCTION
  436. atmega1280: $(PROGRAM)_atmega1280.lst
  437. endif
  438. #---------------------------------------------------------------------------
  439. # "Board-level Platform" targets.
  440. # A "Board-level Platform" implies a manufactured platform with a particular
  441. # AVR_FREQ, LED, and so on. Parameters are not particularly changable from
  442. # the "make" command line.
  443. # Most of the board-level platform builds should envoke make recursively
  444. # appropriate specific options
  445. #---------------------------------------------------------------------------
  446. # 20MHz clocked platforms
  447. #
  448. # These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
  449. #
  450. pro20: TARGET = pro_20mhz
  451. pro20: CHIP = atmega168
  452. pro20:
  453. "$(MAKE)" atmega168 AVR_FREQ=20000000L LED_START_FLASHES=3
  454. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  455. ifndef PRODUCTION
  456. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  457. endif
  458. pro20_isp: pro20
  459. pro20_isp: TARGET = pro_20mhz
  460. # 4.3V brownout (for max speed!)
  461. pro20_isp: HFUSE ?= DC
  462. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  463. pro20_isp: LFUSE ?= F7
  464. # 512 byte boot
  465. pro20_isp: EFUSE ?= FC
  466. pro20_isp: isp
  467. # 16MHz clocked platforms
  468. #
  469. # These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
  470. #
  471. pro16: TARGET = pro_16MHz
  472. pro16: CHIP = atmega168
  473. pro16:
  474. "$(MAKE)" $(CHIP) AVR_FREQ=16000000L LED_START_FLASHES=3
  475. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  476. ifndef PRODUCTION
  477. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  478. endif
  479. pro16_isp: pro16
  480. pro16_isp: TARGET = pro_16MHz
  481. # 2.7V brownout
  482. pro16_isp: HFUSE ?= DD
  483. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  484. pro16_isp: LFUSE ?= F7
  485. # 512 byte boot
  486. pro16_isp: EFUSE ?= FC
  487. pro16_isp: isp
  488. diecimila: TARGET = diecimila
  489. diecimila: CHIP = atmega168
  490. diecimila:
  491. "$(MAKE)" $(CHIP) AVR_FREQ=16000000L LED_START_FLASHES=3
  492. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  493. ifndef PRODUCTION
  494. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  495. endif
  496. diecimila_isp: diecimila
  497. diecimila_isp: TARGET = diecimila
  498. # 2.7V brownout
  499. diecimila_isp: HFUSE ?= DD
  500. # Low power xtal (16MHz) 16KCK/14CK+65ms
  501. diecimila_isp: LFUSE ?= F7
  502. # 512 byte boot
  503. diecimila_isp: EFUSE ?= FC
  504. diecimila_isp: isp
  505. # MEGA1280 Board (this is different from the atmega1280 chip platform)
  506. # Mega has a minimum boot size of 1024 bytes, so enable extra functions
  507. # Note that optiboot does not (can not) work on the MEGA2560
  508. #mega: TARGET = atmega1280
  509. mega1280: atmega1280
  510. mega1280_isp: mega1280
  511. mega1280_isp: TARGET = atmega1280
  512. mega1280_isp: MCU_TARGET = atmega1280
  513. # 1024 byte boot
  514. mega1280_isp: HFUSE ?= DE
  515. # Low power xtal (16MHz) 16KCK/14CK+65ms
  516. mega1280_isp: LFUSE ?= FF
  517. # 2.7V brownout; wants F5 for some reason...
  518. mega1280_isp: EFUSE ?= F5
  519. mega1280_isp: isp
  520. # 8MHz clocked platforms
  521. #
  522. # These are capable of 115200 baud
  523. # Note that "new" Arduinos with an AVR as USB/Serial converter will NOT work
  524. # with an 8MHz target Arduino. The bitrate errors are in opposite directions,
  525. # and total too large a number.
  526. #
  527. lilypad: TARGET = $@
  528. lilypad: CHIP = atmega168
  529. lilypad:
  530. "$(MAKE)" $(CHIP) AVR_FREQ=8000000L LED_START_FLASHES=3
  531. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  532. ifndef PRODUCTION
  533. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  534. endif
  535. lilypad_isp: lilypad
  536. lilypad_isp: TARGET = lilypad
  537. # 2.7V brownout
  538. lilypad_isp: HFUSE ?= DD
  539. # Internal 8MHz osc (8MHz) Slow rising power
  540. lilypad_isp: LFUSE ?= E2
  541. # 512 byte boot
  542. lilypad_isp: EFUSE ?= FC
  543. lilypad_isp: isp
  544. # lilypad_resonator is the same as a 8MHz lilypad, except for fuses.
  545. lilypad_resonator: lilypad
  546. lilypad_resonator_isp: lilypad
  547. lilypad_resonator_isp: TARGET = lilypad
  548. # 2.7V brownout
  549. lilypad_resonator_isp: HFUSE ?= DD
  550. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  551. lilypad_resonator_isp: LFUSE ?= C6
  552. # 512 byte boot
  553. lilypad_resonator_isp: EFUSE ?= FC
  554. lilypad_resonator_isp: isp
  555. pro8: TARGET = pro_8MHz
  556. pro8: CHIP = atmega168
  557. pro8:
  558. "$(MAKE)" $(CHIP) AVR_FREQ=8000000L LED_START_FLASHES=3
  559. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  560. ifndef PRODUCTION
  561. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  562. endif
  563. pro8_isp: pro8
  564. pro8_isp: TARGET = pro_8MHz
  565. # 2.7V brownout
  566. pro8_isp: HFUSE ?= DD
  567. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  568. pro8_isp: LFUSE ?= C6
  569. # 512 byte boot
  570. pro8_isp: EFUSE ?= FC
  571. pro8_isp: isp
  572. atmega328_pro8: TARGET = atmega328_pro_8MHz
  573. atmega328_pro8: CHIP = atmega328
  574. atmega328_pro8:
  575. "$(MAKE)" $(CHIP) AVR_FREQ=8000000L LED_START_FLASHES=3
  576. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  577. ifndef PRODUCTION
  578. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  579. endif
  580. atmega328_pro8_isp: atmega328_pro8
  581. atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
  582. atmega328_pro8_isp: MCU_TARGET = atmega328p
  583. # 512 byte boot, SPIEN
  584. atmega328_pro8_isp: HFUSE ?= DE
  585. # Low power xtal (16MHz) 16KCK/14CK+65ms
  586. atmega328_pro8_isp: LFUSE ?= FF
  587. # 2.7V brownout
  588. atmega328_pro8_isp: EFUSE ?= FD
  589. atmega328_pro8_isp: isp
  590. #
  591. # Include additional platforms
  592. include Makefile.atmel
  593. include Makefile.extras
  594. include Makefile.1284
  595. include Makefile.custom
  596. include Makefile.2560
  597. include Makefile.tiny
  598. include Makefile.mcudude
  599. include Makefile.usbmcus
  600. BAUDCHECK=
  601. ifndef PRODUCTION
  602. ifndef SOFT_UART
  603. BAUDCHECK= baudcheck
  604. endif
  605. endif
  606. #---------------------------------------------------------------------------
  607. #
  608. # Generic build instructions
  609. #
  610. FORCE:
  611. baudcheck: FORCE
  612. - @$(CC) --version
  613. - @$(CC) $(CFLAGS) -E baudcheck.c -o baudcheck.tmp.sh
  614. - @$(SH) baudcheck.tmp.sh
  615. isp: $(TARGET)
  616. "$(MAKE)" -f Makefile.isp isp TARGET=$(TARGET)
  617. isp-stk500: $(PROGRAM)_$(TARGET).hex
  618. $(STK500-1)
  619. $(STK500-2)
  620. %.elf: $(OBJ) $(BAUDCHECK) $(dummy)
  621. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
  622. $(SIZE) $@
  623. #windows "rm" is dumb and objects to wildcards that don't exist
  624. clean:
  625. @touch __temp_.o __temp_.elf __temp_.lst __temp_.map
  626. @touch __temp_.sym __temp_.lss __temp_.eep __temp_.srec
  627. @touch __temp_.bin __temp_.hex __temp_.tmp.sh
  628. rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex *.tmp.sh
  629. clean_asm:
  630. rm -rf *.lst
  631. %.lst: %.elf
  632. $(OBJDUMP) -h -S $< > $@
  633. %.hex: %.elf
  634. $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@
  635. %.srec: %.elf
  636. $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@
  637. %.bin: %.elf
  638. $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@
  639. help:
  640. @echo -e $(HELPTEXT)
  641. install: all
  642. avrdude -c usbasp -p atmega644p -U lfuse:w:0xff:m -U hfuse:w:0x14:m -U efuse:w:0xfe:m -B100
  643. avrdude -c usbasp -p atmega644p -U flash:w:optiboot_atmega644p.hex