I am a newbie in the world of router customized firmware, so please excuse my question.
I have been given an old TP Link TL-WR710N router from my friend with DD-WRT installed. I have seen that this router supports OpenWRT too. I tried to "upgrade the firmware through the admin console to install OpenWRT, but the router, upon rebooting, still shows up DD-WRT.
mtd -f write openwrt-your-router-factory.bin linux
I have compared those two images using hexdump, and I think probably either of them should work if flashed directly to firmware partition. sysupgrade one is probably preferable, because it doesn't have 4325372 unused 0xff bytes at the end.
In general, OpenWrt sysupgrade image is flashed directly to partition by sysupgrade script, while factory image is flashed via vendor web interface and can contain different/additional headers.
But the original poster does not have openwrt installed yet, hence no sysupgrade script
My point is that script is not necessary. It does verification and backs config up, but mainly it does is writing directly to mtd which can be done by mtd write without sysupgrade, from factory or dd-wrt. For this router both images work, but for other routers attempt to write factory directly to flash will brick the device, while writing openwrt-sysupgrade to correct flash offset/partition should work for majority of devices.
Just thought I'd report back my own experience with trying to move from DD WRT to OpenWrt on my TP-Link Archer C7 AC1750 v5.
I tried using the DD WRT firmware upgrade to install openwrt-21.02.1-ath79-generic-tplink_archer-c7-v5-squashfs-factory.bin. After reboot, back to DD-WRT without any effect.
Next did an scp to /tmp of the above OpenWRT binary. Copy was good - exactly the same byte count.
Finally did a "mtd -f write <openwrt-your-router-factory.bin> linux" as suggested above. Here's the result:
root@DD-WRT:/tmp# mtd -f write openwrt-21.02.1-ath79-generic-tplink_archer-c7-v5-squashfs-factory.bin linux
Unlocking linux ...
[flash] : Could not unlock MTD device: linux
linux: No such file or directory
Writing from openwrt-21.02.1-ath79-generic-tplink_archer-c7-v5-squashfs-factory.bin to linux ... [w]
Warning unaligned data, we use manual padding to avoid errors. size was 24939!!!
Sensing a reboot would brick the router I reflashed, using the DD-WRT GUI, firmware DD-WRT v3.0-r47942 std (12/30/21) and thankfully everything came up.
Any explanation of what went wrong with the "mtd -f write" approach?
Is reverting back to the OEM factory firmware the only way to get to OpenWrt?
This is the recommended approach. The OpenWrt factory images / methods are designed to work from the OEM factory state (or from a TFTP or similar 'recovery' mechanism). When the device is running an alternative firmware, the firmware flashing functions may not understand what to do with an OpenWrt image, and it is possible that things will be written to the wrong places in memory. Flashing directly from DD-WRT to OpenWrt has never been recommended. Always revert to the factory firmware and then flash to OpenWrt from there.
Be careful factory images usually consist of the mtd image with some headers containing magic numbers or checksums. Those are required by the stock updater to prevent flashing an image incompatible to your device. But those headers will get stripped before being written on the flash.
Depending on the type of router there is no image that can directly been written by mtd, see here for a rather interesting thread regarding a Linksys: