I had a dead motherboard that had been kicking around for a while after a failed BIOS update. The flash part on there was the Winbond W39V040B, which is 3.3V only and has an LPC interface. The device programmer I have access to wouldn’t touch it, so I put together some simple AVR code to handle the protocol and connected the device up to my STK500. Although reading the device posed no problems, it quickly became apparent that the flash chip was not responding properly to write transactions. This meant there was no way to erase or program it, and is presumably why the BIOS flash failed in the first place.
Searching through the junk box I managed to find a dual-mode LPC/FWH device of the same size (PMC Pm49FL004). This one was responding properly to write commands, but I needed a way of reliably transferring the new BIOS image down to the AVR. The flashrom project already has support for an external AVR-based programmer (called serprog) but this is for devices using a parallel interface only. However, it was a fairly simple task to take the serprog protocol support from the existing flashrom programmer and graft it onto the LPC interface code I had already written. The resulting AVR code can be downloaded here and was tested with both the Ubuntu 10.04 version of flashrom, and with the latest development build from SVN. A Makefile is included for building the project on Linux using the GNU AVR tools.
The hardware side was based around an ATMEGA88, although it could be ported to pretty much any ATMEGA device with minimal effort. Connections to the LPC bus are defined in board.h, and these can be connected directly to the flash chip, although care should be taken to ensure that the supply voltage is restricted to 3.3V. If using the STK500 then this has a programmable target supply which can be changed using AVR Studio, or with avrdude in terminal mode. As well as the various power connections that the flash device will require (refer to its datasheet) it was also necessary to tie /WP,/TBL and /INIT high for correct operation. Other pins can be left unconnected. For best results the AVR clock needs to be faster than the 3.6864 MHz that the STK500 can provide by itself, but it does need to be of a suitable frequency for baud-rate generation; I used a 7.3728 MHz crystal. The actual frequency used needs to be specified in the Makefile.
Many thanks to carldani and others on #flashrom for their help in putting this hack together!
Updated: The source code archive was missing a couple of files, which are now included.