Скетч чтения Fuse Arduino

Исходники скетча https://github.com/WestfW/fusebytes

Исходники содержат два файла: непосредственно чтения фьюзов и дополнительный файл со списком сигнатур.
Копируем оба файла в одну папку «fusebytes» и перемещаем ее в папку «/libraries»
Затем выбираем в примерах наш скетч, загружаем в Ардуино и запускаем монитор порта.
Скетч

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
char Arduino_preprocess_edge; // hint to Arduino pre-processor
 
#include <avr/boot.h>
#include
#include "cpuname.h"
 
#define BOOT_READABLE (1<<BLB12)
 
#include <avr/pgmspace.h>
#define fp(string) flashprint(PSTR(string))
 
#if 0
/*
* These were used to fill up flash to debug some issues with
* optiboot uploads of large sketches.
*/
 
#define make64bytes(a) FLASH_STRING(__flash1 ## a, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
 
#define make256bytes(a) make64bytes(x ## a); make64bytes(x1 ##a);
make64bytes(x2 ## a); make64bytes(x3 ## a)
 
#define make1kbytes(a) make256bytes(x1 ## a); make256bytes(x2 ## a);
make256bytes(x3 ## a); make256bytes(x4 ## a)
 
#define make4kbytes(a) make1kbytes(x1 ## a); make1kbytes(x2 ## a);
make1kbytes(x3 ## a); make1kbytes(x4 ## a)
 
#define make16kbytes(a) make4kbytes(x1 ## a); make4kbytes(x2 ## a);
make4kbytes(x3 ## a); make4kbytes(x4 ## a)
 
make16kbytes(foo);
make4kbytes(bar);
make256bytes(baz);
make256bytes(baz1);
make256bytes(baz2);
#endif
 
/*
* SIGRD is a "must be zero" bit on most Arduino CPUs;
* can we read the sig or not? (Apparently, only on picopower parts)
*/
#if (!defined(SIGRD))
#define SIGRD 5
#endif
 
unsigned char _bits_low;
uint8_t fuse_bits_extended;
uint8_t fuse_bits_high;
uint8_t lock_bits;
uint8_t sig1, sig2, sig3;
uint8_t oscal;
 
#define FLASHSIZE (FLASHEND+1)
 
uint8_t *bootaddr = (uint8_t *) 0;
unsigned short bootlen = 0;
 
void setup()
{
Serial.begin(19200);
}
 
void space() {
Serial.print(' ');
}
 
void flashprint (const char p[])
{
uint8_t c;
while (0 != (c = pgm_read_byte(p++))) {
Serial.write(c);
}
}
 
void print_serno(void)
{
int i;
int unoSerial[6];
int startAddr=1018;
unsigned long serno = 0;
 
for (i = 0; i < 6; i++) {
unoSerial[i] = EEPROM.read(startAddr + i);
}
if (unoSerial[0] == 'U' && unoSerial[1] == 'N' && unoSerial[2] == 'O') {
 
fp("Your Serial Number is: UNO");
 
for (i = 3; i < 6; i = i + 1) { serno = serno*256 + unoSerial[i]; Serial.print(" "); Serial.print(unoSerial[i], HEX); } fp(" ("); Serial.print(serno); Serial.write(')'); } else { fp("No Serial Number"); } Serial.println(); }  void print_binary(uint8_t b) { for (uint8_t i=0x80; i>0; i>>=1) {
if (b&i) {
Serial.write('1');
}
else {
Serial.write('0');
}
}
}
 
/*
* print_fuse_low
* Explain the contents of the "low" fuse byte.
*
* Note that most fuses are active-low, and the the avr include files
* define them as inverted bitmasks...
*/
 
void print_fuse_low(void)
{
uint8_t b;
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) ||
defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) ||
defined(AVR_ATmega168A__) || defined(__AVR_ATmega168PA__) ||
defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) ||
defined(__AVR_ATmega8__)
/*
* Fuse Low is same on 48/88/168/328/1280/2560
*/
fp("Fuse Low = ");
print_binary(fuse_bits_low);
fp(" (");
Serial.print(fuse_bits_low, HEX);
fp(")n");
fp(" ||||++++______");
#if FLASHSIZE > 16000
switch (fuse_bits_low & 0xF) {
case 0:
fp("Reserved");
break;
case 1:
fp("External Clock");
break;
case 2:
fp("Calibrated 8MHz Internal Clock");
break;
case 3:
fp("Internal 128kHz Clock");
break;
case 4:
fp("LF Crystal, 1K CK Startup");
break;
case 5:
fp("LF Crystal 32K CK Startup");
break;
case 6:
fp("Full Swing Crystal ");
break;
case 7:
fp("Full Swing Crystal");
break;
case 8:
case 9:
fp("Low Power Crystal 0.4 - 0.8MHz");
break;
case 10:
case 11:
fp("Low Power Crystal 0.9 - 3.0MHz");
break;
case 12:
case 13:
fp("Low Power Crystal 3 - 8MHz");
break;
case 14:
case 15:
fp("Low Power Crystal 8 - 16MHz");
break;
}
 
#else
b = fuse_bits_low & 15;
if (b == 1) fp("Ext Clk");
else if (b == 3) fp("Slow Int Clk");
else {
fp("xtal Osc Type=");
Serial.print((fuse_bits_low) & 15, BIN);
}
#endif
Serial.println();
fp(" ||++__________");
fp("Start Up Time=");
Serial.print((fuse_bits_low >> 4) & 3, BIN);
#if !defined(__AVR_ATmega8__)
Serial.println();
fp(" |+____________");
fp("Clock Output ");
if (fuse_bits_low & (~FUSE_CKOUT))
fp("Disabled");
else
fp("Enabled");
 
Serial.println();
fp(" +_____________");
if (fuse_bits_low & (~FUSE_CKDIV8)) {
fp("(no divide)");
}
else {
fp("Divide Clock by 8");
}
#else
Serial.println();
fp(" |+____________");
if (fuse_bits_low & (~FUSE_BODEN))
fp("BOD Disabled");
else
fp("BOD Enabled");
 
Serial.println();
fp(" +_____________");
if (fuse_bits_low & (~FUSE_BODLEVEL)) {
fp("BOD at 2.7V");
}
else {
fp("BOD at 4.0V");
}
#endif
#endif
Serial.println();
}
 
void print_fuse_high()
{
fp("nFuse High = ");
print_binary(fuse_bits_high);
fp(" (");
Serial.print(fuse_bits_high, HEX);
fp(")n");
 
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
fp(" |||||||+______");
if (fuse_bits_high & bit(FUSE_BOOTRST)) {
fp("Reset to Start of memoryn");
}
else {
fp("Reset to Bootstrapn");
}
fp(" |||||++_______");
switch ((uint8_t)(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)))) {
case (uint8_t)((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)):
fp("256 words (512 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-512);
break;
case (uint8_t)((~FUSE_BOOTSZ1)):
fp("512 words (1024 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-1024);
break;
case (uint8_t)((~FUSE_BOOTSZ0)):
fp("1024 words (2048 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-2048);
break;
case 0:
fp("2048 words (4096 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-4096);
break;
default:
Serial.println(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)), BIN);
}
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) ||
defined(__AVR_ATmega168A__) || defined(__AVR_ATmega168PA__)
fp(" |||||+++______");
switch ((uint8_t)(fuse_bits_high & 7)) {
case 7:
fp("Brownout Disabledn");
break;
case 6:
fp("Brownout at 1.8Vn");
break;
case 5:
fp("Brownout at 2.7Vn");
break;
case 4:
fp("Brownout at 4.3Vn");
break;
default:
fp("Brownout Reserved value");
Serial.println(fuse_bits_high& 7, BIN);
break;
}
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
fp(" |||||||+______");
if (fuse_bits_high & bit(FUSE_BOOTRST)) {
fp("Reset to Start of memoryn");
}
else {
fp("Reset to Bootstrapn");
}
fp(" |||||++_______");
switch ((uint8_t)(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)))) {
case (uint8_t)((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)):
fp("512 words (1024 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-1024);
break;
case (uint8_t)((~FUSE_BOOTSZ1)):
fp("1024 words (2048 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-2048);
break;
case (uint8_t)((~FUSE_BOOTSZ0)):
fp("2048 words (4096 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-4096);
break;
case 0:
fp("4096 words (8192 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-8192);
break;
default:
Serial.println(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)), BIN);
}
#elif defined(__AVR_ATmega8__)
fp(" |||||||+______");
if (fuse_bits_high & bit(FUSE_BOOTRST)) {
fp("Reset to 0x0n");
}
else {
fp("Reset to Bootn");
}
fp(" |||||++_______");
switch ((uint8_t)(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)))) {
case (uint8_t)((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)):
fp("256 bytesn");
bootaddr = (uint8_t *) (FLASHSIZE-256);
break;
case (uint8_t)((~FUSE_BOOTSZ1)):
fp("512 bytesn");
bootaddr = (uint8_t *) (FLASHSIZE-512);
break;
case (uint8_t)((~FUSE_BOOTSZ0)):
fp("1024 bytesn");
bootaddr = (uint8_t *) (FLASHSIZE-1024);
break;
case 0:
fp("2048 bytesn");
bootaddr = (uint8_t *) (FLASHSIZE-2048);
break;
default:
Serial.println(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)), BIN);
}
#endif
fp(" ||||+_________");
if (fuse_bits_high & ~(FUSE_EESAVE)) {
fp("EEPROM Erased on chip erasen");
}
else {
fp("EEPROM Preserved on chip erasen");
}
#if !defined(__AVR_ATmega8__)
fp(" |||+__________");
if (fuse_bits_high & ~(FUSE_WDTON)) {
fp("Watchdog programmablen");
}
else {
fp("Watchdog always onn");
}
fp(" ||+___________");
if (fuse_bits_high & ~(FUSE_SPIEN)) {
fp("ISP programming disabledn");
}
else {
fp("ISP programming enabledn");
}
#if defined(FUSE_JTAGEN)
#warning Testing for JTAGEN
/*
* Big chips have JTAG and OCD
*/
fp(" |+____________");
if (fuse_bits_high & ~(FUSE_JTAGEN)) {
fp("JTAG offn");
}
else {
fp("JTAG enabledn");
}
fp(" +_____________");
if (fuse_bits_high & ~(FUSE_OCDEN)) {
fp("OCD enabledn");
}
else {
fp("OCD disabledn");
}
#else
/*
* Smaller chips have debugwire and a reprogrammable RESET
*/
#if defined (FUSE_DWEN)
fp(" |+____________");
if (fuse_bits_high & ~(FUSE_DWEN)) {
fp("DebugWire offn");
}
else {
fp("DebugWire enabledn");
}
#endif
fp(" +_____________");
if (fuse_bits_high & ~(FUSE_RSTDISBL)) {
fp("RST enabledn");
}
else {
fp("RST disabledn");
}
#endif
 
