initialize flash area for config
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
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 <stdio.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "wifi.h"
|
||||
#include "web.h"
|
||||
#include "mqtt.h"
|
||||
|
@ -15,5 +16,5 @@ void user_init(void)
|
|||
|
||||
sdk_wifi_set_sleep_type(WIFI_SLEEP_MODEM);
|
||||
|
||||
while(1);
|
||||
system_init_config();
|
||||
}
|
||||
|
|
|
@ -21,3 +21,17 @@ void system_clear_config(){
|
|||
}
|
||||
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
|
||||
|
||||
void system_clear_config();
|
||||
void system_init_config();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue