Run another app once (without switching to it for the default)

Shanee
Posts: 7
Joined: Tue May 24, 2016 8:06 am

Run another app once (without switching to it for the default)

Postby Shanee » Wed Sep 13, 2017 5:28 pm

Hello. I have 2 partitions, ota_0 and ota_1.

I would like to always boot to ota_0.

However, I would then like to run ota_1.

Is it possible to run ota_1 without making this the default?

If I use esp_ota_set_boot_partition(ota_1) I can run ota_1. However, if there is a reset while ota_1 is running, it will restart ota_1. I want to always run ota_0 after a reset.

Additionally, I do not want to rely on code in ota_1 to run esp_ota_set_boot_partition(ota_0).

Is it possible to run another app once only?

Shanee
Posts: 7
Joined: Tue May 24, 2016 8:06 am

Re: Run another app once (without switching to it for the default)

Postby Shanee » Tue Sep 26, 2017 8:52 am

In case anyone else wants this, here's my solution:

I've included the bootloader component and in bootloader_main() I've added this modification just before the call to load_boot_image().

if (boot_index == 1) {
ESP_LOGI(TAG, "Now booting into ota_1. But we are setting the partition to boot into ota_0 again next time.");
//Boot OTA1 this time. But do 0 next time.
//To make it boot 0 next time we set the otadata partition to FF, which means boot the factory app (which instead starts ota0)
esp_rom_spiflash_erase_area(bs.ota_info.offset, SPI_SEC_SIZE*2);
}

Then if you set the ESP32 to boot ota_1 and then restart, it will boot ota_1 once only, before switching back to booting the factory app again.

I'm not super happy with this, as it's going to "use up" two writes to the flash every boot. This is quite a lot of wear, but it's the best I could come up with.

If anyone has a better solution, I'd love to hear about it.


Who is online

Users browsing this forum: No registered users and 149 guests