On Friday, February 11, 2011 10:25:46 pm Albert ARIBAUD wrote: > Le 12/02/2011 01:15, Aaron Williams a écrit : > > I think I found the problem. The cfi code does not work properly in x8 > > mode. > > > > In x8 mode, according to the datasheet, the addresses should be doubled > > for all of the commands. Additionally, according to my correspondence > > with Spansion, there needs to be at least a 500ns delay after a reset > > command. > > > > The cfi code is incorrectly detecting the port width as FLASH_CFI_16BIT > > when it is actually 8-bits. Currently things just happen to work because > > the bus is being incorrectly detected as 16-bits, > > > > The 16-bit bus detection, however, breaks in x8 mode when it issues the > > commands for the manufacturer ID. > > > > In this case, the following takes place: > > > > In cmdset_amd_read_jedec_ids > > fwc addr 1f400000 cmd f0 f0f0 16bit x 8 bit > > flash_write16: Wrote 0xf0f0 to address 1f400000 > > funlock writing 0xaa to address 0xaaa > > fwc addr 1f401554 cmd aa aaaa 16bit x 8 bit > > flash_write16: Wrote 0xaaaa to address 1f401554 > > funlock writing 0xaa to address 0x555 > > fwc addr 1f400aaa cmd 55 5555 16bit x 8 bit > > flash_write16: Wrote 0x5555 to address 1f400aaa > > fwc addr 1f401554 cmd 90 9090 16bit x 8 bit > > flash_write16: Wrote 0x9090 to address 1f401554 > > flash_read8: Read 0x0 from address 1f400001 > > flash_read8: Read 0x3f from address 1f400003 > > > > This does not work. > > > > If the proper sequence is written, then it works fine. > > > > The proper sequence, according to the datasheet, is to do the following: > > > > write 0xf0 to address 0x0000 > > write 0xaa to address 0xaaa > > write 0x55 to address 0x555 > > write 0x90 to address 0xaaa > > read address 0 (returns 1 as expected) > > read address 2 (returns 0x7e as expected) > > ... > > > > So the cfi code is broken in the x8 case. > > Hmm... It would be surprising that the x8 CFI code be broken -- not > impossible, mind you -- because it was intensively used with a variety > of chips, and thus extensively checked for brokenness. > > What *might* be at stake is the result of the width detection, because > many reputedly CFI compliant Flash devices are actually not compliant, > especially among the dual-width, x8/x16, ones. On my ED Mini V2, there > is a Macronix x8/x16 part which presents its CFI QRY response as a pure > x16 even though it is a x8/x16, thus tricking the width detection > mechanism into taking the wrong decision; I had to resort to using the > LEGACY feature of manually defining the widths. > > Did you check the Flash part against the CFI specs, including the QRY > location and layout? > > Can you boot into a RAM-baed u-boot and use its memory write and read > commands (m[wd].[lwb]) to test the main CFI sequences of your Flash device? > > Amicalement,
I've placed the results of the scan below. The problem is that in 8-bit mode the code that scans the CFI does not follow the specification. In the specification to read the CFI data you write 0x98 to address 0xAA, not address 0x55 as you do in 16-bit mode. flash_offset_cfi is set to 0x55 which in this case is wrong and won't work. When it tries 16-bit mode then it writes to address 0xAA which causes it to work. -Aaron Here's the results of the scan: flash detect cfi fwc addr 1f400000 cmd f0 f0 8bit x 8 bit flash_write8: Wrote 0xf0 to address 1f400000 fwc addr 1f400055 cmd 98 98 8bit x 8 bit flash_write8: Wrote 0x98 to address 1f400055 is= cmd 51(Q) addr 1f400010 flash_read8: Read 0x0 from address 1f400010 is= 0 51 flash_read8: Read 0x0 from address 1f400010 fwc addr 1f400000 cmd f0 f0 8bit x 8 bit flash_write8: Wrote 0xf0 to address 1f400000 fwc addr 1f400555 cmd 98 98 8bit x 8 bit flash_write8: Wrote 0x98 to address 1f400555 is= cmd 51(Q) addr 1f400010 flash_read8: Read 0x0 from address 1f400010 is= 0 51 flash_read8: Read 0x0 from address 1f400010 fwc addr 1f400000 cmd f0 f0 8bit x 8 bit flash_write8: Wrote 0xf0 to address 1f400000 fwc addr 1f400000 cmd 98 98 8bit x 8 bit flash_write8: Wrote 0x98 to address 1f400000 is= cmd 51(Q) addr 1f400010 flash_read8: Read 0x0 from address 1f400010 is= 0 51 flash_read8: Read 0x0 from address 1f400010 fwc addr 1f400000 cmd f0 f0f0 16bit x 8 bit flash_write16: Wrote 0xf0f0 to address 1f400000 fwc addr 1f4000aa cmd 98 9898 16bit x 8 bit flash_write16: Wrote 0x9898 to address 1f4000aa is= cmd 51(Q) addr 1f400020 flash_read16: Read 0x5151 from address 1f400020 is= 5151 5151 flash_read16: Read 0x5151 from address 1f400020 is= cmd 52(R) addr 1f400022 flash_read16: Read 0x5252 from address 1f400022 is= 5252 5252 flash_read16: Read 0x5252 from address 1f400022 is= cmd 59(Y) addr 1f400024 flash_read16: Read 0x5959 from address 1f400024 is= 5959 5959 flash_read16: Read 0x5959 from address 1f400024 flash_read8: Read 0x51 from address 1f400021 flash_read8: Read 0x52 from address 1f400023 flash_read8: Read 0x59 from address 1f400025 flash_read8: Read 0x2 from address 1f400027 flash_read8: Read 0x0 from address 1f400029 flash_read8: Read 0x40 from address 1f40002b flash_read8: Read 0x0 from address 1f40002d flash_read8: Read 0x0 from address 1f40002f flash_read8: Read 0x0 from address 1f400031 flash_read8: Read 0x0 from address 1f400033 flash_read8: Read 0x0 from address 1f400035 flash_read8: Read 0x27 from address 1f400037 flash_read8: Read 0x36 from address 1f400039 flash_read8: Read 0x0 from address 1f40003b flash_read8: Read 0x0 from address 1f40003d flash_read8: Read 0x7 from address 1f40003f flash_read8: Read 0x7 from address 1f400041 flash_read8: Read 0xa from address 1f400043 flash_read8: Read 0x0 from address 1f400045 flash_read8: Read 0x3 from address 1f400047 flash_read8: Read 0x5 from address 1f400049 flash_read8: Read 0x4 from address 1f40004b flash_read8: Read 0x0 from address 1f40004d flash_read8: Read 0x17 from address 1f40004f flash_read8: Read 0x2 from address 1f400051 flash_read8: Read 0x0 from address 1f400053 flash_read8: Read 0x5 from address 1f400055 flash_read8: Read 0x0 from address 1f400057 flash_read8: Read 0x2 from address 1f400059 flash_read8: Read 0x7 from address 1f40005b flash_read8: Read 0x0 from address 1f40005d flash_read8: Read 0x20 from address 1f40005f flash_read8: Read 0x0 from address 1f400061 flash_read8: Read 0x7e from address 1f400063 flash_read8: Read 0x0 from address 1f400065 flash_read8: Read 0x0 from address 1f400067 flash_read8: Read 0x1 from address 1f400069 flash_read8: Read 0x0 from address 1f40006b flash_read8: Read 0x0 from address 1f40006d flash_read8: Read 0x0 from address 1f40006f flash_read8: Read 0x0 from address 1f400071 flash_read8: Read 0x0 from address 1f400073 flash_read8: Read 0x0 from address 1f400075 flash_read8: Read 0x0 from address 1f400077 flash_read8: Read 0x0 from address 1f400079 device interface is 2 found port 2 chip 1 port 16 bits chip 8 bits __flash_detect_cfi: unlock addresses 0xaaa, 0x555, interface 2 flash_read8: Read 0x31 from address 1f400087 flash_read8: Read 0x33 from address 1f400089 00 : 51 52 59 02 00 40 00 00 00 00 00 27 36 00 00 07 QRY..@.....'6... 10 : 07 0a 00 03 05 04 00 17 02 00 05 00 02 07 00 20 ............... 20 : 00 7e 00 00 01 00 00 00 00 00 00 00 00 06 d6 98 .~.............. In cmdset_amd_read_jedec_ids fwc addr 1f400000 cmd f0 f0f0 16bit x 8 bit flash_write16: Wrote 0xf0f0 to address 1f400000 funlock writing 0xaa to address 0xaaa fwc addr 1f401554 cmd aa aaaa 16bit x 8 bit flash_write16: Wrote 0xaaaa to address 1f401554 funlock writing 0xaa to address 0x555 fwc addr 1f400aaa cmd 55 5555 16bit x 8 bit flash_write16: Wrote 0x5555 to address 1f400aaa fwc addr 1f401554 cmd 90 9090 16bit x 8 bit flash_write16: Wrote 0x9090 to address 1f401554 flash_read8: Read 0x0 from address 1f400001 flash_read8: Read 0x3f from address 1f400003 fwc addr 1f400000 cmd f0 f0f0 16bit x 8 bit flash_write16: Wrote 0xf0f0 to address 1f400000 fwc addr 1f4000aa cmd 98 9898 16bit x 8 bit flash_write16: Wrote 0x9898 to address 1f4000aa flash_read8: Read 0x3 from address 1f40009f manufacturer is 2 manufacturer id is 0x0 device id is 0x3f device id2 is 0x0 cfi version is 0x3133 size_ratio 1 port 16 bits chip 8 bits found 2 erase regions erase region 0: 0x0100007e erase_region_count = 127 erase_region_size = 65536 erase region 1: 0x00200007 erase_region_count = 8 erase_region_size = 8192 fwc addr 1f400000 cmd f0 f0 8bit x 8 bit flash_write8: Wrote 0xf0 to address 1f400000 fwc addr 1fbfe000 cmd 70 70 8bit x 8 bit flash_write8: Wrote 0x70 to address 1fbfe000 flash_read8: Read 0x6f from address 1fbfe000 flash_read8: Read 0x6f from address 1fbfe000 flash_is_busy: 0 Flash: 8 MiB _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot