bool flash_init_data_default(void) { // FLASH SEC - 4 // Dangerous, here are dinosaur infested!!!!! // Reboot required!!! // It will init system data to default! bool result = false; #if defined(FLASH_SAFE_API) if (SPI_FLASH_RESULT_OK == flash_safe_erase_sector((flash_safe_get_sec_num() - 4))) { if (SPI_FLASH_RESULT_OK == flash_safe_write((flash_safe_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)flash_init_data, 128)) { result = true; } } #else if (SPI_FLASH_RESULT_OK == spi_flash_erase_sector((flash_rom_get_sec_num() - 4))) { if (SPI_FLASH_RESULT_OK == spi_flash_write((flash_rom_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)flash_init_data, 128)) { result = true; } } #endif // defined(FLASH_SAFE_API) return result; }
bool flash_init_data_default(void) { /* Can't copy directly from flash (which is where the default data lives) * due to it being unmapped during the write, so bounce via ram buffer. */ uint8_t init_data[128]; os_memcpy (init_data, flash_init_data, 128); // FLASH SEC - 4 // Dangerous, here are dinosaur infested!!!!! // Reboot required!!! // It will init system data to default! bool result = false; #if defined(FLASH_SAFE_API) if (SPI_FLASH_RESULT_OK == flash_safe_erase_sector((flash_safe_get_sec_num() - 4))) { if (SPI_FLASH_RESULT_OK == flash_safe_write((flash_safe_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)init_data, 128)) { result = true; } } #else if (SPI_FLASH_RESULT_OK == spi_flash_erase_sector((flash_rom_get_sec_num() - 4))) { if (SPI_FLASH_RESULT_OK == spi_flash_write((flash_rom_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)init_data, 128)) { result = true; } } #endif // defined(FLASH_SAFE_API) return result; }
bool flash_init_data_blank(void) { // FLASH SEC - 2 // Dangerous, here are dinosaur infested!!!!! // Reboot required!!! // It will init system config to blank! bool result = false; #if defined(FLASH_SAFE_API) if ((SPI_FLASH_RESULT_OK == flash_safe_erase_sector((flash_safe_get_sec_num() - 2))) && (SPI_FLASH_RESULT_OK == flash_safe_erase_sector((flash_safe_get_sec_num() - 1)))) #else if ((SPI_FLASH_RESULT_OK == spi_flash_erase_sector((flash_rom_get_sec_num() - 2))) && (SPI_FLASH_RESULT_OK == spi_flash_erase_sector((flash_rom_get_sec_num() - 1)))) #endif // defined(FLASH_SAFE_API) { result = true; } return result ; }
bool flash_init_data_written(void) { // FLASH SEC - 4 uint32_t data[2] ICACHE_STORE_ATTR; #if defined(FLASH_SAFE_API) if (SPI_FLASH_RESULT_OK == flash_safe_read((flash_safe_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)data, sizeof(data))) #else if (SPI_FLASH_RESULT_OK == spi_flash_read((flash_rom_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)data, sizeof(data))) #endif // defined(FLASH_SAFE_API) { if (data[0] == 0xFFFFFFFF && data[1] == 0xFFFFFFFF) { return false; } } return true; }