1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

REVONANO - Fix erase settings

This commit is contained in:
Alessio Morale 2015-04-10 15:11:48 +02:00
parent 2497b3d605
commit 5ca6e43070
3 changed files with 11 additions and 6 deletions

View File

@ -389,8 +389,11 @@ static int32_t PIOS_Flash_EEPROM_EraseSector(uintptr_t flash_id, uint32_t addr)
if (PIOS_Flash_EEPROM_Validate(flash_dev) != 0) {
return -1;
}
// Rewrite first block of bytes to invalidate the sector.
const uint8_t buf[16] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
// Rewrite the whole page
const uint8_t buf[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
return PIOS_Flash_EEPROM_Write(flash_dev, addr, buf, sizeof(buf));
}

View File

@ -194,10 +194,13 @@ int32_t PIOS_FLASHFS_Format(uintptr_t fs_id)
*/
static int32_t PIOS_FLASHFS_ClearObjectTableHeader(struct flashfs_dev *dev)
{
for (int i = 0; i < 16; i++) {
if (dev->driver->erase_sector(dev->flash_id, 256 * i) != 0) {
uint32_t addr = dev->cfg->obj_table_start;
while (addr < dev->cfg->obj_table_end) {
if (dev->driver->erase_sector(dev->flash_id, addr) != 0) {
return -1;
}
addr += dev->cfg->sector_size;
}
if (dev->driver->write_data(dev->flash_id, 0, (uint8_t *)&dev->cfg->table_magic, sizeof(dev->cfg->table_magic)) != 0) {

View File

@ -352,8 +352,7 @@ void PIOS_Board_Init(void)
if (PIOS_IAP_ReadBootCmd(0) == PIOS_IAP_CLEAR_FLASH_CMD_0 &&
PIOS_IAP_ReadBootCmd(1) == PIOS_IAP_CLEAR_FLASH_CMD_1 &&
PIOS_IAP_ReadBootCmd(2) == PIOS_IAP_CLEAR_FLASH_CMD_2) {
// todo: EEprom ERASE
// PIOS_FLASHFS_Format(pios_uavo_settings_fs_id);
PIOS_FLASHFS_Format(pios_uavo_settings_fs_id);
PIOS_IAP_WriteBootCmd(0, 0);
PIOS_IAP_WriteBootCmd(1, 0);
PIOS_IAP_WriteBootCmd(2, 0);