I have an Arduino Mega 2560 and need to program a 512Kbyte parallel flash chip, a 29F400B, with a binary image that I will need to read from another identical chip.
The flash chip is a 5V part and operates either in 16 bit word or 1 byte mode controlled with a pin, to make it simpler I can use the byte mode so I would use fewer pins. 512Kbyte requires 19 bits of address space, so that adds up to 19+8 pins, plus output enable and write enable pins, bringing the total pin count I need to 29 (chip select I can just tie to ground). The double row header at the tail on the Mega has 32 GPIO pins, so I can just use those for convenience.
The speed/data rate are not a concern, it is fine if it is slow.
Is there any existing code for parallel chip programming? I will need to first read back the data, then write it to a blank chip, meaning I will need some way to capture it on my computer (presumably over serial over USB) and write it to disk, then send it when programming the blank. The computer runs Windows, but can run Linux if utility code runs on that.
Umm. I don't see that you need to read, store, write. Simply set 18 address bits for both the chips(wired in parallel), wire the data lines direct from A to B, and cycle the read, output enable, write pins directly.
Unless, that is, you also want to record the contents. That's different.
Yes, I would like to record the contents to a file so I could inspect it in a hex editor and compare with firmware update images to inspect for things like bit rot (the updates are not 512Kbyte chip images so I can't use them directly).
Your approach would be a feasible last resort, but I would not have any way to inspect the contents.
With a Mega, you have enough pins to simply capture the data as well. The real challenge will be to transmit it somewhere for storage while doing the copy. Can be done, for example using serial at as high a baud as possible; write yourself some form of checksumming algorithm to ensure the data is correct. That, however, will require some code at the PC end to capture the output, process the checksums, and save the data or request a re-read.
Quite doable, really, but I do wonder if it doesn't already exist, it's a pretty common concept. Others here will know.
A quick search for "MEGA2560 parallel flash programmer" brought up a few possibilities.
This one is a Parallel EEPROM Programmer for SST29EE020. It's not a FLASH chip but I would imagine that 99% of the code will be the same. Likely just the code that enables writing to the flash pages needs altering/implementing.
Then there's this one that the author says will program a flash chip.
If you could combine elements of both, then I think you may be able to achieve what you want.
If you sequentiality read your flash device, you could generate intel-hex records on the fly and output them to the serial port. A lot of PC serial terminal apps can log the data so you could use that approach to capture the records - they are in plain text format. You can then use a standard text editor to remove any preamble and postamble text from the start and end of the file.
If you wanted to view the data, then I think HxD can import intel-hex records.
That's also a great suggestion. Intel-hex seems like a good alternative to plain ASCII hex dumping, which I was thinking of trying to do (some or many hex editors such as Cygnus can import ASCII hex into binary). New thing learned.