I accidentally uploaded the WR21 firmware to a WR31. Is there any way to recover the modem?
Yes, there are multiple ways to recover the WR31 depending on how broken it is.
If you have not corrupted the bootloader then a simple flashwrite will work to fix it.
If you have killed the bootloader it is a much trickier process but can be recovered too.