[U-Boot] [mips][cfi] Unable to write into flash under qemu

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

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!
---
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@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
U-Boot 2016.05 (Jul 04 2016 - 19:22:36 +0000)
Board: MIPS Malta CoreLV DRAM: 256 MiB Flash: flash detect cfi fwc addr be000000 cmd f0 f0 8bit x 8 bit fwc addr be000000 cmd ff ff 8bit x 8 bit fwc addr be000055 cmd 98 98 8bit x 8 bit is= cmd 51(Q) addr be000010 is= 0 51 fwc addr be000555 cmd 98 98 8bit x 8 bit is= cmd 51(Q) addr be000010 is= 0 51 fwc addr be000000 cmd f0 f0f0 16bit x 8 bit fwc addr be000000 cmd ff ffff 16bit x 8 bit fwc addr be0000aa cmd 98 9898 16bit x 8 bit is= cmd 51(Q) addr be000020 is= 0000 5151 fwc addr be000aaa cmd 98 9898 16bit x 8 bit is= cmd 51(Q) addr be000020 is= 0000 5151 fwc addr be000000 cmd f0 00f0 16bit x 16 bit fwc addr be000000 cmd ff 00ff 16bit x 16 bit fwc addr be0000aa cmd 98 0098 16bit x 16 bit is= cmd 51(Q) addr be000020 is= 0000 0051 fwc addr be000aaa cmd 98 0098 16bit x 16 bit is= cmd 51(Q) addr be000020 is= 0000 0051 fwc addr be000000 cmd f0 f0f0f0f0 32bit x 8 bit fwc addr be000000 cmd ff ffffffff 32bit x 8 bit fwc addr be000154 cmd 98 98989898 32bit x 8 bit is= cmd 51(Q) addr be000040 is= 00000051 51515151 fwc addr be001554 cmd 98 98989898 32bit x 8 bit is= cmd 51(Q) addr be000040 is= 00000051 51515151 fwc addr be000000 cmd f0 00f000f0 32bit x 16 bit fwc addr be000000 cmd ff 00ff00ff 32bit x 16 bit fwc addr be000154 cmd 98 00980098 32bit x 16 bit is= cmd 51(Q) addr be000040 is= 00000051 00510051 fwc addr be001554 cmd 98 00980098 32bit x 16 bit is= cmd 51(Q) addr be000040 is= 00000051 00510051 fwc addr be000000 cmd f0 000000f0 32bit x 32 bit fwc addr be000000 cmd ff 000000ff 32bit x 32 bit fwc addr be000154 cmd 98 00000098 32bit x 32 bit is= cmd 51(Q) addr be000040 is= 00000051 00000051 is= cmd 52(R) addr be000044 is= 00000052 00000052 is= cmd 59(Y) addr be000048 is= 00000059 00000059 device interface is 2 found port 4 chip 4 port 32 bits chip 32 bits 00 : 51 52 59 01 00 31 00 00 00 00 00 45 55 00 00 07 QRY..1.....EU... 10 : 07 0a 00 04 04 04 00 16 02 00 0b 00 01 3f 00 00 .............?.. 20 : 01 50 52 49 31 30 00 00 00 00 00 00 00 00 00 00 .PRI10.......... fwc addr be000000 cmd ff 000000ff 32bit x 32 bit fwc addr be000000 cmd 90 00000090 32bit x 32 bit fwc addr be000000 cmd ff 000000ff 32bit x 32 bit fwc addr be000154 cmd 98 00000098 32bit x 32 bit manufacturer is 1 manufacturer id is 0x0 device id is 0x0 device id2 is 0x0 cfi version is 0x3130 size_ratio 1 port 32 bits chip 32 bits found 1 erase regions erase region 0: 0x0100003f erase_region_count = 64 erase_region_size = 65536 fwc addr be000000 cmd 90 00000090 32bit x 32 bit fwc addr be000000 cmd ff 000000ff 32bit x 32 bit fwc addr be010000 cmd 90 00000090 32bit x 32 bit fwc addr be010000 cmd ff 000000ff 32bit x 32 bit fwc addr be020000 cmd 90 00000090 32bit x 32 bit fwc addr be020000 cmd ff 000000ff 32bit x 32 bit fwc addr be030000 cmd 90 00000090 32bit x 32 bit fwc addr be030000 cmd ff 000000ff 32bit x 32 bit fwc addr be040000 cmd 90 00000090 32bit x 32 bit fwc addr be040000 cmd ff 000000ff 32bit x 32 bit fwc addr be050000 cmd 90 00000090 32bit x 32 bit fwc addr be050000 cmd ff 000000ff 32bit x 32 bit fwc addr be060000 cmd 90 00000090 32bit x 32 bit fwc addr be060000 cmd ff 000000ff 32bit x 32 bit fwc addr be070000 cmd 90 00000090 32bit x 32 bit fwc addr be070000 cmd ff 000000ff 32bit x 32 bit fwc addr be080000 cmd 90 00000090 32bit x 32 bit fwc addr be080000 cmd ff 000000ff 32bit x 32 bit fwc addr be090000 cmd 90 00000090 32bit x 32 bit fwc addr be090000 cmd ff 000000ff 32bit x 32 bit fwc addr be0a0000 cmd 90 00000090 32bit x 32 bit fwc addr be0a0000 cmd ff 000000ff 32bit x 32 bit fwc addr be0b0000 cmd 90 00000090 32bit x 32 bit fwc addr be0b0000 cmd ff 000000ff 32bit x 32 bit fwc addr be0c0000 cmd 90 00000090 32bit x 32 bit fwc addr be0c0000 cmd ff 000000ff 32bit x 32 bit fwc addr be0d0000 cmd 90 00000090 32bit x 32 bit fwc addr be0d0000 cmd ff 000000ff 32bit x 32 bit fwc addr be0e0000 cmd 90 00000090 32bit x 32 bit fwc addr be0e0000 cmd ff 000000ff 32bit x 32 bit fwc addr be0f0000 cmd 90 00000090 32bit x 32 bit fwc addr be0f0000 cmd ff 000000ff 32bit x 32 bit fwc addr be100000 cmd 90 00000090 32bit x 32 bit fwc addr be100000 cmd ff 000000ff 32bit x 32 bit fwc addr be110000 cmd 90 00000090 32bit x 32 bit fwc addr be110000 cmd ff 000000ff 32bit x 32 bit fwc addr be120000 cmd 90 00000090 32bit x 32 bit fwc addr be120000 cmd ff 000000ff 32bit x 32 bit fwc addr be130000 cmd 90 00000090 32bit x 32 bit fwc addr be130000 cmd ff 000000ff 32bit x 32 bit fwc addr be140000 cmd 90 00000090 32bit x 32 bit fwc addr be140000 cmd ff 000000ff 32bit x 32 bit fwc addr be150000 cmd 90 00000090 32bit x 32 bit fwc addr be150000 cmd ff 000000ff 32bit x 32 bit fwc addr be160000 cmd 90 00000090 32bit x 32 bit fwc addr be160000 cmd ff 000000ff 32bit x 32 bit fwc addr be170000 cmd 90 00000090 32bit x 32 bit fwc addr be170000 cmd ff 000000ff 32bit x 32 bit fwc addr be180000 cmd 90 00000090 32bit x 32 bit fwc addr be180000 cmd ff 000000ff 32bit x 32 bit fwc addr be190000 cmd 90 00000090 32bit x 32 bit fwc addr be190000 cmd ff 000000ff 32bit x 32 bit fwc addr be1a0000 cmd 90 00000090 32bit x 32 bit fwc addr be1a0000 cmd ff 000000ff 32bit x 32 bit fwc addr be1b0000 cmd 90 00000090 32bit x 32 bit fwc addr be1b0000 cmd ff 000000ff 32bit x 32 bit fwc addr be1c0000 cmd 90 00000090 32bit x 32 bit fwc addr be1c0000 cmd ff 000000ff 32bit x 32 bit fwc addr be1d0000 cmd 90 00000090 32bit x 32 bit fwc addr be1d0000 cmd ff 000000ff 32bit x 32 bit fwc addr be1e0000 cmd 90 00000090 32bit x 32 bit fwc addr be1e0000 cmd ff 000000ff 32bit x 32 bit fwc addr be1f0000 cmd 90 00000090 32bit x 32 bit fwc addr be1f0000 cmd ff 000000ff 32bit x 32 bit fwc addr be200000 cmd 90 00000090 32bit x 32 bit fwc addr be200000 cmd ff 000000ff 32bit x 32 bit fwc addr be210000 cmd 90 00000090 32bit x 32 bit fwc addr be210000 cmd ff 000000ff 32bit x 32 bit fwc addr be220000 cmd 90 00000090 32bit x 32 bit fwc addr be220000 cmd ff 000000ff 32bit x 32 bit fwc addr be230000 cmd 90 00000090 32bit x 32 bit fwc addr be230000 cmd ff 000000ff 32bit x 32 bit fwc addr be240000 cmd 90 00000090 32bit x 32 bit fwc addr be240000 cmd ff 000000ff 32bit x 32 bit fwc addr be250000 cmd 90 00000090 32bit x 32 bit fwc addr be250000 cmd ff 000000ff 32bit x 32 bit fwc addr be260000 cmd 90 00000090 32bit x 32 bit fwc addr be260000 cmd ff 000000ff 32bit x 32 bit fwc addr be270000 cmd 90 00000090 32bit x 32 bit fwc addr be270000 cmd ff 000000ff 32bit x 32 bit fwc addr be280000 cmd 90 00000090 32bit x 32 bit fwc addr be280000 cmd ff 000000ff 32bit x 32 bit fwc addr be290000 cmd 90 00000090 32bit x 32 bit fwc addr be290000 cmd ff 000000ff 32bit x 32 bit fwc addr be2a0000 cmd 90 00000090 32bit x 32 bit fwc addr be2a0000 cmd ff 000000ff 32bit x 32 bit fwc addr be2b0000 cmd 90 00000090 32bit x 32 bit fwc addr be2b0000 cmd ff 000000ff 32bit x 32 bit fwc addr be2c0000 cmd 90 00000090 32bit x 32 bit fwc addr be2c0000 cmd ff 000000ff 32bit x 32 bit fwc addr be2d0000 cmd 90 00000090 32bit x 32 bit fwc addr be2d0000 cmd ff 000000ff 32bit x 32 bit fwc addr be2e0000 cmd 90 00000090 32bit x 32 bit fwc addr be2e0000 cmd ff 000000ff 32bit x 32 bit fwc addr be2f0000 cmd 90 00000090 32bit x 32 bit fwc addr be2f0000 cmd ff 000000ff 32bit x 32 bit fwc addr be300000 cmd 90 00000090 32bit x 32 bit fwc addr be300000 cmd ff 000000ff 32bit x 32 bit fwc addr be310000 cmd 90 00000090 32bit x 32 bit fwc addr be310000 cmd ff 000000ff 32bit x 32 bit fwc addr be320000 cmd 90 00000090 32bit x 32 bit fwc addr be320000 cmd ff 000000ff 32bit x 32 bit fwc addr be330000 cmd 90 00000090 32bit x 32 bit fwc addr be330000 cmd ff 000000ff 32bit x 32 bit fwc addr be340000 cmd 90 00000090 32bit x 32 bit fwc addr be340000 cmd ff 000000ff 32bit x 32 bit fwc addr be350000 cmd 90 00000090 32bit x 32 bit fwc addr be350000 cmd ff 000000ff 32bit x 32 bit fwc addr be360000 cmd 90 00000090 32bit x 32 bit fwc addr be360000 cmd ff 000000ff 32bit x 32 bit fwc addr be370000 cmd 90 00000090 32bit x 32 bit fwc addr be370000 cmd ff 000000ff 32bit x 32 bit fwc addr be380000 cmd 90 00000090 32bit x 32 bit fwc addr be380000 cmd ff 000000ff 32bit x 32 bit fwc addr be390000 cmd 90 00000090 32bit x 32 bit fwc addr be390000 cmd ff 000000ff 32bit x 32 bit fwc addr be3a0000 cmd 90 00000090 32bit x 32 bit fwc addr be3a0000 cmd ff 000000ff 32bit x 32 bit fwc addr be3b0000 cmd 90 00000090 32bit x 32 bit fwc addr be3b0000 cmd ff 000000ff 32bit x 32 bit fwc addr be3c0000 cmd 90 00000090 32bit x 32 bit fwc addr be3c0000 cmd ff 000000ff 32bit x 32 bit fwc addr be3d0000 cmd 90 00000090 32bit x 32 bit fwc addr be3d0000 cmd ff 000000ff 32bit x 32 bit fwc addr be3e0000 cmd 90 00000090 32bit x 32 bit fwc addr be3e0000 cmd ff 000000ff 32bit x 32 bit fwc addr be3f0000 cmd 90 00000090 32bit x 32 bit fwc addr be3f0000 cmd ff 000000ff 32bit x 32 bit fwc addr be000000 cmd ff 000000ff 32bit x 32 bit 4 MiB *** Warning - bad CRC, using default environment
In: serial Out: serial Err: serial Net: pcnet#0 IDE: Bus 0: not available 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 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 malta #
On 5 July 2016 at 03:08, Alon Bar-Lev alon.barlev@gmail.com 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

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@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
U-Boot 2016.05 (Jul 04 2016 - 19:22:36 +0000)
Board: MIPS Malta CoreLV DRAM: 256 MiB Flash: flash detect cfi fwc addr be000000 cmd f0 f0 8bit x 8 bit fwc addr be000000 cmd ff ff 8bit x 8 bit fwc addr be000055 cmd 98 98 8bit x 8 bit is= cmd 51(Q) addr be000010 is= 0 51 fwc addr be000555 cmd 98 98 8bit x 8 bit is= cmd 51(Q) addr be000010 is= 0 51 fwc addr be000000 cmd f0 f0f0 16bit x 8 bit fwc addr be000000 cmd ff ffff 16bit x 8 bit fwc addr be0000aa cmd 98 9898 16bit x 8 bit is= cmd 51(Q) addr be000020 is= 0000 5151 fwc addr be000aaa cmd 98 9898 16bit x 8 bit is= cmd 51(Q) addr be000020 is= 0000 5151 fwc addr be000000 cmd f0 00f0 16bit x 16 bit fwc addr be000000 cmd ff 00ff 16bit x 16 bit fwc addr be0000aa cmd 98 0098 16bit x 16 bit is= cmd 51(Q) addr be000020 is= 0000 0051 fwc addr be000aaa cmd 98 0098 16bit x 16 bit is= cmd 51(Q) addr be000020 is= 0000 0051 fwc addr be000000 cmd f0 f0f0f0f0 32bit x 8 bit fwc addr be000000 cmd ff ffffffff 32bit x 8 bit fwc addr be000154 cmd 98 98989898 32bit x 8 bit is= cmd 51(Q) addr be000040 is= 00000051 51515151 fwc addr be001554 cmd 98 98989898 32bit x 8 bit is= cmd 51(Q) addr be000040 is= 00000051 51515151 fwc addr be000000 cmd f0 00f000f0 32bit x 16 bit fwc addr be000000 cmd ff 00ff00ff 32bit x 16 bit fwc addr be000154 cmd 98 00980098 32bit x 16 bit is= cmd 51(Q) addr be000040 is= 00000051 00510051 fwc addr be001554 cmd 98 00980098 32bit x 16 bit is= cmd 51(Q) addr be000040 is= 00000051 00510051 fwc addr be000000 cmd f0 000000f0 32bit x 32 bit fwc addr be000000 cmd ff 000000ff 32bit x 32 bit fwc addr be000154 cmd 98 00000098 32bit x 32 bit is= cmd 51(Q) addr be000040 is= 00000051 00000051 is= cmd 52(R) addr be000044 is= 00000052 00000052 is= cmd 59(Y) addr be000048 is= 00000059 00000059 device interface is 2 found port 4 chip 4 port 32 bits chip 32 bits 00 : 51 52 59 01 00 31 00 00 00 00 00 45 55 00 00 07 QRY..1.....EU... 10 : 07 0a 00 04 04 04 00 16 02 00 0b 00 01 3f 00 00 .............?.. 20 : 01 50 52 49 31 30 00 00 00 00 00 00 00 00 00 00 .PRI10.......... fwc addr be000000 cmd ff 000000ff 32bit x 32 bit fwc addr be000000 cmd 90 00000090 32bit x 32 bit fwc addr be000000 cmd ff 000000ff 32bit x 32 bit fwc addr be000154 cmd 98 00000098 32bit x 32 bit manufacturer is 1 manufacturer id is 0x0 device id is 0x0 device id2 is 0x0 cfi version is 0x3130 size_ratio 1 port 32 bits chip 32 bits found 1 erase regions erase region 0: 0x0100003f erase_region_count = 64 erase_region_size = 65536 fwc addr be000000 cmd 90 00000090 32bit x 32 bit fwc addr be000000 cmd ff 000000ff 32bit x 32 bit fwc addr be010000 cmd 90 00000090 32bit x 32 bit fwc addr be010000 cmd ff 000000ff 32bit x 32 bit fwc addr be020000 cmd 90 00000090 32bit x 32 bit fwc addr be020000 cmd ff 000000ff 32bit x 32 bit fwc addr be030000 cmd 90 00000090 32bit x 32 bit fwc addr be030000 cmd ff 000000ff 32bit x 32 bit fwc addr be040000 cmd 90 00000090 32bit x 32 bit fwc addr be040000 cmd ff 000000ff 32bit x 32 bit fwc addr be050000 cmd 90 00000090 32bit x 32 bit fwc addr be050000 cmd ff 000000ff 32bit x 32 bit fwc addr be060000 cmd 90 00000090 32bit x 32 bit fwc addr be060000 cmd ff 000000ff 32bit x 32 bit fwc addr be070000 cmd 90 00000090 32bit x 32 bit fwc addr be070000 cmd ff 000000ff 32bit x 32 bit fwc addr be080000 cmd 90 00000090 32bit x 32 bit fwc addr be080000 cmd ff 000000ff 32bit x 32 bit fwc addr be090000 cmd 90 00000090 32bit x 32 bit fwc addr be090000 cmd ff 000000ff 32bit x 32 bit fwc addr be0a0000 cmd 90 00000090 32bit x 32 bit fwc addr be0a0000 cmd ff 000000ff 32bit x 32 bit fwc addr be0b0000 cmd 90 00000090 32bit x 32 bit fwc addr be0b0000 cmd ff 000000ff 32bit x 32 bit fwc addr be0c0000 cmd 90 00000090 32bit x 32 bit fwc addr be0c0000 cmd ff 000000ff 32bit x 32 bit fwc addr be0d0000 cmd 90 00000090 32bit x 32 bit fwc addr be0d0000 cmd ff 000000ff 32bit x 32 bit fwc addr be0e0000 cmd 90 00000090 32bit x 32 bit fwc addr be0e0000 cmd ff 000000ff 32bit x 32 bit fwc addr be0f0000 cmd 90 00000090 32bit x 32 bit fwc addr be0f0000 cmd ff 000000ff 32bit x 32 bit fwc addr be100000 cmd 90 00000090 32bit x 32 bit fwc addr be100000 cmd ff 000000ff 32bit x 32 bit fwc addr be110000 cmd 90 00000090 32bit x 32 bit fwc addr be110000 cmd ff 000000ff 32bit x 32 bit fwc addr be120000 cmd 90 00000090 32bit x 32 bit fwc addr be120000 cmd ff 000000ff 32bit x 32 bit fwc addr be130000 cmd 90 00000090 32bit x 32 bit fwc addr be130000 cmd ff 000000ff 32bit x 32 bit fwc addr be140000 cmd 90 00000090 32bit x 32 bit fwc addr be140000 cmd ff 000000ff 32bit x 32 bit fwc addr be150000 cmd 90 00000090 32bit x 32 bit fwc addr be150000 cmd ff 000000ff 32bit x 32 bit fwc addr be160000 cmd 90 00000090 32bit x 32 bit fwc addr be160000 cmd ff 000000ff 32bit x 32 bit fwc addr be170000 cmd 90 00000090 32bit x 32 bit fwc addr be170000 cmd ff 000000ff 32bit x 32 bit fwc addr be180000 cmd 90 00000090 32bit x 32 bit fwc addr be180000 cmd ff 000000ff 32bit x 32 bit fwc addr be190000 cmd 90 00000090 32bit x 32 bit fwc addr be190000 cmd ff 000000ff 32bit x 32 bit fwc addr be1a0000 cmd 90 00000090 32bit x 32 bit fwc addr be1a0000 cmd ff 000000ff 32bit x 32 bit fwc addr be1b0000 cmd 90 00000090 32bit x 32 bit fwc addr be1b0000 cmd ff 000000ff 32bit x 32 bit fwc addr be1c0000 cmd 90 00000090 32bit x 32 bit fwc addr be1c0000 cmd ff 000000ff 32bit x 32 bit fwc addr be1d0000 cmd 90 00000090 32bit x 32 bit fwc addr be1d0000 cmd ff 000000ff 32bit x 32 bit fwc addr be1e0000 cmd 90 00000090 32bit x 32 bit fwc addr be1e0000 cmd ff 000000ff 32bit x 32 bit fwc addr be1f0000 cmd 90 00000090 32bit x 32 bit fwc addr be1f0000 cmd ff 000000ff 32bit x 32 bit fwc addr be200000 cmd 90 00000090 32bit x 32 bit fwc addr be200000 cmd ff 000000ff 32bit x 32 bit fwc addr be210000 cmd 90 00000090 32bit x 32 bit fwc addr be210000 cmd ff 000000ff 32bit x 32 bit fwc addr be220000 cmd 90 00000090 32bit x 32 bit fwc addr be220000 cmd ff 000000ff 32bit x 32 bit fwc addr be230000 cmd 90 00000090 32bit x 32 bit fwc addr be230000 cmd ff 000000ff 32bit x 32 bit fwc addr be240000 cmd 90 00000090 32bit x 32 bit fwc addr be240000 cmd ff 000000ff 32bit x 32 bit fwc addr be250000 cmd 90 00000090 32bit x 32 bit fwc addr be250000 cmd ff 000000ff 32bit x 32 bit fwc addr be260000 cmd 90 00000090 32bit x 32 bit fwc addr be260000 cmd ff 000000ff 32bit x 32 bit fwc addr be270000 cmd 90 00000090 32bit x 32 bit fwc addr be270000 cmd ff 000000ff 32bit x 32 bit fwc addr be280000 cmd 90 00000090 32bit x 32 bit fwc addr be280000 cmd ff 000000ff 32bit x 32 bit fwc addr be290000 cmd 90 00000090 32bit x 32 bit fwc addr be290000 cmd ff 000000ff 32bit x 32 bit fwc addr be2a0000 cmd 90 00000090 32bit x 32 bit fwc addr be2a0000 cmd ff 000000ff 32bit x 32 bit fwc addr be2b0000 cmd 90 00000090 32bit x 32 bit fwc addr be2b0000 cmd ff 000000ff 32bit x 32 bit fwc addr be2c0000 cmd 90 00000090 32bit x 32 bit fwc addr be2c0000 cmd ff 000000ff 32bit x 32 bit fwc addr be2d0000 cmd 90 00000090 32bit x 32 bit fwc addr be2d0000 cmd ff 000000ff 32bit x 32 bit fwc addr be2e0000 cmd 90 00000090 32bit x 32 bit fwc addr be2e0000 cmd ff 000000ff 32bit x 32 bit fwc addr be2f0000 cmd 90 00000090 32bit x 32 bit fwc addr be2f0000 cmd ff 000000ff 32bit x 32 bit fwc addr be300000 cmd 90 00000090 32bit x 32 bit fwc addr be300000 cmd ff 000000ff 32bit x 32 bit fwc addr be310000 cmd 90 00000090 32bit x 32 bit fwc addr be310000 cmd ff 000000ff 32bit x 32 bit fwc addr be320000 cmd 90 00000090 32bit x 32 bit fwc addr be320000 cmd ff 000000ff 32bit x 32 bit fwc addr be330000 cmd 90 00000090 32bit x 32 bit fwc addr be330000 cmd ff 000000ff 32bit x 32 bit fwc addr be340000 cmd 90 00000090 32bit x 32 bit fwc addr be340000 cmd ff 000000ff 32bit x 32 bit fwc addr be350000 cmd 90 00000090 32bit x 32 bit fwc addr be350000 cmd ff 000000ff 32bit x 32 bit fwc addr be360000 cmd 90 00000090 32bit x 32 bit fwc addr be360000 cmd ff 000000ff 32bit x 32 bit fwc addr be370000 cmd 90 00000090 32bit x 32 bit fwc addr be370000 cmd ff 000000ff 32bit x 32 bit fwc addr be380000 cmd 90 00000090 32bit x 32 bit fwc addr be380000 cmd ff 000000ff 32bit x 32 bit fwc addr be390000 cmd 90 00000090 32bit x 32 bit fwc addr be390000 cmd ff 000000ff 32bit x 32 bit fwc addr be3a0000 cmd 90 00000090 32bit x 32 bit fwc addr be3a0000 cmd ff 000000ff 32bit x 32 bit fwc addr be3b0000 cmd 90 00000090 32bit x 32 bit fwc addr be3b0000 cmd ff 000000ff 32bit x 32 bit fwc addr be3c0000 cmd 90 00000090 32bit x 32 bit fwc addr be3c0000 cmd ff 000000ff 32bit x 32 bit fwc addr be3d0000 cmd 90 00000090 32bit x 32 bit fwc addr be3d0000 cmd ff 000000ff 32bit x 32 bit fwc addr be3e0000 cmd 90 00000090 32bit x 32 bit fwc addr be3e0000 cmd ff 000000ff 32bit x 32 bit fwc addr be3f0000 cmd 90 00000090 32bit x 32 bit fwc addr be3f0000 cmd ff 000000ff 32bit x 32 bit fwc addr be000000 cmd ff 000000ff 32bit x 32 bit 4 MiB *** Warning - bad CRC, using default environment
In: serial Out: serial Err: serial Net: pcnet#0 IDE: Bus 0: not available 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 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 malta #
On 5 July 2016 at 03:08, Alon Bar-Lev alon.barlev@gmail.com 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@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

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 daniel.schwierzeck@gmail.com 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@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 alon.barlev@gmail.com 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@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
--
- Daniel

