Tuesday, 22 October 2013 22:13

Identify which Arduino bootloader do I have

Written by
Here’s an Arduino sketch which tries to identify the bootloader and reports it on the serial port
 
The sample output look like this:
[bootCheck.2]
  CRC 2048b @ 0x7800 = CD70
  CRC 512b @ 0x7E00 = FD70
Boot loader: OptiBoot 4.4
 

// Detect which type of boot loader is present, using a fixed built-in table
// 2012-03-06 <This email address is being protected from spambots. You need JavaScript enabled to view it.; http://opensource.org/licenses/mit-license.php

#include <avr/pgmspace.h>
#include <util/crc16.h>

#define VERSION "2"

// list of all known boot loaders with their unique signatures
struct { word crc; const char* desc; } signatures[] = {
0x489C, "Duemilanove",
0xF1A0, "Nanode (Duemilanove mod)",
0xFD70, "OptiBoot 4.4",
0, 0
};

static word CalculateChecksum (word addr, word size) {
word crc = ~0;
prog_uint8_t* p = (prog_uint8_t*) addr;
for (word i = 0; i < size; ++i)
crc = _crc16_update(crc, pgm_read_byte(p++));
Serial.print(" CRC ");
Serial.print(size);
Serial.print("b @ 0x");
Serial.print(addr, HEX);
Serial.print(" = ");
Serial.println(crc, HEX);
return crc;
}

static const char* IdentifyBootLoader (word addr, word size) {
word crc = CalculateChecksum(addr, size);
for (byte i = 0; signatures[i].desc != 0; ++i)
if (signatures[i].crc == crc)
return signatures[i].desc;
return 0;
}

void setup () {
Serial.begin(57600);
Serial.println("\n[bootCheck." VERSION "]");

const char* message = IdentifyBootLoader(0x7800, 2048);
if (message == 0)
message = IdentifyBootLoader(0x7E00, 512);
if (message == 0)
message = "(UNKNOWN)";

Serial.print("Boot loader: ");
Serial.println(message);
}

void loop () {}


Read 7441 times Last modified on Tuesday, 22 October 2013 22:28

4 comments

  • Comment Link Aappencyavafe Monday, 20 January 2020 09:28 posted by Aappencyavafe

    protest http://cialisoni.com/# - buy online cialis impossible cheap cialis online squeeze
    company https://cialsagen.com/# - buying generic viagra online safe best places to buy generic viagra viagra cheap online survivor

  • Comment Link MatWeetle Friday, 17 January 2020 20:21 posted by MatWeetle

    Does Alcohol Affect Cephalexin Zithromax Purpose Keflex Overdose Buy Cialis Best Price 100mg Generic Viagra Order Propecia Online No Prescription Does Propecia Regrow Hair

  • Comment Link Aappencyavafe Friday, 10 January 2020 06:49 posted by Aappencyavafe

    tire http://cialisoni.com/# - generic cialis online anticipate cialis online buy intend
    electronic https://cialsagen.com/# - viagra generic online usa pharmacy generic sildenafil generic viagra take

  • Comment Link Stevambums Wednesday, 20 November 2019 23:15 posted by Stevambums

    Cialis 20mg Fta Propecia Online Prices viagra online pharmacy Plavix Online Purchase

Leave a comment

Back to Top