#else
/* ATmega8 */
fp(" |||+__________");
if (fuse_bits_high & ~(FUSE_CKOPT)) {
fp("Low pwr Oscn");
}
else {
fp("Full swing Oscn");
}
fp(" ||+___________");
if (fuse_bits_high & ~(FUSE_SPIEN)) {
fp("ISP disabledn");
}
else {
fp("ISP OKn");
}
fp(" |+____________");
if (fuse_bits_high & ~(FUSE_WDTON)) {
fp("Watchdog progn");
}
else {
fp("Watchdog always onn");
}
fp(" +_____________");
if (fuse_bits_high & ~(FUSE_RSTDISBL)) {
fp("RST enabledn");
}
else {
fp("RST disabledn");
}
#endif
}
 
/*
* Print info about the contents of the "Extended" fuse byte
*
*/
void print_fuse_extended()
{
#if !defined(__AVR_ATmega8__)
fp("nFuse Extended = ");
print_binary(fuse_bits_extended);
fp(" (");
Serial.print(fuse_bits_extended, HEX);
fp(")n");
#endif
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) ||
defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
fp(" |||||+++______");
switch ((uint8_t)(fuse_bits_extended & 7)) {
case 7:
fp("Brownout Disabledn");
break;
case 6:
fp("Brownout at 1.8Vn");
break;
case 5:
fp("Brownout at 2.7Vn");
break;
case 4:
fp("Brownout at 4.3Vn");
break;
default:
fp("Brownout Reserved value");
Serial.println(fuse_bits_extended & 7, BIN);
break;
}
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__)
fp(" |||||||+______");
if (fuse_bits_extended & bit(FUSE_BOOTRST)) {
fp("Reset to Start of memoryn");
}
else {
fp("Reset to Bootstrapn");
}
fp(" |||||++_______");
switch ((uint8_t)(fuse_bits_extended & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)))) {
case (uint8_t)((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)):
fp("128 words (256 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-256);
break;
case (uint8_t)((~FUSE_BOOTSZ1)):
fp("256 words (512 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-512);
break;
case (uint8_t)((~FUSE_BOOTSZ0)):
fp("512 words (1024 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-1024);
break;
case 0:
fp("1024 words (2048 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-2048);
break;
default:
Serial.println(fuse_bits_extended & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)), BIN);
}
#elif defined(__AVR_ATmega8__)
// fp("nFuse Extended not existent on ATmega8 ");
#endif
}
 
/*
* Interpret the lock bits.
* These seem to be the same on all AVRs that have them!
*/
void print_lock_bits()
{
#if FLASHSIZE > 16000
fp("nLock Bits = ");
print_binary(lock_bits);
fp(" (");
Serial.print(lock_bits, HEX);
fp(")n");
fp(" ||||||++______");
switch (((uint8_t)(lock_bits & (uint8_t)3))) {
case 3:
fp("Read/Write to everywheren");
break;
case 2:
fp("Programming of Flash/EEPROM disabledn");
break;
case 0:
fp("No Read/Write of Flash/EEPROMn");
break;
default:
Serial.println();
}
fp(" ||||++________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b1100)) { //BLB0x
case 0b1100:
fp("R/W Applicationn");
break;
case 0b1000:
fp("No Write to Appn");
break;
case 0b0000:
fp("No Write to App, no read from Bootn");
break;
case 0b0100:
fp("No Write to App, no read from Boot, no Ints to Appn");
break;
}
 
fp(" ||++__________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b110000)) { //BLB0x
case 0b110000:
fp("R/W Boot Sectionn");
break;
case 0b100000:
fp("No Write to Boot Sectionn");
break;
case 0b000000:
fp("No Write to Boot, no read from Appn");
break;
case 0b010000:
fp("No Write to Boot, no read from App, no Ints to Bootn");
break;
}
#else
fp("nLock Bits = ");
print_binary(lock_bits);
fp(" (");
Serial.print(lock_bits, HEX);
fp(")n");
fp(" ||||||++______");
switch (((uint8_t)(lock_bits & (uint8_t)3))) {
case 3:
fp("ISP RWn");
break;
case 2:
fp("ISP ROn");
break;
case 0:
fp("ISP no accessn");
break;
default:
Serial.println();
}
fp(" ||||++________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b1100)) { //BLB0x
case 0b1100:
fp("App R/Wn");
break;
case 0b1000:
fp("App ROn");
break;
case 0b0000:
fp("App No Accessn");
break;
case 0b0100:
fp("App No Access, Ints disabledn");
break;
}
 
fp(" ||++__________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b110000)) { //BLB0x
case 0b110000:
fp("Boot R/Wn");
break;
case 0b100000:
fp("Boot ROn");
break;
case 0b000000:
fp("Boot No Accessn");
break;
case 0b010000:
fp("Boot No Access. Ints disabledn");
break;
}
#endif
}
 
void print_signature()
{
fp("nSignature: ");
Serial.print(sig1, HEX);
space();
Serial.print(sig2, HEX);
space();
Serial.print(sig3, HEX);
if (sig1 == 0x1E) { /* Atmel ? */
switch (sig2) {
case 0x92: /* 4K flash */
if (sig3 == 0x0A)
fp(" (ATmega48P)");
else if (sig3 == 0x05)
fp(" (ATmega48A)");
else if (sig3 == 0x09)
fp(" (ATmega48)");
break;
case 0x93: /* 8K flash */
if (sig3 == 0x0F)
fp(" (ATmega88P)");
else if (sig3 == 0x0A)
fp(" (ATmega88A)");
else if (sig3 == 0x11)
fp(" (ATmega88)");
else if (sig3 == 0x07)
fp(" (ATmega8)");
break;
case 0x94: /* 16K flash */
if (sig3 == 0x0B)
fp(" (ATmega168P)");
else if (sig3 == 0x06)
fp(" (ATmega168A)");
break;
case 0x95: /* 32K flash */
if (sig3 == 0x0F)
fp(" (ATmega328P)");
else if (sig3 == 0x14)
fp(" (ATmega328)");
break;
case 0x96: /* 64K flash */
if (sig3 == 0x08)
fp(" (ATmega640)");
else
fp(" (????)");
break;
case 0x97: /* 128K flash */
if (sig3 == 0x03)
fp(" (ATmega1280)");
else if (sig3 == 0x04)
fp(" (ATmega1281)");
break;
case 0x98: /* 256K flash */
if (sig3 == 0x01)
fp(" (ATmega2560)");
else if (sig3 == 0x02)
fp(" (ATmega2561)");
break;
}
}
else {
#if defined (__AVR_ATmega168__) || defined(__AVR_ATmega8__)
fp(" (Fuses not readable on non-P AVR)");
#else
fp("????");
#endif
}
}
 
void print_boot_analysis()
{
uint8_t verh, verl;
unsigned int cksum = 0;
 
fp("nBootloader at 0x");
Serial.print((int)bootaddr, HEX);
if (!(lock_bits & BOOT_READABLE)) {
fp(" is not readablen");
return;
}
verh = pgm_read_byte(FLASHEND);
verl = pgm_read_byte(FLASHEND-1);
if (verh == 0xFF || verh == 0x00) {
fp(" has no versionn");
} else {
fp(" looks like version ");
Serial.print(verh, DEC);
Serial.print('.');
Serial.println(verl, DEC);
}
for (uint8_t i=0; i < 16; i+=2) { space(); Serial.print(pgm_read_word(&bootaddr[i]), HEX); } } void loop() { delay(2000); fp("nCompiled for " __CPUNAME "n"); print_serno(); cli(); fuse_bits_low = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS); fuse_bits_extended = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS); fuse_bits_high = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); lock_bits = boot_lock_fuse_bits_get(GET_LOCK_BITS); sig1 = boot_signature_byte_get(0); sig2 = boot_signature_byte_get(2); sig3 = boot_signature_byte_get(4); oscal = boot_signature_byte_get(1); sei(); fp("nFuse bits (L/H/E): "); Serial.print(fuse_bits_low, HEX); space(); Serial.print(fuse_bits_high, HEX); #if !defined(__AVR_ATmega8__) space(); Serial.print(fuse_bits_extended, HEX); #endif fp("nLock bits: "); Serial.print(lock_bits, HEX); print_signature(); fp("nOscal: "); Serial.println(oscal, HEX); Serial.println(); print_fuse_low(); print_fuse_high(); print_fuse_extended(); print_lock_bits(); print_boot_analysis(); #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega168A__) || defined(__AVR_ATmega168PA__) #elif defined(__AVR_ATmega8__) #endif while (1) { if (Serial.available()) { int c; while ((c = Serial.read()) > 0) {
Serial.print(c, DEC);
space();
delay(1);
}
break;
}
}
}
char Arduino_preprocess_edge; // hint to Arduino pre-processor

