initialize flash area for config
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
j3d1 2021-07-09 21:35:41 +02:00
parent 283bd6a5c1
commit 171a11eebf
3 changed files with 17 additions and 1 deletions

View file

@ -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();
}

View file

@ -20,4 +20,18 @@ void system_clear_config(){
spiflash_erase_sector(start + i * sdk_flashchip.sector_size);
}
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();
}
}

View file

@ -10,6 +10,7 @@ extern "C" {
#endif
void system_clear_config();
void system_init_config();
#ifdef __cplusplus
}