iMX6ULL unstable Write operation on UBIFS with NAND

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

iMX6ULL unstable Write operation on UBIFS with NAND

跳至解决方案
2,209 次查看
hsgim
Contributor II

 

Custom Board with i.MX6ULL 14x14

U-Boot : U-Boot 2022.04
https://github.com/nxp-imx/uboot-imx : lf_v2022.04 Branch

Kernel : 5.15.52
https://github.com/nxp-imx/linux-imx : lf-5.15.y Branch

NAND : hynix 2Gb SLC NAND Flash H27U2G8F2CTR

DTS :
&gpmi {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpmi_nand_1>; //same as one in imx6ull-14x14-evk-gpmi-weim.dts
status = "okay";
nand-on-flash-bbt;
fsl,use-minimum-ecc; //with or without this, results not differ
}

Kernel config : Kernel.config.txt attached

 

Hello,

I'm struggling with using UBIFS on NAND, especially in write operations.
When I test with small files, I don't see the problem as easily.
So I'm testing with a 10MB large file.

I don't see the problem at the moment of writing.
I always did "sync" after all the copy operations like "cp 10mb.bin a1; sync".
But after rebooting, when I read the file again (cp a1 /tmp/), some areas are read as "0xFF".
I guess it was not written properly.

When I tested with an initramfs without UBIFS rootfs,
I made fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.zst.u-boot of about 50MB size.
I "nand write" the file on U-Boot, it worked well.
On U-Boot, NAND operations have never failed.
So I guess there doesn't seem to be any soldering or H/W issue with the board.

This is the error log.
Thank you for your review.

