I would now like to upgrade to the latest version, preferably by installing OpenWRT also to partition 1, which currently holds the stock firmware.
Unfortunately, when I try to flash from OpenWRT, the process starts but never completes. After waiting for 20minutes I power the device off and on, after which it boots back to the old OpenWRT partition and partition 1 still has the stock firmware.
Which image version (factory or sysupgrade) should I be using when I flash from OpenWRT but the target partition has stock fw? I have tried with both, but result is the same.
How was your original plan to install it on partition 1?
Every time you install a system update the current working partition is moved to the other partition. So if you make a system upgrade in this case in your working openwrt partition 2, the old openwrt partition 2 becomes partition 1. And the upgraded openwrt becomes partition 2.
If you want to keep OEM you need to switch to the oem partition and install a OpenWrt factory image there. And oem goes to the other partition 2 and openwrt on partition 1.
This switching is handled automatically in hardware.
The "current" partition stays as it is. Nothing is copied/flashed to it.
New firmware is flashed to the other "Alternative" partition (overwriting the other firmware there) and settings from the current OpenWrt firmware are attached to that.
U-boot env flags are modifed so that the booting switches to the new firmware.
Partition numbering remains constant, just the booting selection varies.
That strategy holds true to both OpenWrt and OEM firmwares.
There are every now and then some similar trouble with mvebu dual firmware devices. As there are two bootflags that need to be set in sync, it is possible that sometimes you may end up with them mixed.
See e.g. discussion in