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
 #define EEPROM_ERASE (0xff)
57
 #define EEPROM_ERASE (0xff)
58
 #define SLOT_ADDRESS(sector, slot) (((uint8_t *)SECTOR_START(sector)) + slot * EEPROM_SIZE)
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
 static bool eeprom_dirty = false;
61
 static bool eeprom_dirty = false;
62
 static int current_slot = 0;
62
 static int current_slot = 0;
63
 
63
 
92
     if (--current_slot < 0) {
92
     if (--current_slot < 0) {
93
       // all slots have been used, erase everything and start again
93
       // all slots have been used, erase everything and start again
94
       __disable_irq();
94
       __disable_irq();
95
-      PrepareSector(EEPROM_SECTOR, EEPROM_SECTOR);
96
       status = EraseSector(EEPROM_SECTOR, EEPROM_SECTOR);
95
       status = EraseSector(EEPROM_SECTOR, EEPROM_SECTOR);
97
       __enable_irq();
96
       __enable_irq();
98
 
97
 
100
     }
99
     }
101
 
100
 
102
     __disable_irq();
101
     __disable_irq();
103
-    PrepareSector(EEPROM_SECTOR, EEPROM_SECTOR);
104
     status = CopyRAM2Flash(SLOT_ADDRESS(EEPROM_SECTOR, current_slot), ram_eeprom, IAP_WRITE_4096);
102
     status = CopyRAM2Flash(SLOT_ADDRESS(EEPROM_SECTOR, current_slot), ram_eeprom, IAP_WRITE_4096);
105
     __enable_irq();
103
     __enable_irq();
106
 
104
 

Loading…
Cancel
Save