[flashrom] [PATCH 9/10] 4BA: SFDP downgrade to 1.5 to support new Micron chips

Boris Baykov dev at borisbaykov.com
Fri Jan 16 15:15:40 CET 2015


* Date of changes fixed from 2014 to 2015. It's correct now.

The corrected file of [PATCH 9/10] is here below.


After I added SFDP 1.6 parser I found in Micron's datasheet
for MT25Q 512Mb chip (MT25QL512AB/MT25QU512AB) that the chip
returnes SFDP revision 1.5 but simultaniously provides the
required information about addressing mode switch, however
all information about direct-4BA functions isn't provided.

I decided to parse new SFDP 4-bytes info from SFDP
revision 1.5 besides of direct-4BA instructions. This
assumption is made for better support of Micron flash chips.

This code should be checked and may be modified or removed.

Patched files
-------------
sfdp.c
+ added fix for Micron chips to read 16th dword stating from SFDP revision 1.5


Signed-off-by: Boris Baykov <dev at borisbaykov.com>, Russia, Jan 2014
---
diff -U 5 -N ./flashrom/sfdp.c ./flashrom-1868-4ba-9/sfdp.c
--- ./flashrom/sfdp.c   2015-01-16 17:06:21.000000000 +0300
+++ ./flashrom-1868-4ba-9/sfdp.c        2015-01-16 17:01:42.000000000 +0300
@@ -19,10 +19,11 @@
  */
 
 /*   
  *   History of changes:
  *     05/01/2015  Added compliance to JESD216B standard and SFDP revision 1.6
+ *     07/01/2015  Modified to support SFDP revision 1.5 (for Micron flash chips)
  */
 
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
@@ -177,11 +178,11 @@
                  __func__, eraser_type);
        return 1;
 }
 
 /* Parse of JEDEC SFDP Basic Flash Parameter Table */
