Browse Source

Fix problems with LPC1768 EEPROM flash emulation (#12503)

* Remove duplicate calls to PrepareSector

Some flash memory API calls require that a call to `PrepareSector` is done before use. However this call is already made by the LPC1768 framework so the calls in this code are not required.

* Ensure correct alignment of RAM buffer

The LPC176X flash API requires that the RAM buffer used for write operations must be word-aligned. This change ensures that this is the case.
Andy Shaw 6 years ago
parent
commit
4975b13b74
1 changed files with 1 additions and 3 deletions
  1. 1
    3
      Marlin/src/HAL/HAL_LPC1768/persistent_store_flash.cpp

+ 1
- 3
Marlin/src/HAL/HAL_LPC1768/persistent_store_flash.cpp View File

@@ -57,7 +57,7 @@ extern "C" {
57 57
 #define EEPROM_ERASE (0xff)
58 58
 #define SLOT_ADDRESS(sector, slot) (((uint8_t *)SECTOR_START(sector)) + slot * EEPROM_SIZE)
59 59
 
60
-static uint8_t ram_eeprom[EEPROM_SIZE];
60
+static uint8_t ram_eeprom[EEPROM_SIZE] __attribute__((aligned(4))) = {0};
61 61
 static bool eeprom_dirty = false;
62 62
 static int current_slot = 0;
63 63
 
@@ -92,7 +92,6 @@ bool PersistentStore::access_finish() {
92 92
     if (--current_slot < 0) {
93 93
       // all slots have been used, erase everything and start again
94 94
       __disable_irq();
95
-      PrepareSector(EEPROM_SECTOR, EEPROM_SECTOR);
96 95
       status = EraseSector(EEPROM_SECTOR, EEPROM_SECTOR);
97 96
       __enable_irq();
98 97
 
@@ -100,7 +99,6 @@ bool PersistentStore::access_finish() {
100 99
     }
101 100
 
102 101
     __disable_irq();
103
-    PrepareSector(EEPROM_SECTOR, EEPROM_SECTOR);
104 102
     status = CopyRAM2Flash(SLOT_ADDRESS(EEPROM_SECTOR, current_slot), ram_eeprom, IAP_WRITE_4096);
105 103
     __enable_irq();
106 104
 

Loading…
Cancel
Save