Makefile 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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. DEFS =
  127. CC = $(GCCROOT)avr-gcc
  128. # Override is only needed by avr-lib build system.
  129. HELPTEXT += "Option AVR_FREQ=<n> - Clock rate of AVR CPU\n"
  130. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
  131. override LDFLAGS = $(LDSECTIONS) -Wl,--relax -nostartfiles
  132. OBJCOPY = $(GCCROOT)avr-objcopy
  133. OBJDUMP = $(call fixpath,$(GCCROOT)avr-objdump)
  134. SIZE = $(GCCROOT)avr-size
  135. #
  136. # Make command-line Options.
  137. # Permit commands like "make atmega328 LED_START_FLASHES=10" to pass the
  138. # appropriate parameters ("-DLED_START_FLASHES=10") to gcc
  139. #
  140. ifdef PRODUCTION
  141. ifneq ($(PRODUCTION),0)
  142. VERSION_CMD = -DPRODUCTION=1
  143. endif
  144. dummy = FORCE
  145. endif
  146. HELPTEXT += "Option CUSTOM_VERSION=nn - set a customer version number\n"
  147. ifdef CUSTOM_VERSION
  148. ifneq ($(CUSTOM_VERSION), 0)
  149. VERSION_CMD = -DOPTIBOOT_CUSTOMVER=$(CUSTOM_VERSION)
  150. else
  151. VERSION_CMD = -DPRODUCTION=1
  152. endif
  153. dummy = FORCE
  154. endif
  155. HELPTEXT += "Option BAUD_RATE=nnnn - set the bit rate for communications\n"
  156. ifdef BAUD_RATE
  157. BAUD_RATE_CMD = -DBAUD_RATE=$(BAUD_RATE)
  158. dummy = FORCE
  159. else
  160. BAUD_RATE_CMD = -DBAUD_RATE=115200
  161. endif
  162. HELPTEXT += "Option LED=B3 - set LED pin to particular port/bit\n"
  163. ifdef LED
  164. LED_CMD = -DLED=$(LED)
  165. dummy = FORCE
  166. endif
  167. HELPTEXT += "Option LED_START_FLASHES=n - set number of LED flashes when bootloader starts\n"
  168. ifdef LED_START_FLASHES
  169. LED_START_FLASHES_CMD = -DLED_START_FLASHES=$(LED_START_FLASHES)
  170. dummy = FORCE
  171. else
  172. LED_START_FLASHES_CMD = -DLED_START_FLASHES=3
  173. endif
  174. HELPTEXT += "Option LED_DATA_FLASH=1 - flash the LED each time data is received.\n"
  175. ifdef LED_DATA_FLASH
  176. ifneq ($(LED_DATA_FLASH), 0)
  177. LED_DATA_FLASH_CMD = -DLED_DATA_FLASH=1
  178. dummy = FORCE
  179. endif
  180. endif
  181. HELPTEXT += "Option LED_START_ON=1 - Turn the LED on at bootload start\n"
  182. ifdef LED_START_ON
  183. ifneq ($(LED_START_ON), 0)
  184. LED_START_ON_CMD = -DLED_START_ON=1
  185. endif
  186. dummy = FORCE
  187. endif
  188. HELPTEXT += "Option BIGBOOT=1 - enable extra features up to 1kbytes\n"
  189. # BIGBOOT: Include extra features, up to 1K.
  190. ifdef BIGBOOT
  191. ifneq ($(BIGBOOT), 0)
  192. BIGBOOT_CMD = -DBIGBOOT=1
  193. dummy = FORCE
  194. endif
  195. endif
  196. HELPTEXT += "Option SUPPORT_EEPROM=1 - Include code to read/write EEPROM\n"
  197. ifdef SUPPORT_EEPROM
  198. ifneq ($(SUPPORT_EEPROM), 0)
  199. SUPPORT_EEPROM_CMD = -DSUPPORT_EEPROM
  200. dummy = FORCE
  201. endif
  202. endif
  203. HELPTEXT += "Option SOFT_UART=1 - use a software (bit-banged) UART\n"
  204. ifdef SOFT_UART
  205. ifneq ($(SOFT_UART), 0)
  206. SOFT_UART_CMD = -DSOFT_UART=1
  207. dummy = FORCE
  208. endif
  209. endif
  210. HELPTEXT += "Option SOFTTX=B5 - pin for software UART xmit \n"
  211. ifdef SOFTTX
  212. SOFT_UART_CMD += -DSOFTTX=$(SOFTTX)
  213. dummy = FORCE
  214. endif
  215. HELPTEXT += "Option SOFTRX=B6 - pin for software UART receive\n"
  216. ifdef SOFTRX
  217. SOFT_UART_CMD += -DSOFTRX=$(SOFTRX)
  218. dummy = FORCE
  219. endif
  220. HELPTEXT += "Option SINGLESPEED=1 - do not use U2X mode on UART\n"
  221. ifdef SINGLESPEED
  222. ifneq ($(SINGLESPEED), 0)
  223. SS_CMD = -DSINGLESPEED=1
  224. endif
  225. endif
  226. HELPTEXT += "Option RS485=B0 - Pin for optional rs485 tx enable\n"
  227. ifdef RS485
  228. RS485_CMD = -DRS485=$(RS485)
  229. dummy = FORCE
  230. endif
  231. HELPTEXT += "Option NO_APP_SPM=1 - disallow application call of do_spm\n"
  232. ifdef NO_APP_SPM
  233. ifneq ($(NO_APP_SPM),0)
  234. APPSPM_CMD = -DAPP_NOSPM=1
  235. endif
  236. endif
  237. HELPTEXT += "Option OSCCAL_VALUE=nnn - set set OSCCAL_VALUE in bootloader\n"
  238. ifdef OSCCAL_VALUE
  239. OSCCAL_VALUE_CMD = -DOSCCAL_VALUE=$(OSCCAL_VALUE)
  240. dummy = FORCE
  241. endif
  242. HELPTEXT += "Option BOOT_ON_POR - Run bootloader on power-on\n"
  243. ifdef NO_START_APP_ON_POR
  244. ifneq ($(NO_START_APP_ON_POR),0)
  245. POR_CMD = -DNO_START_APP_ON_POR=1
  246. dummy = FORCE
  247. endif
  248. endif
  249. ifdef BOOT_ON_POR
  250. ifneq ($(NO_START_APP_ON_POR),0)
  251. POR_CMD = -DNO_START_APP_ON_POR=1
  252. dummy = FORCE
  253. endif
  254. endif
  255. HELPTEXT += "Option APP_ON_EXTR - Run App on External Reset\n"
  256. ifdef START_APP_ON_EXTR
  257. ifneq ($(START_APP_ON_EXTR),0)
  258. EXTR_CMD = -DSTART_APP_ON_EXTR=1
  259. dummy = FORCE
  260. endif
  261. endif
  262. ifdef APP_ON_EXTR
  263. ifneq ($(START_APP_ON_EXTR),0)
  264. EXTR_CMD = -DSTART_APP_ON_EXTR=1
  265. dummy = FORCE
  266. endif
  267. endif
  268. COMMON_OPTIONS = $(BAUD_RATE_CMD) $(LED_START_FLASHES_CMD) $(BIGBOOT_CMD)
  269. COMMON_OPTIONS += $(SOFT_UART_CMD) $(LED_DATA_FLASH_CMD) $(LED_CMD) $(SS_CMD)
  270. COMMON_OPTIONS += $(SUPPORT_EEPROM_CMD) $(LED_START_ON_CMD) $(APPSPM_CMD)
  271. COMMON_OPTIONS += $(OSCCAL_VALUE_CMD) $(VERSION_CMD) $(TIMEOUT_CMD)
  272. COMMON_OPTIONS += $(POR_CMD) $(EXTR_CMD) $(RS485_CMD)
  273. #UART is handled separately and only passed for devices with more than one.
  274. HELPTEXT += "Option UART=n - use UARTn for communications\n"
  275. ifdef UART
  276. UART_CMD = -DUART=$(UART)
  277. endif
  278. ifdef UARTTX
  279. UART_CMD = -DUARTTX=$(UARTTX)
  280. endif
  281. HELPTEXT += "Option TIMEOUT=n - set WDT to 1, 2, 4, or 8 seconds\n"
  282. ifdef TIMEOUT
  283. TIMEOUT_CMD = -DWDTTIME=$(TIMEOUT)
  284. dummy = FORCE
  285. endif
  286. .PRECIOUS: %.elf
  287. #---------------------------------------------------------------------------
  288. # "Chip-level Platform" targets.
  289. # A "Chip-level Platform" compiles for a particular chip, but probably does
  290. # not have "standard" values for things like clock speed, LED pin, etc.
  291. # Makes for chip-level platforms should usually explicitly define their
  292. # options like: "make atmega1285 AVR_FREQ=16000000L LED=D0"
  293. #---------------------------------------------------------------------------
  294. #
  295. # Note about fuses:
  296. # the efuse should really be 0xf8; since, however, only the lower
  297. # three bits of that byte are used on the atmega168, avrdude gets
  298. # confused if you specify 1's for the higher bits, see:
  299. # http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
  300. #
  301. # similarly, the lock bits should be 0xff instead of 0x3f (to
  302. # unlock the bootloader section) and 0xcf instead of 0x2f (to
  303. # lock it), but since the high two bits of the lock byte are
  304. # unused, avrdude would get confused.
  305. #---------------------------------------------------------------------------
  306. #
  307. HELPTEXT += "\n-------------\n\n"
  308. # Test platforms
  309. # Virtual boot block test
  310. HELPTEXT += "target virboot8 - ATmega8 with virtual boot partition\n"
  311. virboot8: TARGET = atmega8
  312. virboot8: MCU_TARGET = atmega8
  313. virboot8: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-Dsave_vect_num=EE_RDY_vect_num'
  314. virboot8: AVR_FREQ ?= 16000000L
  315. virboot8: $(PROGRAM)_virboot8.hex
  316. ifndef PRODUCTION
  317. virboot8: $(PROGRAM)_virboot8.lst
  318. endif
  319. HELPTEXT += "target virboot328p - ATmega328 with virtual boot partition\n"
  320. virboot328: TARGET = atmega328
  321. virboot328: MCU_TARGET = atmega328p
  322. virboot328: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION'
  323. virboot328: AVR_FREQ ?= 16000000L
  324. virboot328: $(PROGRAM)_virboot328.hex
  325. ifndef PRODUCTION
  326. virboot328: $(PROGRAM)_virboot328.lst
  327. endif
  328. virboot328_isp: virboot328
  329. virboot328_isp: TARGET = virboot328
  330. virboot328_isp: MCU_TARGET = atmega328p
  331. # no boot section, SPIEN
  332. virboot328_isp: HFUSE ?= DF
  333. # Low power xtal (16MHz) 16KCK/14CK+65ms
  334. virboot328_isp: LFUSE ?= FF
  335. # 2.7V brownout
  336. virboot328_isp: EFUSE ?= FD
  337. virboot328_isp: isp
  338. virboot8_isp: virboot8
  339. virboot8_isp: TARGET = virboot8
  340. virboot8_isp: MCU_TARGET = atmega8
  341. # SPIEN, CKOPT (for full swing xtal), boot section 1k
  342. # Note that we need boot section to include our SPM instructions,
  343. # even though we do not enable BOOTRST
  344. virboot8_isp: HFUSE ?= CB
  345. # 2.7V brownout, 16MHz Xtal, 16KCK/14CK+65ms
  346. virboot8_isp: LFUSE ?= BF
  347. virboot8_isp: isp
  348. # Diecimila, Duemilanove with m168, and NG use identical bootloaders
  349. # Call it "atmega168" for generality and clarity, keep "diecimila" for
  350. # backward compatibility of makefile
  351. # ATmega8
  352. #
  353. HELPTEXT += "target atmega8 - ATmega8, ATmega8A, ATmega8L\n"
  354. atmega8: TARGET = atmega8
  355. atmega8: MCU_TARGET = atmega8
  356. atmega8: CFLAGS += $(COMMON_OPTIONS)
  357. atmega8: AVR_FREQ ?= 16000000L
  358. atmega8: $(PROGRAM)_atmega8.hex
  359. ifndef PRODUCTION
  360. atmega8: $(PROGRAM)_atmega8.lst
  361. endif
  362. atmega8_isp: atmega8
  363. atmega8_isp: TARGET = atmega8
  364. atmega8_isp: MCU_TARGET = atmega8
  365. ifndef BIGBOOT
  366. # SPIEN, CKOPT (for full swing xtal), Bootsize=512B
  367. atmega8_isp: HFUSE ?= CC
  368. else
  369. # SPIEN, CKOPT (for full swing xtal), Bootsize=1024B
  370. atmega8_isp: HFUSE ?= CA
  371. endif
  372. # 2.7V brownout, 16MHz Xtal, 16KCK/14CK+65ms
  373. atmega8_isp: LFUSE ?= BF
  374. atmega8_isp: isp
  375. HELPTEXT += "target atmega168* - ATmega168/A, ATmega168P, ATMEGA1268PB\n"
  376. atmega168: TARGET = atmega168
  377. atmega168: MCU_TARGET = atmega168
  378. atmega168: CFLAGS += $(COMMON_OPTIONS)
  379. atmega168: AVR_FREQ ?= 16000000L
  380. atmega168: $(PROGRAM)_atmega168.hex
  381. ifndef PRODUCTION
  382. atmega168: $(PROGRAM)_atmega168.lst
  383. endif
  384. atmega168_isp: atmega168
  385. atmega168_isp: TARGET = atmega168
  386. # 2.7V brownout
  387. atmega168_isp: HFUSE ?= DD
  388. # Full swing (16MHz) 16KCK/14CK+65ms
  389. atmega168_isp: LFUSE ?= F7
  390. ifndef BIGBOOT
  391. # 512 byte boot
  392. atmega168_isp: EFUSE ?= FC
  393. else
  394. # 1024byte boot
  395. atmega168_isp: EFUSE ?= FA
  396. endif
  397. atmega168_isp: isp
  398. HELPTEXT += "target atmega328* - ATmega328, ATmega328p, ATmega328pb\n"
  399. atmega328: TARGET = atmega328
  400. atmega328: MCU_TARGET = atmega328p
  401. atmega328: CFLAGS += $(COMMON_OPTIONS)
  402. atmega328: AVR_FREQ ?= 16000000L
  403. atmega328: $(PROGRAM)_atmega328.hex
  404. ifndef PRODUCTION
  405. atmega328: $(PROGRAM)_atmega328.lst
  406. endif
  407. atmega328_isp: atmega328
  408. atmega328_isp: TARGET = atmega328
  409. atmega328_isp: MCU_TARGET = atmega328p
  410. ifndef BIGBOOT
  411. # 512 byte boot, SPIEN
  412. atmega328_isp: HFUSE ?= DE
  413. else
  414. # 1k byte boot, SPIEN
  415. atmega328_isp: HFUSE ?= DC
  416. endif
  417. # Low power xtal (16MHz) 16KCK/14CK+65ms
  418. atmega328_isp: LFUSE ?= FF
  419. # 2.7V brownout
  420. atmega328_isp: EFUSE ?= FD
  421. atmega328_isp: isp
  422. #Atmega1280
  423. #HELPTEXT += "target atmega1280 - ATmega1280 (100pin, 128k)\n"
  424. atmega1280: MCU_TARGET = atmega1280
  425. atmega1280: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
  426. atmega1280: AVR_FREQ ?= 16000000L
  427. atmega1280: $(PROGRAM)_atmega1280.hex
  428. ifndef PRODUCTION
  429. atmega1280: $(PROGRAM)_atmega1280.lst
  430. endif
  431. #---------------------------------------------------------------------------
  432. # "Board-level Platform" targets.
  433. # A "Board-level Platform" implies a manufactured platform with a particular
  434. # AVR_FREQ, LED, and so on. Parameters are not particularly changable from
  435. # the "make" command line.
  436. # Most of the board-level platform builds should envoke make recursively
  437. # appropriate specific options
  438. #---------------------------------------------------------------------------
  439. # 20MHz clocked platforms
  440. #
  441. # These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
  442. #
  443. pro20: TARGET = pro_20mhz
  444. pro20: CHIP = atmega168
  445. pro20:
  446. "$(MAKE)" atmega168 AVR_FREQ=20000000L LED_START_FLASHES=3
  447. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  448. ifndef PRODUCTION
  449. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  450. endif
  451. pro20_isp: pro20
  452. pro20_isp: TARGET = pro_20mhz
  453. # 4.3V brownout (for max speed!)
  454. pro20_isp: HFUSE ?= DC
  455. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  456. pro20_isp: LFUSE ?= F7
  457. # 512 byte boot
  458. pro20_isp: EFUSE ?= FC
  459. pro20_isp: isp
  460. # 16MHz clocked platforms
  461. #
  462. # These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
  463. #
  464. pro16: TARGET = pro_16MHz
  465. pro16: CHIP = atmega168
  466. pro16:
  467. "$(MAKE)" $(CHIP) AVR_FREQ=16000000L LED_START_FLASHES=3
  468. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  469. ifndef PRODUCTION
  470. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  471. endif
  472. pro16_isp: pro16
  473. pro16_isp: TARGET = pro_16MHz
  474. # 2.7V brownout
  475. pro16_isp: HFUSE ?= DD
  476. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  477. pro16_isp: LFUSE ?= F7
  478. # 512 byte boot
  479. pro16_isp: EFUSE ?= FC
  480. pro16_isp: isp
  481. diecimila: TARGET = diecimila
  482. diecimila: CHIP = atmega168
  483. diecimila:
  484. "$(MAKE)" $(CHIP) AVR_FREQ=16000000L LED_START_FLASHES=3
  485. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  486. ifndef PRODUCTION
  487. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  488. endif
  489. diecimila_isp: diecimila
  490. diecimila_isp: TARGET = diecimila
  491. # 2.7V brownout
  492. diecimila_isp: HFUSE ?= DD
  493. # Low power xtal (16MHz) 16KCK/14CK+65ms
  494. diecimila_isp: LFUSE ?= F7
  495. # 512 byte boot
  496. diecimila_isp: EFUSE ?= FC
  497. diecimila_isp: isp
  498. # MEGA1280 Board (this is different from the atmega1280 chip platform)
  499. # Mega has a minimum boot size of 1024 bytes, so enable extra functions
  500. # Note that optiboot does not (can not) work on the MEGA2560
  501. #mega: TARGET = atmega1280
  502. mega1280: atmega1280
  503. mega1280_isp: mega1280
  504. mega1280_isp: TARGET = atmega1280
  505. mega1280_isp: MCU_TARGET = atmega1280
  506. # 1024 byte boot
  507. mega1280_isp: HFUSE ?= DE
  508. # Low power xtal (16MHz) 16KCK/14CK+65ms
  509. mega1280_isp: LFUSE ?= FF
  510. # 2.7V brownout; wants F5 for some reason...
  511. mega1280_isp: EFUSE ?= F5
  512. mega1280_isp: isp
  513. # 8MHz clocked platforms
  514. #
  515. # These are capable of 115200 baud
  516. # Note that "new" Arduinos with an AVR as USB/Serial converter will NOT work
  517. # with an 8MHz target Arduino. The bitrate errors are in opposite directions,
  518. # and total too large a number.
  519. #
  520. lilypad: TARGET = $@
  521. lilypad: CHIP = atmega168
  522. lilypad:
  523. "$(MAKE)" $(CHIP) AVR_FREQ=8000000L LED_START_FLASHES=3
  524. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  525. ifndef PRODUCTION
  526. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  527. endif
  528. lilypad_isp: lilypad
  529. lilypad_isp: TARGET = lilypad
  530. # 2.7V brownout
  531. lilypad_isp: HFUSE ?= DD
  532. # Internal 8MHz osc (8MHz) Slow rising power
  533. lilypad_isp: LFUSE ?= E2
  534. # 512 byte boot
  535. lilypad_isp: EFUSE ?= FC
  536. lilypad_isp: isp
  537. # lilypad_resonator is the same as a 8MHz lilypad, except for fuses.
  538. lilypad_resonator: lilypad
  539. lilypad_resonator_isp: lilypad
  540. lilypad_resonator_isp: TARGET = lilypad
  541. # 2.7V brownout
  542. lilypad_resonator_isp: HFUSE ?= DD
  543. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  544. lilypad_resonator_isp: LFUSE ?= C6
  545. # 512 byte boot
  546. lilypad_resonator_isp: EFUSE ?= FC
  547. lilypad_resonator_isp: isp
  548. pro8: TARGET = pro_8MHz
  549. pro8: CHIP = atmega168
  550. pro8:
  551. "$(MAKE)" $(CHIP) AVR_FREQ=8000000L LED_START_FLASHES=3
  552. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  553. ifndef PRODUCTION
  554. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  555. endif
  556. pro8_isp: pro8
  557. pro8_isp: TARGET = pro_8MHz
  558. # 2.7V brownout
  559. pro8_isp: HFUSE ?= DD
  560. # Full swing xtal (20MHz) 258CK/14CK+4.1ms
  561. pro8_isp: LFUSE ?= C6
  562. # 512 byte boot
  563. pro8_isp: EFUSE ?= FC
  564. pro8_isp: isp
  565. atmega328_pro8: TARGET = atmega328_pro_8MHz
  566. atmega328_pro8: CHIP = atmega328
  567. atmega328_pro8:
  568. "$(MAKE)" $(CHIP) AVR_FREQ=8000000L LED_START_FLASHES=3
  569. mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
  570. ifndef PRODUCTION
  571. mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst
  572. endif
  573. atmega328_pro8_isp: atmega328_pro8
  574. atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
  575. atmega328_pro8_isp: MCU_TARGET = atmega328p
  576. # 512 byte boot, SPIEN
  577. atmega328_pro8_isp: HFUSE ?= DE
  578. # Low power xtal (16MHz) 16KCK/14CK+65ms
  579. atmega328_pro8_isp: LFUSE ?= FF
  580. # 2.7V brownout
  581. atmega328_pro8_isp: EFUSE ?= FD
  582. atmega328_pro8_isp: isp
  583. #
  584. # Include additional platforms
  585. include Makefile.atmel
  586. include Makefile.extras
  587. include Makefile.1284
  588. include Makefile.custom
  589. include Makefile.2560
  590. include Makefile.tiny
  591. include Makefile.mcudude
  592. include Makefile.usbmcus
  593. BAUDCHECK=
  594. ifndef PRODUCTION
  595. ifndef SOFT_UART
  596. BAUDCHECK= baudcheck
  597. endif
  598. endif
  599. #---------------------------------------------------------------------------
  600. #
  601. # Generic build instructions
  602. #
  603. FORCE:
  604. baudcheck: FORCE
  605. - @$(CC) --version
  606. - @$(CC) $(CFLAGS) -E baudcheck.c -o baudcheck.tmp.sh
  607. - @$(SH) baudcheck.tmp.sh
  608. isp: $(TARGET)
  609. "$(MAKE)" -f Makefile.isp isp TARGET=$(TARGET)
  610. isp-stk500: $(PROGRAM)_$(TARGET).hex
  611. $(STK500-1)
  612. $(STK500-2)
  613. %.elf: $(OBJ) $(BAUDCHECK) $(dummy)
  614. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
  615. $(SIZE) $@
  616. #windows "rm" is dumb and objects to wildcards that don't exist
  617. clean:
  618. @touch __temp_.o __temp_.elf __temp_.lst __temp_.map
  619. @touch __temp_.sym __temp_.lss __temp_.eep __temp_.srec
  620. @touch __temp_.bin __temp_.hex __temp_.tmp.sh
  621. rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex *.tmp.sh
  622. clean_asm:
  623. rm -rf *.lst
  624. %.lst: %.elf
  625. $(OBJDUMP) -h -S $< > $@
  626. %.hex: %.elf
  627. $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@
  628. %.srec: %.elf
  629. $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@
  630. %.bin: %.elf
  631. $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@
  632. help:
  633. @echo -e $(HELPTEXT)
  634. install: all
  635. avrdude -c usbasp -p atmega644p -U lfuse:w:0xff:m -U hfuse:w:0x14:m -U efuse:w:0xfe:m -B100
  636. avrdude -c usbasp -p atmega644p -U flash:w:optiboot_atmega644p.hex