-static int sfdp_fill_flash(struct flashchip *chip, uint8_t *buf, uint16_t len, int sfdp_rev_16)
+static int sfdp_fill_flash(struct flashchip *chip, uint8_t *buf, uint16_t len, int sfdp_rev_15)
 {
        uint8_t opcode_4k_erase = 0xFF;
        uint32_t tmp32;
        uint8_t tmp8;
        uint32_t total_size; /* in bytes */
@@ -296,14 +297,14 @@
        total_size = ((tmp32 & 0x7FFFFFFF) + 1) / 8;
        chip->total_size = total_size / 1024;
        msg_cdbg2("  Flash chip size is %d kB.\n", chip->total_size);
        
        if (total_size > (1 << 24)) {
-               if(!sfdp_rev_16) {
+               if(!sfdp_rev_15) {
                        msg_cdbg("Flash chip size is bigger than what 3-Byte addressing "
                                 "can access but chip's SFDP revision is lower than 1.6 "
-                                "\nConsequently 4-bytes addressing can NOT be "
+                                "(1.5).\nConsequently 4-bytes addressing can NOT be "
                                 "properly configured using current SFDP information.\n");
 #ifndef FBA_USE_EXT_ADDR_REG_BY_DEFAULT
                        msg_cdbg("Assuming that 4-bytes addressing mode can be "
                                 "entered by CMD B7h with WREN.\n");
 #else
@@ -374,14 +375,14 @@
           because we don't have to know how to switch to 4-bytes mode and back 
           when we are already in 4-bytes mode permanently. */
        if (chip->feature_bits & FEATURE_4BA_ONLY)
                goto done;
 
-       /* If the SFDP revision supported by the chip is lower that 1.6
+       /* If the SFDP revision supported by the chip is lower that 1.6 (1.5)
           we can not read and analyze 16th DWORD of Basic Flash Parameter Table.
           Using defaults by FBA_USE_EXT_ADDR_REG_BY_DEFAULT define. */
-       if(!sfdp_rev_16)
+       if(!sfdp_rev_15)
                goto done;
 
        if (len < 16 * 4) {
                msg_cdbg("%s: len of BFPT is out of spec\n", __func__);
                msg_cerr("ERROR: Unable read 4-bytes addressing parameters.\n");
@@ -600,11 +601,11 @@
        /* need to limit the table loop by comparing i to uint8_t nph hence: */
        uint16_t i;
        struct sfdp_tbl_hdr *hdrs;
        uint8_t *hbuf;
        uint8_t *tbuf;
-       int sfdp_rev_16 = 0;
+       int sfdp_rev_16 = 0, sfdp_rev_15 = 0;
 
        if (spi_sfdp_read_sfdp(flash, 0x00, buf, 4)) {
                msg_cdbg("Receiving SFDP signature failed.\n");
                return 0;
        }
@@ -634,12 +635,29 @@
        /* JEDEC JESD216B defines SFDP revision 1.6 and includes:
           1) 16 dwords in Basic Flash Parameter Table
           2) 16th dword has information how to enter 
                and exit 4-bytes addressing mode
           3) 4-Bytes Address Instruction Table with ID 0xFF84
+
+               However we can see in the datasheet for Micron's
+          MT25Q 512Mb chip (MT25QL512AB/MT25QU512AB) that the 
+          chip returnes SFDP revision 1.5 and has 16 dwords
+          in its Basic Flash Paramater Table. Also the information
+          about addressing mode switch is exist in the 16th dword. 
+          But 4-Bytes Address Instruction Table is absent.
+
+               So we will use 16th dword from SFDP revision 1.5
+          but 4-Bytes Address Instruction Table from SFDP 1.6 only. 
+          This assumption is made for better support of Micron
+          flash chips.
+               
+               FIXME: SFDP revisions compliance should be checked
+          more carefully after more information about JESD216B
+          SFDP tables will be known from real flash chips.
        */
        sfdp_rev_16 = (buf[1] == 1 && buf[0] >= 6) || buf[1] > 1;
+       sfdp_rev_15 = (buf[1] == 1 && buf[0] >= 5) || buf[1] > 1;
 
        nph = buf[2];
        msg_cdbg2("SFDP number of parameter headers is %d (NPH = %d).\n",
                  nph + 1, nph);
 
@@ -715,21 +733,21 @@
                                         "parameter table is not 0xFF00 as"
                                         "demanded by JESD216 (warning only)."
                                         "\n");
 #ifdef JESD216B_SIMULATION
                        if(!sfdp_jesd216b_simulation_dw16(&tbuf, &len))
-                               sfdp_rev_16 = 1; /* pretend as SFDP rev 1.6 */
+                               sfdp_rev_16 = sfdp_rev_15 = 1; /* pretend as SFDP rev 1.6 */
 #endif
                        if (hdrs[i].v_major != 0x01) {
                                msg_cdbg("The chip contains an unknown "
                                          "version of the JEDEC flash "
                                          "parameters table, skipping it.\n");
                        } else if (len != 16 * 4 && len != 9 * 4 && len != 4 * 4) {
                                msg_cdbg("Length of the mandatory JEDEC SFDP "
                                         "parameter table is wrong (%d B), "
                                         "skipping it.\n", len);
-                       } else if (sfdp_fill_flash(flash->chip, tbuf, len, sfdp_rev_16) == 0)
+                       } else if (sfdp_fill_flash(flash->chip, tbuf, len, sfdp_rev_15) == 0)
                                ret = 1;
 #ifdef JESD216B_SIMULATION
                        if(ret == 1 && !sfdp_jesd216b_simulation_4bait(&tbuf, &len))
                                sfdp_parse_4ba_table(flash->chip, tbuf, len);
 #endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flashrom-r1868-4ba-part-9.patch.tar.bz2
Type: application/octet-stream
Size: 2569 bytes
Desc: not available
URL: <http://www.flashrom.org/pipermail/flashrom/attachments/20150116/58163132/attachment.obj>


More information about the flashrom mailing list