码迷,mamicode.com
首页 > 系统相关 > 详细

WyBox使用shell脚本检测io口是否正常

时间:2016-02-27 23:33:59      阅读:667      评论:0      收藏:0      [点我收藏+]

标签:

1、 修改mt7620a.dts文件,把gpio管脚复用全都定义为通用gpio

/dts-v1/;

/include/ "mt7620a.dtsi"

/ {
    compatible = "ralink,mt7620a-eval-board", "ralink,mt7620a-soc";
    model = "Ralink MT7620a + MT7610e evaluation board";

    palmbus@10000000 {
        gpio1: gpio@638 {
            status = "okay";
        };
        gpio2: gpio@660 {
            status = "okay";
        };
        gpio3: gpio@688 {
            status = "okay";
        };
                
        spi@b00 {
            status = "okay";

            m25p80@0 {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "en25q64";
                reg = <0 0>;
                linux,modalias = "m25p80", "en25q64";
                spi-max-frequency = <10000000>;

                partition@0 {
                    label = "u-boot";
                    reg = <0x0 0x30000>;
                    read-only;
                };

                partition@30000 {
                    label = "u-boot-env";
                    reg = <0x30000 0x10000>;
                    read-only;
                };

                factory: partition@40000 {
                    label = "factory";
                    reg = <0x40000 0x10000>;
                    read-only;
                };

                partition@50000 {
                    label = "firmware";
                    reg = <0x50000 0x1fb0000>;
                };
            };
        };
    };

    pinctrl {
        state_default: pinctrl0 {
            gpio {
                ralink,group = "i2c", "uartf", "wdt", "pa", "mdio", 
                "rgmii1", "pcie","spi refclk","ephy", "nd_sd", "rgmii2","wled";
                ralink,function = "gpio";
            };
        };
    };

    
    ethernet@10100000 {
        mtd-mac-address = <&factory 0x4>;
        ralink,port-map = "llllw";
    };

    gpio-keys-polled {
        compatible = "gpio-keys";
        #address-cells = <1>;
        #size-cells = <0>;
        poll-interval = <20>;
        s2 {
            label = "S2";
            gpios = <&gpio0 1 1>;
            linux,code = <0x100>;
        };
        s3 {
            label = "S3";
            gpios = <&gpio0 2 1>;
            linux,code = <0x101>;
        };
    };
};

2、 将如下放shell脚本放在/root文件夹下,命名为test,依次执行如下,就可以将gpio0 ~ gpio72都设为输出,输出为低电平。

#!/bin/sh

cd /sys/class/gpio

for i in 0 `seq 72`
do
        echo $i >/sys/class/gpio/export
        echo out >./gpio$i/direction
        #echo out >/sys/devices/10000000.palmbus/10000600.gpio/gpio/gpio$i/direction
        echo 0 >./gpio$i/value
done
root@OpenWrt:~# 
root@OpenWrt:~# chmod 777 test
root@OpenWrt:~# ./test

3、可以得到如下管脚可以正常使用(打钩):

技术分享

技术分享

 

问题:

1、不知gpio7被什么占用了,会出现如下问题

技术分享

2、 其他的可以创建gpio的io不知道为什么,手动敲入命令行没反应,但直接执行脚本命令就有效果。

参考:

http://blog.sina.com.cn/s/blog_9d074aae01012ytf.html

WyBox使用shell脚本检测io口是否正常

标签:

原文地址:http://www.cnblogs.com/smbx-ztbz/p/5223795.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!