From f5c92e0ed3ee677d85543a8928b7c42b0cba1c44 Mon Sep 17 00:00:00 2001 From: Manfred Steiner Date: Mon, 22 Jul 2024 19:09:04 +0200 Subject: [PATCH] bugfix flashWrite --- software/gdb-stub/src/gdb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/software/gdb-stub/src/gdb.cpp b/software/gdb-stub/src/gdb.cpp index 20ee10c..5602acc 100644 --- a/software/gdb-stub/src/gdb.cpp +++ b/software/gdb-stub/src/gdb.cpp @@ -308,15 +308,15 @@ namespace gdb { bootloader::putUint8Hex(GDB_DEBUG_UART, (uint8_t)size); #endif - uint8_t *p = (uint8_t *)RAMSTART; uint16_t address = startAddress; + uint8_t *p = (uint8_t *)(RAMSTART + (address % SPM_PAGESIZE)); for (uint16_t i = 0; i < size; i++, address++) { uint16_t page = address / SPM_PAGESIZE; if (pgdb->status.flashPage >= 0 && page != (uint16_t)pgdb->status.flashPage) { flashWrite(); - p = (uint8_t *)RAMSTART; } if (pgdb->status.flashPage < 0) { + p = (uint8_t *)RAMSTART; pgdb->status.flashPage = address / SPM_PAGESIZE; for (uint16_t j = 0; j < SPM_PAGESIZE; j++) { p[j] = 0xff; -- 2.39.5