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
[email protected]:~#
[email protected]:~# chmod 777 test
[email protected]:~# ./test

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

问题:

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

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

参考:

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

时间: 2024-08-15 21:08:40

WyBox使用shell脚本检测io口是否正常的相关文章

linux shell脚本检测硬盘磁盘空间 邮件报警

使用 http://www.weiruoyu.cn/?p=368 shell脚本监控硬盘空间剩余空间 邮件报警 1.先观察一下磁盘,和如何使用脚本 [[email protected] ~]# df -h 文件系统              容量  已用 可用 已用% 挂载点 /dev/mapper/VolGroup00-LogVol00 8.9G  2.6G  5.9G  31% / /dev/sda1              99M   13M   82M  13% /boot tmpfs

shell脚本检测网络是否畅通

shell初始化安装脚本执行时,需从网络上安装一些rpm包,所有需要先检测网络的畅通性, 代码 #检测网络链接&&ftp上传数据 function networkAndFtp() { #超时时间 timeout=5 #目标网站 target=www.baidu.com #获取响应状态码 ret_code=`curl -I -s --connect-timeout $timeout $target -w %{http_code} | tail -n1` if [ "x$ret_co

shell脚本检测监控mysql的CPU占用率

网站访问量大的时候mysql的压力就比较大,当mysql的CPU利用率超过300%的时候就不能提供服务了,近乎卡死状态,这时候最好的方法 就是重启mysql服务.由于这种事具有不可预见性,我们不知道什么时候mysql的占用率达到300%,还是写个程序定期判断比较靠谱. 学了shell编程,写了下面的脚本: #!/bin/bash cpu=`ps aux | grep 'mysqld$' | cut -d " " -f6 | cut -d. -f1` if [ $cpu -gt 300

使用shell脚本检测lvs中realserver状态,并实现自动删除已挂机主机

#!/bin/sh # Describe:check the real server status # History:2015-08-25 22:21:38 # Author:Tim PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH VIP=192.168.1.121 DIP=192.168.1.112 RIP=("192.168.1.122" "192.1

shell脚本 检测根分区硬盘空间使用率

#!/bin/bash IP=$(ifconfig eth0 |grep "inet addr"| awk '{print $2}' |cut -f1 -d":")  a=$(df -h |grep /dev/sda2 |awk '{print $5}'|cut -f1 -b"%" )    #截取分区使用率 if [ $a -ge 80 ]     then         echo "$IP 服务器根分区即将没有空间,请及时清理.&

shell脚本检测mysql是否启动的方法

(1)端口检测# netstat -lntup |grep 3306|wc -l1 #1表示mysql已开启,0表示关闭 #!/bin/bashport=`netstat -intup |grep 3306|wc -l`if [ $port -ne 1 ]then /etc/init.d/mysqld startelse echo "Mysql is running"fi (2)是否显示mysql版本#!/bin/bashmysql -uroot -p密码 -e "selec

Shell脚本检测程序,如果挂了就重启程序

脚本如下: #!/bin/sh #要检查的进程名 PROGRESS_NAME="heihu_server" #----------------------------------- # 函数: CheckProgress# 功能: 检查一个进程是否存在 # 参数: $1 --- 要检查的进程名称# 返回: 如果存在返回0, 否则返回1. #--------------------------------------- CheckProgress(){ # 检查输入的参数是否有效 if

shell脚本检测局域网内存活主机

<1> d211 admin # for i in {3..254} ; do ping -c 1 192.168.1.$i &>/dev/null && echo 192.168.1.$i is alive ;done192.168.1.5 is alive192.168.1.7 is alive <2> fping -a -g 192.168.5.1 192.168.5.177 -s -n >lele.txt -a   Show system

shell 脚本检测端口状态

方法一: # cat check_port.sh #!/bin/bash cat ip.txt|while read line do /usr/bin/nc -w 1 -z $line > /dev/null 2>&1 if [ $? -eq 0 ] then echo telnet $line ok sleep 1 else echo telnet $line fail fi done # cat ip.txt 124.234.83.15 80 124.234.83.10 80 原文