#include <avr/boot.h>
#include
#include "cpuname.h"

#define BOOT_READABLE (1<<BLB12)

#include <avr/pgmspace.h>
#define fp(string) flashprint(PSTR(string))

#if 0
/*
* These were used to fill up flash to debug some issues with
* optiboot uploads of large sketches.
*/

#define make64bytes(a) FLASH_STRING(__flash1 ## a, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

#define make256bytes(a) make64bytes(x ## a); make64bytes(x1 ##a);
make64bytes(x2 ## a); make64bytes(x3 ## a)

#define make1kbytes(a) make256bytes(x1 ## a); make256bytes(x2 ## a);
make256bytes(x3 ## a); make256bytes(x4 ## a)

#define make4kbytes(a) make1kbytes(x1 ## a); make1kbytes(x2 ## a);
make1kbytes(x3 ## a); make1kbytes(x4 ## a)

#define make16kbytes(a) make4kbytes(x1 ## a); make4kbytes(x2 ## a);
make4kbytes(x3 ## a); make4kbytes(x4 ## a)

make16kbytes(foo);
make4kbytes(bar);
make256bytes(baz);
make256bytes(baz1);
make256bytes(baz2);
#endif

/*
* SIGRD is a "must be zero" bit on most Arduino CPUs;
* can we read the sig or not? (Apparently, only on picopower parts)
*/
#if (!defined(SIGRD))
#define SIGRD 5
#endif

unsigned char fuse_bits_low;
uint8_t fuse_bits_extended;
uint8_t fuse_bits_high;
uint8_t lock_bits;
uint8_t sig1, sig2, sig3;
uint8_t oscal;

#define FLASHSIZE (FLASHEND+1)

uint8_t *bootaddr = (uint8_t *) 0;
unsigned short bootlen = 0;

void setup()
{
Serial.begin(19200);
}

void space() {
Serial.print(' ');
}

void flashprint (const char p[])
{
uint8_t c;
while (0 != (c = pgm_read_byte(p++))) {
Serial.write(c);
}
}

void print_serno(void)
{
int i;
int unoSerial[6];
int startAddr=1018;
unsigned long serno = 0;

for (i = 0; i < 6; i++) {
unoSerial[i] = EEPROM.read(startAddr + i);
}
if (unoSerial[0] == 'U' && unoSerial[1] == 'N' && unoSerial[2] == 'O') {

fp("Your Serial Number is: UNO");

for (i = 3; i < 6; i = i + 1) { serno = serno*256 + unoSerial[i]; Serial.print(" "); Serial.print(unoSerial[i], HEX); } fp(" ("); Serial.print(serno); Serial.write(')'); } else { fp("No Serial Number"); } Serial.println(); }  void print_binary(uint8_t b) { for (uint8_t i=0x80; i>0; i>>=1) {
if (b&i) {
Serial.write('1');
}
else {
Serial.write('0');
}
}
}

/*
* print_fuse_low
* Explain the contents of the "low" fuse byte.
*
* Note that most fuses are active-low, and the the avr include files
* define them as inverted bitmasks...
*/

void print_fuse_low(void)
{
uint8_t b;
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) ||
defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) ||
defined(AVR_ATmega168A__) || defined(__AVR_ATmega168PA__) ||
defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) ||
defined(__AVR_ATmega8__)
/*
* Fuse Low is same on 48/88/168/328/1280/2560
*/
fp("Fuse Low = ");
print_binary(fuse_bits_low);
fp(" (");
Serial.print(fuse_bits_low, HEX);
fp(")n");
fp(" ||||++++______");
#if FLASHSIZE > 16000
switch (fuse_bits_low & 0xF) {
case 0:
fp("Reserved");
break;
case 1:
fp("External Clock");
break;
case 2:
fp("Calibrated 8MHz Internal Clock");
break;
case 3:
fp("Internal 128kHz Clock");
break;
case 4:
fp("LF Crystal, 1K CK Startup");
break;
case 5:
fp("LF Crystal 32K CK Startup");
break;
case 6:
fp("Full Swing Crystal ");
break;
case 7:
fp("Full Swing Crystal");
break;
case 8:
case 9:
fp("Low Power Crystal 0.4 - 0.8MHz");
break;
case 10:
case 11:
fp("Low Power Crystal 0.9 - 3.0MHz");
break;
case 12:
case 13:
fp("Low Power Crystal 3 - 8MHz");
break;
case 14:
case 15:
fp("Low Power Crystal 8 - 16MHz");
break;
}

#else
b = fuse_bits_low & 15;
if (b == 1) fp("Ext Clk");
else if (b == 3) fp("Slow Int Clk");
else {
fp("xtal Osc Type=");
Serial.print((fuse_bits_low) & 15, BIN);
}
#endif
Serial.println();
fp(" ||++__________");
fp("Start Up Time=");
Serial.print((fuse_bits_low >> 4) & 3, BIN);
#if !defined(__AVR_ATmega8__)
Serial.println();
fp(" |+____________");
fp("Clock Output ");
if (fuse_bits_low & (~FUSE_CKOUT))
fp("Disabled");
else
fp("Enabled");

Serial.println();
fp(" +_____________");
if (fuse_bits_low & (~FUSE_CKDIV8)) {
fp("(no divide)");
}
else {
fp("Divide Clock by 8");
}
#else
Serial.println();
fp(" |+____________");
if (fuse_bits_low & (~FUSE_BODEN))
fp("BOD Disabled");
else
fp("BOD Enabled");

Serial.println();
fp(" +_____________");
if (fuse_bits_low & (~FUSE_BODLEVEL)) {
fp("BOD at 2.7V");
}
else {
fp("BOD at 4.0V");
}
#endif
#endif
Serial.println();
}

void print_fuse_high()
{
fp("nFuse High = ");
print_binary(fuse_bits_high);
fp(" (");
Serial.print(fuse_bits_high, HEX);
fp(")n");

#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
fp(" |||||||+______");
if (fuse_bits_high & bit(FUSE_BOOTRST)) {
fp("Reset to Start of memoryn");
}
else {
fp("Reset to Bootstrapn");
}
fp(" |||||++_______");
switch ((uint8_t)(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)))) {
case (uint8_t)((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)):
fp("256 words (512 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-512);
break;
case (uint8_t)((~FUSE_BOOTSZ1)):
fp("512 words (1024 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-1024);
break;
case (uint8_t)((~FUSE_BOOTSZ0)):
fp("1024 words (2048 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-2048);
break;
case 0:
fp("2048 words (4096 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-4096);
break;
default:
Serial.println(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)), BIN);
}
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) ||
defined(__AVR_ATmega168A__) || defined(__AVR_ATmega168PA__)
fp(" |||||+++______");
switch ((uint8_t)(fuse_bits_high & 7)) {
case 7:
fp("Brownout Disabledn");
break;
case 6:
fp("Brownout at 1.8Vn");
break;
case 5:
fp("Brownout at 2.7Vn");
break;
case 4:
fp("Brownout at 4.3Vn");
break;
default:
fp("Brownout Reserved value");
Serial.println(fuse_bits_high& 7, BIN);
break;
}
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
fp(" |||||||+______");
if (fuse_bits_high & bit(FUSE_BOOTRST)) {
fp("Reset to Start of memoryn");
}
else {
fp("Reset to Bootstrapn");
}
fp(" |||||++_______");
switch ((uint8_t)(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)))) {
case (uint8_t)((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)):
fp("512 words (1024 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-1024);
break;
case (uint8_t)((~FUSE_BOOTSZ1)):
fp("1024 words (2048 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-2048);
break;
case (uint8_t)((~FUSE_BOOTSZ0)):
fp("2048 words (4096 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-4096);
break;
case 0:
fp("4096 words (8192 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-8192);
break;
default:
Serial.println(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)), BIN);
}
#elif defined(__AVR_ATmega8__)
fp(" |||||||+______");
if (fuse_bits_high & bit(FUSE_BOOTRST)) {
fp("Reset to 0x0n");
}
else {
fp("Reset to Bootn");
}
fp(" |||||++_______");
switch ((uint8_t)(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)))) {
case (uint8_t)((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)):
fp("256 bytesn");
bootaddr = (uint8_t *) (FLASHSIZE-256);
break;
case (uint8_t)((~FUSE_BOOTSZ1)):
fp("512 bytesn");
bootaddr = (uint8_t *) (FLASHSIZE-512);
break;
case (uint8_t)((~FUSE_BOOTSZ0)):
fp("1024 bytesn");
bootaddr = (uint8_t *) (FLASHSIZE-1024);
break;
case 0:
fp("2048 bytesn");
bootaddr = (uint8_t *) (FLASHSIZE-2048);
break;
default:
Serial.println(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)), BIN);
}
#endif
fp(" ||||+_________");
if (fuse_bits_high & ~(FUSE_EESAVE)) {
fp("EEPROM Erased on chip erasen");
}
else {
fp("EEPROM Preserved on chip erasen");
}
#if !defined(__AVR_ATmega8__)
fp(" |||+__________");
if (fuse_bits_high & ~(FUSE_WDTON)) {
fp("Watchdog programmablen");
}
else {
fp("Watchdog always onn");
}
fp(" ||+___________");
if (fuse_bits_high & ~(FUSE_SPIEN)) {
fp("ISP programming disabledn");
}
else {
fp("ISP programming enabledn");
}
#if defined(FUSE_JTAGEN)
#warning Testing for JTAGEN
/*
* Big chips have JTAG and OCD
*/
fp(" |+____________");
if (fuse_bits_high & ~(FUSE_JTAGEN)) {
fp("JTAG offn");
}
else {
fp("JTAG enabledn");
}
fp(" +_____________");
if (fuse_bits_high & ~(FUSE_OCDEN)) {
fp("OCD enabledn");
}
else {
fp("OCD disabledn");
}
#else
/*
* Smaller chips have debugwire and a reprogrammable RESET
*/
#if defined (FUSE_DWEN)
fp(" |+____________");
if (fuse_bits_high & ~(FUSE_DWEN)) {
fp("DebugWire offn");
}
else {
fp("DebugWire enabledn");
}
#endif
fp(" +_____________");
if (fuse_bits_high & ~(FUSE_RSTDISBL)) {
fp("RST enabledn");
}
else {
fp("RST disabledn");
}
#endif

