diff --git a/avr/libraries/Optiboot_flasher/examples/Flash_iterate/Flash_iterate.ino b/avr/libraries/Optiboot_flasher/examples/Flash_iterate/Flash_iterate.ino index ca4d594bd..44da63fb6 100644 --- a/avr/libraries/Optiboot_flasher/examples/Flash_iterate/Flash_iterate.ino +++ b/avr/libraries/Optiboot_flasher/examples/Flash_iterate/Flash_iterate.ino @@ -72,6 +72,12 @@ void setup() delay(2000); Serial.begin(9600); + if(!flash.check_writable()) + { + Serial.println(F("Incompatible or no bootloader present! Please burn correct bootloader")); + while(1); + } + // If the allocated flash space is above 64kiB, a 16-bit pointer won't be enough anymore. // As a workaround, you can set the address to the allocated space like this, and the // library will handle the rest. You'll also have to allocate your flash space in diff --git a/avr/libraries/Optiboot_flasher/examples/Flash_put_get/Flash_put_get.ino b/avr/libraries/Optiboot_flasher/examples/Flash_put_get/Flash_put_get.ino index eabbfb4ae..dbb121226 100644 --- a/avr/libraries/Optiboot_flasher/examples/Flash_put_get/Flash_put_get.ino +++ b/avr/libraries/Optiboot_flasher/examples/Flash_put_get/Flash_put_get.ino @@ -106,6 +106,12 @@ void setup() delay(2000); Serial.begin(9600); + if(!flash.check_writable()) + { + Serial.println(F("Incompatible or no bootloader present! Please burn correct bootloader")); + while(1); + } + // If the allocated flash space is above 64kiB, a 16-bit pointer won't be enough anymore. // As a workaround, you can set the address to the allocated space like this, and the // library will handle the rest. You'll also have to allocate your flash space in diff --git a/avr/libraries/Optiboot_flasher/examples/Read_write_without_buffer/Read_write_without_buffer.ino b/avr/libraries/Optiboot_flasher/examples/Read_write_without_buffer/Read_write_without_buffer.ino index b535fdc24..743fa25e9 100644 --- a/avr/libraries/Optiboot_flasher/examples/Read_write_without_buffer/Read_write_without_buffer.ino +++ b/avr/libraries/Optiboot_flasher/examples/Read_write_without_buffer/Read_write_without_buffer.ino @@ -88,6 +88,12 @@ void setup() delay(2000); Serial.begin(9600); + if(!optiboot_check_writable()) + { + Serial.println(F("Incompatible or no bootloader present! Please burn correct bootloader")); + while(1); + } + static uint16_t addr = 0; Serial.print(F("Filling up flash page 0 with 16-bit values...\n")); diff --git a/avr/libraries/Optiboot_flasher/examples/Serial_read_write/Serial_read_write.ino b/avr/libraries/Optiboot_flasher/examples/Serial_read_write/Serial_read_write.ino index 5d9ab939f..b9172f848 100644 --- a/avr/libraries/Optiboot_flasher/examples/Serial_read_write/Serial_read_write.ino +++ b/avr/libraries/Optiboot_flasher/examples/Serial_read_write/Serial_read_write.ino @@ -51,6 +51,12 @@ void setup() { // Initialize serial Serial.begin(9600); + + if(!optiboot_check_writable()) + { + Serial.println(F("Incompatible or no bootloader present! Please burn correct bootloader")); + while(1); + } } diff --git a/avr/libraries/Optiboot_flasher/keywords.txt b/avr/libraries/Optiboot_flasher/keywords.txt index acb6c5127..351b9767b 100644 --- a/avr/libraries/Optiboot_flasher/keywords.txt +++ b/avr/libraries/Optiboot_flasher/keywords.txt @@ -27,6 +27,7 @@ put KEYWORD2 # Optiboot do_spm_cli KEYWORD2 +optiboot_check_writable KEYWORD2 optiboot_page_erase KEYWORD2 optiboot_page_fill KEYWORD2 optiboot_page_write KEYWORD2