[ 100.976731] UBIFS error (ubi2:0 pid 507): ubifs_decompress: cannot decompress 1829 bytes, compressor lzo, error -22
[ 100.987376] UBIFS error (ubi2:0 pid 507): do_readpage: bad data node (block 2224, inode 6274)
[ 101.001068] magic 0x6101831
[ 101.004903] crc 0xc6ae696b
[ 101.008666] node_type 1 (data node)
[ 101.012683] group_type 0 (no node group)
[ 101.017102] sqnum 73699
[ 101.020423] len 1877
[ 101.023658] key (6274, data, 2224)
[ 101.028136] size 4096
[ 101.031368] compr_typ 1
[ 101.034362] data size 1829
[ 101.037594] data (length = 1829):
[ 101.041005] 00000000: 03 24 af 09 00 00 00 60 00 06 0c 00 37 00 00 00 30 af 09 70 01 07 00 00 00 0c 00 18 00 00 00 6c
[ 101.051743] 00000020: 29 3c 00 7d 03 74 29 3c 00 7d 03 a8 29 3c 00 7d 03 b0 29 3c 00 7e 03 f8 b1 28 3c 01 7e 03 0c b2
[ 101.062470] 00000040: 28 3c 00 7f 03 60 49 1c dc 0d 03 0e 00 9c 02 00 00 7c 01 0e 0b 00 00 00 01 00 0e 00 e5 02 00 00
[ 101.073191] 00000060: 6c 49 1c 00 20 dc 01 06 b2 02 00 00 8c 49 1c 00 1d dc 01 06 91 02 00 00 ac 49 1c 00 1f de 01 d8
[ 101.083916] 00000080: 27 c8 09 04 00 00 00 04 00 f1 ff 7d 0b cc 29 7c 01 7d 0f e4 2d fe 01 14 b5 2c 3e 02 68 4a 2c 3c
[ 101.094638] 000000a0: 02 7d 01 1a dd 0b e3 2d 7c 01 7d 09 80 2d fd 00 84 29 fc 00 7d 0f e4 29 7c 00 7d 05 e8 29 3c 00
[ 101.105360] 000000c0: 7e 03 44 b6 28 fc 01 7d 03 4c 29 3c 00 7d 03 60 29 3c 00 7d 03 68 29 3c 00 7d 03 d2 2d 3e 00 c8
[ 101.116078] 000000e0: b7 2c 3d 01 d8 29 3c 00 7e 05 18 bc 2c 7d 00 40 29 3c 00 7e 03 ec bd 2c 7e 00 0c be 28 3c 00 7e
[ 101.126800] 00000100: 03 6c bf 28 3c 00 7d 11 7c 29 3c 00 7e 03 c0 c0 2c 7d 00 c8 29 3c 00 7e 03 94 c1 2c 7d 00 9c 29
[ 101.137519] 00000120: 3c 00 7d 03 e8 29 3c 00 7d 0b f0 29 3c 00 7e 03 40 c2 2c fd 00 48 29 3c 00 0a ed 27 00 00 8d c2
[ 101.148251] 00000140: 09 00 68 00 00 00 02 dd 57 ec 29 7c 00 7d 09 f4 29 3c 00 7e 09 48 c4 2c 3d 01 50 29 3c 00 7e 03
[ 101.158981] 00000160: 4c c5 2c 7d 00 5c 29 3c 00 7d 03 d0 29 3c 00 7d 0b d8 29 3c 00 7e 03 58 c6 2c fd 00 60 29 3c 00
[ 101.169712] 00000180: 7d 03 9c 29 3c 00 7d 07 a4 29 3c 00 7d 03 e0 29 3c 00 7d 03 e8 29 3c 00 7e 03 84 c7 2c 7d 01 98
[ 101.180438] 000001a0: 29 3c 00 7e 03 3c c8 2c 7d 00 50 29 3c 00 7e 03 24 c9 2c 7d 00 3c 29 3c 00 7d 03 90 29 3c 00 7d
[ 101.191160] 000001c0: 0f 98 29 3c 00 7e 03 c0 ca 2c fd 00 e0 29 3c 00 7d 03 f8 29 3c 00 7e 07 00 cb 28 bc 00 7d 03 58
[ 101.201883] 000001e0: 2d 3e 00 70 4b 28 fc 0d 01 dc 26 00 00 7d 01 19 dc 6f 06 f4 26 00 00 8c 4b 1c 00 14 dc 01 06 00
[ 101.212604] 00000200: 27 00 00 a0 4b 1c 00 17 dc 01 06 0c 27 00 00 b8 4b 1c 00 15 dc 01 02 18 27 00 00 d0 29 3c 00 06
[ 101.223326] 00000220: 24 27 00 00 e8 4b 1c 00 10 dc 03 02 30 27 00 00 f8 29 3c 00 03 3c 27 00 00 08 4c 28 fc 00 05 48
[ 101.234047] 00000240: 27 00 00 20 4c 1c 00 64 12 7c 91 06 60 27 00 00 3c 4c 1c 00 08 dc 07 06 6c 27 00 00 44 4c 1c 00
[ 101.244774] 00000260: 13 dc 01 06 78 27 00 00 58 4c 1c 00 16 dc 01 02 2b 0f 00 00 70 29 3c 01 02 96 03 00 00 88 29 3c
[ 101.255498] 00000280: 00 06 75 03 00 00 a0 4c 1c 00 21 dc 05 06 a1 03 00 00 c4 4c 1c 00 22 dc 01 06 8b 03 00 00 e8 4c
[ 101.266223] 000002a0: 1c 00 0d dc 01 06 80 03 00 00 f8 4c 1c 00 25 dc 01 06 f0 02 00 00 20 4d 1c 00 2a dc 01 7e a5 4c
[ 101.276945] 000002c0: 4d 2c be 14 6c 4d 28 3c 01 7c a5 02 90 4d 1c 00 12 dc 05 7e ad a4 4d 28 fc 02 7f 31 f0 27 24 d0
[ 101.287668] 000002e0: a8 03 13 00 f5 27 00 00 7d 01 6c 9d 05 13 9d c1 e5 29 bc 11 7d 39 e6 29 3e 00 03 28 c8 07 29 fe
[ 101.298390] 00000300: 15 b8 4d 74 27 7d 02 0e 9d cb 64 2d be 07 c8 cd 28 3c 08 7e 09 10 ce 28 3c 00 7e 11 58 cf 28 3c
[ 101.309113] 00000320: 00 7d 03 8c 29 3c 00 7e 03 1c d2 28 7c 00 7e 01 30 4e 28 bc 01 7c 21 7c 01 fc 47 7e c7 4c 4e 28
[ 101.319834] 00000340: 3c 07 7e 21 68 4e 28 bc 07 7c 21 02 80 4e 1c 00 0e 9f 1d 0e 00 11 31 3d 03 90 29 7c 01 07 1e 28
[ 101.330554] 00000360: 00 00 59 d2 09 00 48 02 bc 8d 7d 13 58 2d 3d 02 98 29 3c 00 7d 03 a0 29 3c 00 7e 15 6c d4 28 fc
[ 101.341276] 00000380: 02 9c 03 29 3c 00 06 c4 24 00 00 a1 d4 09 00 c8 29 3e 13 3c d5 2c bd 00 68 29 3c 00 7d 09 88 29
[ 101.351996] 000003a0: 3c 00 7d 09 8c 29 3c 00 7d 03 c0 29 3c 00 7d 03 c4 29 3c 00 7e 03 08 d6 2c 7d 01 10 29 3c 00 7d
[ 101.362722] 000003c0: 03 3c 29 3c 00 7d 07 44 29 3c 00 7d 03 70 29 3c 00 7d 03 78 29 3c 00 7d 03 b0 29 3c 00 7d 03 b8
[ 101.373443] 000003e0: 29 3c 00 7d 03 f0 29 3c 00 7d 03 f8 29 3c 00 7e 03 30 d7 2c 7d 02 38 29 3c 00 7d 03 70 29 3c 00
[ 101.384170] 00000400: 7d 07 78 29 3c 00 7e 03 ac df 2c fe 00 d8 e0 28 3c 00 7e 03 40 e1 2c 3e 00 f4 4f 28 3c 09 7c 71
[ 101.394893] 00000420: 7c 01 fc 8b 7e 71 0c 50 28 bc 0f 7d 85 24 29 3c 00 9c 85 01 50 1c 00 1e dc 49 7f 85 5c 50 1c 27
[ 101.405615] 00000440: bc 0f 7c 85 02 80 50 1c 00 2d dc 03 7c 85 01 b0 50 1c 00 78 4e 7c 8d 7c 85 01 d8 50 1c 00 22 d8
[ 101.416337] 00000460: 21 7c 01 7c 85 02 00 51 1c 00 2c dc 05 7e 85 2c 51 28 3c 24 7c 81 01 4c 51 1c 00 2a fe 24 58 51
[ 101.427060] 00000480: 28 3c 0b 7c 5f 02 68 51 1c 00 11 dc 07 7e 5f 7c 51 28 3c 14 7e 5f 8c 51 28 7d 0c 33 60 11 68 77
[ 101.437778] 000004a0: dc 79 7d 29 50 2d 7e 04 a8 51 28 7c 04 7d 27 68 2d 7d 00 c4 29 3c 00 7d 07 ec 29 3c 00 07 40 28
[ 101.448498] 000004c0: 00 00 ed e1 09 00 2c 03 bc 67 7e 07 50 e3 28 fc 05 7d 05 6a 29 3c 00 7e 03 7c e4 2c 7e 00 18 e5
[ 101.459219] 000004e0: 28 3c 00 7d 03 94 29 3c 00 7d 07 9c 29 3c 00 7d 03 e8 29 3c 00 7d 03 f0 ff ff ff ff ff ff ff ff
[ 101.469940] 00000500: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.480660] 00000520: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.491385] 00000540: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.502107] 00000560: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.512837] 00000580: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.523563] 000005a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.534283] 000005c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.545003] 000005e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.555726] 00000600: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.566447] 00000620: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.577169] 00000640: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.587887] 00000660: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.598616] 00000680: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.609340] 000006a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.620062] 000006c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.630782] 000006e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.641503] 00000700: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 101.652220] 00000720: ff ff ff ff ff
cp: read error: Input/output error

 

