-
Notifications
You must be signed in to change notification settings - Fork 11
/
fusebytes.ino
782 lines (737 loc) · 17.9 KB
/
fusebytes.ino
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
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
char Arduino_preprocess_edge; // hint to Arduino pre-processor
#include <avr/boot.h>
#include <EEPROM.h>
#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 memory\n");
}
else {
fp("Reset to Bootstrap\n");
}
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 Disabled\n");
break;
case 6:
fp("Brownout at 1.8V\n");
break;
case 5:
fp("Brownout at 2.7V\n");
break;
case 4:
fp("Brownout at 4.3V\n");
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 memory\n");
}
else {
fp("Reset to Bootstrap\n");
}
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 0x0\n");
}
else {
fp("Reset to Boot\n");
}
fp(" |||||++_______");
switch ((uint8_t)(fuse_bits_high & ((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)))) {
case (uint8_t)((~FUSE_BOOTSZ1)+(~FUSE_BOOTSZ0)):
fp("256 bytes\n");
bootaddr = (uint8_t *) (FLASHSIZE-256);
break;
case (uint8_t)((~FUSE_BOOTSZ1)):
fp("512 bytes\n");
bootaddr = (uint8_t *) (FLASHSIZE-512);
break;
case (uint8_t)((~FUSE_BOOTSZ0)):
fp("1024 bytes\n");
bootaddr = (uint8_t *) (FLASHSIZE-1024);
break;
case 0:
fp("2048 bytes\n");
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 erase\n");
}
else {
fp("EEPROM Preserved on chip erase\n");
}
#if !defined(__AVR_ATmega8__)
fp(" |||+__________");
if (fuse_bits_high & ~(FUSE_WDTON)) {
fp("Watchdog programmable\n");
}
else {
fp("Watchdog always on\n");
}
fp(" ||+___________");
if (fuse_bits_high & ~(FUSE_SPIEN)) {
fp("ISP programming disabled\n");
}
else {
fp("ISP programming enabled\n");
}
#if defined(FUSE_JTAGEN)
#warning Testing for JTAGEN
/*
* Big chips have JTAG and OCD
*/
fp(" |+____________");
if (fuse_bits_high & ~(FUSE_JTAGEN)) {
fp("JTAG off\n");
}
else {
fp("JTAG enabled\n");
}
fp(" +_____________");
if (fuse_bits_high & ~(FUSE_OCDEN)) {
fp("OCD enabled\n");
}
else {
fp("OCD disabled\n");
}
#else
/*
* Smaller chips have debugwire and a reprogrammable RESET
*/
#if defined (FUSE_DWEN)
fp(" |+____________");
if (fuse_bits_high & ~(FUSE_DWEN)) {
fp("DebugWire off\n");
}
else {
fp("DebugWire enabled\n");
}
#endif
fp(" +_____________");
if (fuse_bits_high & ~(FUSE_RSTDISBL)) {
fp("RST enabled\n");
}
else {
fp("RST disabled\n");
}
#endif
#else
/* ATmega8 */
fp(" |||+__________");
if (fuse_bits_high & ~(FUSE_CKOPT)) {
fp("Low pwr Osc\n");
}
else {
fp("Full swing Osc\n");
}
fp(" ||+___________");
if (fuse_bits_high & ~(FUSE_SPIEN)) {
fp("ISP disabled\n");
}
else {
fp("ISP OK\n");
}
fp(" |+____________");
if (fuse_bits_high & ~(FUSE_WDTON)) {
fp("Watchdog prog\n");
}
else {
fp("Watchdog always on\n");
}
fp(" +_____________");
if (fuse_bits_high & ~(FUSE_RSTDISBL)) {
fp("RST enabled\n");
}
else {
fp("RST disabled\n");
}
#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 Disabled\n");
break;
case 6:
fp("Brownout at 1.8V\n");
break;
case 5:
fp("Brownout at 2.7V\n");
break;
case 4:
fp("Brownout at 4.3V\n");
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 memory\n");
}
else {
fp("Reset to Bootstrap\n");
}
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 everywhere\n");
break;
case 2:
fp("Programming of Flash/EEPROM disabled\n");
break;
case 0:
fp("No Read/Write of Flash/EEPROM\n");
break;
default:
Serial.println();
}
fp(" ||||++________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b1100)) { //BLB0x
case 0b1100:
fp("R/W Application\n");
break;
case 0b1000:
fp("No Write to App\n");
break;
case 0b0000:
fp("No Write to App, no read from Boot\n");
break;
case 0b0100:
fp("No Write to App, no read from Boot, no Ints to App\n");
break;
}
fp(" ||++__________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b110000)) { //BLB0x
case 0b110000:
fp("R/W Boot Section\n");
break;
case 0b100000:
fp("No Write to Boot Section\n");
break;
case 0b000000:
fp("No Write to Boot, no read from App\n");
break;
case 0b010000:
fp("No Write to Boot, no read from App, no Ints to Boot\n");
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 RW\n");
break;
case 2:
fp("ISP RO\n");
break;
case 0:
fp("ISP no access\n");
break;
default:
Serial.println();
}
fp(" ||||++________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b1100)) { //BLB0x
case 0b1100:
fp("App R/W\n");
break;
case 0b1000:
fp("App RO\n");
break;
case 0b0000:
fp("App No Access\n");
break;
case 0b0100:
fp("App No Access, Ints disabled\n");
break;
}
fp(" ||++__________");
switch ((uint8_t)((uint8_t)lock_bits & (uint8_t)0b110000)) { //BLB0x
case 0b110000:
fp("Boot R/W\n");
break;
case 0b100000:
fp("Boot RO\n");
break;
case 0b000000:
fp("Boot No Access\n");
break;
case 0b010000:
fp("Boot No Access. Ints disabled\n");
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 readable\n");
return;
}
verh = pgm_read_byte(FLASHEND);
verl = pgm_read_byte(FLASHEND-1);
if (verh == 0xFF || verh == 0x00) {
fp(" has no version\n");
} 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;
}
}
}