Browse Source

gcode_D EEPROM size, cleanup

Fixes #19920

Co-Authored-By: Orel <37673727+0r31@users.noreply.github.com>
vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
2774b70fbf
  1. 2
      Marlin/src/HAL/AVR/eeprom.cpp
  2. 2
      Marlin/src/HAL/DUE/eeprom_flash.cpp
  3. 2
      Marlin/src/HAL/DUE/eeprom_wired.cpp
  4. 2
      Marlin/src/HAL/ESP32/eeprom.cpp
  5. 2
      Marlin/src/HAL/LINUX/eeprom.cpp
  6. 2
      Marlin/src/HAL/LPC1768/eeprom_flash.cpp
  7. 2
      Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp
  8. 2
      Marlin/src/HAL/LPC1768/eeprom_wired.cpp
  9. 2
      Marlin/src/HAL/SAMD51/eeprom_flash.cpp
  10. 2
      Marlin/src/HAL/SAMD51/eeprom_qspi.cpp
  11. 2
      Marlin/src/HAL/SAMD51/eeprom_wired.cpp
  12. 2
      Marlin/src/HAL/STM32/eeprom_flash.cpp
  13. 2
      Marlin/src/HAL/STM32/eeprom_sdcard.cpp
  14. 2
      Marlin/src/HAL/STM32/eeprom_sram.cpp
  15. 2
      Marlin/src/HAL/STM32/eeprom_wired.cpp
  16. 2
      Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp
  17. 2
      Marlin/src/HAL/STM32F1/eeprom_flash.cpp
  18. 2
      Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp
  19. 2
      Marlin/src/HAL/STM32F1/eeprom_wired.cpp
  20. 2
      Marlin/src/HAL/STM32_F4_F7/eeprom_flash.cpp
  21. 2
      Marlin/src/HAL/STM32_F4_F7/eeprom_wired.cpp
  22. 2
      Marlin/src/HAL/TEENSY31_32/eeprom.cpp
  23. 2
      Marlin/src/HAL/TEENSY35_36/eeprom.cpp
  24. 2
      Marlin/src/HAL/TEENSY40_41/eeprom.cpp
  25. 46
      Marlin/src/gcode/gcode_d.cpp