Am 05.07.2016 um 18:50 schrieb Alon Bar-Lev:
Thank you so much! Erase does not complain any more.
please do not top-quote on a mailing list.
However, write is not working.
Result is always something like: be040000: 00800080 00800080 00800080 00800080 ................
hm, I can't reproduce that:
$ qemu-system-mips -M malta -cpu 24Kc -m 256 -nographic -drive if=pflash,file=/work/u-boot-mips/pflash.bin,format=raw -netdev user,id=ubtest,tftp=/work/u-boot-mips -device pcnet,netdev=ubtest
malta # md BE040000 4 be040000: ffffffff ffffffff ffffffff ffffffff ................ malta # erase BE040000 +10000
. done Erased 1 sectors malta # md BE040000 4 be040000: ffffffff ffffffff ffffffff ffffffff ................
and saveenv works for me too:
U-Boot 2016.07-rc3-00016-gbf4c649 (Jul 05 2016 - 18:55:54 +0200)
Board: MIPS Malta CoreLV DRAM: 256 MiB Flash: 4 MiB *** Warning - bad CRC, using default environment
In: serial@3f8 Out: serial@3f8 Err: serial@3f8 Net: pcnet#0 IDE: Bus 0: not available malta # md be3e0000 be3e0000: ffffffff ffffffff ffffffff ffffffff ................ be3e0010: ffffffff ffffffff ffffffff ffffffff ................ be3e0020: ffffffff ffffffff ffffffff ffffffff ................ be3e0030: ffffffff ffffffff ffffffff ffffffff ................ be3e0040: ffffffff ffffffff ffffffff ffffffff ................ be3e0050: ffffffff ffffffff ffffffff ffffffff ................ be3e0060: ffffffff ffffffff ffffffff ffffffff ................ be3e0070: ffffffff ffffffff ffffffff ffffffff ................ be3e0080: ffffffff ffffffff ffffffff ffffffff ................ be3e0090: ffffffff ffffffff ffffffff ffffffff ................ be3e00a0: ffffffff ffffffff ffffffff ffffffff ................ be3e00b0: ffffffff ffffffff ffffffff ffffffff ................ be3e00c0: ffffffff ffffffff ffffffff ffffffff ................ be3e00d0: ffffffff ffffffff ffffffff ffffffff ................ be3e00e0: ffffffff ffffffff ffffffff ffffffff ................ be3e00f0: ffffffff ffffffff ffffffff ffffffff ................ malta # save Saving Environment to Flash... Un-Protected 2 sectors Erasing Flash... .. done Erased 2 sectors Writing to Flash... done Protected 2 sectors malta # md be3e0000 be3e0000: cc07705a 62617564 72617465 3d313135 ..pZbaudrate=115 be3e0010: 32303000 65746861 63743d70 636e6574 200.ethact=pcnet be3e0020: 23300065 74686164 64723d35 323a3534 #0.ethaddr=52:54 be3e0030: 3a30303a 31323a33 343a3536 00666474 :00:12:34:56.fdt be3e0040: 636f6e74 726f6c61 6464723d 38666666 controladdr=8fff be3e0050: 37373030 00737464 6572723d 73657269 7700.stderr=seri be3e0060: 616c4033 66380073 7464696e 3d736572 al@3f8.stdin=ser be3e0070: 69616c40 33663800 7374646f 75743d73 ial@3f8.stdout=s be3e0080: 65726961 6c403366 38000000 00000000 erial@3f8....... be3e0090: 00000000 00000000 00000000 00000000 ................ be3e00a0: 00000000 00000000 00000000 00000000 ................ be3e00b0: 00000000 00000000 00000000 00000000 ................ be3e00c0: 00000000 00000000 00000000 00000000 ................ be3e00d0: 00000000 00000000 00000000 00000000 ................ be3e00e0: 00000000 00000000 00000000 00000000 ................ be3e00f0: 00000000 00000000 00000000 00000000 ................
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?
I'm also using master of U-Boot and Qemu

On 5 July 2016 at 20:05, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
Am 05.07.2016 um 18:50 schrieb Alon Bar-Lev:
Thank you so much! Erase does not complain any more.
please do not top-quote on a mailing list.
Sorry.
However, write is not working.
Result is always something like: be040000: 00800080 00800080 00800080 00800080 ................
hm, I can't reproduce that:
$ qemu-system-mips -M malta -cpu 24Kc -m 256 -nographic -drive if=pflash,file=/work/u-boot-mips/pflash.bin,format=raw -netdev user,id=ubtest,tftp=/work/u-boot-mips -device pcnet,netdev=ubtest
malta # md BE040000 4 be040000: ffffffff ffffffff ffffffff ffffffff ................ malta # erase BE040000 +10000
. done Erased 1 sectors malta # md BE040000 4 be040000: ffffffff ffffffff ffffffff ffffffff ................
Can you please try to copy from sector in flash to another as I've shown? It seems to happen especially in this case. Maybe it is just impossible...
<snip>

Am 05.07.2016 um 19:17 schrieb Alon Bar-Lev:
On 5 July 2016 at 20:05, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
Am 05.07.2016 um 18:50 schrieb Alon Bar-Lev:
Thank you so much! Erase does not complain any more.
please do not top-quote on a mailing list.
Sorry.
However, write is not working.
Result is always something like: be040000: 00800080 00800080 00800080 00800080 ................
hm, I can't reproduce that:
$ qemu-system-mips -M malta -cpu 24Kc -m 256 -nographic -drive if=pflash,file=/work/u-boot-mips/pflash.bin,format=raw -netdev user,id=ubtest,tftp=/work/u-boot-mips -device pcnet,netdev=ubtest
malta # md BE040000 4 be040000: ffffffff ffffffff ffffffff ffffffff ................ malta # erase BE040000 +10000
. done Erased 1 sectors malta # md BE040000 4 be040000: ffffffff ffffffff ffffffff ffffffff ................
Can you please try to copy from sector in flash to another as I've shown? It seems to happen especially in this case. Maybe it is just impossible...
<snip>
I think it's a bug in flash_write_cfibuffer(). It looks like the flash status value is written to the destination address. It works if you disable CONFIG_SYS_FLASH_USE_BUFFER_WRITE in include/configs/malta.h.

