diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2018-06-05 10:10:34 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2018-06-05 10:10:34 +0200 |
commit | beca53b79fd595da46da779a20464c333d63e3a0 (patch) | |
tree | 5ca2567d571711773f2036221259eff30db85e3e /ota-test | |
parent | fadeb06d74c3d739dc1202031e1eea1374e8917e (diff) | |
download | modern-esp-sandbox-beca53b79fd595da46da779a20464c333d63e3a0.tar.gz modern-esp-sandbox-beca53b79fd595da46da779a20464c333d63e3a0.tar.bz2 modern-esp-sandbox-beca53b79fd595da46da779a20464c333d63e3a0.tar.xz modern-esp-sandbox-beca53b79fd595da46da779a20464c333d63e3a0.zip |
wip
Diffstat (limited to 'ota-test')
-rw-r--r-- | ota-test/Makefile | 10 | ||||
-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 | ||||
-rw-r--r-- | ota-test/sdkconfig | 8 | ||||
-rw-r--r-- | ota-test/sdkconfig2 | 2 |
7 files changed, 76 insertions, 9 deletions
diff --git a/ota-test/Makefile b/ota-test/Makefile index 19bd536..489289e 100644 --- a/ota-test/Makefile +++ b/ota-test/Makefile @@ -7,4 +7,14 @@ PROJECT_NAME := ota_test IDF_PATH=../thirdparty/ESP8266_RTOS_SDK +ifeq ($(APP),2) +SDKCONFIG1 = $(PWD)/sdkconfig +SDKCONFIG2 = $(BUILD_DIR_BASE)/sdkconfig-app2 +SDKCONFIG = $(SDKCONFIG2) +endif + include $(IDF_PATH)/make/project.mk + +$(SDKCONFIG2): $(SDKCONFIG1) sdkconfig2 + echo "Generating sdkconfig for app 2" + cat $(SDKCONFIG1) sdkconfig2 > $@ 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 +} +*/ diff --git a/ota-test/sdkconfig b/ota-test/sdkconfig index 12f4b7d..b0ed00c 100644 --- a/ota-test/sdkconfig +++ b/ota-test/sdkconfig @@ -17,14 +17,14 @@ CONFIG_ESPTOOLPY_PORT="/dev/ttyUSB0" CONFIG_ESPTOOLPY_BAUD_57600B= CONFIG_ESPTOOLPY_BAUD_115200B= CONFIG_ESPTOOLPY_BAUD_230400B= -CONFIG_ESPTOOLPY_BAUD_256000B= -CONFIG_ESPTOOLPY_BAUD_460800B=y +CONFIG_ESPTOOLPY_BAUD_256000B=y +CONFIG_ESPTOOLPY_BAUD_460800B= CONFIG_ESPTOOLPY_BAUD_512000B= CONFIG_ESPTOOLPY_BAUD_921600B= CONFIG_ESPTOOLPY_BAUD_2MB= CONFIG_ESPTOOLPY_BAUD_OTHER= CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 -CONFIG_ESPTOOLPY_BAUD=460800 +CONFIG_ESPTOOLPY_BAUD=256000 CONFIG_ESPTOOLPY_COMPRESSED=y CONFIG_FLASHMODE_QIO=y CONFIG_FLASHMODE_QOUT= @@ -85,7 +85,7 @@ CONFIG_ESP8266_APP_SIZE=0xFEFF0 CONFIG_ESP8266_APP_FLASH_ADDRESS=0x2000 CONFIG_ESP8266_BOOTLOADER_ESPRESSIF= CONFIG_ESP8266_BOOTLOADER_CUSTOM=y -CONFIG_ESP8266_BOOTLOADER_CUSTOM_VAL="../thirdparty/rboot/firmware/rboot.bin" +CONFIG_ESP8266_BOOTLOADER_CUSTOM_VAL="build/rboot.bin" CONFIG_ESP8266_BOOTLOADER="CUSTOM" # diff --git a/ota-test/sdkconfig2 b/ota-test/sdkconfig2 new file mode 100644 index 0000000..a05a754 --- /dev/null +++ b/ota-test/sdkconfig2 @@ -0,0 +1,2 @@ +CONFIG_ESP8266_APP_START_ADDRESS=0x40282010 +CONFIG_ESP8266_APP_FLASH_ADDRESS=0x82000 |