Преглед изворни кода

STM32F1: SD EEPROM fallback (#17715)

Jason Smith пре 4 година
родитељ
комит
f709c565a1
No account linked to committer's email address

+ 1
- 1
.github/workflows/test-builds.yml Прегледај датотеку

@@ -58,6 +58,7 @@ jobs:
58 58
         - ARMED
59 59
         - FYSETC_S6
60 60
         - malyan_M300
61
+        - mks_robin_lite
61 62
 
62 63
         # Put lengthy tests last
63 64
 
@@ -75,7 +76,6 @@ jobs:
75 76
         #- at90usb1286_cdc
76 77
         #- at90usb1286_dfu
77 78
         #- STM32F103CB_malyan
78
-        #- mks_robin_lite
79 79
         #- mks_robin_mini
80 80
         #- mks_robin_nano
81 81
 

+ 1
- 1
Marlin/src/HAL/STM32/inc/Conditionals_post.h Прегледај датотеку

@@ -22,6 +22,6 @@
22 22
 #pragma once
23 23
 
24 24
 // If no real EEPROM, Flash emulation, or SRAM emulation is available fall back to SD emulation
25
-#if ENABLED(EEPROM_SETTINGS) && NONE(USE_WIRED_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION)
25
+#if USE_FALLBACK_EEPROM
26 26
   #define SDCARD_EEPROM_EMULATION
27 27
 #endif

+ 8
- 0
Marlin/src/HAL/STM32/inc/SanityCheck.h Прегледај датотеку

@@ -35,3 +35,11 @@
35 35
 #if ENABLED(FAST_PWM_FAN)
36 36
   #error "FAST_PWM_FAN is not yet implemented for this platform."
37 37
 #endif
38
+
39
+#if ENABLED(SDCARD_EEPROM_EMULATION) && DISABLED(SDSUPPORT)
40
+  #undef SDCARD_EEPROM_EMULATION // Avoid additional error noise
41
+  #if USE_FALLBACK_EEPROM
42
+    #warning "EEPROM type not specified. Fallback is SDCARD_EEPROM_EMULATION."
43
+  #endif
44
+  #error "SDCARD_EEPROM_EMULATION requires SDSUPPORT. Enable SDSUPPORT or choose another EEPROM emulation."
45
+#endif

+ 22
- 31
Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp Прегледај датотеку

@@ -32,6 +32,7 @@
32 32
 #if ENABLED(SDCARD_EEPROM_EMULATION)
33 33
 
34 34
 #include "../shared/eeprom_api.h"
35
+#include "../../sd/cardreader.h"
35 36
 
36 37
 #ifndef E2END
37 38
   #define E2END 0xFFF // 4KB
@@ -41,44 +42,34 @@
41 42
 #define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat.
42 43
 static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
43 44
 
44
-#if ENABLED(SDSUPPORT)
45
+#define EEPROM_FILENAME "eeprom.dat"
45 46
 
46
-  #include "../../sd/cardreader.h"
47
+bool PersistentStore::access_start() {
48
+  if (!card.isMounted()) return false;
47 49
 
48
-  #define EEPROM_FILENAME "eeprom.dat"
50
+  SdFile file, root = card.getroot();
51
+  if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
52
+    return true; // false aborts the save
49 53
 
50
-  bool PersistentStore::access_start() {
51
-    if (!card.isMounted()) return false;
54
+  int bytes_read = file.read(HAL_eeprom_data, HAL_EEPROM_SIZE);
55
+  if (bytes_read < 0) return false;
56
+  for (; bytes_read < HAL_EEPROM_SIZE; bytes_read++)
57
+    HAL_eeprom_data[bytes_read] = 0xFF;
58
+  file.close();
59
+  return true;
60
+}
52 61
 
53
-    SdFile file, root = card.getroot();
54
-    if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
55
-      return true; // false aborts the save
62
+bool PersistentStore::access_finish() {
63
+  if (!card.isMounted()) return false;
56 64
 
57
-    int bytes_read = file.read(HAL_eeprom_data, HAL_EEPROM_SIZE);
58
-    if (bytes_read < 0) return false;
59
-    for (; bytes_read < HAL_EEPROM_SIZE; bytes_read++)
60
-      HAL_eeprom_data[bytes_read] = 0xFF;
65
+  SdFile file, root = card.getroot();
66
+  int bytes_written = 0;
67
+  if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
68
+    bytes_written = file.write(HAL_eeprom_data, HAL_EEPROM_SIZE);
61 69
     file.close();
62
-    return true;
63
-  }
64
-
65
-  bool PersistentStore::access_finish() {
66
-    if (!card.isMounted()) return false;
67
-
68
-    SdFile file, root = card.getroot();
69
-    int bytes_written = 0;
70
-    if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
71
-      bytes_written = file.write(HAL_eeprom_data, HAL_EEPROM_SIZE);
72
-      file.close();
73
-    }
74
-    return (bytes_written == HAL_EEPROM_SIZE);
75 70
   }
76
-
77
-#else // !SDSUPPORT
78
-
79
-  #error "Please define SPI_EEPROM (in Configuration.h) or disable EEPROM_SETTINGS."
80
-
81
-#endif // !SDSUPPORT
71
+  return (bytes_written == HAL_EEPROM_SIZE);
72
+}
82 73
 
