Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jtu5p-0004kh-IT for qemu-devel@nongnu.org; Wed, 07 May 2008 20:34:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jtu5n-0004jj-J3 for qemu-devel@nongnu.org; Wed, 07 May 2008 20:34:40 -0400 Received: from [199.232.76.173] (port=56925 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jtu5n-0004jd-Gw for qemu-devel@nongnu.org; Wed, 07 May 2008 20:34:39 -0400 Received: from miranda.se.axis.com ([193.13.178.8]:44659) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jtu5n-0005yD-0d for qemu-devel@nongnu.org; Wed, 07 May 2008 20:34:39 -0400 Received: from axis.com (edgar.se.axis.com [10.93.151.1]) by miranda.se.axis.com (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id m480YZsQ008965 for ; Thu, 8 May 2008 02:34:35 +0200 Date: Thu, 8 May 2008 02:34:35 +0200 From: "Edgar E. Iglesias" Message-ID: <20080508003435.GB15238@edgar.se.axis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] CFI02 flashes Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hello, I ran into problems when mounting jffs2 images on CFI02 flashes on a linu= x guest. Looks like we got some fields wrong in our CFI table. We are reporting a too large device size, MTD doesn't like that. We are reporting timing info for buffer writes, this makes MTD beleive we support buffer writes leading failures when programming. Also linux MTD seems to require an extended CFI table to use the device. This patch seems to work (only tested with ETRAX/CRIS). Comments? Best regards -- Edgar E. Iglesias Axis Communications AB commit 7f62e4f49c65f64ef8624474c5d22d9785d9b18c Author: Edgar E. Iglesias Date: Thu May 8 01:48:55 2008 +0200 CFI-0002 linux MTD compatibility. * Add an extended table area. * Clear buffer write timeouts to indicate that we dont support it. * Correct device size. diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c index cb9b250..1daaac3 100644 --- a/hw/pflash_cfi02.c +++ b/hw/pflash_cfi02.c @@ -608,8 +608,8 @@ pflash_t *pflash_cfi02_register(target_phys_addr_t ba= se, ram_addr_t off, /* Command set (AMD/Fujitsu) */ pfl->cfi_table[0x13] =3D 0x02; pfl->cfi_table[0x14] =3D 0x00; - /* Primary extended table address (none) */ - pfl->cfi_table[0x15] =3D 0x00; + /* Primary extended table address */ + pfl->cfi_table[0x15] =3D 0x31; pfl->cfi_table[0x16] =3D 0x00; /* Alternate command set (none) */ pfl->cfi_table[0x17] =3D 0x00; @@ -627,22 +627,22 @@ pflash_t *pflash_cfi02_register(target_phys_addr_t = base, ram_addr_t off, pfl->cfi_table[0x1E] =3D 0x00; /* Reserved */ pfl->cfi_table[0x1F] =3D 0x07; - /* Timeout for min size buffer write (16 =C3=84=C4=90s) */ - pfl->cfi_table[0x20] =3D 0x04; + /* Timeout for min size buffer write (NA) */ + pfl->cfi_table[0x20] =3D 0x00; /* Typical timeout for block erase (512 ms) */ pfl->cfi_table[0x21] =3D 0x09; /* Typical timeout for full chip erase (4096 ms) */ pfl->cfi_table[0x22] =3D 0x0C; /* Reserved */ pfl->cfi_table[0x23] =3D 0x01; - /* Max timeout for buffer write */ - pfl->cfi_table[0x24] =3D 0x04; + /* Max timeout for buffer write (NA) */ + pfl->cfi_table[0x24] =3D 0x00; /* Max timeout for block erase */ pfl->cfi_table[0x25] =3D 0x0A; /* Max timeout for chip erase */ pfl->cfi_table[0x26] =3D 0x0D; /* Device size */ - pfl->cfi_table[0x27] =3D ctz32(chip_len) + 1; + pfl->cfi_table[0x27] =3D ctz32(chip_len); /* Flash device interface (8 & 16 bits) */ pfl->cfi_table[0x28] =3D 0x02; pfl->cfi_table[0x29] =3D 0x00; @@ -659,5 +659,23 @@ pflash_t *pflash_cfi02_register(target_phys_addr_t b= ase, ram_addr_t off, pfl->cfi_table[0x2F] =3D sector_len >> 8; pfl->cfi_table[0x30] =3D sector_len >> 16; =20 + /* Extended */ + pfl->cfi_table[0x31] =3D 'P'; + pfl->cfi_table[0x32] =3D 'R'; + pfl->cfi_table[0x33] =3D 'I'; + + pfl->cfi_table[0x34] =3D '1'; + pfl->cfi_table[0x35] =3D '0'; + + pfl->cfi_table[0x36] =3D 0x00; + pfl->cfi_table[0x37] =3D 0x00; + pfl->cfi_table[0x38] =3D 0x00; + pfl->cfi_table[0x39] =3D 0x00; + + pfl->cfi_table[0x3a] =3D 0x00; + + pfl->cfi_table[0x3b] =3D 0x00; + pfl->cfi_table[0x3c] =3D 0x00; + return pfl; }