From 3334163e7357dafe2c88e89bad84c342f814067f Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 2 Aug 2019 11:12:46 +0200 Subject: [PATCH] STM32F1: Align SD EEPROM data for SDIO (#14809) --- Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp b/Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp index 454dccfae..955ef2b1c 100644 --- a/Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp +++ b/Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp @@ -22,6 +22,7 @@ /** * HAL for stm32duino.com based on Libmaple and compatible (STM32F1) + * Implementation of EEPROM settings in SD Card */ #ifdef __STM32F1__ @@ -37,7 +38,8 @@ #endif #define HAL_STM32F1_EEPROM_SIZE (E2END + 1) -static char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE]; +#define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat. +static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE]; #if ENABLED(SDSUPPORT) @@ -52,7 +54,7 @@ static char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE]; if (!file.open(&root, EEPROM_FILENAME, O_RDONLY)) return false; - int16_t bytes_read = file.read(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE); + int bytes_read = file.read(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE); if (bytes_read < 0) return false; for (; bytes_read < HAL_STM32F1_EEPROM_SIZE; bytes_read++) HAL_STM32F1_eeprom_content[bytes_read] = 0xFF; @@ -64,7 +66,7 @@ static char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE]; if (!card.isDetected()) return false; SdFile file, root = card.getroot(); - int16_t bytes_written = 0; + int bytes_written = 0; if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) { bytes_written = file.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE); file.close();