83 74
 bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
84 75
   for (size_t i = 0; i < size; i++)

+ 5
- 0
Marlin/src/HAL/STM32F1/inc/Conditionals_post.h Прегледај датотеку

@@ -20,3 +20,8 @@
20 20
  *
21 21
  */
22 22
 #pragma once
23
+
24
+// If no real EEPROM, Flash emulation, or SRAM emulation is available fall back to SD emulation
25
+#if USE_FALLBACK_EEPROM
26
+  #define SDCARD_EEPROM_EMULATION
27
+#endif

+ 8
- 0
Marlin/src/HAL/STM32F1/inc/SanityCheck.h Прегледај датотеку

@@ -41,3 +41,11 @@
41 41
   #warning "With TMC2208/9 consider using SoftwareSerialM with HAVE_SW_SERIAL and appropriate SS_TIMER."
42 42
   #error "Missing SoftwareSerial implementation."
43 43
 #endif
44
+
45
+#if ENABLED(SDCARD_EEPROM_EMULATION) && DISABLED(SDSUPPORT)
46
+  #undef SDCARD_EEPROM_EMULATION // Avoid additional error noise
47
+  #if USE_FALLBACK_EEPROM
48
+    #warning "EEPROM type not specified. Fallback is SDCARD_EEPROM_EMULATION."
49
+  #endif
50
+  #error "SDCARD_EEPROM_EMULATION requires SDSUPPORT. Enable SDSUPPORT or choose another EEPROM emulation."
51
+#endif

+ 5
- 5
buildroot/share/tests/mks_robin_lite-tests Прегледај датотеку

@@ -6,12 +6,12 @@
6 6
 # exit on first failure
7 7
 set -e
8 8
 
9
-use_example_configs Mks/Robin
9
+restore_configs
10 10
 opt_set MOTHERBOARD BOARD_MKS_ROBIN_LITE
11
-opt_set EXTRUDERS 1
12
-opt_set TEMP_SENSOR_1 0
13
-opt_disable FSMC_GRAPHICAL_TFT
14
-exec_test $1 $2 "Default Configuration"
11
+opt_set SERIAL_PORT -1
12
+opt_enable EEPROM_SETTINGS
13
+opt_enable SDSUPPORT
14
+exec_test $1 $2 "Default Configuration with Fallback SD EEPROM"
15 15
 
16 16
 # cleanup
17 17
 restore_configs

Loading…
Откажи
Сачувај