[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  Electronics
. -> [Folder]  Microprocessors
. . -> [Subject]  Sketch to detect Atmega chip types

Sketch to detect Atmega chip types

Postings by administrators only.

[Refresh] Refresh page


Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Fri 04 May 2012 06:06 AM (UTC)

Amended on Mon 19 Jan 2015 05:50 AM (UTC) by Nick Gammon

Message
The sketch below demonstrates how you can use ICSP (In Circuit Serial Programming) to investigate the device signature, and other information, about target chips that you are interested in.

Without needing any extra hardware, or software, apart from the serial monitor, you can find out the device signature, and get a sumcheck of the bootloader.

Sketch


You can get the code from GitHub:

https://github.com/nickgammon/arduino_sketches

(See the Atmega_Board_Detector folder).


Example output for ATtiny85



Atmega chip detector.
Entered programming mode OK.
Signature = 1E 93 0B 
Processor = ATtiny85
Flash memory size = 8192
LFuse = E2 
HFuse = DF 
EFuse = FF 
Lock byte = FF 
No bootloader support.

First 256 bytes of program memory:

0: 1B C0 3F C0 3E C0 3A C1 A8 C2 3B C0 3A C0 39 C0 
10: 38 C0 37 C0 36 C0 35 C0 4A C0 33 C0 32 C0 00 37 
20: 00 38 00 36 01 01 01 01 01 01 01 02 04 08 10 20 
30: 01 03 00 00 00 00 69 00 11 24 1F BE CF E5 D2 E0 
40: DE BF CD BF 10 E0 A0 E6 B0 E0 E6 E6 F8 E0 02 C0 
50: 05 90 0D 92 A2 36 B1 07 D9 F7 10 E0 A2 E6 B0 E0 
60: 01 C0 1D 92 AA 38 B1 07 E1 F7 10 E0 C8 E3 D0 E0 
70: 03 C0 22 97 FE 01 F1 D3 C6 33 D1 07 D1 F7 91 D3 
80: F0 C3 BE CF 96 B1 16 B8 14 BE 88 E1 81 BD 81 E6 
90: 81 BD A8 95 85 B7 87 7E 80 61 85 BF 85 B7 80 62 
A0: 85 BF 88 95 85 B7 8F 7D 85 BF 96 B9 08 95 1F 92 
B0: 0F 92 0F B6 0F 92 11 24 8F 93 88 E1 0F B6 F8 94 
C0: 81 BD 11 BC 0F BE 8F 91 0F 90 0F BE 0F 90 1F 90 
D0: 18 95 82 E6 90 E0 A9 D1 08 95 1F 93 CF 93 DF 93 
E0: 82 E6 90 E0 61 E0 40 E2 52 E0 28 E9 38 E0 DD D1 
F0: 80 91 68 00 61 E0 20 D3 C0 E0 D0 E0 82 E6 90 E0 


Wiring for ATtiny85




For each chip you need to wire MISO/MOSI/SCK together, and connect D10 on your "main" chip to the reset pin of the device under test. In this case:


Arduino Uno      ATtiny

D10 (SS)            1
D11 (MOSI)          5
D12 (MISO)          6
D13 (SCK)           7

Gnd                 4
+5V                 8


Programming cable


For boards which have an ICSP header, it helps to make up a programming cable (although not essential). You can do this by getting a 6-pin IDC cable, and cutting the 5th wire out of circuit and soldering a pin onto it, like this:



This wire (the reset signal) gets plugged into D10 on the Arduino with the detection sketch on it, as in the images below.

If you don't have such a cable, just connect together the pins as described below.

Example output for Uno



Atmega chip detector.
Entered programming mode OK.
Signature = 1E 95 0F 
Processor = ATmega328P
Flash memory size = 32768
LFuse = FF 
HFuse = DE 
EFuse = FD 
Lock byte = CF 
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 512 bytes starting at 7E00

Bootloader:

7E00: 11 24 84 B7 14 BE 81 FF E6 D0 85 E0 80 93 81 00 
7E10: 82 E0 80 93 C0 00 88 E1 80 93 C1 00 86 E0 80 93 
...
7FE0: E7 DF 80 32 09 F0 F7 DF 84 E1 DA CF 1F 93 18 2F 
7FF0: DF DF 11 50 E9 F7 F4 DF 1F 91 08 95 FF FF FF FF 

MD5 sum of bootloader = 0F 02 31 72 95 C8 F7 FD 1B B7 07 17 85 A5 66 87 

First 256 bytes of program memory:

0: 0C 94 35 00 0C 94 5D 00 0C 94 5D 00 0C 94 5D 00 
10: 0C 94 5D 00 0C 94 5D 00 0C 94 5D 00 0C 94 5D 00 
20: 0C 94 5D 00 0C 94 5D 00 0C 94 5D 00 0C 94 5D 00 
30: 0C 94 5D 00 0C 94 5D 00 0C 94 5D 00 0C 94 5D 00 
40: 0C 94 80 03 0C 94 5D 00 0C 94 C9 00 0C 94 5D 00 
50: 0C 94 5D 00 0C 94 5D 00 0C 94 5D 00 0C 94 5D 00 
60: 0C 94 5D 00 0C 94 5D 00 E5 01 11 24 1F BE CF EF 
70: D8 E0 DE BF CD BF 11 E0 A0 E0 B1 E0 E0 E9 F8 E0 
80: 02 C0 05 90 0D 92 A2 32 B1 07 D9 F7 11 E0 A2 E2 
90: B1 E0 01 C0 1D 92 A2 3C B1 07 E1 F7 10 E0 CA E6 
A0: D0 E0 04 C0 22 97 FE 01 0E 94 42 04 C8 36 D1 07 
B0: C9 F7 0E 94 1F 02 0C 94 46 04 0C 94 00 00 08 95 
C0: FF 92 0F 93 1F 93 06 EA 11 E0 C8 01 40 E0 52 EC 
D0: 61 E0 70 E0 0E 94 FA 00 C8 01 0E 94 44 03 C8 01 
E0: 60 E0 71 E0 0E 94 75 03 91 E2 F9 2E E0 E0 F0 E0 
F0: F0 92 57 00 E4 91 C8 01 6E 2F 40 E1 50 E0 0E 94 


If a bootloader is detected, the entire bootloader is dumped. Also an MD5 sumcheck is taken. This lets you compare sumchecks to a "known" board, and work out whether a board has an Optiboot loader, or other, by making a list of MD5 sums for each bootloader.

Wiring for Uno and similar




(Ruggeduino depicted)


Arduino Uno      Target Uno

D10 (SS)            Reset
D11 (MOSI)          D11
D12 (MISO)          D12
D13 (SCK)           D13

Gnd                 Gnd
+5V                 +5V


If you don't have the special IDC cable, here is how you can wire up each pin directly:




Example output for Mega2560



Atmega chip detector.
Entered programming mode OK.
Signature = 1E 98 01 
Processor = ATmega2560
Flash memory size = 262144
LFuse = FF 
HFuse = D8 
EFuse = FD 
Lock byte = FF 
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 8192 bytes starting at 3E000

Bootloader:

3E000: 0D 94 89 F1 0D 94 B2 F1 0D 94 B2 F1 0D 94 B2 F1 
3E010: 0D 94 B2 F1 0D 94 B2 F1 0D 94 B2 F1 0D 94 B2 F1 
...
3FFD0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
3FFE0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
3FFF0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

MD5 sum of bootloader = B9 49 93 09 49 1A 64 6E CD 58 47 89 C2 D8 A4 6C 

First 256 bytes of program memory:

0: 0C 94 4C 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
10: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
20: 0C 94 79 01 0C 94 21 02 0C 94 4F 02 0C 94 7D 02 
30: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
40: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
50: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 71 05 
60: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
70: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
80: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
90: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
A0: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
B0: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
C0: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
D0: 0C 94 79 01 0C 94 79 01 0C 94 79 01 0C 94 79 01 
E0: 0C 94 79 01 00 C2 01 00 01 00 11 00 11 00 0C 00 
F0: 00 E1 00 00 0A 00 25 00 25 00 21 00 00 96 00 00 


Wiring for Mega2560 and similar





Arduino Uno      Target Mega2560

D10 (SS)            Reset
D11 (MOSI)          D51
D12 (MISO)          D50
D13 (SCK)           D52

Gnd                 Gnd
+5V                 +5V


Example output for Sanguino



Atmega chip detector.
Entered programming mode OK.
Signature = 1E 96 0A 
Processor = ATmega644P
Flash memory size = 65536
LFuse = FF 
HFuse = DC 
EFuse = FD 
Lock byte = CF 
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 2048 bytes starting at F800

Bootloader:

F800: 0C 94 3E 7C 0C 94 5B 7C 0C 94 5B 7C 0C 94 5B 7C 
F810: 0C 94 5B 7C 0C 94 5B 7C 0C 94 5B 7C 0C 94 5B 7C 
...
FFE0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
FFF0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

MD5 sum of bootloader = 51 69 10 40 8F 07 81 C6 48 51 54 5E 96 73 C2 EB 

First 256 bytes of program memory:

0: 0C 94 77 00 0C 94 9F 00 0C 94 9F 00 0C 94 9F 00 
10: 0C 94 9F 00 0C 94 9F 00 0C 94 9F 00 0C 94 9F 00 
20: 0C 94 9F 00 0C 94 9F 00 0C 94 9F 00 0C 94 9F 00 
30: 0C 94 9F 00 0C 94 9F 00 0C 94 9F 00 0C 94 9F 00 
40: 0C 94 9F 00 0C 94 9F 00 0C 94 CD 00 0C 94 9F 00 
50: 0C 94 0A 02 0C 94 9F 00 0C 94 9F 00 0C 94 9F 00 
60: 0C 94 9F 00 0C 94 9F 00 0C 94 9F 00 0C 94 9F 00 
70: 0C 94 47 02 0C 94 9F 00 0C 94 9F 00 00 21 24 27 
80: 2A 00 22 25 28 2B 00 20 23 26 29 02 02 02 02 02 
90: 02 02 02 04 04 04 04 04 04 04 04 03 03 03 03 03 
A0: 03 03 03 01 01 01 01 01 01 01 01 01 02 04 08 10 
B0: 20 40 80 01 02 04 08 10 20 40 80 01 02 04 08 10 
C0: 20 40 80 80 40 20 10 08 04 02 01 00 00 00 01 02 
D0: 00 00 00 00 00 00 00 04 03 07 06 00 00 00 00 00 
E0: 00 00 00 00 00 00 00 00 00 00 00 00 90 03 11 24 
F0: 1F BE CF EF D0 E1 DE BF CD BF 11 E0 A0 E0 B1 E0 


Wiring for Sanguino and similar





Arduino Uno      Target Sanguino

D10 (SS)            Reset (pin 9)
D11 (MOSI)          Pin 6
D12 (MISO)          Pin 7
D13 (SCK)           Pin 8

Gnd                 Gnd
+5V                 +5V


Example output for ATtiny84



Atmega chip detector.
Entered programming mode OK.
Signature = 1E 93 0C 
Processor = ATtiny84
Flash memory size = 8192
LFuse = 62 
HFuse = DF 
EFuse = FF 
Lock byte = FF 
No bootloader support.

First 256 bytes of program memory:

0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
10: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
20: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
30: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
40: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
50: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
60: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
70: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
80: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
90: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
A0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
B0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
C0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
D0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
E0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
F0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 


Wiring for ATtiny84 and similar





Arduino Uno         ATtiny84

D10 (SS)            Reset (pin 4)
D11 (MOSI)          Pin 7
D12 (MISO)          Pin 8
D13 (SCK)           Pin 9

Gnd                 Gnd
+5V                 +5V





Hopefully the sketch illustrates how you might write fairly simple code to investigate the contents of another processor, find its signature, and download its flash memory.

Caveats


I have only tested this sketch with the boards pictured in this post. I can't guarantee that it will work with every board/chip you might have to hand.

I have keyed in the signatures for various other chips from the Atmega datasheets. It should work for those as well. See the "signatures" table in the sketch for supported processors.

Use at your own risk.

Certain combinations of fuse bytes may make the sketch not work. In particular if you have disabled SPI programming.

Uploading a new bootloader


The thread below describes a sketch you can use to reprogram your bootloader:

http://www.gammon.com.au/forum/?id=11635

Alternate clock source


As an alternative to a crystal or resonator, the sketch also outputs an 8 MHz clock on pin D9 of the programming board (using Timer 1). Thus you just need to connect D9 on the programming board to XTAL1 of the target board and this will provide a clock signal, enabling this sketch to run.




[EDIT]

Modifications

Version 1.1 released on 5th May 2012. Added support for ATtiny84 family, slowed down SPI clock by a factor of 2 to make it more reliable.

Version 1.9 released on 23 August 2014. Fixed problem where some chips (eg. Atmega168) would report incorrect bootloader information because it was reading the wrong fuse byte.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sat 05 May 2012 04:48 AM (UTC)

Amended on Mon 07 May 2012 09:46 PM (UTC) by Nick Gammon

Message
Database of bootloader checksums


Below is what I believe to be the MD5 sums for each bootloader shipped with Arduino 0022 (beta) and IDE 1.0 (first full release).

They are grouped into directories by board type (eg. lilypad).

The lines are:


  • File name of the bootloader (hex) file in that directory
  • MD5 sumcheck of the disk file (eg. md5 ATmegaBOOT_168_atmega328.hex)
  • Where the bootloader starts in memory and its size in bytes
  • The MD5 sumcheck of the actual bootloader data - this should agree with what the sketch above produces.
  • The board name in the IDE. You need to choose this board for uploading so that the board rate and protocol agree.



IDE 0022



Atmega

ATmegaBOOT_168_atmega328.hex
be77c6d6bbfec061d55024d6251af883 *ATmegaBOOT_168_atmega328.hex
Loader start: 7800, length: 2048
MD5 sum = 0A AC F7 16 F4 3C A2 C9 27 7E 08 B9 D6 90 BC 02
Board name in IDE: Arduino Duemilanove w/ ATmega328

ATmegaBOOT_168_atmega328_pro_8MHz.hex
654f86b6aff0ce8a50e161bfa497f787 *ATmegaBOOT_168_atmega328_pro_8MHz.hex
Loader start: 7800, length: 2048
MD5 sum = 27 EB 87 14 5D 45 D4 D8 41 44 52 CE 0A 2B 8C 5F 
Board name in IDE: Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328

ATmegaBOOT_168_atmega1280.hex
e68a53e9e6281a430baf25f7878abb70 *ATmegaBOOT_168_atmega1280.hex
Loader start: 1F000, length: 4096
MD5 sum = 01 24 13 56 60 4D 91 7E DC EE 84 D1 19 EF 91 CE 
Board name in IDE: Arduino Mega (ATmega1280)

ATmegaBOOT_168_diecimila.hex
53eaa14387a624b5aa082a735cdb402b *ATmegaBOOT_168_diecimila.hex
Loader start: 3800, length: 2048
MD5 sum = 14 61 CE DF 85 46 0D 96 CC 41 CB 01 69 40 28 1A 
Board name in IDE: Arduino Diecimila or Duemilanove w/ ATmega168

ATmegaBOOT_168_ng.hex
766b52a6c6cda1e9e9f7ca2cd7bb2565 *ATmegaBOOT_168_ng.hex
Loader start: 3800, length: 2048
MD5 sum = 6A 22 9F B4 64 37 3F A3 0C 68 39 1D 6A 97 2C 40 
Board name in IDE: Arduino NG or older w/ ATmega168

ATmegaBOOT_168_pro_8MHz.hex
008ee429f3410c178b79a83f16634ecd *ATmegaBOOT_168_pro_8MHz.hex
Loader start: 3800, length: 2048
MD5 sum = FF 99 A2 C0 D9 C9 E5 1B 98 7D 9E 56 12 C2 A4 A1 
Board name in IDE: Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168

Atmega8

ATmegaBOOT.hex
1c4c695f896b467178d208d9f055ff16 *ATmegaBOOT.hex
Loader start: 1C00, length: 1024
MD5 sum = 98 6D CF BB 55 E1 22 1E E4 3C C2 07 B2 2B 46 AE 
Board name in IDE: Arduino NG or older w/ ATmega8

bt

ATmegaBOOT_168.hex
a9a0a48376bb51ddb6cec16ef6a61ad2 *ATmegaBOOT_168.hex
Loader start: 3800, length: 2048
MD5 sum = 37 C0 FC 90 E2 A0 5D 8F 62 EB AE 9C 36 C2 24 05 
Board name in IDE: Arduino BT w/ ATmega168

ATmegaBOOT_168_atmega328_bt.hex
9a4830486da6bd635b3aa54919362d4b *ATmegaBOOT_168_atmega328_bt.hex
Loader start: 7000, length: 4096
MD5 sum = 29 3E B3 B7 39 84 2D 35 BA 9D 02 F9 C7 F7 C9 D6 
Board name in IDE: Arduino BT w/ ATmega328

lilypad

LilyPadBOOT_168.hex
ef8d52df2201310371ca6b1079ebe041 *LilyPadBOOT_168.hex
Loader start: 3800, length: 2048
MD5 sum = FC AF 05 0E B4 D7 2D 75 8F 41 8C 85 83 56 AA 35 
Board name in IDE: LilyPad Arduino w/ ATmega168

optiboot

optiboot_atmega328.hex
38e4251545217bea70ab6c322b669a09 *optiboot_atmega328.hex
Loader start: 7E00, length: 512
MD5 sum = 55 71 A1 8C 81 3B 9E D2 E6 3B C9 3B 9A B1 79 53 
Board name in IDE: Arduino Uno

optiboot_atmega328_pro_8MHz.hex
ca1e42a7654f1062eb4bcd69b2833a15 *optiboot_atmega328_pro_8MHz.hex
Loader start: 7E00, length: 512
MD5 sum = 3C 08 90 A1 6A 13 A2 F0 A5 1D 26 EC F1 4B 0F B3 
Board name in IDE: (unsure)

optiboot_diecimila.hex
14fee7f2b13ae2f3ce522f8770e2846b *optiboot_diecimila.hex
Loader start: 3E00, length: 512
MD5 sum = 6A 95 0A E1 DB 1F 9D C7 8C F8 A4 80 B5 1E 54 E1 
Board name in IDE: (unsure)

optiboot_lilypad.hex
30f3b54fe0c7a1cb9b39f9bbc28aa912 *optiboot_lilypad.hex
Loader start: 3E00, length: 512
MD5 sum = AD BD A7 4A 4F AB A8 65 34 92 F8 C9 CE 58 7D 78 
Board name in IDE: (unsure)

optiboot_lilypad_resonator.hex
30f3b54fe0c7a1cb9b39f9bbc28aa912 *optiboot_lilypad_resonator.hex
Loader start: 3E00, length: 512
MD5 sum = AD BD A7 4A 4F AB A8 65 34 92 F8 C9 CE 58 7D 78 
Board name in IDE: (unsure)

optiboot_luminet.hex
adeecc6556a711d21bfbdf7bb46349fc *optiboot_luminet.hex
Loader start: 1D00, length: 768
MD5 sum = 7B 5C AC 08 2A 0B 2D 45 69 11 A7 A0 AE 65 7F 66 
Board name in IDE: (unsure)

optiboot_pro_8MHz.hex
30f3b54fe0c7a1cb9b39f9bbc28aa912 *optiboot_pro_8MHz.hex
Loader start: 3E00, length: 512
MD5 sum = AD BD A7 4A 4F AB A8 65 34 92 F8 C9 CE 58 7D 78 
Board name in IDE: (unsure)

optiboot_pro_16MHz.hex
14fee7f2b13ae2f3ce522f8770e2846b *optiboot_pro_16MHz.hex
Loader start: 3E00, length: 512
MD5 sum = 6A 95 0A E1 DB 1F 9D C7 8C F8 A4 80 B5 1E 54 E1 
Board name in IDE: (unsure)

optiboot_pro_20mhz.hex
7edd1ff90089d94aa380389cd6ec031e *optiboot_pro_20mhz.hex
Loader start: 3E00, length: 512
MD5 sum = 2C 55 B4 B8 B5 C5 CB C4 D3 36 99 CB 4B 9F DA BE 
Board name in IDE: (unsure)

stk500v2

stk500boot_v2_mega2560.hex
23d339e0ba55f179dd02e0e29d736991 *stk500boot_v2_mega2560.hex
Loader start: 3E000, length: 8192
MD5 sum = 1E 35 14 08 1F 65 7F 8C 96 50 69 9F 19 1E 3D F0 
Board name in IDE: Arduino Mega 2560 or Mega ADK



IDE 1.0




Atmega

ATmegaBOOT_168_atmega328.hex
(same as Version 0022 above)

ATmegaBOOT_168_atmega328_pro_8MHz.hex
(same as Version 0022 above)

ATmegaBOOT_168_atmega1280.hex
(same as Version 0022 above)

ATmegaBOOT_168_diecimila.hex
(same as Version 0022 above)

ATmegaBOOT_168_ng.hex
(same as Version 0022 above)

ATmegaBOOT_168_pro_8MHz.hex
(same as Version 0022 above)


Atmega8

ATmegaBOOT.hex
(same as Version 0022 above)


bt

ATmegaBOOT_168.hex
(same as Version 0022 above)

ATmegaBOOT_168_atmega328_bt.hex
(same as Version 0022 above)


diskloader

DiskLoader-Leonardo.hex
71287c9b57939d53139288d6f88a62e1 *DiskLoader-Leonardo.hex
Loader start: 7800, length: 2048
MD5 sum = C2 59 71 5F 96 28 E3 AA B0 69 E2 AF F0 85 A1 20 
Board name in IDE: Arduino Leonardo

lilypad

LilyPadBOOT_168.hex
(same as Version 0022 above)


optiboot

optiboot_atmega8.hex
c359be9d31d9303dbcdf28744a69880f *optiboot_atmega8.hex
Loader start: 1E00, length: 512
MD5 sum = E4 AF F6 6B 78 DA E4 30 FE B6 52 AF 53 52 18 49 
Board name in IDE: (unsure)

optiboot_atmega168.hex
d41403881d29a1c3842bb313e80ca356 *optiboot_atmega168.hex
Loader start: 3E00, length: 512
MD5 sum = 3A 89 30 4B 15 F5 BB 11 AA E6 E6 DC 7C F5 91 35 
Board name in IDE: (unsure)

optiboot_atmega328.hex
19b917aeec553ea1e47333cd9b1bbc5a *optiboot_atmega328.hex
Loader start: 7E00, length: 512
MD5 sum = FB F4 9B 7B 59 73 7F 65 E8 D0 F8 A5 08 12 E7 9F
Board name in IDE: Arduino Uno

optiboot_atmega328-Mini.hex
015669f383a68e4cddad5b49e9b3d302 *optiboot_atmega328-Mini.hex
Loader start: 7E00, length: 512
MD5 sum = 7F DF E1 B2 6F 52 8F BD 7C FE 7E E0 84 C0 A5 6B 
Board name in IDE: Arduino Mini w/ ATmega328


stk500v2

stk500boot_v2_mega2560.hex
(same as Version 0022 above)



Sanguino



ATmegaBOOT_324P.hex
88b1e142d82308288b532dde7855f3fa *ATmegaBOOT_324P.hex
Loader start: F800, length: 2048
MD5 sum = 31 28 0B 06 AD B5 A4 C9 2D EF B3 69 29 22 EA BF 
Board name in IDE: (unsure)

ATmegaBOOT_644.hex
0088dd9888922842641de3a2c02c5735 *ATmegaBOOT_644.hex
Loader start: F800, length: 2048
MD5 sum = E8 93 44 43 37 D3 28 3C 7D 9A EB 84 46 D5 45 42 
Board name in IDE: (unsure)

ATmegaBOOT_644P.hex
e8ced50b3a9ec50241bd4d16e9a6c86a *ATmegaBOOT_644P.hex
Loader start: F800, length: 2048
MD5 sum = 51 69 10 40 8F 07 81 C6 48 51 54 5E 96 73 C2 EB 
Board name in IDE: (unsure)


Original Mega2560 bootloader


This is downloaded from my Mega2560 purchased from Adafruit in January 2011. It is different to the one listed above so probably does not support all 256K of program memory.


Mega2560.hex
Loader start: 3E000, length: 8192
MD5 sum = B9 49 93 09 49 1A 64 6E CD 58 47 89 C2 D8 A4 6C 
Board name in IDE: Arduino Mega 2560 or Mega ADK


Ruggeduino bootloader


According to Rugged Circuits their supplied bootloader has a small fix in it compared to the original Optiboot (initialing register R1), so their bootloader will have a different sumcheck:


Loader start: 7E00, length: 512
MD5 sum = 0F 02 31 72 95 C8 F7 FD 1B B7 07 17 85 A5 66 87 
Board name in IDE: Arduino Uno



Caveat


Every known bootloader is not necessarily there. For example, the ones in the first post are not in the table above. However I think that is because I had an early Mega, and the Uno-like board was really a Ruggeduino. When I test a "real" Uno I get this:


Atmega chip detector.
Entered programming mode OK.
Signature = 1E 95 0F 
Processor = ATmega328P
Flash memory size = 32768
LFuse = FF 
HFuse = DE 
EFuse = FD 
Lock byte = CF 
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 512 bytes starting at 7E00

Bootloader:

7E00: 11 24 84 B7 14 BE 81 FF F0 D0 85 E0 80 93 81 00 
7E10: 82 E0 80 93 C0 00 88 E1 80 93 C1 00 86 E0 80 93 
...
7FE0: 11 50 E9 F7 F2 DF 1F 91 08 95 80 E0 E8 DF EE 27 
7FF0: FF 27 09 94 FF FF FF FF FF FF FF FF FF FF 04 04 

MD5 sum of bootloader = FB F4 9B 7B 59 73 7F 65 E8 D0 F8 A5 08 12 E7 9F 


The MD5 sum agrees with the one for the file optiboot_atmega328.hex.


[EDIT] Found the Sanguino bootloader file. Also found out why the Ruggeduino one was different. Added the "board names" so you can choose the correct board once you know which bootloader you have.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Tue 22 Oct 2013 11:12 PM (UTC)
Message
Board type self-detector


A modification to the above code lets a board "self-detect" its signature, fuses, and bootloader.

Code available from:

http://gammon.com.au/Arduino/Atmega_Self_Read_Signature.zip

Download, unzip, and place the resulting folder into where your Arduino sketches go.

You can also get the code from GitHub (this will also show recent changes):

https://github.com/nickgammon/arduino_sketches


This does not require any extra hardware, the board reads its own signature, lock bits, fuses, and bootloader.

Example output:


Signature detector.
Written by Nick Gammon.
Signature = 1E  95  87 
Fuses
Low = FF High = D8 Ext = CB Lock = FF 

Processor = ATmega32U4
Flash memory size = 32768
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 4096 bytes starting at 7000

Bootloader:

7000: 55 C0 00 00 6E C0 00 00 6C C0 00 00 6A C0 00 00 
7010: 68 C0 00 00 66 C0 00 00 64 C0 00 00 62 C0 00 00 
7020: 60 C0 00 00 5E C0 00 00 EE C4 00 00 5A C0 00 00 
...
7F70: 01 07 05 82 03 08 00 FF 09 04 01 00 02 0A 00 00 
7F80: 00 07 05 04 02 10 00 01 07 05 83 02 10 00 01 04 
7F90: 03 09 04 22 03 41 00 72 00 64 00 75 00 69 00 6E 
7FA0: 00 6F 00 20 00 4C 00 65 00 6F 00 6E 00 61 00 72 
7FB0: 00 64 00 6F 00 00 00 18 03 41 00 72 00 64 00 75 
7FC0: 00 69 00 6E 00 6F 00 20 00 4C 00 4C 00 43 00 00 
7FD0: 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
7FE0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
7FF0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

MD5 sum of bootloader = 53 E0 2C BC 87 F5 0B 68 2C 71 13 E0 ED 84 05 34 


Note that if the "lock bits" do not permit the bootloader to be read then the bootloader information will be wrong. For example:


Signature detector.
Written by Nick Gammon.
Signature = 1E  95  0F 
Fuses
Low = FF High = D6 Ext = FF Lock = CF

Processor = ATmega328P
Flash memory size = 32768
Bootloader in use: Yes
EEPROM preserved through erase: Yes
Watchdog timer always on: No
Bootloader is 512 bytes starting at 7E00

Bootloader:

7E00: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
7E10: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
7E20: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
7E30: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
...
7FB0: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
7FC0: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
7FD0: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
7FE0: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
7FF0: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 

MD5 sum of bootloader = 56 72 75 2D 5D B5 0D BA 25 10 DF BE 87 D2 A1 27 


If the bootloader looks like the above (basically 01 02 03 04 05 06 07 etc.) then that is not the "real" bootloader, the lock bits prevent it from being read.

In this case the lock byte (0xCF) prevents the bootloader from being read. You would have to use the ICSP method described above (with a second board) to read the bootloader.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 28 Oct 2014 04:18 AM (UTC)
Message
Detection of bootloader name from MD5 sum


Version 1.10+ of the main sketch now looks up the bootloader MD5 sum from an inbuilt table of known bootloaders. If found, it prints something like this:


MD5 sum of bootloader = FB F4 9B 7B 59 73 7F 65 E8 D0 F8 A5 08 12 E7 9F 
Bootloader name: optiboot_atmega328


This lets you quickly check you have a particular bootloader without having to muck around checking MD5 sums against a list.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


123,069 views.

Postings by administrators only.

[Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]