After a wrong upgrade firmware of a TP-Link router, the only alternative was to write the flash memory directly.
The strategy I used was: Update only the u-boot sector, which is responsible for loading the kernel, and then updating using tftp [link].
It is possible to write all the firmware, however I preferred this method because it is faster. Writing the whole flash (ex: 8mb) can take about 10min.
I’ve developed a sketch for this purpose, and it can be downloaded from the link:
The entire wiring diagram and details is also on the link above.
Currently (04-2017), it is only compatible with Winbond memories, but can be adapted for other libraries
I used the Arduino DUE because it is 3.3v. If you are using another arduino, you need to create a voltage divider.
The u-boot has 128 kb, which corresponds to the “512 pages” of “256 bytes”. You should adjust the base file size to the multiples of 256. This can be configured directly on the serial console