Wind River Support Network

HomeDefectsLIN6-9303
Fixed

LIN6-9303 : Flash write/erase commands completes before they are actually finished

Created: Jan 23, 2015    Updated: Dec 3, 2018
Resolved Date: Feb 26, 2015
Found In Version: 6.0.0.16
Fix Version: 6.0.0.18
Severity: Standard
Applicable for: Wind River Linux 6
Component/s: Kernel

Description

We have found a bug in the xilinx-zynq BSP in WR Linux 6 RCPL 13. 
The problem is seen when erasing a flash sector/block followed by an immediate system reset. After reboot the flash sector/block is not erased. 

This can be reproduced using the flash_eraseall command (from mtd-utils package) on a /dev/mtdX partition directly followed by a board reset using "echo b > /proc/sysrq-trigger" command. 
--------------- 
Example (on a 2 MiB mtd partition): 

First, write zeros to the mtd partition and verify: 

# dd if=/dev/zero of=/dev/mtd5 
dd: writing to '/dev/mtd5': No space left on device 
4097+0 records in 
4096+0 records out 
2097152 bytes (2.1 MB) copied, 1.15371 s, 1.8 MB/s 

# hexdump -C /dev/mtd5 
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 
* 
00200000 

Second, erase the mtd partition followed by an immediate system reset: 

# flash_eraseall /dev/mtd5 ; echo b > /proc/sysrq-trigger Erasing 512 Kibyte @ 200000 - 100% complete. 
902.416594] SysRq : Resetting 

After reboot, dump the mtd partition: 
# hexdump -C /dev/mtd5 
00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 
* 
00180000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 
* 
00200000 

As seen above the last flash sector/block (512 KiB) is still filled with zeros! 
--------------- 
We have identified the problem to the kernel code in drivers/mtd/devices/m25p80.c, function erase_sector(), where we see that the driver waits for the previous command to be finished but doesn't wait for the current command to be finished. It seems that the erase_chip() and m25p80_write() functions has same issues. 
The flash erase (and write) should be synchronous and not complete before finished. 

In the latest kernel git repo the following commit seems to fix the same issue: 
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/mtd/spi-nor/spi-nor.c?id=dfa9c0cba4ea20e766bbb4f89152b05d00ab9ab3 

We need a fix for this a.s.a.p. 

Other Downloads


Live chat
Online