Skip to content

Commit 22bf774

Browse files
committed
🐛 Fix LPC1768 SD-based EEPROM debug
Fixes #22746
1 parent e2a790b commit 22bf774

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/**
22
* Marlin 3D Printer Firmware
3-
*
43
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5-
* Copyright (c) 2016 Bob Cousins [email protected]
6-
* Copyright (c) 2015-2016 Nico Tonnhofer [email protected]
7-
* Copyright (c) 2016 Victor Perez [email protected]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
87
*
98
* This program is free software: you can redistribute it and/or modify
109
* it under the terms of the GNU General Public License as published by
@@ -20,12 +19,19 @@
2019
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2120
*
2221
*/
22+
23+
/**
24+
* Implementation of EEPROM settings in SD Card
25+
*/
26+
2327
#ifdef TARGET_LPC1768
2428

2529
#include "../../inc/MarlinConfig.h"
2630

2731
#if ENABLED(SDCARD_EEPROM_EMULATION)
2832

33+
//#define DEBUG_SD_EEPROM_EMULATION
34+
2935
#include "../shared/eeprom_api.h"
3036

3137
#include <chanfs/diskio.h>
@@ -38,9 +44,11 @@ FATFS fat_fs;
3844
FIL eeprom_file;
3945
bool eeprom_file_open = false;
4046

47+
#define EEPROM_FILENAME "eeprom.dat"
4148
#ifndef MARLIN_EEPROM_SIZE
4249
#define MARLIN_EEPROM_SIZE size_t(0x1000) // 4KiB of Emulated EEPROM
4350
#endif
51+
4452
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
4553

4654
bool PersistentStore::access_start() {
@@ -50,7 +58,7 @@ bool PersistentStore::access_start() {
5058
MSC_Release_Lock();
5159
return false;
5260
}
53-
FRESULT res = f_open(&eeprom_file, "eeprom.dat", FA_OPEN_ALWAYS | FA_WRITE | FA_READ);
61+
FRESULT res = f_open(&eeprom_file, EEPROM_FILENAME, FA_OPEN_ALWAYS | FA_WRITE | FA_READ);
5462
if (res) MSC_Release_Lock();
5563

5664
if (res == FR_OK) {
@@ -81,18 +89,20 @@ bool PersistentStore::access_finish() {
8189
// This extra chit-chat goes away soon, but is helpful for now
8290
// to see errors that are happening in read_data / write_data
8391
static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) {
84-
PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
85-
SERIAL_CHAR(' ');
86-
SERIAL_ECHOPGM_P(rw_str);
87-
SERIAL_ECHOLNPGM("_data(", pos, ",", value, ",", size, ", ...)");
88-
if (total) {
89-
SERIAL_ECHOPGM(" f_");
92+
#if ENABLED(DEBUG_SD_EEPROM_EMULATION)
93+
PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
94+
SERIAL_CHAR(' ');
9095
SERIAL_ECHOPGM_P(rw_str);
91-
SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
92-
SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total);
93-
}
94-
else
95-
SERIAL_ECHOLNPGM(" f_lseek()=", s);
96+
SERIAL_ECHOLNPGM("_data(", pos, ",", *value, ",", size, ", ...)");
97+
if (total) {
98+
SERIAL_ECHOPGM(" f_");
99+
SERIAL_ECHOPGM_P(rw_str);
100+
SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
101+
SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total);
102+
}
103+
else
104+
SERIAL_ECHOLNPGM(" f_lseek()=", s);
105+
#endif
96106
}
97107

98108
// File function return codes for type FRESULT. This goes away soon, but

Marlin/src/pins/stm32f4/pins_ARMED.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
#define BOARD_INFO_NAME "Arm'ed"
3939
#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME
4040

41-
#define I2C_EEPROM
42-
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
41+
#if NO_EEPROM_SELECTED
42+
#define I2C_EEPROM
43+
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
44+
#endif
4345

4446
//
4547
// Limit Switches

0 commit comments

Comments
 (0)