2
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; 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 { do {
uint8_t c = eeprom_read_byte((uint8_t*)pos); uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c; if (writing) *value = c;

2
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; 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 { do {
uint8_t c = ee_Read(uint32_t(pos)); uint8_t c = ee_Read(uint32_t(pos));
if (writing) *value = c; if (writing) *value = c;

2
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; 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 { do {
uint8_t c = eeprom_read_byte((uint8_t*)pos); uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c; if (writing) *value = c;

2
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; 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++) { for (size_t i = 0; i < size; i++) {
uint8_t c = EEPROM.read(pos++); uint8_t c = EEPROM.read(pos++);
if (writing) value[i] = c; if (writing) value[i] = c;

2
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 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; std::size_t bytes_read = 0;
if (writing) { if (writing) {
for (std::size_t i = 0; i < size; i++) { for (std::size_t i = 0; i < size; i++) {

2
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 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]; 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]; if (writing) for (size_t i = 0; i < size; i++) value[i] = ram_eeprom[pos + i];
crc16(crc, buff, size); crc16(crc, buff, size);

2
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 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; if (!eeprom_file_open) return true;
UINT bytes_read = 0; UINT bytes_read = 0;
FRESULT s; FRESULT s;

2
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; 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 { do {
// Read from external EEPROM // Read from external EEPROM
const uint8_t c = eeprom_read_byte((uint8_t*)pos); const uint8_t c = eeprom_read_byte((uint8_t*)pos);

2
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; 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--) { while (size--) {
SYNC(NVMCTRL->SEESTAT.bit.BUSY); SYNC(NVMCTRL->SEESTAT.bit.BUSY);
uint8_t c = ((volatile uint8_t *)SEEPROM_ADDR)[pos]; uint8_t c = ((volatile uint8_t *)SEEPROM_ADDR)[pos];

2
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; 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--) { while (size--) {
uint8_t c = qspi.readByte(pos); uint8_t c = qspi.readByte(pos);
if (writing) *value = c; if (writing) *value = c;

2
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; 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--) { while (size--) {
uint8_t c = eeprom_read_byte((uint8_t*)pos); uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c; if (writing) *value = c;

2
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; 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 { do {
const uint8_t c = TERN(FLASH_EEPROM_LEVELING, ram_eeprom[pos], eeprom_buffered_read_byte(pos)); const uint8_t c = TERN(FLASH_EEPROM_LEVELING, ram_eeprom[pos], eeprom_buffered_read_byte(pos));
if (writing) *value = c; if (writing) *value = c;

2
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; 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++) { for (size_t i = 0; i < size; i++) {
uint8_t c = HAL_eeprom_data[pos + i]; uint8_t c = HAL_eeprom_data[pos + i];
if (writing) value[i] = c; if (writing) value[i] = c;

2
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; 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 { do {
// Read from either external EEPROM, program flash or Backup SRAM // Read from either external EEPROM, program flash or Backup SRAM
const uint8_t c = ( *(__IO uint8_t *)(BKPSRAM_BASE + ((uint8_t*)pos)) ); const uint8_t c = ( *(__IO uint8_t *)(BKPSRAM_BASE + ((uint8_t*)pos)) );

2
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; 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 { do {
// Read from either external EEPROM, program flash or Backup SRAM // Read from either external EEPROM, program flash or Backup SRAM
const uint8_t c = eeprom_read_byte((uint8_t*)pos); const uint8_t c = eeprom_read_byte((uint8_t*)pos);

2
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; 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 { do {
uint8_t * const p = (uint8_t * const)pos; uint8_t * const p = (uint8_t * const)pos;
uint8_t c = eeprom_read_byte(p); uint8_t c = eeprom_read_byte(p);

2
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 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]; 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]; if (writing) for (size_t i = 0; i < size; i++) value[i] = ram_eeprom[pos + i];
crc16(crc, buff, size); crc16(crc, buff, size);

2
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; 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++) { for (size_t i = 0; i < size; i++) {
uint8_t c = HAL_eeprom_data[pos + i]; uint8_t c = HAL_eeprom_data[pos + i];
if (writing) value[i] = c; if (writing) value[i] = c;

2
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; 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 { do {
uint8_t c = eeprom_read_byte((uint8_t*)pos); uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing && value) *value = c; if (writing && value) *value = c;

2
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; 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 { do {
uint8_t c = ee_read_byte((uint8_t*)pos); uint8_t c = ee_read_byte((uint8_t*)pos);
if (writing) *value = c; if (writing) *value = c;

2
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; 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 { do {
uint8_t c = eeprom_read_byte((uint8_t*)pos); uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c; if (writing) *value = c;

2
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; 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 { do {
uint8_t c = eeprom_read_byte((uint8_t*)pos); uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c; if (writing) *value = c;

2
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; 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 { do {
uint8_t c = eeprom_read_byte((uint8_t*)pos); uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c; if (writing) *value = c;

2
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; 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 { do {
uint8_t c = eeprom_read_byte((uint8_t*)pos); uint8_t c = eeprom_read_byte((uint8_t*)pos);
if (writing) *value = c; if (writing) *value = c;

46
Marlin/src/gcode/gcode_d.cpp

@ -54,9 +54,7 @@
size_t total = persistentStore.capacity(); size_t total = persistentStore.capacity();
int pos = 0; int pos = 0;
const uint8_t value = 0x0; const uint8_t value = 0x0;
while(total--) { while (total--) persistentStore.write_data(pos, &value, 1);
persistentStore.write_data(pos, &value, 1);
}
persistentStore.access_finish(); persistentStore.access_finish();
#else #else
settings.reset(); settings.reset();
@ -70,7 +68,7 @@
uint8_t *pointer = parser.hex_adr_val('A'); uint8_t *pointer = parser.hex_adr_val('A');
uint16_t len = parser.ushortval('C', 1); uint16_t len = parser.ushortval('C', 1);
uintptr_t addr = (uintptr_t)pointer; 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); NOMORE(len, SRAM_SIZE - addr);
if (parser.seenval('X')) { if (parser.seenval('X')) {
// Write the hex bytes after the X // Write the hex bytes after the X
@ -91,16 +89,13 @@
uint8_t *pointer = parser.hex_adr_val('A'); uint8_t *pointer = parser.hex_adr_val('A');
uint16_t len = parser.ushortval('C', 1); uint16_t len = parser.ushortval('C', 1);
uintptr_t addr = (uintptr_t)pointer; uintptr_t addr = (uintptr_t)pointer;
#ifndef MARLIN_EEPROM_SIZE NOMORE(addr, size_t(persistentStore.capacity() - 1));
#define MARLIN_EEPROM_SIZE size_t(E2END + 1) NOMORE(len, persistentStore.capacity() - addr);
#endif
NOMORE(addr, (size_t)(MARLIN_EEPROM_SIZE - 1));
NOMORE(len, MARLIN_EEPROM_SIZE - addr);
if (parser.seenval('X')) { if (parser.seenval('X')) {
uint16_t val = parser.hex_val('X'); uint16_t val = parser.hex_val('X');
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
persistentStore.access_start(); persistentStore.access_start();
while(len--) { while (len--) {
int pos = 0; int pos = 0;
persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val)); persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val));
} }
@ -111,23 +106,18 @@
#endif #endif
} }
else { else {
while (len--) { // Read bytes from EEPROM
// Read bytes from EEPROM #if ENABLED(EEPROM_SETTINGS)
#if ENABLED(EEPROM_SETTINGS) persistentStore.access_start();
persistentStore.access_start(); int pos = 0;
uint8_t val; uint8_t val;
while(len--) { while (len--) if (!persistentStore.read_data(pos, &val, 1)) print_hex_byte(val);
int pos = 0; SERIAL_EOL();
if (!persistentStore.read_data(pos, (uint8_t *)&val, sizeof(val))) { persistentStore.access_finish();
print_hex_byte(val); #else
} SERIAL_ECHOLNPGM("NO EEPROM");
} len = 0;
SERIAL_EOL(); #endif
persistentStore.access_finish();
#else
SERIAL_ECHOLNPGM("NO EEPROM");
#endif
}
SERIAL_EOL(); SERIAL_EOL();
} }
} break; } break;
@ -156,7 +146,7 @@
uint8_t *pointer = parser.hex_adr_val('A'); uint8_t *pointer = parser.hex_adr_val('A');
uint16_t len = parser.ushortval('C', 1); uint16_t len = parser.ushortval('C', 1);
uintptr_t addr = (uintptr_t)pointer; 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); NOMORE(len, FLASH_SIZE - addr);
if (parser.seenval('X')) { if (parser.seenval('X')) {
// TODO: Write the hex bytes after the X // TODO: Write the hex bytes after the X

Loading…
Cancel
Save