forked from baerwolf/USBaspLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.inc
392 lines (309 loc) · 12.1 KB
/
Makefile.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# Name: Makefile.inc
# Project: USBaspLoader (updater)
# Author: Stephan Bärwolf
# Creation Date: 2012-09-01
# Tabsize: 4
# License: GNU GPL v2 (see License.txt)
F_CPU = 16000000
DEVICE = atmega8
# where the updating firmware should be located (starting address)
FLASHADDRESS = 0x0000
# use any fix (ATxmega compatible) crc32, uncomment to disable feature or set automatically with value "0"
;UPDATECRC32 = 0
# some MCU independent defines...
#...will be extended within MCU dependend configuration below...
DEFINES += -DCONFIG_NO__CHIP_ERASE -DCONFIG_NO__ONDEMAND_PAGEERASE -DCONFIG_NO__PRESERVE_WATCHDOG
# have the bootloader always enter the programming mode
;DEFINES += -DCONFIG_HAVE__BOOTLOADER_ALWAYSENTERPROGRAMMODE
# have the bootloader exit itself after around 3 seconds (@16MHz) inactivity
;DEFINES += -DCONFIG_BOOTLOADER_LOOPCYCLES_TIMEOUT=16 -DCONFIG_HAVE__BOOTLOADER_ABORTTIMEOUTONACT
# save the PROG button on the layout (CAREFUL - read feature description first)
;DEFINES += -DCONFIG_HAVE__BOOTLOADER_IGNOREPROGBUTTON
# some MCUs with small BLS (bootloader section) need to deactivate some
# features in order to fit into BLS.
# If this option is enabled, also essential features may become deactivated
# Esp. you MUST ensure not to have watchdog initially enabled when using this!
DANGEROUS=0
# PROGRAMMER contains AVRDUDE options to address your programmer
# PROGRAMMER = -c pony-stk200
PROGRAMMER = -c usbasp
# since USBaspLoader supports HAVE_BLB11_SOFTW_LOCKBIT...
LOCKOPT = -U lock:w:0x3f:m
#untested devices (WARNING: may destroy ISP ability!)
#device always should select maximum bootloader-section size
#please mail tests-reports to [email protected]
#
#some features may be deactivated to fit into bootloader section
#ATTANTION: CONFIG_NO... feature deactivation may not be optimal!
FUSEOPT_8535 = -U lfuse:w:0x1f:m -U hfuse:w:0xc0:m
BOOTLOADER_ADDRESS_8535 = 0x1800
DEFINES_8535 = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP
FUSEOPT_16 = -U lfuse:w:0x1f:m -U hfuse:w:0xc0:m
BOOTLOADER_ADDRESS_16 = 0x3800
DEFINES_16 = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP
ifeq ($(F_CPU), 12000000)
DEFINES_16 += -DCONFIG_NO__HAVE_READ_LOCK_FUSE
endif
FUSEOPT_88 = -U lfuse:w:0xd7:m -U hfuse:w:0xd4:m -U efuse:w:0xf8:m
BOOTLOADER_ADDRESS_88 = 0x1800
DEFINES_88 = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP -DCONFIG_NO__HAVE_READ_LOCK_FUSE
FUSEOPT_164 = -U lfuse:w:0xd7:m -U hfuse:w:0xd0:m -U efuse:w:0xfc:m
BOOTLOADER_ADDRESS_164 = 0x3800
DEFINES_164 = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP -DCONFIG_NO__FLASH_BYTE_READACCESS -DCONFIG_NO__HAVE_READ_LOCK_FUSE
ifeq ($(F_CPU), 12000000)
DEFINES_164 += -DCONFIG_NO__BOOTLOADER_CAN_EXIT
endif
FUSEOPT_324 = $(FUSEOPT_164)
BOOTLOADER_ADDRESS_324 = 0x7000
DEFINES_324 = #-DEMPTY
FUSEOPT_128 = -U lfuse:w:0x1f:m -U hfuse:w:0xc0:m -U efuse:w:0xfd:m
BOOTLOADER_ADDRESS_128 = 0x1E000
DEFINES_128 = -D__AVR_LIBC_DEPRECATED_ENABLE__
FUSEOPT_640 = -U lfuse:w:0xd7:m -U hfuse:w:0xd0:m -U efuse:w:0xfc:m
BOOTLOADER_ADDRESS_640 = 0xE000
DEFINES_640 = #-DEMPTY
FUSEOPT_1280 = $(FUSEOPT_640)
BOOTLOADER_ADDRESS_1280 = 0x1E000
DEFINES_1280 = #-DEMPTY
FUSEOPT_1281 = $(FUSEOPT_1280)
BOOTLOADER_ADDRESS_1281 = 0x1E000
DEFINES_1281 = #-DEMPTY
FUSEOPT_2561 = $(FUSEOPT_1281)
BOOTLOADER_ADDRESS_2561 = 0x3E000
DEFINES_2561 = #-DEMPTY
#tested devices
# standard atmega8 needs BODLEVEL to be programed, since it is a 5V device
# you may also want to UNprogram SUT1 to get a SLOWER bootup (lfuse then would be 0x3f)
FUSEOPT_8 = -U lfuse:w:0x1f:m -U hfuse:w:0xc0:m
BOOTLOADER_ADDRESS_8 = 0x1800
DEFINES_8 = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP
FUSEOPT_32 = $(FUSEOPT_16)
BOOTLOADER_ADDRESS_32 = 0x7000
DEFINES_32 = #-DEMPTY
FUSEOPT_162 = -U lfuse:w:0xff:m -U hfuse:w:0x90:m -U efuse:w:0xf9:m
BOOTLOADER_ADDRESS_162 = 0x3800
DEFINES_162 = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP -DCONFIG_NO__HAVE_READ_LOCK_FUSE
ifeq ($(F_CPU), 12000000)
DEFINES_162 += -DCONFIG_NO__BOOTLOADER_CAN_EXIT
endif
FUSEOPT_168 = $(FUSEOPT_88)
BOOTLOADER_ADDRESS_168 = 0x3800
DEFINES_168 = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP -DCONFIG_NO__FLASH_BYTE_READACCESS -DCONFIG_NO__HAVE_READ_LOCK_FUSE
FUSEOPT_328 = -U lfuse:w:0xd7:m -U hfuse:w:0xd0:m -U efuse:w:0x04:m
BOOTLOADER_ADDRESS_328 = 0x7000
DEFINES_328 = #-DEMPTY
FUSEOPT_644 = $(FUSEOPT_324)
BOOTLOADER_ADDRESS_644 = 0xE000
DEFINES_644 = #-DEMPTY
FUSEOPT_1284 = -U lfuse:w:0xd7:m -U hfuse:w:0xd0:m -U efuse:w:0xfc:m
BOOTLOADER_ADDRESS_1284 = 0x1E000
DEFINES_1284 = #-DEMPTY
FUSEOPT_2560 = $(FUSEOPT_1280)
BOOTLOADER_ADDRESS_2560 = 0x3E000
DEFINES_2560 = #-DEMPTY
#http://www.nongnu.org/avr-libc/user-manual/using_tools.html
#autoselect logic
ifeq ($(DEVICE), atmega8535)
FUSEOPT = $(FUSEOPT_8535)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_8535)
MCUARCH = avr4
DEFINES += $(DEFINES_8535)
else ifeq ($(DEVICE), atmega8)
FUSEOPT = $(FUSEOPT_8)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_8)
MCUARCH = avr4
DEFINES += $(DEFINES_8)
else ifeq ($(DEVICE), atmega16)
FUSEOPT = $(FUSEOPT_16)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_16)
MCUARCH = avr5
DEFINES += $(DEFINES_16)
else ifeq ($(DEVICE), atmega32)
FUSEOPT = $(FUSEOPT_32)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_32)
MCUARCH = avr5
DEFINES += $(DEFINES_32)
else ifeq ($(DEVICE), atmega88)
FUSEOPT = $(FUSEOPT_88)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_88)
MCUARCH = avr4
DEFINES += $(DEFINES_88)
else ifeq ($(DEVICE), atmega88a)
FUSEOPT = $(FUSEOPT_88)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_88)
MCUARCH = avr4
DEFINES += $(DEFINES_88)
else ifeq ($(DEVICE), atmega88p)
FUSEOPT = $(FUSEOPT_88)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_88)
MCUARCH = avr4
DEFINES += $(DEFINES_88)
else ifeq ($(DEVICE), atmega88pa)
FUSEOPT = $(FUSEOPT_88)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_88)
MCUARCH = avr4
DEFINES += $(DEFINES_88)
else ifeq ($(DEVICE), atmega162)
FUSEOPT = $(FUSEOPT_162)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_162)
MCUARCH = avr5
DEFINES += $(DEFINES_162)
else ifeq ($(DEVICE), atmega164a)
FUSEOPT = $(FUSEOPT_164)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_164)
MCUARCH = avr5
DEFINES += $(DEFINES_164)
else ifeq ($(DEVICE), atmega164p)
FUSEOPT = $(FUSEOPT_164)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_164)
MCUARCH = avr5
DEFINES += $(DEFINES_164)
else ifeq ($(DEVICE), atmega164pa)
FUSEOPT = $(FUSEOPT_164)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_164)
MCUARCH = avr5
DEFINES += $(DEFINES_164)
else ifeq ($(DEVICE), atmega168)
FUSEOPT = $(FUSEOPT_168)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_168)
MCUARCH = avr5
DEFINES += $(DEFINES_168)
else ifeq ($(DEVICE), atmega168a)
FUSEOPT = $(FUSEOPT_168)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_168)
MCUARCH = avr5
DEFINES += $(DEFINES_168)
else ifeq ($(DEVICE), atmega168p)
FUSEOPT = $(FUSEOPT_168)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_168)
MCUARCH = avr5
DEFINES += $(DEFINES_168)
else ifeq ($(DEVICE), atmega168pa)
FUSEOPT = $(FUSEOPT_168)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_168)
MCUARCH = avr5
DEFINES += $(DEFINES_168)
else ifeq ($(DEVICE), atmega324a)
FUSEOPT = $(FUSEOPT_324)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_324)
MCUARCH = avr5
DEFINES += $(DEFINES_324)
else ifeq ($(DEVICE), atmega324p)
FUSEOPT = $(FUSEOPT_324)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_324)
MCUARCH = avr5
DEFINES += $(DEFINES_324)
else ifeq ($(DEVICE), atmega324pa)
FUSEOPT = $(FUSEOPT_324)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_324)
MCUARCH = avr5
DEFINES += $(DEFINES_324)
else ifeq ($(DEVICE), atmega328)
FUSEOPT = $(FUSEOPT_328)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_328)
MCUARCH = avr5
DEFINES += $(DEFINES_328)
else ifeq ($(DEVICE), atmega328p)
FUSEOPT = $(FUSEOPT_328)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_328)
MCUARCH = avr5
DEFINES += $(DEFINES_328)
else ifeq ($(DEVICE), atmega640)
FUSEOPT = $(FUSEOPT_640)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_640)
MCUARCH = avr5
DEFINES += $(DEFINES_640)
else ifeq ($(DEVICE), atmega644)
FUSEOPT = $(FUSEOPT_644)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_644)
MCUARCH = avr5
DEFINES += $(DEFINES_644)
else ifeq ($(DEVICE), atmega644a)
FUSEOPT = $(FUSEOPT_644)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_644)
MCUARCH = avr5
DEFINES += $(DEFINES_644)
else ifeq ($(DEVICE), atmega644p)
FUSEOPT = $(FUSEOPT_644)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_644)
MCUARCH = avr5
DEFINES += $(DEFINES_644)
else ifeq ($(DEVICE), atmega644pa)
FUSEOPT = $(FUSEOPT_644)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_644)
MCUARCH = avr5
DEFINES += $(DEFINES_644)
else ifeq ($(DEVICE), atmega128)
FUSEOPT = $(FUSEOPT_128)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_128)
MCUARCH = avr51
DEFINES += $(DEFINES_128)
else ifeq ($(DEVICE), atmega1280)
FUSEOPT = $(FUSEOPT_1280)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_1280)
MCUARCH = avr51
DEFINES += $(DEFINES_1280)
else ifeq ($(DEVICE), atmega1281)
FUSEOPT = $(FUSEOPT_1281)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_1281)
MCUARCH = avr51
DEFINES += $(DEFINES_1281)
else ifeq ($(DEVICE), atmega1284)
FUSEOPT = $(FUSEOPT_1284)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_1284)
MCUARCH = avr51
DEFINES += $(DEFINES_1284)
else ifeq ($(DEVICE), atmega1284p)
FUSEOPT = $(FUSEOPT_1284)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_1284)
MCUARCH = avr51
DEFINES += $(DEFINES_1284)
else ifeq ($(DEVICE), atmega2560)
FUSEOPT = $(FUSEOPT_2560)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_2560)
MCUARCH = avr6
DEFINES += $(DEFINES_2560)
else ifeq ($(DEVICE), atmega2561)
FUSEOPT = $(FUSEOPT_2561)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_2561)
MCUARCH = avr6
DEFINES += $(DEFINES_2561)
else
FUSEOPT = unknown
endif
NEW_BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS)
# Tools:
AVRPATH = $(AVR8TOOLCHAINBINDIR)
AVRDUDE = $(AVRDUDEBINDIR)avrdude $(PROGRAMMER) -p $(DEVICE)
# Platform
# Check operative system.
# Check if we are on Windows.
ifeq ($(OS), Windows_NT)
HOSTOS := Windows_NT
# Check if although we are on a windows machine it's a linux-like
# environment (Cygwin/Mingw or similar).
ifeq (marks,$(shell echo "marks"))
HOSTOS := Linux
endif
else
UNAME := $(shell uname -s)
# Check if it's a OS X system.
ifeq ($(UNAME), Darwin)
HOSTOS := Darwin
# Default as Linux.
else
HOSTOS := Linux
endif
endif
ECHO=@echo
GCC=@gcc
MAKE=@make
ifeq ($(HOSTOS), Windows_NT)
RM=@del /F /Q
else
RM=@rm -f
endif
CC=@$(AVRPATH)avr-gcc
OBC=@$(AVRPATH)avr-objcopy
OBD=@$(AVRPATH)avr-objdump
SIZ=@$(AVRPATH)avr-size