On Fri, 19 Apr 2013 10:44:29 +0800 Chi Zhang zhangchi866@gmail.com wrote:
在 2013年4月19日 星期五 02:28:02,Stefan Tauner 写道:
On Wed, 03 Apr 2013 12:40:07 +0800
Chi Zhang zhangchi866@gmail.com wrote:
Applied patch: http://patchwork.coreboot.org/patch/3927/ And now AT26DF161A is NOT working any more.
I have to admit that I don't understand the problem yet at all. It should have worked IMHO. If you have some time please retry with -VV again after applying the following patch on top of the previous patch (3927). This should print what we actually try to write to the status register to disable the alleged write protection. Maybe I am misreading the datasheet, and if so the debug output should make it easier to understand what's going on.
Done with latest SVN version (r1671) and patch 3927 and the patch in your mail.
Thanks for testing. This is quite odd: we do the right thing IMHO. The relevant code is in spi25_statusreg.c spi_disable_blockprotect_at25df() calls spi_disable_blockprotect_generic(flash, 0x0C, 1 << 7, 1 << 4) In the beginning the status register is 0x1C, i.e. the status register is not locked, the hardware protection pin is not asserted, only the write protection bits are set. spi_disable_blockprotect_generic() correctly detects that and tries to set the protection bits to 0 by trying to write 0x10 (not touching the r/o WP pin bit), but that apparently has no effect.
Unpatched r1671 still works:
Interestingly here the initial contents of the status register are what we would expect them to be after unlocking(!). Maybe the chip reacts too slow? Do you have another explanation for that behavior?
The patch below adds a delay of five seconds after trying to write to the status register for unlocking.
diff --git a/spi25_statusreg.c b/spi25_statusreg.c index b325a2e..b692851 100644 --- a/spi25_statusreg.c +++ b/spi25_statusreg.c @@ -163,6 +163,7 @@ static int spi_disable_blockprotect_generic(struct flashctx *flash, uint8_t bp_m msg_cerr("spi_write_status_register failed.\n"); return result; } + programmer_delay(5*1000*1000); status = spi_read_status_register(flash); if ((status & bp_mask) != 0) { msg_cerr("Block protection could not be disabled!\n");