Switch between 2 app images?

Simple question (probably complicated answer :-))

On an ESP32 based Arduino board, can I have 2 different applications in different partitions, and choose which to reboot into?

I know the OTA mechanisms do something similar to recover from a bad update by marking a partition bad, can I leverage this mechanism with 2 applications, each of which will have say a pushbutton that triggers a reboot into the other partition?

Searches so far turn up modifying the bootloader and other such things that are beyond my skill level at the moment. I'm hoping someone has done this using calls like esp_ota_set_boot_partition() then esp.restart().

It needs to be able to happen any time - this is not for OTA, this is for the user to choose app1 or app2 at any time....

https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/ota.html

Why not have a single sketch that switches between two modes of operation when a button is pressed ?

Sorry - pertinent info I should have included!

This may be my lack of knowledge, and trying to swat a fly with a hammer, but don't think I have the skills to switch the apps cleanly. Each app is a lighting control type thing, which I want to be controlling an LED WS28xx type strip. Each app does a set of things I want very well, but I would like to have my cake and eat it too.

HomeSpan is one of the apps - quite complex, but with the provided examples I can make it do what I want (shoulders of giants type thing).

I seriously doubt I have the skill to integrated the other WLED type app and HomeSpan together... my first thought was a relay that switches the data line of the LED strip between 2 ESP's which are both running.... this seems inelegant but hey it will work :slight_smile:

I saw some discussion on the forums about OTA and partitions and things, I have used OTA in very simple mode following the example, and it hit me that being able to boot one of two images at will would be a more elegant solution to my issue.

Use the ESP32’s dual-partition OTA setup. Flash two firmware images (one for WLED, one for HomeSpan) to separate partitions. Implement a bootloader that selects which partition to boot based on a condition (e.g., flag or button press). This allows you to switch between the two apps without hardware changes and ensures easy updates via OTA.

this is an other solution for your current issue:
You can use a single ESP32 with a software solution to switch between WLED and HomeSpan. Implement a simple web interface or MQTT control that toggles a flag in your firmware. Based on this flag, the ESP32 can either load WLED or HomeSpan functionality at startup. This avoids complex hardware setups and allows seamless software switching.
Regards,
Jasson