制作A20蜂鸟开发板干净系统[修复NAND驱动B]

之前修复NAND驱动遇到了时钟不能用的问题,究极原因是缺了mod时钟驱动,然后我们在内核中[准确来说是驱动树]必须打开这个时钟,编辑dts文件,使用如下时钟[AHB,MOD]:

compatible = "allwinner,sun4i-a10-nand";
reg = <0x01c03000 0x1000>;
interrupts = <0 37 1>;
clocks = <&ahb_gates 13>, <&nand_clk>;
clock-names = "ahb", "mod";
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&nand_pins_a &nand_cs0_pins_a &nand_rb0_pins_a>;
status = "okay";

 其实是原来的AHB_CLK这个名字也废弃了,详细看看dts的其他字段的描述就知道了.然后重启查看日志,发现如下错误:

root@Tater-ARM:~# dmesg | grep nand
[ 0.923309] nand: Could not find valid ONFI parameter page; aborting
[ 0.929719] nand: device found, Manufacturer ID: 0xad, Chip ID: 0xd7
[ 0.936086] nand: Hynix NAND 4GiB 3,3V 8-bit
[ 0.940354] nand: 4096 MiB, MLC, erase size: 2048 KiB, page size: 4096, OOB size: 128
[ 0.948196] sunxi_nand 1c03000.nand: ECC init failed: -22
[ 0.953600] sunxi_nand 1c03000.nand: failed to init nand chips
[ 0.959498] sunxi_nand: probe of 1c03000.nand failed with error -22
root@Tater-ARM:~#

发现信息不对,自然ECC是不可能执行的.对照了一下板子,原来不是H27UBG8T2BTR,而是H27UBG8T2CTR,所以删除原来H27UBG8T2BTR数组,新建一个关于我NAND的数据[详情还是要看手册啊.]

 {"H27UBG8T2CTR 4GiB 3.3V 8-bit",
                { .id = {0xad, 0xd7, 0x94, 0x91, 0x60, 0x44} },
                  SZ_8K, SZ_4K, SZ_2M, 0, 6, 640, NAND_ECC_INFO(40, SZ_1K),

然后重启就能识别了,并且没有ECC错误:

root@Tater-ARM:~# dmesg | grep nand
[    0.909993] nand: device found, Manufacturer ID: 0xad, Chip ID: 0xd7
[    0.916406] nand: Hynix H27UBG8T2CTR 4GiB 3.3V 8-bit
[    0.921387] nand: 4096 MiB, MLC, erase size: 2048 KiB, page size: 8192, OOB size: 640

另外/dev/mtd0[最后一个字符是数字0]也生成了,安装mtd-utils就可以进行测试,我这闪存质量真不咋的.

nandtest

因为NAND坏块在Linux中不支持擦除,所以,执行flash_erase[all]时候会出错,是正常的.比如我这个NAND尾端都是有问题的:

nand_eraseall你可以在内核上屏蔽掉,就是把块数量限定在一个保险的数量,比如1800等等,或者U-Boot中擦掉,等等方法,如果真有强迫症,那你买最好的闪存嘛.

发表评论

电子邮件地址不会被公开。 必填项已用*标注