diff options
Diffstat (limited to 'ota-test/main')
-rw-r--r-- | ota-test/main/Makefile.projbuild | 13 | ||||
-rw-r--r-- | ota-test/main/component.mk | 7 | ||||
-rw-r--r-- | ota-test/main/include/rboot-integration.h | 2 | ||||
-rw-r--r-- | ota-test/main/main.cpp | 43 |
4 files changed, 60 insertions, 5 deletions
diff --git a/ota-test/main/Makefile.projbuild b/ota-test/main/Makefile.projbuild new file mode 100644 index 0000000..634dc6b --- /dev/null +++ b/ota-test/main/Makefile.projbuild @@ -0,0 +1,13 @@ +RBOOT_OPTS += RBOOT_EXTRA_INCDIR=$(PWD)/main/include +RBOOT_OPTS += RBOOT_INTEGRATION=1 + +$(BUILD_DIR_BASE)/rboot.bin: + @echo ------------------------------------------------------- + @echo BUILDING RBOOT + cd ../thirdparty/rboot && \ + env -i PATH=$(PATH) V=$(V) \ + make $(RBOOT_OPTS) && \ + cp firmware/rboot.bin $(BUILD_DIR_BASE)/rboot.bin + @echo ------------------------------------------------------- + +$(APP_BIN): $(BUILD_DIR_BASE)/rboot.bin diff --git a/ota-test/main/component.mk b/ota-test/main/component.mk index a98f634..367eb27 100644 --- a/ota-test/main/component.mk +++ b/ota-test/main/component.mk @@ -2,3 +2,10 @@ # "main" pseudo-component makefile. # # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) + +CFLAGS += -DRBOOT_INTEGRATION +COMPONENT_ADD_INCLUDEDIRS += \ + ../../thirdparty/rboot/appcode \ + ../../thirdparty/rboot +COMPONENT_SRCDIRS += \ + ../../thirdparty/rboot/appcode diff --git a/ota-test/main/include/rboot-integration.h b/ota-test/main/include/rboot-integration.h new file mode 100644 index 0000000..a04741b --- /dev/null +++ b/ota-test/main/include/rboot-integration.h @@ -0,0 +1,2 @@ +#define BOOT_DELAY_MICROS 500000 +// #define BOOT_CUSTOM_DEFAULT_CONFIG diff --git a/ota-test/main/main.cpp b/ota-test/main/main.cpp index a64f03f..08b2c2e 100644 --- a/ota-test/main/main.cpp +++ b/ota-test/main/main.cpp @@ -4,6 +4,7 @@ #include "esp_wifi.h" #include "esp_spiffs.h" #include "sdkconfig.h" +#include "rboot-api.h" #include <assert.h> @@ -13,11 +14,6 @@ uint32_t user_rf_cal_sector_set(); extern "C" void user_init(); -enum events { - EVENTS_GOT_IP = (1 << 0), - EVENTS_LOST_IP = (1 << 1), -}; - static void set_wifi_mode() { if (wifi_get_opmode_default() != NULL_MODE) { printf("Setting default station mode"); @@ -46,7 +42,44 @@ 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 +} +*/ |