This repository has been archived by the owner on May 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.h
369 lines (309 loc) · 9.29 KB
/
config.h
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
/* vim:fdm=marker ts=4 et ai
* {{{
*
* (c) by Alexander Neumann <[email protected]>
* Lars Noschinski <[email protected]>
*
* Idea and implementation for char startup mode by
* Scott Torborg - [email protected] - August 2006
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* For more information on the GPL, please go to:
* http://www.gnu.org/copyleft/gpl.html
}}} */
#ifndef _FOODLOADER_CONFIG_H
#define _FOODLOADER_CONFIG_H
/* only do avr specific configuration when compiling for avr architecture */
#ifdef __AVR__
#include <avr/version.h>
/* check for avr-libc version */
#if __AVR_LIBC_VERSION__ < 10402UL
#error newer libc version (>= 1.4.2) needed!
#endif
/* check if cpu speed is defined */
#ifndef F_CPU
#error please define F_CPU!
#endif
/* check if the bootloader start address has been given */
#if !(defined(BOOT_SECTION_START))
#error please define BOOT_SECTION_START as the byte address of bootloader section
#endif
/* cpu specific configuration registers */
#if defined(__AVR_ATmega8__)
/* {{{ */
#define _ATMEGA8
#define _TIMSK_TIMER1 TIMSK
#define _UDRIE_UART0 UDRIE
#define _TXEN_UART0 TXEN
#define _RXEN_UART0 RXEN
#define _RXCIE_UART0 RXCIE
#define _UBRRH_UART0 UBRRH
#define _UBRRL_UART0 UBRRL
#define _UCSRA_UART0 UCSRA
#define _UCSRB_UART0 UCSRB
#define _UCSRC_UART0 UCSRC
#define _UCSZ0_UART0 UCSZ0
#define _UCSZ1_UART0 UCSZ1
#define _SIG_UART_RECV_UART0 SIG_UART_RECV
#define _SIG_UART_DATA_UART0 SIG_UART_DATA
#define _UDR_UART0 UDR
#define _UDRE_UART0 UDRE
#define _RXC_UART0 RXC
#define _IVREG GICR
#define _TIFR_TIMER1 TIFR
#define MCUSR MCUCSR
/* see datasheet! */
#define _SIG_BYTE_1 0x1e
#define _SIG_BYTE_2 0x93
#define _SIG_BYTE_3 0x07
/* see avrdude configuration */
#define _AVR910_DEVCODE 0x76
/* }}} */
#elif defined(__AVR_ATmega88__)
/* {{{ */
#define _ATMEGA88
#define _TIMSK_TIMER1 TIMSK1
#define _UDRIE_UART0 UDRIE0
#define _TXEN_UART0 TXEN0
#define _RXEN_UART0 RXEN0
#define _RXCIE_UART0 RXCIE0
#define _UBRRH_UART0 UBRR0H
#define _UBRRL_UART0 UBRR0L
#define _UCSRA_UART0 UCSR0A
#define _UCSRB_UART0 UCSR0B
#define _UCSRC_UART0 UCSR0C
#define _UCSZ0_UART0 UCSZ00
#define _UCSZ1_UART0 UCSZ01
#define _SIG_UART_RECV_UART0 SIG_USART_RECV
#define _SIG_UART_DATA_UART0 SIG_USART_DATA
#define _UDR_UART0 UDR0
#define _UDRE_UART0 UDRE0
#define _RXC_UART0 RXC0
#define _IVREG MCUCR
#define _TIFR_TIMER1 TIFR1
/* see datasheet! */
#define _SIG_BYTE_1 0x1e
#define _SIG_BYTE_2 0x93
#define _SIG_BYTE_3 0x0a
/* see avrdude configuration */
#define _AVR910_DEVCODE 0x33
/* }}} */
#elif defined(__AVR_ATmega168__)
/* {{{ */
#define _ATMEGA168
#define _TIMSK_TIMER1 TIMSK1
#define _UDRIE_UART0 UDRIE0
#define _TXEN_UART0 TXEN0
#define _RXEN_UART0 RXEN0
#define _RXCIE_UART0 RXCIE0
#define _UBRRH_UART0 UBRR0H
#define _UBRRL_UART0 UBRR0L
#define _UCSRA_UART0 UCSR0A
#define _UCSRB_UART0 UCSR0B
#define _UCSRC_UART0 UCSR0C
#define _UCSZ0_UART0 UCSZ00
#define _UCSZ1_UART0 UCSZ01
#define _SIG_UART_RECV_UART0 SIG_USART_RECV
#define _SIG_UART_DATA_UART0 SIG_USART_DATA
#define _UDR_UART0 UDR0
#define _UDRE_UART0 UDRE0
#define _RXC_UART0 RXC0
#define _IVREG MCUCR
#define _TIFR_TIMER1 TIFR1
/* see datasheet! */
#define _SIG_BYTE_1 0x1e
#define _SIG_BYTE_2 0x94
#define _SIG_BYTE_3 0x06
/* see avrdude configuration */
#define _AVR910_DEVCODE 0x35
/* }}} */
#elif defined(__AVR_ATmega32__)
/* {{{ */
#define _ATMEGA32
#define _TIMSK_TIMER1 TIMSK1
#define _UDRIE_UART0 UDRIE0
#define _TXEN_UART0 TXEN
#define _RXEN_UART0 RXEN
#define _RXCIE_UART0 RXCIE0
#define _UBRRH_UART0 UBRRH
#define _UBRRL_UART0 UBRRL
#define _UCSRA_UART0 UCSRA
#define _UCSRB_UART0 UCSRB
#define _UCSRC_UART0 UCSRC
#define _UCSZ0_UART0 UCSZ00
#define _UCSZ1_UART0 UCSZ01
#define _SIG_UART_RECV_UART0 SIG_USART_RECV
#define _SIG_UART_DATA_UART0 SIG_USART_DATA
#define _UDR_UART0 UDR
#define _UDRE_UART0 UDRE
#define _RXC_UART0 RXC
#define _IVREG MCUCR
#define _TIFR_TIMER1 TIFR
/* see datasheet! */
#define _SIG_BYTE_1 0x1e
#define _SIG_BYTE_2 0x95
#define _SIG_BYTE_3 0x02
/* see avrdude configuration */
#define _AVR910_DEVCODE 0x72
/* }}} */
#elif defined(__AVR_ATmega16__)
/* {{{ */
#define _ATMEGA16
#define _TIMSK_TIMER1 TIMSK1
#define _UDRIE_UART0 UDRIE0
#define _TXEN_UART0 TXEN
#define _RXEN_UART0 RXEN
#define _RXCIE_UART0 RXCIE0
#define _UBRRH_UART0 UBRRH
#define _UBRRL_UART0 UBRRL
#define _UCSRA_UART0 UCSRA
#define _UCSRB_UART0 UCSRB
#define _UCSRC_UART0 UCSRC
#define _UCSZ0_UART0 UCSZ00
#define _UCSZ1_UART0 UCSZ01
#define _SIG_UART_RECV_UART0 SIG_USART_RECV
#define _SIG_UART_DATA_UART0 SIG_USART_DATA
#define _UDR_UART0 UDR
#define _UDRE_UART0 UDRE
#define _RXC_UART0 RXC
#define _IVREG MCUCR
#define _TIFR_TIMER1 TIFR
#define MCUSR MCUCSR
/* see datasheet! */
#define _SIG_BYTE_1 0x1e
#define _SIG_BYTE_2 0x94
#define _SIG_BYTE_3 0x03
/* see avrdude configuration */
#define _AVR910_DEVCODE 0x75
/* }}} */
#elif defined(__AVR_ATmega644__)
/* {{{ */
#define _ATMEGA644
#define _TIMSK_TIMER1 TIMSK1
#define _UDRIE_UART0 UDRIE0
#define _TXEN_UART0 TXEN0
#define _RXEN_UART0 RXEN0
#define _RXCIE_UART0 RXCIE0
#define _UBRRH_UART0 UBRR0H
#define _UBRRL_UART0 UBRR0L
#define _UCSRA_UART0 UCSR0A
#define _UCSRB_UART0 UCSR0B
#define _UCSRC_UART0 UCSR0C
#define _UCSZ0_UART0 UCSZ00
#define _UCSZ1_UART0 UCSZ01
#define _SIG_UART_RECV_UART0 SIG_USART_RECV
#define _SIG_UART_DATA_UART0 SIG_USART_DATA
#define _UDR_UART0 UDR0
#define _UDRE_UART0 UDRE0
#define _RXC_UART0 RXC0
#define _IVREG MCUCR
#define _TIFR_TIMER1 TIFR1
/* see datasheet! */
#define _SIG_BYTE_1 0x1e
#define _SIG_BYTE_2 0x96
#define _SIG_BYTE_3 0x09
/* see avrdude configuration */
#define _AVR910_DEVCODE 0x02
/* }}} */
#elif defined(__AVR_ATmega128__)
/* {{{ */
#define _ATMEGA128
#define _TIMSK_TIMER1 TIMSK1
#define _UDRIE_UART0 UDRIE0
#define _TXEN_UART0 TXEN
#define _RXEN_UART0 RXEN
#define _RXCIE_UART0 RXCIE0
#define _UBRRH_UART0 UBRR0H
#define _UBRRL_UART0 UBRR0L
#define _UCSRA_UART0 UCSR0A
#define _UCSRB_UART0 UCSR0B
#define _UCSRC_UART0 UCSR0C
#define _UCSZ0_UART0 UCSZ00
#define _UCSZ1_UART0 UCSZ01
#define _SIG_UART_RECV_UART0 SIG_USART_RECV
#define _SIG_UART_DATA_UART0 SIG_USART_DATA
#define _UDR_UART0 UDR0
#define _UDRE_UART0 UDRE
#define _RXC_UART0 RXC
#define _IVREG MCUCR
#define _TIFR_TIMER1 TIFR
/* see datasheet! */
#define _SIG_BYTE_1 0x1e
#define _SIG_BYTE_2 0x97
#define _SIG_BYTE_3 0x02
/* see avrdude configuration */
#define _AVR910_DEVCODE 0x44
/* }}} */
#else
#error "this cpu is not supported yet!"
#endif
#endif /* __AVR__ */
/* debug defines */
#ifndef DEBUG
#define DEBUG 0
#endif
/* do not send boot message by default */
#ifndef SEND_BOOT_MESSAGE
#define SEND_BOOT_MESSAGE 0
#endif
/* bootloader activation methods */
/* 1) activation via jumper */
//#define BOOTLOADER_JUMPER
/* jumper configuration */
#ifndef BOOTLOADER_DDR
#define BOOTLOADER_DDR DDRC
#endif
#ifndef BOOTLOADER_PORT
#define BOOTLOADER_PORT PORTC
#endif
#ifndef BOOTLOADER_PIN
#define BOOTLOADER_PIN PINC
#endif
#ifndef BOOTLOADER_PINNUM
#define BOOTLOADER_PINNUM PINC0
#endif
#define BOOTLOADER_MASK _BV(BOOTLOADER_PINNUM)
/* 2) activation via char */
//#define BOOTLOADER_CHAR
#ifndef BOOTLOADER_ENTRY_CHAR
#define BOOTLOADER_ENTRY_CHAR 'p'
#endif
#ifndef BOOTLOADER_SUCCESS_CHAR
#define BOOTLOADER_SUCCESS_CHAR 'S'
#endif
/* uart configuration */
#define UART_BAUDRATE 115200
/* watchdog configuration */
#define HONOR_WATCHDOG_RESET
/* buffer load configuration */
#define BLOCKSIZE SPM_PAGESIZE
/* by default, ignore the exit-bootloader command */
#define EXIT_BOOTLOADER 0
/* use 8 or 16 bit counter, according to the page size of the target device */
#if SPM_PAGESIZE < 256
# define BUF_T uint8_t
#else
# define BUF_T uint16_t
#endif
/* use 16 or 32 bit counter, according to the flash page count of the target device */
#if BOOT_SECTION_START <= 65535
# define FLASH_ADDR_T uint16_t
#else
# define FLASH_ADDR_T uint32_t
#endif
/* version information */
#define VERSION_BYTE_1 '0'
#define VERSION_BYTE_2 '2'
#endif /* _FOODLOADER_CONFIG_H */