Browse Source

STM32F1: Align SD EEPROM data for SDIO (#14809)

Tanguy Pruvot 6 years ago
parent
commit
3334163e73
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp

+ 5
- 3
Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp View File

22
 
22
 
23
 /**
23
 /**
24
  * HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
24
  * HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
25
+ * Implementation of EEPROM settings in SD Card
25
  */
26
  */
26
 
27
 
27
 #ifdef __STM32F1__
28
 #ifdef __STM32F1__
37
 #endif
38
 #endif
38
 #define HAL_STM32F1_EEPROM_SIZE (E2END + 1)
39
 #define HAL_STM32F1_EEPROM_SIZE (E2END + 1)
39
 
40
 
40
-static char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
41
+#define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat.
42
+static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
41
 
43
 
42
 #if ENABLED(SDSUPPORT)
44
 #if ENABLED(SDSUPPORT)
43
 
45
 
52
     if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
54
     if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
53
       return false;
55
       return false;
54
 
56
 
55
-    int16_t bytes_read = file.read(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
57
+    int bytes_read = file.read(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
56
     if (bytes_read < 0) return false;
58
     if (bytes_read < 0) return false;
57
     for (; bytes_read < HAL_STM32F1_EEPROM_SIZE; bytes_read++)
59
     for (; bytes_read < HAL_STM32F1_EEPROM_SIZE; bytes_read++)
58
       HAL_STM32F1_eeprom_content[bytes_read] = 0xFF;
60
       HAL_STM32F1_eeprom_content[bytes_read] = 0xFF;
64
     if (!card.isDetected()) return false;
66
     if (!card.isDetected()) return false;
65
 
67
 
66
     SdFile file, root = card.getroot();
68
     SdFile file, root = card.getroot();
67
-    int16_t bytes_written = 0;
69
+    int bytes_written = 0;
68
     if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
70
     if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
69
       bytes_written = file.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
71
       bytes_written = file.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
70
       file.close();
72
       file.close();

Loading…
Cancel
Save