Ok, so I had this motherboard with a corrupted bios on it, it wouldn't boot anymore, wouldn't even post.
So I removed the bios chip from it (luckily, it wasn't soldered, the mobo uses a dip-8 socket).
The chip is a Winbond W25Q16BV.
I put the chip on a breadboard, wire everything as it should be with my UNO and start playing with some SPI code.
Eventually, I came up with a working sketch that would let me read the whole chip.
Comparing the dump with the actual ROM file, it appeared that the first 96bytes of the chip were all messed up.
Sweet, now on to the write code.
I write everything, test test test, I was able to write a few bytes at the specified address without any issues.
So far so good, reading is working, erasing is working and writing is working. Did a last test writing 2 full pages of 256bytes, still working fine.
NOTE: On this chip, in order to be able to write, the memory location should be previously erased, using the sector erase instruction (0x20), which I did. The thing is, this instruction actually erases a full 4K sector. Oh well, no big deal, I can just re-write the full 4k part of the ROM.
I was now ready to write the missing 4k bytes to the rom - wrote my sketch and triggered everything...
I had some debugging code printing progress on the serial monitor, I was up to page 12 of 16 (I was writing in pages of 256bytes) when I suddenly bumped the Arduino board by accident. Then I noticed my power 3.3v wire was almost out of the breadboard socket, so without even thinking I pulled it in as it should be.
I restarted my sketch and started to see ugly things - so I made some test.
If I previously executed an erase on the chip, I could read the erased memroy location and they would output as "FF" as expected, 4096 of them would be "FF"... after the little bumping accident, I see some addresses with "FF", but a lot of other addresses showing "0".
BEFORE:
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
...
AFTER:
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 0000 0000 0000 0000 FFFF FFFF
...
If I try to write to the chip now, it will work in some location, not on other.
Also, reading memory way past the 4k that is erased also now returns only FFs and 0s - I was able to get valid data before.
It's weird though because if I run my normal sketch, that erase a sector then write to it, I'm getting different results each time, meaning that one first run, it won't write to some memory location, then on other, it will write to them...
Is it possible that the fact the 3.3v wire got unplugged/plugged during the execution shorted something and messed up the chip memory?
It's really frustrating, I was that close from fixing it...
What do you guys think ?