#else
/* ATmega8 */
fp(" |||+__________");
if (fuse_bits_high & ~(FUSE_CKOPT)) {
fp("Low pwr Oscn");
}
else {
fp("Full swing Oscn");
}
fp(" ||+___________");
if (fuse_bits_high & ~(FUSE_SPIEN)) {
fp("ISP disabledn");
}
else {
fp("ISP OKn");
}
fp(" |+____________");
if (fuse_bits_high & ~(FUSE_WDTON)) {
fp("Watchdog progn");
}
else {
fp("Watchdog always onn");
}
fp(" +_____________");
if (fuse_bits_high & ~(FUSE_RSTDISBL)) {
fp("RST enabledn");
}
else {
fp("RST disabledn");
}
#endif
}

/*
* Print info about the contents of the "Extended" fuse byte
*
*/
void print_fuse_extended()
{
#if !defined(__AVR_ATmega8__)
fp("nFuse Extended = ");
print_binary(fuse_bits_extended);
fp(" (");
Serial.print(fuse_bits_extended, HEX);
fp(")n");
#endif
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) ||
defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
fp(" |||||+++______");
switch ((uint8_t)(fuse_bits_extended & 7)) {
case 7:
fp("Brownout Disabledn");
break;
case 6:
fp("Brownout at 1.8Vn");
break;
case 5:
fp("Brownout at 2.7Vn");
break;
case 4:
fp("Brownout at 4.3Vn");
break;
default:
fp("Brownout Reserved value");
Serial.println(fuse_bits_extended & 7, BIN);
break;
}
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__)
fp(" |||||||+______");
if (fuse_bits_extended & bit(FUSE_BOOTRST)) {
fp("Reset to Start of memoryn");
}
else {
fp("Reset to Bootstrapn");
}
fp(" |||||++_______");
switch ((uint8_t)(fuse_bits_extended & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)))) {
case (uint8_t)((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)):
fp("128 words (256 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-256);
break;
case (uint8_t)((~FUSE_BOOTSZ1)):
fp("256 words (512 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-512);
break;
case (uint8_t)((~FUSE_BOOTSZ0)):
fp("512 words (1024 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-1024);
break;
case 0:
fp("1024 words (2048 bytes)n");
bootaddr = (uint8_t *) (FLASHSIZE-2048);
break;
default:
Serial.println(fuse_bits_extended & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)), BIN);
}
#elif defined(__AVR_ATmega8__)
// fp("nFuse Extended not existent on ATmega8 ");
#endif
}

