File: using-tools.dox

package info (click to toggle)
avr-libc 1%3A1.6.2.cvs20080610-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 14,848 kB
  • ctags: 55,619
  • sloc: ansic: 92,267; asm: 6,692; sh: 4,131; makefile: 2,481; python: 976; pascal: 426; perl: 116
file content (749 lines) | stat: -rw-r--r-- 29,288 bytes parent folder | download
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
/* Copyright (c) 2002,2004,2005,2006,2007 Joerg Wunsch
   All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:

   * Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
   * Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in
     the documentation and/or other materials provided with the
     distribution.
   * Neither the name of the copyright holders nor the names of
     contributors may be used to endorse or promote products derived
     from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  POSSIBILITY OF SUCH DAMAGE. */

/* $Id: using-tools.dox,v 1.39.2.10 2008/03/25 22:33:29 arcanum Exp $ */

/** \page using_tools Using the GNU tools

This is a short summary of the AVR-specific aspects of using the GNU
tools.  Normally, the generic documentation of these tools is fairly
large and maintained in \c texinfo files.  Command-line options are
explained in detail in the manual page.

\section using_avr_gcc Options for the C compiler avr-gcc

\subsection using_avr_gcc_mach_opt Machine-specific options for the AVR

The following machine-specific options are recognized by the C
compiler frontend.
In addition to the preprocessor macros indicated in the tables
below, the preprocessor will define the macros __AVR and __AVR__
(to the value 1) when compiling for an AVR target.  The macro
AVR will be defined as well when using the standard levels gnu89
(default) and gnu99 but not with c89 and c99.

- <tt>-mmcu=</tt><em>architecture</em>
  <p>
  Compile code for \e architecture.  Currently known architectures
  are
  </p>
  <p>
  <table>
  <tr>
    <td>Architecture</td>
    <td>Macros</td>
    <td>Description</td>
  </tr>
  <tr>
    <td>avr1</td>
    <td>
    __AVR_ARCH__=1<BR>
    __AVR_ASM_ONLY__<BR>
    __AVR_2_BYTE_PC__&nbsp;[2]
    </td>
    <td>Simple CPU core, only assembler support</td>
  </tr>
  <tr>
    <td>avr2</td>
    <td>
    __AVR_ARCH__=2<BR>
    __AVR_2_BYTE_PC__&nbsp;[2]
    </td>
    <td>"Classic" CPU core, up to 8 KB of ROM</td>
  </tr>
  <tr>
    <td>avr25&nbsp;[1]</td>
    <td>
    __AVR_ARCH__=25<BR>
    __AVR_HAVE_MOVW__&nbsp;[1]<BR>
    __AVR_HAVE_LPMX__&nbsp;[1]<BR>
    __AVR_2_BYTE_PC__&nbsp;[2]
    </td>
    <td>"Classic" CPU core with 'MOVW' and 'LPM Rx, Z[+]' instruction, up to 8 KB of ROM</td>
  </tr>
  <tr>
    <td>avr3</td>
    <td>
    __AVR_ARCH__=3<BR>
    __AVR_MEGA__&nbsp;[5]<BR>
    __AVR_HAVE_JMP_CALL__&nbsp;[4]<BR>
    __AVR_2_BYTE_PC__&nbsp;[2]
    </td>
    <td>"Classic" CPU core, 16 KB to 64 KB of ROM</td>
  </tr>
  <tr>
    <td>avr31</td>
    <td>
    __AVR_ARCH__=31<BR>
    __AVR_MEGA__<BR>
    __AVR_HAVE_RAMPZ__[4]<BR>
    __AVR_HAVE_ELPM__[4]<BR>
    __AVR_2_BYTE_PC__&nbsp;[2]
    </td>
    <td>"Classic" CPU core, 128 KB of ROM</td>  </tr>
  <tr>
    <td>avr35&nbsp;[3]</td>
    <td>
    __AVR_ARCH__=35<BR>
    __AVR_MEGA__&nbsp;[5]<BR>
    __AVR_HAVE_JMP_CALL__&nbsp;[4]<BR>
    __AVR_HAVE_MOVW__&nbsp;[1]<BR>
    __AVR_HAVE_LPMX__&nbsp;[1]<BR>
    __AVR_2_BYTE_PC__&nbsp;[2]
    </td>
    <td>"Classic" CPU core with 'MOVW' and 'LPM Rx, Z[+]' instruction, 16 KB to 64 KB of ROM</td>
  </tr>
  <tr>
    <td>avr4</td>
    <td>
    __AVR_ARCH__=4<BR>
    __AVR_ENHANCED__&nbsp;[5]<BR>
    __AVR_HAVE_MOVW__&nbsp;[1]<BR>
    __AVR_HAVE_LPMX__&nbsp;[1]<BR>
    __AVR_HAVE_MUL__&nbsp;[1]<BR>
    __AVR_2_BYTE_PC__&nbsp;[2]
    </td>
    <td>"Enhanced" CPU core, up to 8 KB of ROM</td>
  </tr>
  <tr>
    <td>avr5</td>
    <td>
    __AVR_ARCH__=5<BR>
    __AVR_MEGA__&nbsp;[5]<BR>
    __AVR_ENHANCED__&nbsp;[5]<BR>
    __AVR_HAVE_JMP_CALL__&nbsp;[4]<BR>
    __AVR_HAVE_MOVW__&nbsp;[1]<BR>
    __AVR_HAVE_LPMX__&nbsp;[1]<BR>
    __AVR_HAVE_MUL__&nbsp;[1]<BR>
    __AVR_2_BYTE_PC__&nbsp;[2]
    </td>
    <td>"Enhanced" CPU core, 16 KB to 64 KB of ROM</td>
  </tr>
  <tr>
    <td>avr51</td>
    <td>
    __AVR_ARCH__=51<BR>
    __AVR_MEGA__<BR>
    __AVR_ENHANCED__<BR>
    __AVR_HAVE_MOVW__&nbsp;[1]<BR>
    __AVR_HAVE_LPMX__&nbsp;[1]<BR>
    __AVR_HAVE_MUL__&nbsp;[1]<BR>
    __AVR_HAVE_RAMPZ__[4]<BR>
    __AVR_HAVE_ELPM__[4]<BR>
    __AVR_HAVE_ELPMX__[4]<BR>
    __AVR_2_BYTE_PC__&nbsp;[2]
    </td>
    <td>"Enhanced" CPU core, 128 KB of ROM</td>
  </tr>
  <tr>
    <td>avr6&nbsp;[2]</td>
    <td>
    __AVR_ARCH__=6<BR>
    __AVR_MEGA__&nbsp;[5]<BR>
    __AVR_ENHANCED__&nbsp;[5]<BR>
    __AVR_HAVE_JMP_CALL__&nbsp;[4]<BR>
    __AVR_HAVE_MOVW__&nbsp;[1]<BR>
    __AVR_HAVE_LPMX__&nbsp;[1]<BR>
    __AVR_HAVE_MUL__&nbsp;[1]<BR>
    __AVR_HAVE_RAMPZ__[4]<BR>
    __AVR_HAVE_ELPM__[4]<BR>
    __AVR_HAVE_ELPMX__[4]<BR>
    __AVR_3_BYTE_PC__&nbsp;[2]
    </td>
    <td>"Enhanced" CPU core, 256 KB of ROM</td>
  </tr>
  </table>
  <p>
  [1] New in GCC 4.2<BR>
  [2] Unofficial patch for GCC 4.1<BR>
  [3] New in GCC 4.2.3<BR>
  [4] New in GCC 4.3<BR>
  [5] Obsolete.
  </p>
  </p>
  <p>
  By default, code is generated for the avr2 architecture.
  </p>
  <p>
  Note that when only using <tt>-mmcu=</tt><em>architecture</em> but
  no <tt>-mmcu=</tt><em>MCU type</em>, including the file
  <tt>&lt;avr/io.h&gt;</tt> cannot work since it cannot decide which
  device's definitions to select.
  </p>

- <tt>-mmcu=</tt><em>MCU type</em>
  <p>
  The following MCU types are currently understood by avr-gcc.  The
  table matches them against the corresponding avr-gcc architecture
  name, and shows the preprocessor symbol declared by the \c -mmcu
  option.
  </p>
  <p>
  <table>
  <tr><td>Architecture</td><td>MCU name</td><td>Macro</td></tr>
  <tr><td>avr1</td><td>at90s1200</td><td>__AVR_AT90S1200__</td></tr>
  <tr><td>avr1</td><td>attiny11</td><td>__AVR_ATtiny11__</td></tr>
  <tr><td>avr1</td><td>attiny12</td><td>__AVR_ATtiny12__</td></tr>
  <tr><td>avr1</td><td>attiny15</td><td>__AVR_ATtiny15__</td></tr>
  <tr><td>avr1</td><td>attiny28</td><td>__AVR_ATtiny28__</td></tr>
  <tr><td>avr2</td><td>at90s2313</td><td>__AVR_AT90S2313__</td></tr>
  <tr><td>avr2</td><td>at90s2323</td><td>__AVR_AT90S2323__</td></tr>
  <tr><td>avr2</td><td>at90s2333</td><td>__AVR_AT90S2333__</td></tr>
  <tr><td>avr2</td><td>at90s2343</td><td>__AVR_AT90S2343__</td></tr>
  <tr><td>avr2</td><td>attiny22</td><td>__AVR_ATtiny22__</td></tr>
  <tr><td>avr2</td><td>attiny26</td><td>__AVR_ATtiny26__</td></tr>
  <tr><td>avr2</td><td>at90s4414</td><td>__AVR_AT90S4414__</td></tr>
  <tr><td>avr2</td><td>at90s4433</td><td>__AVR_AT90S4433__</td></tr>
  <tr><td>avr2</td><td>at90s4434</td><td>__AVR_AT90S4434__</td></tr>
  <tr><td>avr2</td><td>at90s8515</td><td>__AVR_AT90S8515__</td></tr>
  <tr><td>avr2</td><td>at90c8534</td><td>__AVR_AT90C8534__</td></tr>
  <tr><td>avr2</td><td>at90s8535</td><td>__AVR_AT90S8535__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>at86rf401</td><td>__AVR_AT86RF401__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny13</td><td>__AVR_ATtiny13__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny2313</td><td>__AVR_ATtiny2313__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny24</td><td>__AVR_ATtiny24__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny25</td><td>__AVR_ATtiny25__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny261</td><td>__AVR_ATtiny261__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny43u</td><td>__AVR_ATtiny43U__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny44</td><td>__AVR_ATtiny44__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny45</td><td>__AVR_ATtiny45__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny461</td><td>__AVR_ATtiny461__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny48</td><td>__AVR_ATtiny48__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny84</td><td>__AVR_ATtiny84__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny85</td><td>__AVR_ATtiny85__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny861</td><td>__AVR_ATtiny861__</td></tr>
  <tr><td>avr2/avr25&nbsp;[1]</td><td>attiny88</td><td>__AVR_ATtiny88__</td></tr>
  <tr><td>avr3</td><td>atmega603</td><td>__AVR_ATmega603__</td></tr>
  <tr><td>avr3</td><td>at43usb320</td><td>__AVR_AT43USB320__</td></tr>
  <tr><td>avr3</td><td>at43usb355</td><td>__AVR_AT43USB355__</td></tr>
  <tr><td>avr3/avr31&nbsp;[3]</td><td>atmega103</td><td>__AVR_ATmega103__</td></tr>
  <tr><td>avr3/avr35&nbsp;[2]</td><td>at90usb82</td><td>__AVR_AT90USB82__</td></tr>
  <tr><td>avr3/avr35&nbsp;[2]</td><td>at90usb162</td><td>__AVR_AT90USB162__</td></tr>
  <tr><td>avr3/avr35&nbsp;[2]</td><td>attiny167</td><td>__AVR_ATtiny167__</td></tr>
  <tr><td>avr3</td><td>at76c711</td><td>__AVR_AT76C711__</td></tr>
  <tr><td>avr4</td><td>atmega48</td><td>__AVR_ATmega48__</td></tr>
  <tr><td>avr4</td><td>atmega48p</td><td>__AVR_ATmega48P__</td></tr>
  <tr><td>avr4</td><td>atmega8</td><td>__AVR_ATmega8__</td></tr>
  <tr><td>avr4</td><td>atmega8515</td><td>__AVR_ATmega8515__</td></tr>
  <tr><td>avr4</td><td>atmega8535</td><td>__AVR_ATmega8535__</td></tr>
  <tr><td>avr4</td><td>atmega88</td><td>__AVR_ATmega88__</td></tr>
  <tr><td>avr4</td><td>atmega88p</td><td>__AVR_ATmega88P__</td></tr>
  <tr><td>avr4</td><td>atmega8hva</td><td>__AVR_ATmega8HVA__</td></tr>
  <tr><td>avr4</td><td>at90pwm1</td><td>__AVR_AT90PWM1__</td></tr>
  <tr><td>avr4</td><td>at90pwm2</td><td>__AVR_AT90PWM2__</td></tr>
  <tr><td>avr4</td><td>at90pwm2b</td><td>__AVR_AT90PWM2B__</td></tr>
  <tr><td>avr4</td><td>at90pwm3</td><td>__AVR_AT90PWM3__</td></tr>
  <tr><td>avr4</td><td>at90pwm3b</td><td>__AVR_AT90PWM3B__</td></tr>
  <tr><td>avr5</td><td>at90pwm216</td><td>__AVR_AT90PWM216__</td></tr>
  <tr><td>avr5</td><td>at90pwm316</td><td>__AVR_AT90PWM316__</td></tr>
  <tr><td>avr5</td><td>at90can32</td><td>__AVR_AT90CAN32__</td></tr>
  <tr><td>avr5</td><td>at90can64</td><td>__AVR_AT90CAN64__</td></tr>
  <tr><td>avr5</td><td>at90usb646</td><td>__AVR_AT90USB646__</td></tr>
  <tr><td>avr5</td><td>at90usb647</td><td>__AVR_AT90USB647__</td></tr>
  <tr><td>avr5</td><td>atmega16</td><td>__AVR_ATmega16__</td></tr>
  <tr><td>avr5</td><td>atmega161</td><td>__AVR_ATmega161__</td></tr>
  <tr><td>avr5</td><td>atmega162</td><td>__AVR_ATmega162__</td></tr>
  <tr><td>avr5</td><td>atmega163</td><td>__AVR_ATmega163__</td></tr>
  <tr><td>avr5</td><td>atmega164p</td><td>__AVR_ATmega164P__</td></tr>
  <tr><td>avr5</td><td>atmega165</td><td>__AVR_ATmega165__</td></tr>
  <tr><td>avr5</td><td>atmega165p</td><td>__AVR_ATmega165P__</td></tr>
  <tr><td>avr5</td><td>atmega168</td><td>__AVR_ATmega168__</td></tr>
  <tr><td>avr5</td><td>atmega168p</td><td>__AVR_ATmega168P__</td></tr>
  <tr><td>avr5</td><td>atmega169</td><td>__AVR_ATmega169__</td></tr>
  <tr><td>avr5</td><td>atmega169p</td><td>__AVR_ATmega169P__</td></tr>
  <tr><td>avr5</td><td>atmega16hva</td><td>__AVR_ATmega16HVA__</td></tr>
  <tr><td>avr5</td><td>atmega32</td><td>__AVR_ATmega32__</td></tr>
  <tr><td>avr5</td><td>atmega323</td><td>__AVR_ATmega323__</td></tr>
  <tr><td>avr5</td><td>atmega324p</td><td>__AVR_ATmega324P__</td></tr>
  <tr><td>avr5</td><td>atmega325</td><td>__AVR_ATmega325__</td></tr>
  <tr><td>avr5</td><td>atmega325p</td><td>__AVR_ATmega325P__</td></tr>
  <tr><td>avr5</td><td>atmega3250</td><td>__AVR_ATmega3250__</td></tr>
  <tr><td>avr5</td><td>atmega3250p</td><td>__AVR_ATmega3250P__</td></tr>
  <tr><td>avr5</td><td>atmega328p</td><td>__AVR_ATmega328P__</td></tr>
  <tr><td>avr5</td><td>atmega329</td><td>__AVR_ATmega329__</td></tr>
  <tr><td>avr5</td><td>atmega329p</td><td>__AVR_ATmega329P__</td></tr>
  <tr><td>avr5</td><td>atmega3290</td><td>__AVR_ATmega3290__</td></tr>
  <tr><td>avr5</td><td>atmega3290p</td><td>__AVR_ATmega3290P__</td></tr>
  <tr><td>avr5</td><td>atmega32c1</td><td>__AVR_ATMEGA32C1__</td></tr>
  <tr><td>avr5</td><td>atmega32hvb</td><td>__AVR_ATmega32HVB__</td></tr>
  <tr><td>avr5</td><td>atmega32m1</td><td>__AVR_ATMEGA32M1__</td></tr>
  <tr><td>avr5</td><td>atmega32u4</td><td>__AVR_ATMEGA32U4__</td></tr>
  <tr><td>avr5</td><td>atmega406</td><td>__AVR_ATmega406__</td></tr>
  <tr><td>avr5</td><td>atmega64</td><td>__AVR_ATmega64__</td></tr>
  <tr><td>avr5</td><td>atmega640</td><td>__AVR_ATmega640__</td></tr>
  <tr><td>avr5</td><td>atmega644</td><td>__AVR_ATmega644__</td></tr>
  <tr><td>avr5</td><td>atmega644p</td><td>__AVR_ATmega644P__</td></tr>
  <tr><td>avr5</td><td>atmega645</td><td>__AVR_ATmega645__</td></tr>
  <tr><td>avr5</td><td>atmega6450</td><td>__AVR_ATmega6450__</td></tr>
  <tr><td>avr5</td><td>atmega649</td><td>__AVR_ATmega649__</td></tr>
  <tr><td>avr5</td><td>atmega6490</td><td>__AVR_ATmega6490__</td></tr>
  <tr><td>avr5</td><td>at94k</td><td>__AVR_AT94K__</td></tr>
  <tr><td>avr5/avr51&nbsp;[3]</td><td>atmega128</td><td>__AVR_ATmega128__</td></tr>
  <tr><td>avr5/avr51&nbsp;[3]</td><td>atmega1280</td><td>__AVR_ATmega1280__</td></tr>
  <tr><td>avr5/avr51&nbsp;[3]</td><td>atmega1281</td><td>__AVR_ATmega1281__</td></tr>
  <tr><td>avr5/avr51&nbsp;[3]</td><td>atmega1284p</td><td>__AVR_ATmega1284P__</td></tr>
  <tr><td>avr5/avr51&nbsp;[3]</td><td>at90can128</td><td>__AVR_AT90CAN128__</td></tr>
  <tr><td>avr5/avr51&nbsp;[3]</td><td>at90usb1286</td><td>__AVR_AT90USB1286__</td></tr>
  <tr><td>avr5/avr51&nbsp;[3]</td><td>at90usb1287</td><td>__AVR_AT90USB1287__</td></tr>
  <tr><td>avr6</td><td>atmega2560</td><td>__AVR_ATmega2560__</td></tr>
  <tr><td>avr6</td><td>atmega2561</td><td>__AVR_ATmega2561__</td></tr>
  <tr><td>avrxmega5</td><td>atxmega64a1</td><td>__AVR_ATxmega64A1__</td></tr>
  <tr><td>avrxmega7</td><td>atxmega128a1</td><td>__AVR_ATxmega128A1__</td></tr>
  

  </table>
  </p>
  <p>
  [1] 'avr25' architecture is new in GCC 4.2<BR>
  [2] 'avr35' architecture is new in GCC 4.2.3
  </p>

- \c -morder1
- \c -morder2
  <p>
  Change the order of register assignment.  The default is
  </p>
  <p>
    r24, r25, r18, r19, r20, r21, r22, r23, r30, r31, r26, r27, r28,
    r29, r17, r16, r15, r14, r13, r12, r11, r10, r9, r8, r7, r6, r5,
    r4, r3, r2, r0, r1
  </p>
  <p>
  Order 1 uses
  </p>
  <p>
    r18, r19, r20, r21, r22, r23, r24, r25, r30, r31, r26, r27, r28,
    r29, r17, r16, r15, r14, r13, r12, r11, r10, r9, r8, r7, r6, r5,
    r4, r3, r2, r0, r1
  </p>
  <p>
  Order 2 uses
  </p>
  <p>
    r25, r24, r23, r22, r21, r20, r19, r18, r30, r31, r26, r27, r28,
    r29, r17, r16, r15, r14, r13, r12, r11, r10, r9, r8, r7, r6, r5,
    r4, r3, r2, r1, r0
  </p>

- \c -mint8
  <p>
  Assume \c int to be an 8-bit integer.  Note that this is not really
  supported by \c avr-libc, so it should normally not be used.  The
  default is to use 16-bit integers.
  </p>

- \c -mno-interrupts
  <p>
  Generates code that changes the stack pointer without disabling
  interrupts.  Normally, the state of the status register \c SREG
  is saved in a temporary register, interrupts are disabled while
  changing the stack pointer, and \c SREG is restored.
  </p>
  <p>
  Specifying this option will define the preprocessor macro
  \c __NO_INTERRUPTS__ to the value 1.
  </p>

- \c -mcall-prologues
  <p>
  Use subroutines for function prologue/epilogue.  For complex
  functions that use many registers (that needs to be saved/restored
  on function entry/exit), this saves some space at the cost of a
  slightly increased execution time.
  </p>

- \c -mtiny-stack
  <p>
  Change only the low 8 bits of the stack pointer.
  </p>

- \c -mno-tablejump
  <p>
  Do not generate tablejump instructions.  By default, jump tables can
  be used to optimize \c switch statements.  When turned off,
  sequences of compare statements are used instead.  Jump tables are
  usually faster to execute on average, but in particular for \c switch
  statements where most of the jumps would go to the default label,
  they might waste a bit of flash memory.
  </p>

- \c -mshort-calls
  <p>
  Use \c rjmp/rcall (limited range) on >8K devices.  On \c avr2 and
  \c avr4 architectures (less than 8 KB or flash memory), this is
  always the case.  On \c avr3 and \c avr5 architectures, calls and
  jumps to targets outside the current function will by default
  use \c jmp/call instructions that can cover the entire address
  range, but that require more flash ROM and execution time.
  </p>

- \c -mrtl
  <p>
  Dump the internal compilation result called "RTL" into comments in
  the generated assembler code.  Used for debugging avr-gcc.
  </p>

- \c -msize
  <p>
  Dump the address, size, and relative cost of each statement into
  comments in the generated assembler code.  Used for debugging avr-gcc.
  </p>

- \c -mdeb
  <p>
  Generate lots of debugging information to \c stderr.
  </p>


\subsection using_sel_gcc_opts Selected general compiler options

The following general gcc options might be of some interest to AVR
users.

- <tt>-O</tt><em>n</em>
  <p>
  \anchor gcc_optO
  Optimization level \e n.  Increasing \e n is meant to optimize more,
  an optimization level of 0 means no optimization at all, which is
  the default if no \c -O option is present.  The special option \c
  -Os is meant to turn on all \c -O2 optimizations that are not
  expected to increase code size.
  </p>
  <p>
  Note that at \c -O3, gcc attempts to inline all "simple" functions.
  For the AVR target, this will normally constitute a large
  pessimization due to the code increasement.  The only other
  optimization turned on with \c -O3 is \c -frename-registers, which
  could rather be enabled manually instead.
  </p>
  <p>
  A simple \c -O option is equivalent to \c -O1.
  </p>
  <p>
  Note also that turning off all optimizations will prevent some
  warnings from being issued since the generation of those warnings
  depends on code analysis steps that are only performed when
  optimizing (unreachable code, unused variables).
  </p>
  <p>
  See also the \ref faq_gdboptimize "appropriate FAQ entry" for
  issues regarding debugging optimized code.
  </p>

- <tt>-Wa,</tt><em>assembler-options</em>
- <tt>-Wl,</tt><em>linker-options</em>
  <p>
  \anchor gcc_minusW
  Pass the listed options to the assembler, or linker, respectively.
  </p>

- \c -g
  <p>
  Generate debugging information that can be used by avr-gdb.
  </p>

- \c -ffreestanding
  <p>
  Assume a "freestanding" environment as per the C standard.  This
  turns off automatic builtin functions (though they can still be
  reached by prepending \c __builtin_ to the actual function name).
  It also makes the compiler not complain when \c main() is declared
  with a \c void return type which makes some sense in a
  microcontroller environment where the application cannot
  meaningfully provide a return value to its environment (in most
  cases, \c main() won't even return anyway).  However, this also
  turns off all optimizations normally done by the compiler which
  assume that functions known by a certain name behave as described
  by the standard.  E. g., applying the function strlen() to a
  literal string will normally cause the compiler to immediately
  replace that call by the actual length of the string, while with
  \c -ffreestanding, it will always call strlen() at run-time.
  </p>

- \c -funsigned-char
  <p>
  Make any unqualfied \c char type an unsigned char.  Without this
  option, they default to a signed char.
  </p>

- \c -funsigned-bitfields
  <p>
  Make any unqualified bitfield type unsigned.  By default, they
  are signed.
  </p>

- \c -fshort-enums
  <p>
  Allocate to an \c enum type only as many bytes as it needs for the
  declared range of possible values. Specifically, the enum type will
  be equivalent to the smallest integer type which has enough room.
  </p>

- \c -fpack-struct
  <p>
  Pack all structure members together without holes.
  </p>

\section using_avr_as Options for the assembler avr-as

\subsection using_avr_as_mach_opts Machine-specific assembler options

- <tt>-mmcu=</tt><em>architecture</em>
- <tt>-mmcu=</tt><em>MCU name</em>
  <p>
  avr-as understands the same \c -mmcu= options as
  \ref using_avr_gcc "avr-gcc".  By default, avr2 is assumed,
  but this can be altered by using the appropriate \c .arch
  pseudo-instruction inside the assembler source file.
  </p>

- \c -mall-opcodes
  <p>
  Turns off opcode checking for the actual MCU type, and allows any
  possible AVR opcode to be assembled.
  </p>

- \c -mno-skip-bug
  <p>
  Don't emit a warning when trying to skip a 2-word instruction
  with a <tt>CPSE/SBIC/SBIS/SBRC/SBRS</tt> instruction.  Early AVR
  devices suffered from a hardware bug where these instructions
  could not be properly skipped.
  </p>

- \c -mno-wrap
  <p>
  For <tt>RJMP/RCALL</tt> instructions, don't allow the target address
  to wrap around for devices that have more than 8 KB of memory.
  </p>

- \c --gstabs
  <p>
  Generate \c .stabs debugging symbols for assembler source lines.
  This enables avr-gdb to trace through assembler source files.  This
  option <em>must not</em> be used when assembling sources that have
  been generated by the C compiler; these files already contain the
  appropriate line number information from the C source files.
  </p>

- <tt>-a[cdhlmns=</tt><em>file</em><tt>]</tt>
  <p>
  Turn on the assembler listing.  The sub-options are:
  </p>
  <p>
  <ul>
    <li>\c c     omit false conditionals</li>
    <li>\c d     omit debugging directives</li>
    <li>\c h     include high-level source</li>
    <li>\c l     include assembly</li>
    <li>\c m     include macro expansions</li>
    <li>\c n     omit forms processing</li>
    <li>\c s     include symbols</li>
    <li><tt>=</tt><em>file</em>   set the name of the listing file</li>
  </ul>
  </p>
  <p>
  The various sub-options can be combined into a single \c -a option
  list; \e =file must be the last one in that case.
  </p>

\subsection using_avr_example Examples for assembler options passed through the C compiler

Remember that assembler options can be passed from the C compiler
frontend using \c -Wa (see \ref gcc_minusW "above"), so in order to
include the C source code into the assembler listing in file
\c foo.lst, when compiling \c foo.c, the following compiler command-line
can be used:

\verbatim
	$ avr-gcc -c -O foo.c -o foo.o -Wa,-ahls=foo.lst
\endverbatim

In order to pass an assembler file through the C preprocessor first,
and have the assembler generate line number debugging information for
it, the following command can be used:

\verbatim
	$ avr-gcc -c -x assembler-with-cpp -o foo.o foo.S -Wa,--gstabs
\endverbatim

Note that on Unix systems that have case-distinguishing file systems,
specifying a file name with the suffix \c .S (upper-case letter S)
will make the compiler automatically assume <tt>-x assembler-with-cpp</tt>,
while using \c .s would pass the file directly to the assembler (no
preprocessing done).

\section using_avr_ld Controlling the linker avr-ld

\subsection using_sel_ld_opts Selected linker options

While there are no machine-specific options for avr-ld, a number of
the standard options might be of interest to AVR users.

- <tt>-l</tt><em>name</em>
  <p>
  Locate the archive library named <tt>lib</tt><em>name</em><tt>.a</tt>,
  and use it to resolve currently unresolved symbols from it.  The
  library is searched along a path that consists of builtin pathname
  entries that have been specified at compile time (e. g.
  \c /usr/local/avr/lib on Unix systems), possibly extended by
  pathname entries as specified by \c -L options (that must precede the
  \c -l options on the command-line).
  </p>

- <tt>-L</tt><em>path</em>
  <p>
  Additional location to look for archive libraries requested by
  \c -l options.
  </p>

- <tt>--defsym </tt><em>symbol=expr</em>
  <p>
  Define a global symbol \e symbol using \e expr as the value.
  </p>

- \c -M
  <p>
  Print a linker map to \c stdout.
  </p>

- <tt>-Map </tt><em>mapfile</em>
  <p>
  Print a linker map to \e mapfile.
  </p>

- \c --cref
  <p>
  Output a cross reference table to the map file (in case \c -Map is
  also present), or to \c stdout.
  </p>

- <tt>--section-start </tt><em>sectionname=org</em>
  <p>
  Start section \e sectionname at absolute address \e org.
  </p>

- <tt>-Tbss </tt><em>org</em>
- <tt>-Tdata </tt><em>org</em>
- <tt>-Ttext </tt><em>org</em>
  <p>
  Start the \c bss, \c data, or \c text section at \e org,
  respectively.
  </p>

- <tt>-T </tt><em>scriptfile</em>
  <p>
  Use \e scriptfile as the linker script, replacing the default linker
  script.  Default linker scripts are stored in a system-specific
  location (e. g. under \c /usr/local/avr/lib/ldscripts on Unix
  systems), and consist of the AVR architecture name (avr2 through avr5)
  with the suffix \c .x appended.  They describe how the various
  \ref mem_sections "memory sections" will be linked together.
  </p>

\subsection using_pass_ld_opts Passing linker options from the C compiler

By default, all unknown non-option arguments on the avr-gcc
command-line (i. e., all filename arguments that don't have a suffix
that is handled by avr-gcc) are passed straight to the linker.  Thus,
all files ending in \c .o (object files) and \c .a (object libraries)
are provided to the linker.

System libraries are usually not passed by their explicit filename but
rather using the \c -l option which uses an abbreviated form of the
archive filename (see above).  avr-libc ships two system libraries,
\c libc.a, and \c libm.a.  While the standard library \c libc.a will
always be searched for unresolved references when the linker is started
using the C compiler frontend (i. e., there's always at least one
implied \c -lc option), the mathematics library \c libm.a needs to be
explicitly requested using \c -lm.  See also the
\ref faq_libm "entry in the FAQ" explaining this.

Conventionally, Makefiles use the \c make macro \c LDLIBS to keep
track of \c -l (and possibly \c -L) options that should only be
appended to the C compiler command-line when linking the final binary.
In contrast, the macro \c LDFLAGS is used to store other command-line
options to the C compiler that should be passed as options during the
linking stage.  The difference is that options are placed early on the
command-line, while libraries are put at the end since they are to be
used to resolve global symbols that are still unresolved at this
point.

Specific linker flags can be passed from the C compiler command-line
using the \c -Wl compiler option, see \ref gcc_minusW "above".
This option requires that there be no spaces in the appended linker
option, while some of the linker options above (like \c -Map or
\c --defsym) would require a space.  In these situations, the space
can be replaced by an equal sign as well.  For example, the following
command-line can be used to compile \c foo.c into an executable, and
also produce a link map that contains a cross-reference list in the
file \c foo.map:

\verbatim
	$ avr-gcc -O -o foo.out -Wl,-Map=foo.map -Wl,--cref foo.c
\endverbatim

Alternatively, a comma as a placeholder will be replaced by a space
before passing the option to the linker.  So for a device with
external SRAM, the following command-line would cause the linker to
place the data segment at address 0x2000 in the SRAM:

\verbatim
	$ avr-gcc -mmcu=atmega128 -o foo.out -Wl,-Tdata,0x802000
\endverbatim

See the explanation of the \ref sec_dot_data "data section" for why
0x800000 needs to be added to the actual value.  Note that
the stack will still
remain in internal RAM, through the symbol \c __stack that is provided
by the run-time startup code.  This is probably a good idea anyway
(since internal RAM access is faster), and even required for some
early devices that had hardware bugs preventing them from using a
stack in external RAM.  Note also that the heap for \c malloc()
will still be placed after all the variables in the data section,
so in this situation, no stack/heap collision can occur.

In order to relocate the stack from its default location at the top
of interns RAM, the value of the symbol \c __stack can be changed
on the linker command-line.  As the linker is typically called from
the compiler frontend, this can be achieved using a compiler option
like

\code
-Wl,--defsym=__stack=0x8003ff
\endcode

The above will make the code use stack space from RAM address 0x3ff
downwards.  The amount of stack space available then depends on the
bottom address of internal RAM for a particular device.  It is the
responsibility of the application to ensure the stack does not grow
out of bounds, as well as to arrange for the stack to not collide
with variable allocations made by the compiler (sections .data
and .bss).

*/