From 2774b70fbf8e62e3bc3b7a0efb23a1c1d8ff12d2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 29 Oct 2020 17:33:59 -0500 Subject: [PATCH] gcode_D EEPROM size, cleanup Fixes #19920 Co-Authored-By: Orel <37673727+0r31@users.noreply.github.com> --- Marlin/src/HAL/AVR/eeprom.cpp | 2 +- Marlin/src/HAL/DUE/eeprom_flash.cpp | 2 +- Marlin/src/HAL/DUE/eeprom_wired.cpp | 2 +- Marlin/src/HAL/ESP32/eeprom.cpp | 2 +- Marlin/src/HAL/LINUX/eeprom.cpp | 2 +- Marlin/src/HAL/LPC1768/eeprom_flash.cpp | 2 +- Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp | 2 +- Marlin/src/HAL/LPC1768/eeprom_wired.cpp | 2 +- Marlin/src/HAL/SAMD51/eeprom_flash.cpp | 2 +- Marlin/src/HAL/SAMD51/eeprom_qspi.cpp | 2 +- Marlin/src/HAL/SAMD51/eeprom_wired.cpp | 2 +- Marlin/src/HAL/STM32/eeprom_flash.cpp | 2 +- Marlin/src/HAL/STM32/eeprom_sdcard.cpp | 2 +- Marlin/src/HAL/STM32/eeprom_sram.cpp | 2 +- Marlin/src/HAL/STM32/eeprom_wired.cpp | 2 +- Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp | 2 +- Marlin/src/HAL/STM32F1/eeprom_flash.cpp | 2 +- Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp | 2 +- Marlin/src/HAL/STM32F1/eeprom_wired.cpp | 2 +- Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp | 2 +- Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp | 2 +- Marlin/src/HAL/TEENSY31_32/eeprom.cpp | 2 +- Marlin/src/HAL/TEENSY35_36/eeprom.cpp | 2 +- Marlin/src/HAL/TEENSY40_41/eeprom.cpp | 2 +- Marlin/src/gcode/gcode_d.cpp | 46 ++++++++------------- 25 files changed, 42 insertions(+), 52 deletions(-) diff --git a/Marlin/src/HAL/AVR/eeprom.cpp b/Marlin/src/HAL/AVR/eeprom.cpp index c7906985eb..ee2a73e410 100644 --- a/Marlin/src/HAL/AVR/eeprom.cpp +++ b/Marlin/src/HAL/AVR/eeprom.cpp @@ -59,7 +59,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t c = eeprom_read_byte((uint8_t*)pos); if (writing) *value = c; diff --git a/Marlin/src/HAL/DUE/eeprom_flash.cpp b/Marlin/src/HAL/DUE/eeprom_flash.cpp index 6f38da0967..209a5161ae 100644 --- a/Marlin/src/HAL/DUE/eeprom_flash.cpp +++ b/Marlin/src/HAL/DUE/eeprom_flash.cpp @@ -996,7 +996,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t c = ee_Read(uint32_t(pos)); if (writing) *value = c; diff --git a/Marlin/src/HAL/DUE/eeprom_wired.cpp b/Marlin/src/HAL/DUE/eeprom_wired.cpp index 4599d6a7cd..b488c36f16 100644 --- a/Marlin/src/HAL/DUE/eeprom_wired.cpp +++ b/Marlin/src/HAL/DUE/eeprom_wired.cpp @@ -62,7 +62,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t c = eeprom_read_byte((uint8_t*)pos); if (writing) *value = c; diff --git a/Marlin/src/HAL/ESP32/eeprom.cpp b/Marlin/src/HAL/ESP32/eeprom.cpp index 1bf687c6fe..cb5f881284 100644 --- a/Marlin/src/HAL/ESP32/eeprom.cpp +++ b/Marlin/src/HAL/ESP32/eeprom.cpp @@ -44,7 +44,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { for (size_t i = 0; i < size; i++) { uint8_t c = EEPROM.read(pos++); if (writing) value[i] = c; diff --git a/Marlin/src/HAL/LINUX/eeprom.cpp b/Marlin/src/HAL/LINUX/eeprom.cpp index 68fff9c433..532f323c6e 100644 --- a/Marlin/src/HAL/LINUX/eeprom.cpp +++ b/Marlin/src/HAL/LINUX/eeprom.cpp @@ -78,7 +78,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return (bytes_written != size); // return true for any error } -bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uint16_t *crc, const bool writing/*=true*/) { std::size_t bytes_read = 0; if (writing) { for (std::size_t i = 0; i < size; i++) { diff --git a/Marlin/src/HAL/LPC1768/eeprom_flash.cpp b/Marlin/src/HAL/LPC1768/eeprom_flash.cpp index 2558486375..3c0c3c8ec3 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_flash.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_flash.cpp @@ -119,7 +119,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; // return true for any error } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { const uint8_t * const buff = writing ? &value[0] : &ram_eeprom[pos]; if (writing) for (size_t i = 0; i < size; i++) value[i] = ram_eeprom[pos + i]; crc16(crc, buff, size); diff --git a/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp b/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp index 9f2475f490..54a64ccd72 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp @@ -143,7 +143,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return bytes_written != size; // return true for any error } -bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uint16_t *crc, const bool writing/*=true*/) { if (!eeprom_file_open) return true; UINT bytes_read = 0; FRESULT s; diff --git a/Marlin/src/HAL/LPC1768/eeprom_wired.cpp b/Marlin/src/HAL/LPC1768/eeprom_wired.cpp index 16c15eaf00..d94aba6119 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_wired.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_wired.cpp @@ -64,7 +64,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { // Read from external EEPROM const uint8_t c = eeprom_read_byte((uint8_t*)pos); diff --git a/Marlin/src/HAL/SAMD51/eeprom_flash.cpp b/Marlin/src/HAL/SAMD51/eeprom_flash.cpp index 429ef1c2d4..871bf22b7f 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_flash.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_flash.cpp @@ -79,7 +79,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { while (size--) { SYNC(NVMCTRL->SEESTAT.bit.BUSY); uint8_t c = ((volatile uint8_t *)SEEPROM_ADDR)[pos]; diff --git a/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp b/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp index b403f7939f..faa7637197 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp @@ -56,7 +56,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { while (size--) { uint8_t c = qspi.readByte(pos); if (writing) *value = c; diff --git a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp b/Marlin/src/HAL/SAMD51/eeprom_wired.cpp index 3283195897..d9a0225a7a 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_wired.cpp @@ -59,7 +59,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { while (size--) { uint8_t c = eeprom_read_byte((uint8_t*)pos); if (writing) *value = c; diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp index 0933b9f4e8..c83376d265 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -261,7 +261,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { const uint8_t c = TERN(FLASH_EEPROM_LEVELING, ram_eeprom[pos], eeprom_buffered_read_byte(pos)); if (writing) *value = c; diff --git a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp index 711a83ed5b..c9180bf09b 100644 --- a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp @@ -78,7 +78,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uint16_t *crc, const bool writing/*=true*/) { for (size_t i = 0; i < size; i++) { uint8_t c = HAL_eeprom_data[pos + i]; if (writing) value[i] = c; diff --git a/Marlin/src/HAL/STM32/eeprom_sram.cpp b/Marlin/src/HAL/STM32/eeprom_sram.cpp index 5f6f26f9c6..135bcabde9 100644 --- a/Marlin/src/HAL/STM32/eeprom_sram.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sram.cpp @@ -52,7 +52,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { // Read from either external EEPROM, program flash or Backup SRAM const uint8_t c = ( *(__IO uint8_t *)(BKPSRAM_BASE + ((uint8_t*)pos)) ); diff --git a/Marlin/src/HAL/STM32/eeprom_wired.cpp b/Marlin/src/HAL/STM32/eeprom_wired.cpp index 8c46e45f03..ad54c12c47 100644 --- a/Marlin/src/HAL/STM32/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32/eeprom_wired.cpp @@ -65,7 +65,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { // Read from either external EEPROM, program flash or Backup SRAM const uint8_t c = eeprom_read_byte((uint8_t*)pos); diff --git a/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp b/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp index 658b7cd4a6..94b5e099bd 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp @@ -68,7 +68,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t * const p = (uint8_t * const)pos; uint8_t c = eeprom_read_byte(p); diff --git a/Marlin/src/HAL/STM32F1/eeprom_flash.cpp b/Marlin/src/HAL/STM32F1/eeprom_flash.cpp index 8db8c8638b..dfcaaaf29f 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_flash.cpp @@ -101,7 +101,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; // return true for any error } -bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uint16_t *crc, const bool writing/*=true*/) { const uint8_t * const buff = writing ? &value[0] : &ram_eeprom[pos]; if (writing) for (size_t i = 0; i < size; i++) value[i] = ram_eeprom[pos + i]; crc16(crc, buff, size); diff --git a/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp index 11959191f6..d608ccee14 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp @@ -79,7 +79,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uint16_t *crc, const bool writing/*=true*/) { for (size_t i = 0; i < size; i++) { uint8_t c = HAL_eeprom_data[pos + i]; if (writing) value[i] = c; diff --git a/Marlin/src/HAL/STM32F1/eeprom_wired.cpp b/Marlin/src/HAL/STM32F1/eeprom_wired.cpp index fffd6ccaf0..6e992a22a3 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_wired.cpp @@ -72,7 +72,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t c = eeprom_read_byte((uint8_t*)pos); if (writing && value) *value = c; diff --git a/Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp b/Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp index 00b808fd48..8c5795b685 100644 --- a/Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp @@ -96,7 +96,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t c = ee_read_byte((uint8_t*)pos); if (writing) *value = c; diff --git a/Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp b/Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp index c0d82dbd07..2bf386bec5 100644 --- a/Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp @@ -62,7 +62,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t c = eeprom_read_byte((uint8_t*)pos); if (writing) *value = c; diff --git a/Marlin/src/HAL/TEENSY31_32/eeprom.cpp b/Marlin/src/HAL/TEENSY31_32/eeprom.cpp index cc5c56f7d5..f2ae5dd534 100644 --- a/Marlin/src/HAL/TEENSY31_32/eeprom.cpp +++ b/Marlin/src/HAL/TEENSY31_32/eeprom.cpp @@ -57,7 +57,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t c = eeprom_read_byte((uint8_t*)pos); if (writing) *value = c; diff --git a/Marlin/src/HAL/TEENSY35_36/eeprom.cpp b/Marlin/src/HAL/TEENSY35_36/eeprom.cpp index ccbdc6b116..8cd6b4ff41 100644 --- a/Marlin/src/HAL/TEENSY35_36/eeprom.cpp +++ b/Marlin/src/HAL/TEENSY35_36/eeprom.cpp @@ -61,7 +61,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t c = eeprom_read_byte((uint8_t*)pos); if (writing) *value = c; diff --git a/Marlin/src/HAL/TEENSY40_41/eeprom.cpp b/Marlin/src/HAL/TEENSY40_41/eeprom.cpp index 030a8c38af..fe2de388a7 100644 --- a/Marlin/src/HAL/TEENSY40_41/eeprom.cpp +++ b/Marlin/src/HAL/TEENSY40_41/eeprom.cpp @@ -61,7 +61,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui return false; } -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t c = eeprom_read_byte((uint8_t*)pos); if (writing) *value = c; diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 2fd03144c5..0bd2955875 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -54,9 +54,7 @@ size_t total = persistentStore.capacity(); int pos = 0; const uint8_t value = 0x0; - while(total--) { - persistentStore.write_data(pos, &value, 1); - } + while (total--) persistentStore.write_data(pos, &value, 1); persistentStore.access_finish(); #else settings.reset(); @@ -70,7 +68,7 @@ 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)(SRAM_SIZE - 1)); + NOMORE(addr, size_t(SRAM_SIZE - 1)); NOMORE(len, SRAM_SIZE - addr); if (parser.seenval('X')) { // Write the hex bytes after the X @@ -91,16 +89,13 @@ uint8_t *pointer = parser.hex_adr_val('A'); uint16_t len = parser.ushortval('C', 1); uintptr_t addr = (uintptr_t)pointer; - #ifndef MARLIN_EEPROM_SIZE - #define MARLIN_EEPROM_SIZE size_t(E2END + 1) - #endif - NOMORE(addr, (size_t)(MARLIN_EEPROM_SIZE - 1)); - NOMORE(len, MARLIN_EEPROM_SIZE - addr); + NOMORE(addr, size_t(persistentStore.capacity() - 1)); + NOMORE(len, persistentStore.capacity() - addr); if (parser.seenval('X')) { uint16_t val = parser.hex_val('X'); #if ENABLED(EEPROM_SETTINGS) persistentStore.access_start(); - while(len--) { + while (len--) { int pos = 0; persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val)); } @@ -111,23 +106,18 @@ #endif } else { - while (len--) { - // Read bytes from EEPROM - #if ENABLED(EEPROM_SETTINGS) - persistentStore.access_start(); - uint8_t val; - while(len--) { - int pos = 0; - if (!persistentStore.read_data(pos, (uint8_t *)&val, sizeof(val))) { - print_hex_byte(val); - } - } - SERIAL_EOL(); - persistentStore.access_finish(); - #else - SERIAL_ECHOLNPGM("NO EEPROM"); - #endif - } + // Read bytes from EEPROM + #if ENABLED(EEPROM_SETTINGS) + persistentStore.access_start(); + int pos = 0; + uint8_t val; + while (len--) if (!persistentStore.read_data(pos, &val, 1)) print_hex_byte(val); + SERIAL_EOL(); + persistentStore.access_finish(); + #else + SERIAL_ECHOLNPGM("NO EEPROM"); + len = 0; + #endif SERIAL_EOL(); } } break; @@ -156,7 +146,7 @@ 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(addr, size_t(FLASH_SIZE - 1)); NOMORE(len, FLASH_SIZE - addr); if (parser.seenval('X')) { // TODO: Write the hex bytes after the X