Here’s a blog post that someone wrote after bricking (really, really messing up) their TP-Link WR740N router. They used an Arduino to communicate over serial pins to the router and then pushed a new firmware to it, thus saving the router.
I can’t imagine that doing this with a Raspberry Pi using the same principal would be that much of a leap. In fact, it’s likely to be a lot easier as you’ll be based inside Linux on the Pi and communicating directly with the router rather than introducing a middle-man in the form of an Arduino.