forked from j3d1/fiatlux
initialize flash area for config
This commit is contained in:
parent
283bd6a5c1
commit
171a11eebf
3 changed files with 17 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include <esp/uart.h>
|
#include <esp/uart.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "system.h"
|
||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
#include "web.h"
|
#include "web.h"
|
||||||
#include "mqtt.h"
|
#include "mqtt.h"
|
||||||
|
@ -15,5 +16,5 @@ void user_init(void)
|
||||||
|
|
||||||
sdk_wifi_set_sleep_type(WIFI_SLEEP_MODEM);
|
sdk_wifi_set_sleep_type(WIFI_SLEEP_MODEM);
|
||||||
|
|
||||||
while(1);
|
system_init_config();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,18 @@ void system_clear_config(){
|
||||||
spiflash_erase_sector(start + i * sdk_flashchip.sector_size);
|
spiflash_erase_sector(start + i * sdk_flashchip.sector_size);
|
||||||
}
|
}
|
||||||
sdk_system_restart();
|
sdk_system_restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
void system_init_config(){
|
||||||
|
uint32_t base_addr;
|
||||||
|
uint32_t num_sectors;
|
||||||
|
if(sysparam_get_info(&base_addr, &num_sectors) != SYSPARAM_OK) {
|
||||||
|
printf("Warning: WiFi config, sysparam not initialized\n");
|
||||||
|
num_sectors = DEFAULT_SYSPARAM_SECTORS;
|
||||||
|
base_addr = sdk_flashchip.chip_size - (5 + num_sectors) * sdk_flashchip.sector_size;
|
||||||
|
if(sysparam_create_area(base_addr, num_sectors, true) == SYSPARAM_OK) {
|
||||||
|
sysparam_init(base_addr, 0);
|
||||||
|
}
|
||||||
|
sdk_system_restart();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void system_clear_config();
|
void system_clear_config();
|
||||||
|
void system_init_config();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue