#include "esp_misc.h" #include "esp_sta.h" #include "esp_system.h" #include "esp_wifi.h" #include "esp_spiffs.h" #include "sdkconfig.h" #include "rboot-api.h" #include extern "C" uint32_t user_rf_cal_sector_set(); extern "C" void user_init(); static void set_wifi_mode() { if (wifi_get_opmode_default() != NULL_MODE) { printf("Setting default station mode"); wifi_set_opmode(NULL_MODE); } wifi_set_opmode_current(NULL_MODE); } void main_task(void *ctx) { (void) ctx; int count = 0; while (1) { printf("Hello World! %d\n", count++); vTaskDelay(pdMS_TO_TICKS(1000)); } } #define THREAD_NAME "main" #define THREAD_STACK_WORDS 2048 #define THREAD_PRIO 8 TaskHandle_t main_task_handle; void user_init() { os_printf("SDK version: %s, free: %d, app build: %s\n", system_get_sdk_version(), system_get_free_heap_size(), __TIMESTAMP__); uint8_t current_rom = rboot_get_current_rom(); os_printf("rboot_get_current_rom=%d\n", rboot_get_current_rom()); rboot_config rboot_config = rboot_get_config(); os_printf("rboot config:\n"); os_printf(" count ROMs: %d\n", rboot_config.count); for (int i = 0; i < rboot_config.count; i++) { os_printf(" #%d: 0x%08x\n", i, rboot_config.roms[i]); } uint8_t next_rom; if (current_rom == 0) { next_rom = 1; } else { next_rom = 0; } os_printf("next_rom=%d\n", next_rom); rboot_set_current_rom(next_rom); set_wifi_mode(); assert(xTaskCreate(main_task, THREAD_NAME, THREAD_STACK_WORDS, NULL, THREAD_PRIO, &main_task_handle) == pdPASS); } /* extern "C" uint8_t default_config(rboot_config *romconf, uint32_t flashsize); uint8_t default_config(rboot_config *romconf, uint32_t flashsize) { romconf->count = 2; romconf->roms[0] = SECTOR_SIZE * (BOOT_CONFIG_SECTOR + 1); romconf->roms[1] = (flashsize / 2) + (SECTOR_SIZE * (BOOT_CONFIG_SECTOR + 1)); #ifdef BOOT_GPIO_ENABLED romconf->mode = MODE_GPIO_ROM; #endif #ifdef BOOT_GPIO_SKIP_ENABLED romconf->mode = MODE_GPIO_SKIP; #endif } */