Sector size with CFI driver?
When using the CFI driver, how is the sector size determined?
The reason I ask is that I have two different versions of U-Boot for my board, both developed in-house. One version is based on 1.1.3, and the other on 1.1.5. The 1.1.5 version cannot erase/program the last sector on the first flash bank. Also, the 1.1.3 says this when I do flinfo:
Bank # 1: CFI conformant FLASH (16 x 16) Size: 8 MB in 135 Sectors
Erase timeout 16384 ms, write timeout 1 ms, buffer write timeout 1 ms,
buffer size 1
Sector Start Addresses:
FE000000 FE002000 FE004000 FE006000 FE008000
FE00A000 FE00C000 FE00E000 FE010000 FE020000And the 1.1.5 version says:
Bank # 1: CFI compatible FLASH (16 port width with 16 chip width) Command set is AMD/Fujitsu standard. Driver is polling DQ6 for status checking.
Size: 8 MB in 135 Sectors
Erase timeout 16384 ms, write timeout 0 ms, buffer write timeout 1 ms,
buffer size 1
Sector Start Addresses:
FE000000 FE010000 FE020000 FE030000 FE040000
FE050000 FE060000 FE070000 FE080000 FE090000As you can see the sector sizes are different, but everything else is the same.
Both versions have this:
#define CFG_FLASH_CFI
#define CFG_FLASH_CFI_DRIVER
#define CFG_FLASH_BASE 0xFE000000
#define CFG_FLASH_SIZE 16
#define CFG_MAX_FLASH_BANKS 2
#define CFG_MAX_FLASH_SECT 135
so I can't figure out why one works and the other doesn't.
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 22 lines · Timur Tabi
When using the CFI driver, how is the sector size determined?
The reason I ask is that I have two different versions of U-Boot for my board, both developed in-house. One version is based on 1.1.3, and the other on 1.1.5. The 1.1.5 version cannot erase/program the last sector on the first flash bank. Also, the 1.1.3 says this when I do flinfo:
Bank # 1: CFI conformant FLASH (16 x 16) Size: 8 MB in 135 Sectors
Erase timeout 16384 ms, write timeout 1 ms, buffer write timeout 1 ms,
buffer size 1
Sector Start Addresses:FE000000 FE002000 FE004000 FE006000 FE008000 FE00A000 FE00C000 FE00E000 FE010000 FE020000And the 1.1.5 version says:
Bank # 1: CFI compatible FLASH (16 port width with 16 chip width) Command set is AMD/Fujitsu standard. Driver is polling DQ6 for status checking.
Size: 8 MB in 135 Sectors
Erase timeout 16384 ms, write timeout 0 ms, buffer write timeout 1 ms,
buffer size 1
Sector Start Addresses:
Quoted 4 lines
FE000000 FE010000 FE020000 FE030000 FE040000 FE050000 FE060000 FE070000 FE080000 FE090000As you can see the sector sizes are different, but everything else is the same.
It looks like you are using a bottom boot block flash and there are 8 smaller sectors of 8KiB and 127 larger sectors of 64KiB. You will have to debug the 1.1.5 version to see why it is not seeing the 8 small sectors. If both builds are using cfi_driver.c then a bug must have been introduced recently.
Quoted 5 lines · Tolunay Orkun
It looks like you are using a bottom boot block flash and there are 8 smaller sectors of 8KiB and 127 larger sectors of 64KiB. You will have to debug the 1.1.5 version to see why it is not seeing the 8 small sectors. If both builds are using
cfi_driver.cthen a bug must have been introduced recently.
I defined CFG_FLASH_EMPTY_INFO and ran some tests. I tried erasing the last two sectors, both 0x10000 bytes in size, at FEFE0000 and FEFF0000.
After I erase FEFE0000 and do "flinfo", an "E" appears after the FEFE0000. When I copy data to FEFE0000 and do "flinfo" again, the E disappears. So far so good.
However, no matter what I do, I can't get an "E" to appears after the FEFF0000. In addition, the only way I can erase that sector is with "erase feff0000 feffffff". Any other end-value gets me a "end address not on sector boundary" message.
Could this be a hardware problem?
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 11 lines · Timur Tabi
Quoted 5 lines · Tolunay Orkun
It looks like you are using a bottom boot block flash and there are 8 smaller sectors of 8KiB and 127 larger sectors of 64KiB. You will have to debug the 1.1.5 version to see why it is not seeing the 8 small sectors. If both builds are using
cfi_driver.cthen a bug must have been introduced recently.I defined
CFG_FLASH_EMPTY_INFOand ran some tests. I tried erasing the last two sectors, both0x10000bytes in size, at FEFE0000 and FEFF0000.
Quoted 8 lines
After I erase FEFE0000 and do "flinfo", an "E" appears after the FEFE0000. When I copy data to FEFE0000 and do "flinfo" again, the E disappears. So far so good.
However, no matter what I do, I can't get an "E" to appears after the FEFF0000. In addition, the only way I can erase that sector is with "erase
feff0000feffffff". Any other end-value gets me a "end address not on sector boundary" message.
A couple of things.
1) End address should be the last byte of the sector.
2) 8MB of flash based on 0xfe000000 should end at 0xfe7fffff. Your address range is behind this.
3) In previous message you listed your configuration having 2 banks. Do you really have two banks of flash? (each having 8MB? with a total of 16MB) If not correct that two 1 bank.
4) Check the syntax of erase command. You can specify the erase range in terms of block numbers instead of addresses as well.
Quoted 3 lines · Tolunay Orkun
3) In previous message you listed your configuration having 2 banks. Do you really have two banks of flash? (each having 8MB? with a total of 16MB)
I have two 8MB flash chips (29LV640) on the board. The first starts at fe000000 and the second at fe800000. I have a jumper that can swap the two chips.
Quoted 2 lines
4) Check the syntax of erase command. You can specify the erase range in terms of block numbers instead of addresses as well.
I'll try that. Thanks.
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Hi Timur,
Quoted 5 lines · Timur Tabi
And the 1.1.5 version says:
Bank # 1: CFI compatible FLASH (16 port width with 16 chip width) Command set is AMD/Fujitsu standard. Driver is polling DQ6 for status checking. Size: 8 MB in 135 Sectors
Hmmm. I have never seen this message in U-Boot and can't find it in the current source code (something like "Command set is AMD/Fujitsu standard"). Could be that I am missing something here.
Please confirm that you are using the "official" git version of U-Boot and not any other repository. I suspect that you have an "updated" CFI driver not available in the official U-Boot version or a board specific FLASH driver.
Best regards,
Stefan
Quoted 7 lines · Stefan Roese
Hmmm. I have never seen this message in U-Boot and can't find it in the current source code (something like "Command set is AMD/Fujitsu standard"). Could be that I am missing something here.
Please confirm that you are using the "official" git version of U-Boot and not any other repository. I suspect that you have an "updated" CFI driver not available in the official U-Boot version or a board specific FLASH driver.
That message is from a hacked up version of 1.1.3. Here's the code that produces it:
void flash_print_info (flash_info_t * info)
{
int i;
if (info->flash_id != FLASH_MAN_CFI) {
puts ("missing or unknown FLASH type\n");
return;
}
printf ("CFI compatible FLASH (%d port width with %d chip width)\n",
(info->portwidth << 3), (info->chipwidth << 3));
printf ("Command set is ");
switch (info->vendor) {
case CFI_CMDSET_INTEL_EXTENDED:
printf ("Intel/Sharp extended\n");
break;
case CFI_CMDSET_AMD_STANDARD:
printf ("AMD/Fujitsu standard. ");
#ifdef POLLING_AMD_DQ7
printf ("Driver is polling DQ7 for status checking.\n");
#else
printf ("Driver is polling DQ6 for status checking.\n");
#endif
break;I believe this code was part of the official 1.1.3.
However, looking at our patch for 1.1.3 (I didn't write that code), I see this juicy tidbit for flash_get_size:
+
+#ifdef CONFIG_MPC8349ITX
+ for (i = num_erase_regions-1; i >= 0; i--) { /* top boot */
+#else
for (i = 0; i < num_erase_regions; i++) {+#endif
+
Can someone explain this top boot vs bottom boot thing?
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 3 lines · Timur Tabi
Can someone explain this top boot vs bottom boot thing?
There are three common NOR flash chip configurations:
1. Uniform sector - all sectors are the same size
2. Bottom boot - There are several smaller sectors at the beginning of
memory space. For example, 8 x 8k sectors + 127 x 64k sectors.
3. Top boot - There are several smaller sectors at the end of memory
space. For example, 127 x 64k sectors + 8 x 8k sectors.
I hope this makes sense.
regards,
Ben
Review
Quoted 7 lines · Timur Tabi
(quoted diff) +6
-0+ +#ifdef CONFIG_MPC8349ITX + for (i = num_erase_regions-1; i >= 0; i--) { /* top boot */ +#else for (i = 0; i < num_erase_regions; i++) { +#endif +
Ok, I put the above change into cfi_flash.c, and now it works! Can someone explain to me why? Does U-Boot not normally support "top boot" flash? If so, is there a better way of doing this?
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 12 lines · Timur Tabi
Review
Quoted 7 lines · Timur Tabi
(quoted diff) +3
-0+ +#ifdef CONFIG_MPC8349ITX + for (i = num_erase_regions-1; i >= 0; i--) { /* topboot */ +#else
for (i = 0; i < num_erase_regions; i++) {(quoted diff) +2
-0+#endif +Ok, I put the above change into
cfi_flash.c, and now it works! Can someone explain to me why? Does U-Boot not normally support "top boot" flash? If so, is there a better way of doing this?
Seems like your FLASH doesn't really support the CFI "Device Geometry Definition". Both versions (top & bottom boot block) most likely report the same layout.
Best regards,
Stefan
Quoted 13 lines · Stefan Roese
Quoted 11 lines · Timur Tabi
Review
Quoted 7 lines · Timur Tabi
(quoted diff) +3
-0+ +#ifdef CONFIG_MPC8349ITX + for (i = num_erase_regions-1; i >= 0; i--) { /* topboot */ +#else
for (i = 0; i < num_erase_regions; i++) {(quoted diff) +2
-0+#endif +Ok, I put the above change into
cfi_flash.c, and now it works! Can someone explain to me why? Does U-Boot not normally support "top boot" flash? If so, is there a better way of doing this?
Quoted 3 lines
Seems like your FLASH doesn't really support the CFI "Device Geometry Definition". Both versions (top & bottom boot block) most likely report the same layout.
Assuming this is true (and I will try to find out), can you recommend how you want me to implement a fix for my board? Should I do something like
#define CFG_CFI_DEV_GEO_BROKEN
in my board header file, and then do something like:
+#ifdef CFG_CFI_DEV_GEO_BROKEN
+ for (i = num_erase_regions-1; i >= 0; i--) {
+#else
for (i = 0; i < num_erase_regions; i++) {+#endif
This is really ugly, I know, but I need help coming up with a method that you guys will accept.
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 30 lines · Timur Tabi
Quoted 12 lines · Stefan Roese
Quoted 11 lines · Timur Tabi
Review
Quoted 7 lines · Timur Tabi
(quoted diff) +3
-0+ +#ifdef CONFIG_MPC8349ITX + for (i = num_erase_regions-1; i >= 0; i--) { /* topboot */ +#else
for (i = 0; i < num_erase_regions; i++) {(quoted diff) +2
-0+#endif +Ok, I put the above change into
cfi_flash.c, and now it works! Can someone explain to me why? Does U-Boot not normally support "top boot" flash? If so, is there a better way of doing this?Quoted 3 lines
Seems like your FLASH doesn't really support the CFI "Device Geometry Definition". Both versions (top & bottom boot block) most likely report the same layout.
Assuming this is true (and I will try to find out), can you recommend how you want me to implement a fix for my board? Should I do something like
#define
CFG_CFI_DEV_GEO_BROKENin my board header file, and then do something like:
(quoted diff) +4
-0+#ifdef CFG_CFI_DEV_GEO_BROKEN + for (i = num_erase_regions-1; i >= 0; i--) { +#else for (i = 0; i < num_erase_regions; i++) { +#endif
Quoted 2 lines
This is really ugly, I know, but I need help coming up with a method that you guys will accept.
I would not assume that all broken geometry to be one way or another.
Secondly, it looks like the erase region list returned is reversed for this flash chip. I think, CFG_CFI_GEOMETRY_REVERSED would be more appropriate.
Perhaps you can identify such a reserved list from the CFI tables on the flash. If this can be done no macros would be needed to handle this case.
Can you tell me the exact part number for your flash. I would like to read the data sheet and compare its CFI structures if I can.
Best regards,
Tolunay
Quoted 5 lines · Timur Tabi
Ok, I put the above change into
cfi_flash.c, and now it works! Can someone explain to me why? Does U-Boot not normally support "top boot" flash? If so, is there a better way of doing this?
I know U-Boot support both "top boot" and "bottom boot" as I used an top boot Intel flash on our board until hardware guys replaced it with the bottom boot version that we actually wanted (we used smaller sectors for U-Boot environment). As I pointed out in my response to other message your flash part is returning the geometry in reversed order.
Quoted 3 lines · Tolunay Orkun
Secondly, it looks like the erase region list returned is reversed for this flash chip. I think,
CFG_CFI_GEOMETRY_REVERSEDwould be more appropriate.
I like that one better.
Quoted 5 lines
Perhaps you can identify such a reserved list from the CFI tables on the flash. If this can be done no macros would be needed to handle this case.
Can you tell me the exact part number for your flash. I would like to read the data sheet and compare its CFI structures if I can.
29LV640BTTC-90G
You can find the specs here by going to http://www.macronix.com, clicking on "Flash Memory", and then scrolling to the bottom for this entry:
MX29LV640B T/B 3V x8/x16 Boot sector 90/120 48-TSOP, 63-CSP
I'm using the 48-pin version.
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale