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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WyBox使用shell脚本检测io口是否正常相关的知识,希望对你有一定的参考价值。

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

/dts-v1/;

/include/ "mt7620a.dtsi"

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

    [email protected]10000000 {
        gpio1: [email protected]638 {
            status = "okay";
        };
        gpio2: [email protected]660 {
            status = "okay";
        };
        gpio3: [email protected]688 {
            status = "okay";
        };
                
        [email protected] {
            status = "okay";

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

                [email protected]0 {
                    label = "u-boot";
                    reg = <0x0 0x30000>;
                    read-only;
                };

                [email protected]30000 {
                    label = "u-boot-env";
                    reg = <0x30000 0x10000>;
                    read-only;
                };

                factory: [email protected]40000 {
                    label = "factory";
                    reg = <0x40000 0x10000>;
                    read-only;
                };

                [email protected]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";
            };
        };
    };

    
    [email protected]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

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

技术分享

技术分享

 

问题:

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

技术分享

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

参考:

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

以上是关于WyBox使用shell脚本检测io口是否正常的主要内容,如果未能解决你的问题,请参考以下文章

[shell]通过ping检测整个网段IP的网络状态脚本

shell脚本检测网络是否畅通

Linux系统shell脚本之监控httpd服务

怎么用js脚本判断自动检测网络连接是不是正常?

shell 练习(13) —— 监控 httpd 进程数是否异常

怎样一键检测域名或url是否正常解析并传输