觉得这个板子最大的优点是什么,肯定是NAND了,这样可以不运行卡上的系统,稳定性也得到很大的提升,用卡做系统就像树莓派完全胜任,价格也不高[最讨厌这样的了,把好板子价格做烂掉].
根本基本习惯,去看看dts上有没有配置,找不到NAND相关的字段,那么看看menuconfig,发现这个配置是N的,所以,要先打开之:
然后查看一下文档,可见目录在Documentation/mtd/nand下找.发现这个驱动没什么特别,那就到配置方法找,目录在Documentation/devicetree/bindings/mtd/sunxi-nand.txt.发现这个字段还是挺复杂的,如下:
Allwinner NAND Flash Controller (NFC) Required properties: - compatible : "allwinner,sun4i-a10-nand". - reg : shall contain registers location and length for data and reg. - interrupts : shall define the nand controller interrupt. - #address-cells: shall be set to 1. Encode the nand CS. - #size-cells : shall be set to 0. - clocks : shall reference nand controller clocks. - clock-names : nand controller internal clock names. Shall contain : * "ahb" : AHB gating clock * "mod" : nand controller clock Optional children nodes: Children nodes represent the available nand chips. Optional properties: - allwinner,rb : shall contain the native Ready/Busy ids. or - rb-gpios : shall contain the gpios used as R/B pins. - nand-ecc-mode : one of the supported ECC modes ("hw", "hw_syndrome", "soft", "soft_bch" or "none") see Documentation/devicetree/mtd/nand.txt for generic bindings. Examples: nfc: nand@01c03000 { 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"; nand@0 { reg = <0>; allwinner,rb = <0>; nand-ecc-mode = "soft_bch"; }; };
可见配置一个字段,然后还要配置nand_pins_a等等,烦人啊.不过这样,就要看原理图了这个是蜂鸟开发板的:
这个是CubieTruck的:
对于CubieTruck用的是K9G8G08U0A,而蜂鸟开发板是H27UBG8T2BTR,他们不尽相同,但都是单片选单状态的.引脚上调整也是比较少的,这样估计就时序改改就好了.另外根据官方Wiki说要保持NAND可用要使用3.4内核,我是不太信的,反正试试看.不行就改驱动.
首先编辑arch/arm/boot/dts/sun7i-a20.dtsi,添加A20通用NAND驱动.
nfc: nand @ 01c03000 { compatible = "allwinner,sun4i-nand"; reg = <0x01c03000 0x1000>; interrupts = <0 37 4>; clocks = <&ahb_gates 13>, <&nand_clk>; clock-names = "ahb_clk", "sclk"; #address-cells = <1>; #size-cells = <0>; status = "disabled"; };
在同一个文件,再添加引脚绑定:
nand_pins_a: nand_base0 @ 0 { allwinner,pins = "PC0", "PC1", "PC2", "PC5", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PC16", allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; }; nand_cs0_pins_a: nand_cs @ 0 { allwinner,pins = "PC4"; allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; }; nand_cs1_pins_a: nand_cs @ 1 { allwinner,pins = "PC3"; allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; }; nand_cs2_pins_a: nand_cs @ 2 { allwinner,pins = "PC17"; allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; }; nand_cs3_pins_a: nand_cs @ 3 { allwinner,pins = "PC18"; allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; }; nand_cs4_pins_a: nand_cs @ 4 { allwinner,pins = "PC19"; allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; }; nand_cs5_pins_a: nand_cs @ 5 { allwinner,pins = "PC20"; allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; }; nand_cs6_pins_a: nand_cs @ 6 { allwinner,pins = "PC21"; allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; }; nand_cs7_pins_a: nand_cs @ 7 { allwinner,pins = "PC22"; allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; }; nand_rb0_pins_a: nand_rb @ 0 { allwinner,pins = "PC6"; allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; }; nand_rb1_pins_a: nand_rb @ 1 { allwinner,pins = "PC7"; allwinner,function = "nand0"; allwinner,drive = <0>; allwinner,pull = <0>; };
然后到设备相关的文件处,arch/arm/boot/dts/sun7i-a20-hummingbird.dts添加驱动绑定:
nfc: nand @ 01c03000 { pinctrl-names = "default"; pinctrl-0 = <&nand_pins_a &nand_cs0_pins_a &nand_rb0_pins_a>; status = "okay"; nand at 0 { #address-cells = <2>; #size-cells = <2>; reg = <0>; allwinner,rb = <0>; nand-ecc-mode = "hw"; onfi,nand-timing-mode = <0x1f>; nand-ecc-strength = <40>; nand-ecc-step-size = <1024>; }; };
然后编译,替换uImage[打开NAND],还有dtb文件,发现什么反应都没有:
root@Tater-ARM:~# dmesg | grep mtd root@Tater-ARM:~# dmesg | grep nand root@Tater-ARM:~#
的确让人很无语,为什么按照文档就不行,无奈只有查sunxi_nand.c驱动,发现1411 - 1414行定义如下:
难怪不行,原来名字改了,是sun4i-a10-nand不是sun4i-nand,编译并替换重启,看到如下信息:
[ 0.909397] sunxi_nand 1c03000.nand: failed to retrieve mod clk [ 0.915422] sunxi_nand: probe of 1c03000.nand failed with error -2
总算有设备,只是出错罢了,好像是无法检查到MOD Clk,究竟MOD Clk是什么呢?出错代码位置:
nfc->mod_clk = devm_clk_get(dev, "mod"); if (IS_ERR(nfc->mod_clk)) { dev_err(dev, "failed to retrieve mod clk "); ret = PTR_ERR(nfc->mod_clk); goto out_ahb_clk_unprepare; }
现在看来是时钟问题,这个留给下回分解吧.
你好,博主现在还有 A20开发板的资料吗?我找了好久,一直没结果。
可以给我一个你的联系方式吗?我的QQ 839281922.
感谢感谢
@A20蜂鸟开发板 现在可以用mainline移植