From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alon Bar-Lev Date: Tue, 5 Jul 2016 19:50:56 +0300 Subject: [U-Boot] [mips][cfi] Unable to write into flash under qemu In-Reply-To: <577BDBF4.8010807@gmail.com> References: <577BDBF4.8010807@gmail.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Thank you so much! Erase does not complain any more. However, write is not working. Result is always something like: be040000: 00800080 00800080 00800080 00800080 ................ I enabled the debug info of both u-boot and qemu. I hope it helps. I am using master of qemu and u-boot, I get similar behavior in qemu since ever 1.5. Any clue? Regards, Alon --- malta # flinfo Bank # 1: CFI conformant flash (32 x 32) Size: 4 MB in 64 Sectors Intel Extended command set, Manufacturer ID: 0x00, Device ID: 0x00 Erase timeout: 16384 ms, write timeout: 3 ms Buffer write timeout: 3 ms, buffer size: 2048 bytes Sector Start Addresses: BE000000 RO BE010000 RO BE020000 RO BE030000 RO BE040000 BE050000 BE060000 BE070000 BE080000 BE090000 BE0A0000 BE0B0000 BE0C0000 BE0D0000 BE0E0000 BE0F0000 BE100000 BE110000 BE120000 BE130000 BE140000 BE150000 BE160000 BE170000 BE180000 BE190000 BE1A0000 BE1B0000 BE1C0000 BE1D0000 BE1E0000 BE1F0000 BE200000 BE210000 BE220000 BE230000 BE240000 BE250000 BE260000 BE270000 BE280000 BE290000 BE2A0000 BE2B0000 BE2C0000 BE2D0000 BE2E0000 BE2F0000 BE300000 BE310000 BE320000 BE330000 BE340000 BE350000 BE360000 BE370000 BE380000 BE390000 BE3A0000 BE3B0000 BE3C0000 BE3D0000 BE3E0000 RO BE3F0000 RO malta # erase BE040000 +10000 fwc addr be040000 cmd 50 00000050 32bit x 32 bit PFLASH: pflash_write: writing offset 0000000000040000 value 00000050 width 4 wcycle 0x0 PFLASH: pflash_write: Clear status bits fwc addr be040000 cmd 20 00000020 32bit x 32 bit PFLASH: pflash_write: writing offset 0000000000040000 value 00000020 width 4 wcycle 0x0 PFLASH: pflash_write: block erase at 0000000000040000 bytes 10000 fwc addr be040000 cmd d0 000000d0 32bit x 32 bit PFLASH: pflash_write: writing offset 0000000000040000 value 000000d0 width 4 wcycle 0x1 PFLASH: pflash_read: status 800080 flash_is_busy: 0 PFLASH: pflash_read: status 800080 fwc addr be040000 cmd ff 000000ff 32bit x 32 bit PFLASH: pflash_write: writing offset 0000000000040000 value 000000ff width 4 wcycle 0x0 PFLASH: pflash_write: Read array mode . done Erased 1 sectors malta # cp.b BE000000 BE040000 10 Copy to Flash... fwc addr be040000 cmd 50 00000050 32bit x 32 bit PFLASH: pflash_write: writing offset 0000000000040000 value 00000050 width 4 wcycle 0x0 PFLASH: pflash_write: Clear status bits fwc addr be040000 cmd 70 00000070 32bit x 32 bit PFLASH: pflash_write: writing offset 0000000000040000 value 00000070 width 4 wcycle 0x0 PFLASH: pflash_write: Read status register fwc addr be040000 cmd e8 000000e8 32bit x 32 bit PFLASH: pflash_write: writing offset 0000000000040000 value 000000e8 width 4 wcycle 0x0 PFLASH: pflash_write: Write to buffer PFLASH: pflash_read: status 800080 flash_is_busy: 0 fwc addr be040000 cmd 3 00000003 32bit x 32 bit PFLASH: pflash_write: writing offset 0000000000040000 value 00000003 width 4 wcycle 0x1 PFLASH: pflash_write: block write of 3 bytes PFLASH: pflash_read: status 800080 PFLASH: pflash_write: writing offset 0000000000040000 value 00800080 width 4 wcycle 0x2 PFLASH: pflash_data_write: block write offset 0000000000040000 value 800080 counter 0000000000000003 PFLASH: pflash_read: status 800080 PFLASH: pflash_write: writing offset 0000000000040004 value 00800080 width 4 wcycle 0x2 PFLASH: pflash_data_write: block write offset 0000000000040004 value 800080 counter 0000000000000002 PFLASH: pflash_read: status 800080 PFLASH: pflash_write: writing offset 0000000000040008 value 00800080 width 4 wcycle 0x2 PFLASH: pflash_data_write: block write offset 0000000000040008 value 800080 counter 0000000000000001 PFLASH: pflash_read: status 800080 PFLASH: pflash_write: writing offset 000000000004000c value 00800080 width 4 wcycle 0x2 PFLASH: pflash_data_write: block write offset 000000000004000c value 800080 counter 0000000000000000 PFLASH: pflash_write: block write finished fwc addr be040000 cmd d0 000000d0 32bit x 32 bit PFLASH: pflash_write: writing offset 0000000000040000 value 000000d0 width 4 wcycle 0x3 PFLASH: pflash_read: status 800080 flash_is_busy: 0 PFLASH: pflash_read: status 800080 fwc addr be040000 cmd ff 000000ff 32bit x 32 bit PFLASH: pflash_write: writing offset 0000000000040000 value 000000ff width 4 wcycle 0x0 PFLASH: pflash_write: Read array mode done malta # md BE000000 be000000: 10000123 00000000 00000000 00000000 ...#............ be000010: 00000420 00000000 00000000 00000000 ... ............ be000020: 00000000 00000000 00000000 00000000 ................ be000030: 00000000 00000000 00000000 00000000 ................ be000040: 00000000 00000000 00000000 00000000 ................ be000050: 00000000 00000000 00000000 00000000 ................ be000060: 00000000 00000000 00000000 00000000 ................ be000070: 00000000 00000000 00000000 00000000 ................ be000080: 00000000 00000000 00000000 00000000 ................ be000090: 00000000 00000000 00000000 00000000 ................ be0000a0: 00000000 00000000 00000000 00000000 ................ be0000b0: 00000000 00000000 00000000 00000000 ................ be0000c0: 00000000 00000000 00000000 00000000 ................ be0000d0: 00000000 00000000 00000000 00000000 ................ be0000e0: 00000000 00000000 00000000 00000000 ................ be0000f0: 00000000 00000000 00000000 00000000 ................ malta # md BE040000 be040000: 00800080 00800080 00800080 00800080 ................ be040010: ffffffff ffffffff ffffffff ffffffff ................ be040020: ffffffff ffffffff ffffffff ffffffff ................ be040030: ffffffff ffffffff ffffffff ffffffff ................ be040040: ffffffff ffffffff ffffffff ffffffff ................ be040050: ffffffff ffffffff ffffffff ffffffff ................ be040060: ffffffff ffffffff ffffffff ffffffff ................ be040070: ffffffff ffffffff ffffffff ffffffff ................ be040080: ffffffff ffffffff ffffffff ffffffff ................ be040090: ffffffff ffffffff ffffffff ffffffff ................ be0400a0: ffffffff ffffffff ffffffff ffffffff ................ be0400b0: ffffffff ffffffff ffffffff ffffffff ................ be0400c0: ffffffff ffffffff ffffffff ffffffff ................ be0400d0: ffffffff ffffffff ffffffff ffffffff ................ be0400e0: ffffffff ffffffff ffffffff ffffffff ................ be0400f0: ffffffff ffffffff ffffffff ffffffff ................ malta # On 5 July 2016 at 19:10, Daniel Schwierzeck wrote: > > Hi Alon, > > +cc Paul, Stefan > > Am 05.07.2016 um 14:04 schrieb Alon Bar-Lev: > > Hi, > > > > Found the debug setting. > > > > When I try to erase flash under qemu I get the following error, the > > erase actually succeeds in the backed file, I see sector as 0xff. > > > > Can anyone check if problem is within u-boot or qemu? > > > > Thanks! > > I've found the problem. Paul sent a fix [1] for pflash in June 2013 > to make 32 Bit access working with YAMON bootloader. > > The fix mirrors the flash status value in the upper 16 Bits of the return > value. Thus U-Boot gets a value of 0x800080 in flash_full_status_check() > after a block erase command. U-Boot compares the status value in > flash_isequal() with the expected value of 0x80 but that fails. > > Because of this I think pflash support for Malta is broken since Qemu 1.6.0. > > A possible fix could be this: > > --- a/drivers/mtd/cfi_flash.c > +++ b/drivers/mtd/cfi_flash.c > @@ -608,7 +608,7 @@ static int flash_full_status_check (flash_info_t * info, flash_sect_t sector, > case CFI_CMDSET_INTEL_EXTENDED: > case CFI_CMDSET_INTEL_STANDARD: > if ((retcode == ERR_OK) > - && !flash_isequal (info, sector, 0, FLASH_STATUS_DONE)) { > + && !flash_isset (info, sector, 0, FLASH_STATUS_DONE)) { > retcode = ERR_INVAL; > printf ("Flash %s error at address %lx\n", prompt, > info->start[sector]); > > > > BTW: you can enable Qemu pflash debug output in hw/block/pflash_cfi01.c > > > > > --- > > > > malta # erase BE230000 BE23FFFF > > > > fwc addr be230000 cmd 50 00000050 32bit x 32 bit > > fwc addr be230000 cmd 20 00000020 32bit x 32 bit > > fwc addr be230000 cmd d0 000000d0 32bit x 32 bit > > flash_is_busy: 0 > > is= cmd 80(?) addr be230000 is= 00800080 00000080 > > Flash erase error at address be230000 > > fwc addr be230000 cmd ff 000000ff 32bit x 32 bit > > done > > > > --- > > > > user1 at localhost ~/linux-course/embedded/qemu $ qemu-system-mips -M > > malta -nographic -net nic,netdev=eth0 -netdev > > tap,id=eth0,ifname=vm0,script=/bin/true -drive > > if=pflash,file=/tmp/flash,format=raw -m 256 > > > > > > > > > > On 5 July 2016 at 03:08, Alon Bar-Lev wrote: > >> > >> Hello, > >> > >> I am using malta board within qemu. I tried recent releases and master of both. > >> Two years ago in qemu-1.5 and qemu-1.6 I could use erase and cp.b in order to erase and write to the flash. > >> Now when I try to erase flash I get an error suggesting the erase failed, however, I do see 0xff all over in the device backed file (-pflash). > >> When I try to write I also receive a failure message. > >> > >> I am unsure how to debug this, I went back in time and tried the qemu-1.6 and got same error. I suspect it is has something to do with u-boot CFI driver. > >> > >> Can anyone help determine if issue is at qemu side or at u-boot side? How can I debug this? > >> > >> Thanks, > >> Alon > > _______________________________________________ > > U-Boot mailing list > > U-Boot at lists.denx.de > > http://lists.denx.de/mailman/listinfo/u-boot > > > > -- > - Daniel >