/*
* Interpret the lock bits.
* These seem to be the same on all AVRs that have them!
*/
void print_lock_bits()
{
#if FLASHSIZE > 16000
fp("nLock Bits = ");
print_binary(lock_bits);
fp(" (");
Serial.print(lock_bits, HEX);
fp(")n");
fp(" ||||||++______");
switch (((uint8_t)(lock_bits & (uint8_t)3))) {
case 3:
fp("Read/Write to everywheren");
break;
case 2:
fp("Programming of Flash/EEPROM disabledn");
break;
case 0:
fp("No Read/Write of Flash/EEPROMn");
break;
default:
Serial.println();
}
fp(" ||||++________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b1100)) { //BLB0x
case 0b1100:
fp("R/W Applicationn");
break;
case 0b1000:
fp("No Write to Appn");
break;
case 0b0000:
fp("No Write to App, no read from Bootn");
break;
case 0b0100:
fp("No Write to App, no read from Boot, no Ints to Appn");
break;
}

fp(" ||++__________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b110000)) { //BLB0x
case 0b110000:
fp("R/W Boot Sectionn");
break;
case 0b100000:
fp("No Write to Boot Sectionn");
break;
case 0b000000:
fp("No Write to Boot, no read from Appn");
break;
case 0b010000:
fp("No Write to Boot, no read from App, no Ints to Bootn");
break;
}
#else
fp("nLock Bits = ");
print_binary(lock_bits);
fp(" (");
Serial.print(lock_bits, HEX);
fp(")n");
fp(" ||||||++______");
switch (((uint8_t)(lock_bits & (uint8_t)3))) {
case 3:
fp("ISP RWn");
break;
case 2:
fp("ISP ROn");
break;
case 0:
fp("ISP no accessn");
break;
default:
Serial.println();
}
fp(" ||||++________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b1100)) { //BLB0x
case 0b1100:
fp("App R/Wn");
break;
case 0b1000:
fp("App ROn");
break;
case 0b0000:
fp("App No Accessn");
break;
case 0b0100:
fp("App No Access, Ints disabledn");
break;
}

fp(" ||++__________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b110000)) { //BLB0x
case 0b110000:
fp("Boot R/Wn");
break;
case 0b100000:
fp("Boot ROn");
break;
case 0b000000:
fp("Boot No Accessn");
break;
case 0b010000:
fp("Boot No Access. Ints disabledn");
break;
}
#endif
}

void print_signature()
{
fp("nSignature: ");
Serial.print(sig1, HEX);
space();
Serial.print(sig2, HEX);
space();
Serial.print(sig3, HEX);
if (sig1 == 0x1E) { /* Atmel ? */
switch (sig2) {
case 0x92: /* 4K flash */
if (sig3 == 0x0A)
fp(" (ATmega48P)");
else if (sig3 == 0x05)
fp(" (ATmega48A)");
else if (sig3 == 0x09)
fp(" (ATmega48)");
break;
case 0x93: /* 8K flash */
if (sig3 == 0x0F)
fp(" (ATmega88P)");
else if (sig3 == 0x0A)
fp(" (ATmega88A)");
else if (sig3 == 0x11)
fp(" (ATmega88)");
else if (sig3 == 0x07)
fp(" (ATmega8)");
break;
case 0x94: /* 16K flash */
if (sig3 == 0x0B)
fp(" (ATmega168P)");
else if (sig3 == 0x06)
fp(" (ATmega168A)");
break;
case 0x95: /* 32K flash */
if (sig3 == 0x0F)
fp(" (ATmega328P)");
else if (sig3 == 0x14)
fp(" (ATmega328)");
break;
case 0x96: /* 64K flash */
if (sig3 == 0x08)
fp(" (ATmega640)");
else
fp(" (????)");
break;
case 0x97: /* 128K flash */
if (sig3 == 0x03)
fp(" (ATmega1280)");
else if (sig3 == 0x04)
fp(" (ATmega1281)");
break;
case 0x98: /* 256K flash */
if (sig3 == 0x01)
fp(" (ATmega2560)");
else if (sig3 == 0x02)
fp(" (ATmega2561)");
break;
}
}
else {
#if defined (__AVR_ATmega168__) || defined(__AVR_ATmega8__)
fp(" (Fuses not readable on non-P AVR)");
#else
fp("????");
#endif
}
}

void print_boot_analysis()
{
uint8_t verh, verl;
unsigned int cksum = 0;

fp("nBootloader at 0x");
Serial.print((int)bootaddr, HEX);
if (!(lock_bits & BOOT_READABLE)) {
fp(" is not readablen");
return;
}
verh = pgm_read_byte(FLASHEND);
verl = pgm_read_byte(FLASHEND-1);
if (verh == 0xFF || verh == 0x00) {
fp(" has no versionn");
} else {
fp(" looks like version ");
Serial.print(verh, DEC);
Serial.print('.');
Serial.println(verl, DEC);
}
for (uint8_t i=0; i < 16; i+=2) { space(); Serial.print(pgm_read_word(&bootaddr[i]), HEX); } } void loop() { delay(2000); fp("nCompiled for " __CPUNAME "n"); print_serno(); cli(); fuse_bits_low = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS); fuse_bits_extended = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS); fuse_bits_high = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); lock_bits = boot_lock_fuse_bits_get(GET_LOCK_BITS); sig1 = boot_signature_byte_get(0); sig2 = boot_signature_byte_get(2); sig3 = boot_signature_byte_get(4); oscal = boot_signature_byte_get(1); sei(); fp("nFuse bits (L/H/E): "); Serial.print(fuse_bits_low, HEX); space(); Serial.print(fuse_bits_high, HEX); #if !defined(__AVR_ATmega8__) space(); Serial.print(fuse_bits_extended, HEX); #endif fp("nLock bits: "); Serial.print(lock_bits, HEX); print_signature(); fp("nOscal: "); Serial.println(oscal, HEX); Serial.println(); print_fuse_low(); print_fuse_high(); print_fuse_extended(); print_lock_bits(); print_boot_analysis(); #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega168A__) || defined(__AVR_ATmega168PA__) #elif defined(__AVR_ATmega8__) #endif while (1) { if (Serial.available()) { int c; while ((c = Serial.read()) > 0) {
Serial.print(c, DEC);
space();
delay(1);
}
break;
}
}
}

