On Sat, 05 May 2012 21:13:21 +0200 Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net wrote:
Am 23.02.2012 02:26 schrieb Stefan Tauner:
On Mon, 20 Feb 2012 19:49:38 +0100 Carl-Daniel Hailfinger wrote:
Not what I meant. The big issue with SFDP and FAST READ and other commands is that the dummy byte after command+address can be either a written or read byte (the chip does not care). Our emulation should be able to handle both. This means a writecnt of 4 is completely legal, but in that case we have to set the copy destination to &readarr[1] instead of &readarr[0]. My logic tried to address that, but it was not completely correct. I have annotated your patch with my suggested changes at the end of this mail. They seem to work in my tests.
ah! :) please re-review that part of this iteration, sorry. NB: we have changed the SFDP code to use a dummy read instead of the write in the meantime. i have tested with both dummy reads and writes and all looks find. if there is no response for a week, ill commit it anyway.
diff --git a/dummyflasher.c b/dummyflasher.c index afe0518..794a2f6 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -629,7 +681,33 @@ static int emulate_spi_chip_response(unsigned int writecnt, /* emu_jedec_ce_c7_size is emu_chip_size. */ memset(flashchip_contents, 0xff, emu_jedec_ce_c7_size); break;
- default:
- case JEDEC_SFDP: {
unsigned int toread;
if (emu_chip != EMULATE_MACRONIX_MX25L6436)
break;
if (writecnt < 5)
Replace with if (writecnt < 4)
break;
offs = writearr[1] << 16 | writearr[2] << 8 | writearr[3];
Insert
/* SFDP expects one dummy byte after the address. */
if (writecnt < 5) {
this can be simplified then... see patch.
/* The dummy byte was not written, make sure it is read
* instead. Shifting and shortening the read array does
* achieve the goal.
*/
readarr += 5 - writecnt;
readcnt -= 5 - writecnt;
writecnt = 5;
}