|
@@ -8,28 +8,6 @@
|
|
|
#include "spi_flash.h"
|
|
|
#include "c_stdio.h"
|
|
|
|
|
|
-#if defined(ESP_INIT_DATA_ENABLE_READVDD33)
|
|
|
-# define INIT_107 0xff
|
|
|
-#elif defined(ESP_INIT_DATA_ENABLE_READADC)
|
|
|
-# define INIT_107 0x00
|
|
|
-#elif defined(ESP_INIT_DATA_FIXED_VDD33_VALUE)
|
|
|
-# define INIT_107 ESP_INIT_DATA_FIXED_VDD33_VALUE
|
|
|
-#else
|
|
|
-# define INIT_107 0xff
|
|
|
-#endif
|
|
|
-
|
|
|
-static const uint8_t flash_init_data[128] =
|
|
|
-{
|
|
|
- 0x05, 0x00, 0x04, 0x02, 0x05, 0x05, 0x05, 0x02, 0x05, 0x00, 0x04, 0x05, 0x05, 0x04, 0x05, 0x05,
|
|
|
- 0x04, 0xFE, 0xFD, 0xFF, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE1, 0x0A, 0xFF, 0xFF, 0xF8, 0x00,
|
|
|
- 0xF8, 0xF8, 0x52, 0x4E, 0x4A, 0x44, 0x40, 0x38, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05,
|
|
|
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
- 0xE1, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x93, 0x43, 0x00, 0x00, 0x00,
|
|
|
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, INIT_107, 0x00, 0x00, 0x00, 0x00,
|
|
|
- 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
-};
|
|
|
-
|
|
|
uint32_t flash_detect_size_byte(void)
|
|
|
{
|
|
|
#define FLASH_BUFFER_SIZE_DETECT 32
|
|
@@ -323,59 +301,6 @@ bool flash_rom_set_speed(uint32_t speed)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-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 ;
|
|
|
-}
|
|
|
-
|
|
|
uint8_t byte_of_aligned_array(const uint8_t *aligned_array, uint32_t index)
|
|
|
{
|
|
|
if ( (((uint32_t)aligned_array) % 4) != 0 )
|