Список сигнатур

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
#ifndef _AVR_CPUNAME_H_
#define _AVR_CPUNAME_H_
 
#if defined (__AVR_AT94K__)
# define __CPUNAME "AT94K"
#elif defined (__AVR_AT43USB320__)
# define __CPUNAME "AT43USB320"
#elif defined (__AVR_AT43USB355__)
# define __CPUNAME "AT43USB355"
#elif defined (__AVR_AT76C711__)
# define __CPUNAME "AT76C711"
#elif defined (__AVR_AT86RF401__)
# define __CPUNAME "AT86RF401"
#elif defined (__AVR_AT90PWM1__)
# define __CPUNAME "AT90PWM1"
#elif defined (__AVR_AT90PWM2__)
# define __CPUNAME "AT90PWM2"
#elif defined (__AVR_AT90PWM2B__)
# define __CPUNAME "AT90PWM2B"
#elif defined (__AVR_AT90PWM3__)
# define __CPUNAME "AT90PWM3"
#elif defined (__AVR_AT90PWM3B__)
# define __CPUNAME "AT90PWM3B"
#elif defined (__AVR_AT90PWM216__)
# define __CPUNAME "AT90PWM216"
#elif defined (__AVR_AT90PWM316__)
# define __CPUNAME "AT90PWM316"
#elif defined (__AVR_ATmega32C1__)
# define __CPUNAME "ATmega32C1"
#elif defined (__AVR_ATmega32M1__)
# define __CPUNAME "ATmega32M1"
#elif defined (__AVR_ATmega32U4__)
# define __CPUNAME "ATmega32U4"
#elif defined (__AVR_ATmega32U6__)
# define __CPUNAME "ATmega32U6"
#elif defined (__AVR_ATmega128__)
# define __CPUNAME "ATmega128"
#elif defined (__AVR_ATmega1280__)
# define __CPUNAME "ATmega1280"
#elif defined (__AVR_ATmega1281__)
# define __CPUNAME "ATmega1281"
#elif defined (__AVR_ATmega1284P__)
# define __CPUNAME "ATmega1284P"
#elif defined (__AVR_ATmega2560__)
# define __CPUNAME "ATmega2560"
#elif defined (__AVR_ATmega2561__)
# define __CPUNAME "ATmega2561"
#elif defined (__AVR_AT90CAN32__)
# define __CPUNAME "AT90CAN32"
#elif defined (__AVR_AT90CAN64__)
# define __CPUNAME "AT90CAN64"
#elif defined (__AVR_AT90CAN128__)
# define __CPUNAME "AT90CAN128"
#elif defined (__AVR_AT90USB82__)
# define __CPUNAME "AT90USB82"
#elif defined (__AVR_AT90USB162__)
# define __CPUNAME "AT90USB162"
#elif defined (__AVR_AT90USB646__)
# define __CPUNAME "AT90USB646"
#elif defined (__AVR_AT90USB647__)
# define __CPUNAME "AT90USB647"
#elif defined (__AVR_AT90USB1286__)
# define __CPUNAME "AT90USB1286"
#elif defined (__AVR_AT90USB1287__)
# define __CPUNAME "AT90USB1287"
#elif defined (__AVR_ATmega64__)
# define __CPUNAME "ATmega64"
#elif defined (__AVR_ATmega640__)
# define __CPUNAME "ATmega640"
#elif defined (__AVR_ATmega644__)
# define __CPUNAME "ATmega644"
#elif defined (__AVR_ATmega644P__)
# define __CPUNAME "ATmega644P"
#elif defined (__AVR_ATmega645__)
# define __CPUNAME "ATmega645"
#elif defined (__AVR_ATmega6450__)
# define __CPUNAME "ATmega6450"
#elif defined (__AVR_ATmega649__)
# define __CPUNAME "ATmega649"
#elif defined (__AVR_ATmega6490__)
# define __CPUNAME "ATmega6490"
#elif defined (__AVR_ATmega103__)
# define __CPUNAME "ATmega103"
#elif defined (__AVR_ATmega32__)
# define __CPUNAME "ATmega32"
#elif defined (__AVR_ATmega323__)
# define __CPUNAME "ATmega323"
#elif defined (__AVR_ATmega324P__)
# define __CPUNAME "ATmega324P"
#elif defined (__AVR_ATmega325__)
# define __CPUNAME "ATmega325"
#elif defined (__AVR_ATmega325P__)
# define __CPUNAME "ATmega325P"
#elif defined (__AVR_ATmega3250__)
# define __CPUNAME "ATmega3250"
#elif defined (__AVR_ATmega3250P__)
# define __CPUNAME "ATmega3250P"
#elif defined (__AVR_ATmega328P__)
# define __CPUNAME "ATmega328P"
#elif defined (__AVR_ATmega329__)
# define __CPUNAME "ATmega329"
#elif defined (__AVR_ATmega329P__)
# define __CPUNAME "ATmega329P"
#elif defined (__AVR_ATmega3290__)
# define __CPUNAME "ATmega3290"
#elif defined (__AVR_ATmega3290P__)
# define __CPUNAME "ATmega3290P"
#elif defined (__AVR_ATmega32HVB__)
# define __CPUNAME "ATmega32HVB"
#elif defined (__AVR_ATmega406__)
# define __CPUNAME "ATmega406"
#elif defined (__AVR_ATmega16__)
# define __CPUNAME "ATmega16"
#elif defined (__AVR_ATmega161__)
# define __CPUNAME "ATmega161"
#elif defined (__AVR_ATmega162__)
# define __CPUNAME "ATmega162"
#elif defined (__AVR_ATmega163__)
# define __CPUNAME "ATmega163"
#elif defined (__AVR_ATmega164P__)
# define __CPUNAME "ATmega164P"
#elif defined (__AVR_ATmega165__)
# define __CPUNAME "ATmega165"
#elif defined (__AVR_ATmega165P__)
# define __CPUNAME "ATmega165P"
#elif defined (__AVR_ATmega168__)
# define __CPUNAME "ATmega168"
#elif defined (__AVR_ATmega168P__)
# define __CPUNAME "ATmega168P"
#elif defined (__AVR_ATmega169__)
# define __CPUNAME "ATmega169"
#elif defined (__AVR_ATmega169P__)
# define __CPUNAME "ATmega169P"
#elif defined (__AVR_ATmega8HVA__)
# define __CPUNAME "ATmega8HVA"
#elif defined (__AVR_ATmega16HVA__)
# define __CPUNAME "ATmega16HVA"
#elif defined (__AVR_ATmega8__)
# define __CPUNAME "ATmega8"
#elif defined (__AVR_ATmega48__)
# define __CPUNAME "ATmega48"
#elif defined (__AVR_ATmega48P__)
# define __CPUNAME "ATmega48P"
#elif defined (__AVR_ATmega88__)
# define __CPUNAME "ATmega88"
#elif defined (__AVR_ATmega88P__)
# define __CPUNAME "ATmega88P"
#elif defined (__AVR_ATmega8515__)
# define __CPUNAME "ATmega8515"
#elif defined (__AVR_ATmega8535__)
# define __CPUNAME "ATmega8535"
#elif defined (__AVR_AT90S8535__)
# define __CPUNAME "AT90S8535"
#elif defined (__AVR_AT90C8534__)
# define __CPUNAME "AT90C8534"
#elif defined (__AVR_AT90S8515__)
# define __CPUNAME "AT90S8515"
#elif defined (__AVR_AT90S4434__)
# define __CPUNAME "AT90S4434"
#elif defined (__AVR_AT90S4433__)
# define __CPUNAME "AT90S4433"
#elif defined (__AVR_AT90S4414__)
# define __CPUNAME "AT90S4414"
#elif defined (__AVR_ATtiny22__)
# define __CPUNAME "ATtiny22"
#elif defined (__AVR_ATtiny26__)
# define __CPUNAME "ATtiny26"
#elif defined (__AVR_AT90S2343__)
# define __CPUNAME "AT90S2343"
#elif defined (__AVR_AT90S2333__)
# define __CPUNAME "AT90S2333"
#elif defined (__AVR_AT90S2323__)
# define __CPUNAME "AT90S2323"
#elif defined (__AVR_AT90S2313__)
# define __CPUNAME "AT90S2313"
#elif defined (__AVR_ATtiny2313__)
# define __CPUNAME "ATtiny2313"
#elif defined (__AVR_ATtiny13__)
# define __CPUNAME "ATtiny13"
#elif defined (__AVR_ATtiny13A__)
# define __CPUNAME "ATtiny13A"
#elif defined (__AVR_ATtiny25__)
# define __CPUNAME "ATtiny25"
#elif defined (__AVR_ATtiny45__)
# define __CPUNAME "ATtiny45"
#elif defined (__AVR_ATtiny85__)
# define __CPUNAME "ATtiny85"
#elif defined (__AVR_ATtiny24__)
# define __CPUNAME "ATtiny24"
#elif defined (__AVR_ATtiny44__)
# define __CPUNAME "ATtiny44"
#elif defined (__AVR_ATtiny84__)
# define __CPUNAME "ATtiny84"
#elif defined (__AVR_ATtiny261__)
# define __CPUNAME "ATtiny261"
#elif defined (__AVR_ATtiny461__)
# define __CPUNAME "ATtiny461"
#elif defined (__AVR_ATtiny861__)
# define __CPUNAME "ATtiny861"
#elif defined (__AVR_ATtiny43U__)
# define __CPUNAME "ATtiny43U"
#elif defined (__AVR_ATtiny48__)
# define __CPUNAME "ATtiny48"
#elif defined (__AVR_ATtiny88__)
# define __CPUNAME "ATtiny88"
#elif defined (__AVR_ATtiny167__)
# define __CPUNAME "ATtiny167"
/* avr1: the following only supported for assembler programs */
#elif defined (__AVR_ATtiny28__)
# define __CPUNAME "ATtiny28"
#elif defined (__AVR_AT90S1200__)
# define __CPUNAME "AT90S1200"
#elif defined (__AVR_ATtiny15__)
# define __CPUNAME "ATtiny15"
#elif defined (__AVR_ATtiny12__)
# define __CPUNAME "ATtiny12"
#elif defined (__AVR_ATtiny11__)
# define __CPUNAME "ATtiny11"
#elif defined (__AVR_ATxmega64A1__)
# define __CPUNAME "ATxmega64A1"
#elif defined (__AVR_ATxmega64A3__)
# define __CPUNAME "ATxmega64A3"
#elif defined (__AVR_ATxmega128A1__)
# define __CPUNAME "ATxmega128A1"
#elif defined (__AVR_ATxmega128A3__)
# define __CPUNAME "ATxmega128A3"
#elif defined (__AVR_ATxmega256A3__)
# define __CPUNAME "ATxmega256A3"
#elif defined (__AVR_ATxmega256A3B__)
# define __CPUNAME "ATxmega256A3B"
#else
# if !defined(__COMPILING_AVR_LIBC__)
# warning "device type not defined"
# endif
#endif
 
