From a039081728cda8e829cb4a90116d150674f69e53 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 20 Dec 2022 21:14:58 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix=20ONBOA?= =?UTF-8?q?RD=5FFLASH=5FSIZE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/gcode_d.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 2ebe38bbcf..aabc6e9d44 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -156,12 +156,16 @@ void GcodeSuite::D(const int16_t dcode) { } break; case 5: { // D5 Read / Write onboard Flash - #define FLASH_SIZE 1024 + #ifdef MARLIN_EEPROM_SIZE + #define ONBOARD_FLASH_SIZE MARLIN_EEPROM_SIZE + #else + #define ONBOARD_FLASH_SIZE 1024 // 0x400 + #endif uint8_t *pointer = parser.hex_adr_val('A'); uint16_t len = parser.ushortval('C', 1); uintptr_t addr = (uintptr_t)pointer; - NOMORE(addr, size_t(FLASH_SIZE - 1)); - NOMORE(len, FLASH_SIZE - addr); + NOMORE(addr, size_t(ONBOARD_FLASH_SIZE - 1)); + NOMORE(len, ONBOARD_FLASH_SIZE - addr); if (parser.seenval('X')) { // TODO: Write the hex bytes after the X //while (len--) {}