Is there a way to wipe Retained variables to the uninitialized state without performing a hard power cycle and removing/disconnecting the RTC battery?
On OTA firmware updates sometimes the retained variables need to change that causes the order to change from the previous, this can cause retained variables to be wrong for the declared variable.
No, but the workaround that I like is to put the retained data in a struct. At the beginning of the struct, put some magic bytes. I usually use a uint32_t (4 bytes).
If something else moves the struct in retained memory, the magic bytes will not be set and you can reinitialize. Same for cold boot.
If you change the struct (add or remove elements), you change the magic bytes to force reinitialization.
“Magic byte” or “magic number” is just a term for some constant number you choose and check whether the data you read matches your expected/chosen value.