#endif /* _AVR_CPUNAME_H_ */
#ifndef _AVR_CPUNAME_H_
#define _AVR_CPUNAME_H_

#if defined (__AVR_AT94K__)
# define __CPUNAME "AT94K"
#elif defined (__AVR_AT43USB320__)
# define __CPUNAME "AT43USB320"
#elif defined (__AVR_AT43USB355__)
# define __CPUNAME "AT43USB355"
#elif defined (__AVR_AT76C711__)
# define __CPUNAME "AT76C711"
#elif defined (__AVR_AT86RF401__)
# define __CPUNAME "AT86RF401"
#elif defined (__AVR_AT90PWM1__)
# define __CPUNAME "AT90PWM1"
#elif defined (__AVR_AT90PWM2__)
# define __CPUNAME "AT90PWM2"
#elif defined (__AVR_AT90PWM2B__)
# define __CPUNAME "AT90PWM2B"
#elif defined (__AVR_AT90PWM3__)
# define __CPUNAME "AT90PWM3"
#elif defined (__AVR_AT90PWM3B__)
# define __CPUNAME "AT90PWM3B"
#elif defined (__AVR_AT90PWM216__)
# define __CPUNAME "AT90PWM216"
#elif defined (__AVR_AT90PWM316__)
# define __CPUNAME "AT90PWM316"
#elif defined (__AVR_ATmega32C1__)
# define __CPUNAME "ATmega32C1"
#elif defined (__AVR_ATmega32M1__)
# define __CPUNAME "ATmega32M1"
#elif defined (__AVR_ATmega32U4__)
# define __CPUNAME "ATmega32U4"
#elif defined (__AVR_ATmega32U6__)
# define __CPUNAME "ATmega32U6"
#elif defined (__AVR_ATmega128__)
# define __CPUNAME "ATmega128"
#elif defined (__AVR_ATmega1280__)
# define __CPUNAME "ATmega1280"
#elif defined (__AVR_ATmega1281__)
# define __CPUNAME "ATmega1281"
#elif defined (__AVR_ATmega1284P__)
# define __CPUNAME "ATmega1284P"
#elif defined (__AVR_ATmega2560__)
# define __CPUNAME "ATmega2560"
#elif defined (__AVR_ATmega2561__)
# define __CPUNAME "ATmega2561"
#elif defined (__AVR_AT90CAN32__)
# define __CPUNAME "AT90CAN32"
#elif defined (__AVR_AT90CAN64__)
# define __CPUNAME "AT90CAN64"
#elif defined (__AVR_AT90CAN128__)
# define __CPUNAME "AT90CAN128"
#elif defined (__AVR_AT90USB82__)
# define __CPUNAME "AT90USB82"
#elif defined (__AVR_AT90USB162__)
# define __CPUNAME "AT90USB162"
#elif defined (__AVR_AT90USB646__)
# define __CPUNAME "AT90USB646"
#elif defined (__AVR_AT90USB647__)
# define __CPUNAME "AT90USB647"
#elif defined (__AVR_AT90USB1286__)
# define __CPUNAME "AT90USB1286"
#elif defined (__AVR_AT90USB1287__)
# define __CPUNAME "AT90USB1287"
#elif defined (__AVR_ATmega64__)
# define __CPUNAME "ATmega64"
#elif defined (__AVR_ATmega640__)
# define __CPUNAME "ATmega640"
#elif defined (__AVR_ATmega644__)
# define __CPUNAME "ATmega644"
#elif defined (__AVR_ATmega644P__)
# define __CPUNAME "ATmega644P"
#elif defined (__AVR_ATmega645__)
# define __CPUNAME "ATmega645"
#elif defined (__AVR_ATmega6450__)
# define __CPUNAME "ATmega6450"
#elif defined (__AVR_ATmega649__)
# define __CPUNAME "ATmega649"
#elif defined (__AVR_ATmega6490__)
# define __CPUNAME "ATmega6490"
#elif defined (__AVR_ATmega103__)
# define __CPUNAME "ATmega103"
#elif defined (__AVR_ATmega32__)
# define __CPUNAME "ATmega32"
#elif defined (__AVR_ATmega323__)
# define __CPUNAME "ATmega323"
#elif defined (__AVR_ATmega324P__)
# define __CPUNAME "ATmega324P"
#elif defined (__AVR_ATmega325__)
# define __CPUNAME "ATmega325"
#elif defined (__AVR_ATmega325P__)
# define __CPUNAME "ATmega325P"
#elif defined (__AVR_ATmega3250__)
# define __CPUNAME "ATmega3250"
#elif defined (__AVR_ATmega3250P__)
# define __CPUNAME "ATmega3250P"
#elif defined (__AVR_ATmega328P__)
# define __CPUNAME "ATmega328P"
#elif defined (__AVR_ATmega329__)
# define __CPUNAME "ATmega329"
#elif defined (__AVR_ATmega329P__)
# define __CPUNAME "ATmega329P"
#elif defined (__AVR_ATmega3290__)
# define __CPUNAME "ATmega3290"
#elif defined (__AVR_ATmega3290P__)
# define __CPUNAME "ATmega3290P"
#elif defined (__AVR_ATmega32HVB__)
# define __CPUNAME "ATmega32HVB"
#elif defined (__AVR_ATmega406__)
# define __CPUNAME "ATmega406"
#elif defined (__AVR_ATmega16__)
# define __CPUNAME "ATmega16"
#elif defined (__AVR_ATmega161__)
# define __CPUNAME "ATmega161"
#elif defined (__AVR_ATmega162__)
# define __CPUNAME "ATmega162"
#elif defined (__AVR_ATmega163__)
# define __CPUNAME "ATmega163"
#elif defined (__AVR_ATmega164P__)
# define __CPUNAME "ATmega164P"
#elif defined (__AVR_ATmega165__)
# define __CPUNAME "ATmega165"
#elif defined (__AVR_ATmega165P__)
# define __CPUNAME "ATmega165P"
#elif defined (__AVR_ATmega168__)
# define __CPUNAME "ATmega168"
#elif defined (__AVR_ATmega168P__)
# define __CPUNAME "ATmega168P"
#elif defined (__AVR_ATmega169__)
# define __CPUNAME "ATmega169"
#elif defined (__AVR_ATmega169P__)
# define __CPUNAME "ATmega169P"
#elif defined (__AVR_ATmega8HVA__)
# define __CPUNAME "ATmega8HVA"
#elif defined (__AVR_ATmega16HVA__)
# define __CPUNAME "ATmega16HVA"
#elif defined (__AVR_ATmega8__)
# define __CPUNAME "ATmega8"
#elif defined (__AVR_ATmega48__)
# define __CPUNAME "ATmega48"
#elif defined (__AVR_ATmega48P__)
# define __CPUNAME "ATmega48P"
#elif defined (__AVR_ATmega88__)
# define __CPUNAME "ATmega88"
#elif defined (__AVR_ATmega88P__)
# define __CPUNAME "ATmega88P"
#elif defined (__AVR_ATmega8515__)
# define __CPUNAME "ATmega8515"
#elif defined (__AVR_ATmega8535__)
# define __CPUNAME "ATmega8535"
#elif defined (__AVR_AT90S8535__)
# define __CPUNAME "AT90S8535"
#elif defined (__AVR_AT90C8534__)
# define __CPUNAME "AT90C8534"
#elif defined (__AVR_AT90S8515__)
# define __CPUNAME "AT90S8515"
#elif defined (__AVR_AT90S4434__)
# define __CPUNAME "AT90S4434"
#elif defined (__AVR_AT90S4433__)
# define __CPUNAME "AT90S4433"
#elif defined (__AVR_AT90S4414__)
# define __CPUNAME "AT90S4414"
#elif defined (__AVR_ATtiny22__)
# define __CPUNAME "ATtiny22"
#elif defined (__AVR_ATtiny26__)
# define __CPUNAME "ATtiny26"
#elif defined (__AVR_AT90S2343__)
# define __CPUNAME "AT90S2343"
#elif defined (__AVR_AT90S2333__)
# define __CPUNAME "AT90S2333"
#elif defined (__AVR_AT90S2323__)
# define __CPUNAME "AT90S2323"
#elif defined (__AVR_AT90S2313__)
# define __CPUNAME "AT90S2313"
#elif defined (__AVR_ATtiny2313__)
# define __CPUNAME "ATtiny2313"
#elif defined (__AVR_ATtiny13__)
# define __CPUNAME "ATtiny13"
#elif defined (__AVR_ATtiny13A__)
# define __CPUNAME "ATtiny13A"
#elif defined (__AVR_ATtiny25__)
# define __CPUNAME "ATtiny25"
#elif defined (__AVR_ATtiny45__)
# define __CPUNAME "ATtiny45"
#elif defined (__AVR_ATtiny85__)
# define __CPUNAME "ATtiny85"
#elif defined (__AVR_ATtiny24__)
# define __CPUNAME "ATtiny24"
#elif defined (__AVR_ATtiny44__)
# define __CPUNAME "ATtiny44"
#elif defined (__AVR_ATtiny84__)
# define __CPUNAME "ATtiny84"
#elif defined (__AVR_ATtiny261__)
# define __CPUNAME "ATtiny261"
#elif defined (__AVR_ATtiny461__)
# define __CPUNAME "ATtiny461"
#elif defined (__AVR_ATtiny861__)
# define __CPUNAME "ATtiny861"
#elif defined (__AVR_ATtiny43U__)
# define __CPUNAME "ATtiny43U"
#elif defined (__AVR_ATtiny48__)
# define __CPUNAME "ATtiny48"
#elif defined (__AVR_ATtiny88__)
# define __CPUNAME "ATtiny88"
#elif defined (__AVR_ATtiny167__)
# define __CPUNAME "ATtiny167"
/* avr1: the following only supported for assembler programs */
#elif defined (__AVR_ATtiny28__)
# define __CPUNAME "ATtiny28"
#elif defined (__AVR_AT90S1200__)
# define __CPUNAME "AT90S1200"
#elif defined (__AVR_ATtiny15__)
# define __CPUNAME "ATtiny15"
#elif defined (__AVR_ATtiny12__)
# define __CPUNAME "ATtiny12"
#elif defined (__AVR_ATtiny11__)
# define __CPUNAME "ATtiny11"
#elif defined (__AVR_ATxmega64A1__)
# define __CPUNAME "ATxmega64A1"
#elif defined (__AVR_ATxmega64A3__)
# define __CPUNAME "ATxmega64A3"
#elif defined (__AVR_ATxmega128A1__)
# define __CPUNAME "ATxmega128A1"
#elif defined (__AVR_ATxmega128A3__)
# define __CPUNAME "ATxmega128A3"
#elif defined (__AVR_ATxmega256A3__)
# define __CPUNAME "ATxmega256A3"
#elif defined (__AVR_ATxmega256A3B__)
# define __CPUNAME "ATxmega256A3B"
#else
# if !defined(__COMPILING_AVR_LIBC__)
# warning "device type not defined"
# endif
#endif

#endif /* _AVR_CPUNAME_H_ */

Результат выполнения скетча на Arduino Duemilanove

Монитор com-порта

Compiled for ATmega328P
No Serial Number

Fuse bits (L/H/E): FF DA FD
Lock bits: CF
Signature: 1E 95 F (ATmega328P)
Oscal: B2

Fuse Low = 11111111 (FF)
||||++++______Low Power Crystal 8 — 16MHz
||++__________Start Up Time=11
|+____________Clock Output Disabled
+_____________(no divide)

Fuse High = 11011010 (DA)
|||||||+______Reset to Bootstrap
|||||++_______1024 words (2048 bytes)
||||+_________EEPROM Erased on chip erase
|||+__________Watchdog programmable
||+___________ISP programming enabled
|+____________DebugWire off
+_____________RST enabled

Fuse Extended = 11111101 (FD)
|||||+++______Brownout at 2.7V

Lock Bits = 11001111 (CF)
||||||++______Read/Write to everywhere
||||++________R/W Application
||++__________No Write to Boot, no read from App

Bootloader at 0x7800 is not readable

Источник
http://forum.arduino.cc/index.php?topic=20649.0

Добавить комментарий