EEPROM Restore added in Bootloader

This commit is contained in:
bsongis
2014-04-09 11:51:38 +02:00
parent ab7218e5cf
commit 5dab6ef38f
5 changed files with 102 additions and 74 deletions
+2 -2
View File
@@ -145,8 +145,8 @@ void delay_01us(uint16_t nb);
#define FLASH_PAGESIZE 256
void unlockFlash();
void writeFlash(uint32_t * address, uint32_t * buffer);
uint32_t isFirmwareStart(uint32_t *block);
uint32_t isBootloaderStart(uint32_t *block);
uint32_t isFirmwareStart(const uint32_t *block);
uint32_t isBootloaderStart(const uint32_t *block);
// Pulses driver
void init_no_pulses(uint32_t port);
+2 -2
View File
@@ -98,7 +98,7 @@ void writeFlash(uint32_t *address, uint32_t *buffer) // page size is 256 bytes
}
}
uint32_t isFirmwareStart(uint32_t *block)
uint32_t isFirmwareStart(const uint32_t *block)
{
if ((block[0] & 0xFFFC0000) != 0x20000000) {
return 0;
@@ -112,7 +112,7 @@ uint32_t isFirmwareStart(uint32_t *block)
return 1;
}
uint32_t isBootloaderStart(uint32_t *block)
uint32_t isBootloaderStart(const uint32_t *block)
{
for (int i=0; i<256; i++) {
if (block[i] == 0x544F4F42/*BOOT*/) {
@@ -724,8 +724,7 @@ int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint32_t count )
}
else if (sector < 3 + (EESIZE/BLOCKSIZE)) {
while (count) {
const EeFs * test = (const EeFs *)buffer;
if (offset == 0 && test->version==EEFS_VERS && test->mySize==sizeof(eeFs) && test->bs==BS) {
if (offset == 0 && isEepromStart(buffer)) {
TRACE("EEPROM start found in sector %d", sector);
offset = sector;
}