replace SPIWrite with flash_write

This commit is contained in:
funshine 2015-01-05 23:57:07 +08:00
parent 824655e2d3
commit 7e51c5d67e
3 changed files with 10 additions and 7 deletions

View File

@ -3,7 +3,7 @@ set BACKPATH=%PATH%
set PATH=%BACKPATH%;%CD%\..\tools
@echo on
make
make %1
del /F ..\bin\eagle.app.v6.flash.bin ..\bin\eagle.app.v6.irom0text.bin ..\bin\eagle.app.v6.dump ..\bin\eagle.app.v6.S

View File

@ -6,6 +6,7 @@
#include "user_config.h"
#include "flash_api.h"
#include "spi_flash.h"
#include "c_stdio.h"
static volatile const uint8_t flash_init_data[128] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR =
{
@ -74,7 +75,7 @@ bool flash_set_size(uint8_t size)
SPIFlashInfo *p_spi_flash_info = (SPIFlashInfo *)(data);
p_spi_flash_info->size = size;
SPIEraseSector(0);
SPIWrite(data, 0, sizeof(data));
spi_flash_write(0, (uint32 *)data, sizeof(data));
//p_spi_flash_info = flash_get_info();
//p_spi_flash_info->size = size;
return true;
@ -193,7 +194,7 @@ bool flash_init_data_default(void)
// It will init system data to default!
SPIEraseSector((flash_get_sec_num() - 4));
SPIWrite((flash_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32_t *)flash_init_data, 128);
spi_flash_write((flash_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)flash_init_data, 128);
return true;
}

View File

@ -82,6 +82,12 @@ void user_init(void)
NODE_DBG("Can not init platform for modules.\n");
return;
}
if(!flash_init_data_written()){
NODE_ERR("Restore init data.\n");
flash_init_data_default();
}
#if defined( BUILD_WOFS )
romfs_init();
@ -96,10 +102,6 @@ void user_init(void)
// test_romfs();
#elif defined ( BUILD_SPIFFS )
spiffs_mount();
if(!flash_init_data_written()){
NODE_ERR("Restore init data.\n");
flash_init_data_default();
}
// test_spiffs();
#endif
// endpoint_setup();