标签 (1)
0 项奖励
回复
1 解答
2,162 次查看
kef2
Senior Contributor V

Hi,

I looked at your Hynix datasheet, and yes, it doesn't support block protection, only #WP pin.

On MX30LF4G28AC there's an additional PT pin, which "0" on power up turns block protection feature off (which I believe is my case, though I need to check). And "1" means block protection enabled by default for all blocks, set feature command allows to protect/unprotect some flash areas. 

MX30xx driver is  drivers/mtd/nand/raw/nand_macronix.c. Patch allows to exit from macronix_nand_onfi_init() early. 

 

If U-Boot works well, perhaps something gets wrong with timings. 

在原帖中查看解决方案

4 回复数
2,195 次查看
kef2
Senior Contributor V

Hi,

Newer kernels, 5.15, 6.1, seem having enabled support for NAND chip write protection, which seems to be continuously engaged/disengaged using NAND chip commands. At least it is so with Macronix MX30xxx flash. I don't know if this applies to your Hynix flash, but what I see with identical Macronix chips, everything works well on dual core iMX7D and keeps reporting UBI errors on single core iMX6ULL. I googled and applied patch for Macronix NAND to make write protection feature switchable off using settings in DT. It fixed the issue. 

0 项奖励
回复
2,175 次查看
hsgim
Contributor II

Hi,

Thanks for the reply.

According to "drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c", the write protection is already off and NANDF_WP_B pin is held high (de-asserted).

/* Disable Write-Protection. */
writel(BM_GPMI_CTRL1_DEV_RESET, r->gpmi_regs + HW_GPMI_CTRL1_SET);

As far as I know, a write protection specific command doesn't exist in NAND command set.

According to "drivers/mtd/nand/raw/nand_macronix.c", Macronix NAND supports Block Protection by Protectoin(PT) pin. Do you mean this write protection function specific to Macronix?

Actually, in my tests, write operations sometimes corrupted the root file system and the board failed to boot. That would mean the writing data was targeted to wrong addresses.

BTW, what's the Kernel version of your iMX6ULL board?

Thanks,

标记 (2)
0 项奖励
回复
2,163 次查看
kef2
Senior Contributor V

Hi,

I looked at your Hynix datasheet, and yes, it doesn't support block protection, only #WP pin.

On MX30LF4G28AC there's an additional PT pin, which "0" on power up turns block protection feature off (which I believe is my case, though I need to check). And "1" means block protection enabled by default for all blocks, set feature command allows to protect/unprotect some flash areas. 

MX30xx driver is  drivers/mtd/nand/raw/nand_macronix.c. Patch allows to exit from macronix_nand_onfi_init() early. 

 

If U-Boot works well, perhaps something gets wrong with timings. 

2,124 次查看
hsgim
Contributor II
Hi,
As you mentioned, it seems that the busy_timeout_cycles would be wrong with my NAND.
Thanks for your help.
0 项奖励
回复