mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-27 16:54:15 +01:00
REVONANO - Fix erase settings
This commit is contained in:
parent
2497b3d605
commit
5ca6e43070
@ -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) {
|
if (PIOS_Flash_EEPROM_Validate(flash_dev) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Rewrite first block of bytes to invalidate the sector.
|
// Rewrite the whole page
|
||||||
const uint8_t buf[16] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
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));
|
return PIOS_Flash_EEPROM_Write(flash_dev, addr, buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,10 +194,13 @@ int32_t PIOS_FLASHFS_Format(uintptr_t fs_id)
|
|||||||
*/
|
*/
|
||||||
static int32_t PIOS_FLASHFS_ClearObjectTableHeader(struct flashfs_dev *dev)
|
static int32_t PIOS_FLASHFS_ClearObjectTableHeader(struct flashfs_dev *dev)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 16; i++) {
|
uint32_t addr = dev->cfg->obj_table_start;
|
||||||
if (dev->driver->erase_sector(dev->flash_id, 256 * i) != 0) {
|
|
||||||
|
while (addr < dev->cfg->obj_table_end) {
|
||||||
|
if (dev->driver->erase_sector(dev->flash_id, addr) != 0) {
|
||||||
return -1;
|
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) {
|
if (dev->driver->write_data(dev->flash_id, 0, (uint8_t *)&dev->cfg->table_magic, sizeof(dev->cfg->table_magic)) != 0) {
|
||||||
|
@ -352,8 +352,7 @@ void PIOS_Board_Init(void)
|
|||||||
if (PIOS_IAP_ReadBootCmd(0) == PIOS_IAP_CLEAR_FLASH_CMD_0 &&
|
if (PIOS_IAP_ReadBootCmd(0) == PIOS_IAP_CLEAR_FLASH_CMD_0 &&
|
||||||
PIOS_IAP_ReadBootCmd(1) == PIOS_IAP_CLEAR_FLASH_CMD_1 &&
|
PIOS_IAP_ReadBootCmd(1) == PIOS_IAP_CLEAR_FLASH_CMD_1 &&
|
||||||
PIOS_IAP_ReadBootCmd(2) == PIOS_IAP_CLEAR_FLASH_CMD_2) {
|
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(0, 0);
|
||||||
PIOS_IAP_WriteBootCmd(1, 0);
|
PIOS_IAP_WriteBootCmd(1, 0);
|
||||||
PIOS_IAP_WriteBootCmd(2, 0);
|
PIOS_IAP_WriteBootCmd(2, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user