On 5 July 2016 at 20:34, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
Am 05.07.2016 um 19:17 schrieb Alon Bar-Lev:
On 5 July 2016 at 20:05, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
Can you please try to copy from sector in flash to another as I've shown? It seems to happen especially in this case. Maybe it is just impossible...
<snip>
I think it's a bug in flash_write_cfibuffer(). It looks like the flash status value is written to the destination address. It works if you disable CONFIG_SYS_FLASH_USE_BUFFER_WRITE in include/configs/malta.h.
Thank you so much for your help. I can confirm this is working, however, it takes about forever to complete. For now I will copy to ram and back to flash.
Regards, Alon

On 5 July 2016 at 19:10, Daniel Schwierzeck daniel.schwierzeck@gmail.com 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:
Hi, Thanks again. How do we merge this fix? Regards, Alon
---
--- 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]);

Hi Alon, Hi Daniel,
On 10.07.2016 22:50, Alon Bar-Lev wrote:
On 5 July 2016 at 19:10, Daniel Schwierzeck daniel.schwierzeck@gmail.com 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:
Hi, Thanks again. How do we merge this fix?
Daniel, could you please send a proper patch (non-inlined) for this so that I can push it to upstream? Or did I miss this patch?
Thanks, Stefan

Hi Stefan,
2016-07-18 10:38 GMT+02:00 Stefan Roese sr@denx.de:
Daniel, could you please send a proper patch (non-inlined) for this so that I can push it to upstream? Or did I miss this patch?
done
http://patchwork.ozlabs.org/patch/649511/
participants (3)
-
Alon Bar-Lev
-
Daniel Schwierzeck
-
Stefan Roese