summaryrefslogtreecommitdiff
path: root/src/bwbootloader/prog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bwbootloader/prog.c')
-rw-r--r--src/bwbootloader/prog.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bwbootloader/prog.c b/src/bwbootloader/prog.c
index 2bd7fa6..f2b5144 100644
--- a/src/bwbootloader/prog.c
+++ b/src/bwbootloader/prog.c
@@ -40,7 +40,7 @@ uint8_t
prog_page_write (uint16_t address, const uint8_t *buffer)
{
/* Bootloader area is protected. */
- if (address >= PROG_FLASH_SIZE - BWBOOTLOADER_SIZE)
+ if (address >= BWBOOTLOADER_LIMIT)
return 0;
/* Aligned write only. */
if (address % PROG_PAGE_SIZE != 0)
@@ -53,7 +53,12 @@ prog_page_write (uint16_t address, const uint8_t *buffer)
{
/* Protect reset vector. */
if (address == 0 && i == 0)
+ {
w = pgm_read_word (0);
+ if (AC_BWBOOTLOADER_BOOTSTRAP
+ && w != *(const uint16_t *) (buffer))
+ return 0;
+ }
else
w = *(const uint16_t *) (buffer + i);
boot_page_fill (address + i, w);