您尚未登录。

楼主 #1 2018-01-23 15:10:59

lzx1044364960
会员
注册时间: 2017-12-15
已发帖子: 35
积分: 35

openwrt下如何添加wifi指示灯和wan指示灯?

openwrt下如何添加wifi指示灯和wan指示灯?
我用的MT7620a的开发板,wled-->gpio#72,wan-->gpio#49,我在openwrt/target/linux/ramips/dts/MT7620a.dts里做了如下操作(红色部分),可是编译出的固件指示灯还是不亮,各位大佬指导一下

/dts-v1/;

/include/ "mt7620a.dtsi"

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

    palmbus@10000000 {

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","wled";
                ralink,function = "gpio";
            };
        };
    };

    ethernet@10100000 {
        status = "okay";

        pinctrl-names = "default";
        pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;

        ralink,port-map = "llllw";

    };

    wmac@10180000{
        ralink,mtd-eeprom = <&factory 0>;
    };


gpio-leds {
		compatible = "gpio-leds";
		
		wan {
			label = "w856n:blue:wan"; /*led灯的标识,会体现在/sys/class/leds目录中*/
			gpios = <&gpio2 9 1>; /*led灯对应的gpio编号;表示是gpio2组中的第4个GPIO;这里的wan对应路由器面板外壳上的丝印*/
		};
		wlan {
			label = "w856n:blue:wlan";
			gpios = <&gpio3 0 1>;
		};
			
	};


gsw@10110000 {
        ralink,port4 = "gmac";
    };

    sdhci@10130000 {
        status = "okay";
    };

    pcie@10140000 {
        status = "okay";
    };

    gpio-keys-polled {
        compatible = "gpio-keys";
        #address-cells = <1>;
        #size-cells = <0>;
        poll-interval = <20>;
        s2 {
            label = "reset";
            gpios = <&gpio0 1 1>;
            linux,code = <0x198>;
        };
        s3 {
            label = "power";
            gpios = <&gpio0 2 1>;
            linux,code = <116>;
        };
    };

    ehci@101c0000 {
        status = "okay";
    };

    ohci@101c1000 {
        status = "okay";
    };
};

离线

楼主 #2 2018-01-23 15:13:34

lzx1044364960
会员
注册时间: 2017-12-15
已发帖子: 35
积分: 35

Re: openwrt下如何添加wifi指示灯和wan指示灯?

以上是我的dts文件,代码部分为我增加的操作,最终不能实现功能,请各位大侠指导一下

离线

#3 2018-01-23 15:21:45

晕哥
管理员
注册时间: 2017-09-06
已发帖子: 9,342
积分: 9202

Re: openwrt下如何添加wifi指示灯和wan指示灯?

可以在用户空间操作io吗?

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





离线

楼主 #4 2018-01-23 16:27:47

lzx1044364960
会员
注册时间: 2017-12-15
已发帖子: 35
积分: 35

Re: openwrt下如何添加wifi指示灯和wan指示灯?

晕哥 说:

可以在用户空间操作io吗?

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


/sys/class/gpio里可以看到,但是我需要怎么配置才能让wifi打开是指示灯亮,关闭WiFi时指示灯灭呢?

root@OpenWrt:/sys/class/gpio#
root@OpenWrt:/sys/class/gpio# ls
export      gpiochip0   gpiochip40  gpiochip72  unexport
root@OpenWrt:/sys/class/gpio#

离线

楼主 #5 2018-01-23 16:39:37

lzx1044364960
会员
注册时间: 2017-12-15
已发帖子: 35
积分: 35

Re: openwrt下如何添加wifi指示灯和wan指示灯?

在/sys/class/leds/下也可以看到w856n:blue:wlan   我如下操作root@OpenWrt:/sys/devices/gpio-leds/leds/w856n:blue:wlan# echo "1" > ./brightness  也能点亮led,但是我要如何才能让WiFi开启时点亮,关闭时熄灭呢?


root@OpenWrt:/sys/class# cd leds/
root@OpenWrt:/sys/class/leds# ls
rt2800soc-phy0::assoc    rt2800soc-phy0::radio
rt2800soc-phy0::quality  w856n:blue:wlan
root@OpenWrt:/sys/class/leds# cd w856n\:blue\:wlan/
root@OpenWrt:/sys/devices/gpio-leds/leds/w856n:blue:wlan# ls
brightness      max_brightness  trigger
device          subsystem       uevent
root@OpenWrt:/sys/devices/gpio-leds/leds/w856n:blue:wlan# echo "1" > ./brightness
root@OpenWrt:/sys/devices/gpio-leds/leds/w856n:blue:wlan#

离线

#6 2018-01-23 18:13:01

晕哥
管理员
注册时间: 2017-09-06
已发帖子: 9,342
积分: 9202

Re: openwrt下如何添加wifi指示灯和wan指示灯?





离线

楼主 #7 2018-01-24 10:33:39

lzx1044364960
会员
注册时间: 2017-12-15
已发帖子: 35
积分: 35

Re: openwrt下如何添加wifi指示灯和wan指示灯?

晕哥 说:

我的/openwrt/target/linux/ramips/base-files/etc/diag.sh文件内容如下,这里面什么以上啊,我网上没找到资料,该如何修改配置呢?

#!/bin/sh
# Copyright (C) 2010-2013 OpenWrt.org

. /lib/functions/leds.sh
. /lib/ramips.sh

get_status_led() {
	case $(ramips_board_name) in
	3g-6200n)
		status_led="edimax:green:power"
		;;
	3g150b | 3g300m | w150m)
		status_led="tenda:blue:ap"
		;;
	ai-br100)
		status_led="aigale:blue:wlan"
		;;
	ar670w)
		status_led="ar670w:green:power"
		;;
	ar725w)
		status_led="ar725w:green:power"
		;;
	awapn2403)
		status_led="asiarf:green:wps"
		;;
	argus-atp52b)
		status_led="argus-atp52b:green:run"
		;;
	asl26555)
		status_led="asl26555:green:power"
		;;
	br6524n)
		status_led="edimax:blue:power"
		;;
	br6425 | br-6475nd)
		status_led="edimax:green:power"
		;;
	cf-wr800n)
		status_led="comfast:white:wps"
		;;
	cy-swr1100)
		status_led="samsung:blue:wps"
		;;
	d105)
		status_led="d105:red:power"
		;;
	dcs-930 | dir-300-b1 | dir-600-b1 | dir-600-b2 | dir-610-a1 | dir-615-h1 | dir-615-d | dir-620-a1| dir-620-d1| dir-300-b7| dir-320-b1)
		status_led="d-link:green:status"
		;;
	dcs-930l-b1)
		status_led="d-link:red:power"
		;;
	dir-645)
		status_led="d-link:green:wps"
		;;
	dap-1350)
		status_led="d-link:blue:power"
		;;
	e1700)
		status_led="linksys:green:power"
		;;
	esr-9753)
		status_led="esr-9753:orange:power"
		;;
	ex2700)
		status_led="ex2700:red:power"
		;;
	f5d8235-v2)
		status_led="f5d8235v2:blue:router"
		;;
	fonera20n)
		status_led="fonera20n:green:power"
		;;
	ip2202)
		status_led="ip2202:green:run"
		;;
	rt-n13u)
		status_led="rt-n13u:power"
		;;
	hlk-rm04)
		status_led="hlk-rm04:red:power"
		;;
	ht-tm02)
		status_led="ht-tm02:blue:wlan"
		;;
	all0239-3g|\
	hw550-3g)
		status_led="hw550-3g:green:status"
		;;
	linkits7688| \
	linkits7688d)
		[ "$1" = "upgrade" ] && status_led="mediatek:orange:wifi"
		;;
	m2m)
		status_led="m2m:blue:wifi"
		;;
	m3)
		status_led="m3:blue:status"
		;;
	m4)
		status_led="m4:blue:status"
		;;
	mlw221|\
	mlwg2)
		status_led="kingston:blue:system"
		;;
	mofi3500-3gn)
		status_led="mofi3500-3gn:green:status"
		;;
	mpr-a1)
		status_led="hame:red:power"
		;;
	mpr-a2)
		status_led="hame:red:power"
		;;
	mr-102n)
		status_led="mr-102n:amber:status"
		;;
	nbg-419n)
		status_led="nbg-419n:green:power"
		;;
	nw718)
		status_led="nw718:amber:cpu"
		;;
	omni-emb|\
	omni-emb-hpm)
		status_led="emb:green:status"
		;;
	pbr-m1)
		status_led="pbr-m1:green:sys"
		;;
	psr-680w)
		status_led="psr-680w:red:wan"
		;;
	pwh2004)
		status_led="pwh2004:green:power"
		;;
	px4885)
		status_led="7links:orange:wifi"
		;;
	re6500)
		status_led="linksys:orange:wifi"
		;;
	rt-n15)
		status_led="rt-n15:blue:power"
		;;
	rt-n10-plus)
		status_led="asus:green:wps"
		;;
	rt-n14u | rt-n56u | wl-330n | wl-330n3g)
		status_led="asus:blue:power"
		;;
	rut5xx)
		status_led="rut5xx:green:status"
		;;
	sl-r7205)
		status_led="sl-r7205:green:status"
		;;
	tew-691gr|\
	tew-692gr)
		status_led="trendnet:green:wps"
		;;
	v11st-fe)
		status_led="v11st-fe:green:status"
		;;
	v22rw-2x2)
		status_led="v22rw-2x2:green:security"
		;;
	vocore)
		status_led="vocore:green:status"
		;;
	w306r-v20)
		status_led="w306r-v20:green:sys"
		;;
	w502u)
		status_led="alfa:blue:wps"
		;;
	wcr-150gn)
		status_led="wcr150gn:amber:power"
		;;
	whr-g300n)
		status_led="whr-g300n:green:router"
		;;
	wizfi630a)
		status_led="wizfi630a::run"
		;;
	wmr300)
		status_led="buffalo:green:status"
		;;
	wli-tx4-ag300n)
		status_led="buffalo:blue:power"
		;;
	wzr-agl300nh)
		status_led="buffalo:green:router"
		;;
	wl-351)
		status_led="wl-351:amber:power"
		;;
	wr512-3gn)
		status_led="wr512:green:wps"
		;;
	wr8305rt)
		status_led="wr8305rt:sys"
		;;
	whr-300hp2 | \
	whr-600d | \
	whr-1166d | \
	wsr-600 | \
	wsr-1166)
		status_led="buffalo:orange:diag"
		;;
	wnce2001)
		status_led="netgear:green:power"
		;;
	nexx-wt1520)
		status_led="nexx-wt1520:white:power"
		;;
	wt3020)
		status_led="nexx:blue:power"
		;;
	mzk-w300nh2)
		status_led="mzkw300nh2:green:power"
		;;
	ur-326n4g)
		status_led="ur326:green:wps"
		;;
	ur-336un)
		status_led="ur336:green:wps"
		;;
	x5)
		status_led="x5:green:power"
		;;
	x8)
		status_led="x8:green:power"
		;;
	xdxrn502j)
		status_led="xdxrn502j:green:power"
		;;
	xiaomi-mini)
		status_led="xiaomi:red:status"
		;;
	f7c027)
		status_led="belkin:orange:status"
		;;
	na930)
		status_led="na930:blue:power"
		;;
	y1 | \
	y1s)
		status_led="lenovo:blue:power"
		;;
	zbt-wg2626)
		status_led="zbt-wg2626:green:status"
		;;
	zte-q7)
		status_led="zte:red:status"
		;;
	esac
}

set_state() {
	get_status_led $1

	case "$1" in
	preinit)
		status_led_blink_preinit
		;;
	failsafe)
		status_led_blink_failsafe
		;;
	upgrade | \
	preinit_regular)
		status_led_blink_preinit_regular
		;;
	done)
		status_led_on
		;;
	esac
}

离线

楼主 #8 2018-01-24 10:52:34

lzx1044364960
会员
注册时间: 2017-12-15
已发帖子: 35
积分: 35

Re: openwrt下如何添加wifi指示灯和wan指示灯?

在openwrt:/sys/class/leds/下可以看到7620a:blue:wifi

root@OpenWrt:/sys/class# cd leds/
root@OpenWrt:/sys/class/leds# ls
7620a:blue:wifi          rt2800soc-phy0::quality
rt2800soc-phy0::assoc    rt2800soc-phy0::radio
root@OpenWrt:/sys/class/leds#

我在代码中是不是应该在/openwrt/target/linux/ramips/base-files/etc/diag.sh这样添加啊?

MT7620a)
        status_led="7620a:blue:wifi "
        ;;

离线

#9 2018-01-24 11:16:27

晕哥
管理员
注册时间: 2017-09-06
已发帖子: 9,342
积分: 9202

Re: openwrt下如何添加wifi指示灯和wan指示灯?

应该是的,你试一试,看看有没有效果?





离线

楼主 #10 2018-01-24 16:22:50

lzx1044364960
会员
注册时间: 2017-12-15
已发帖子: 35
积分: 35

Re: openwrt下如何添加wifi指示灯和wan指示灯?

谢谢!指导!

离线

#11 2018-01-24 16:24:27

bugfix
会员
注册时间: 2017-11-22
已发帖子: 125
积分: 125

Re: openwrt下如何添加wifi指示灯和wan指示灯?

lzx1044364960 说:

谢谢!指导!

搞定了吗?我过段时间也要弄7620了.

离线

楼主 #12 2018-02-02 16:44:23

lzx1044364960
会员
注册时间: 2017-12-15
已发帖子: 35
积分: 35

Re: openwrt下如何添加wifi指示灯和wan指示灯?

bugfix 说:
lzx1044364960 说:

谢谢!指导!

搞定了吗?我过段时间也要弄7620了.

搞定了,我参考了这个 https://www.cnblogs.com/lagujw/p/4645118.html

离线

#13 2019-02-16 13:39:35

zdphpn
会员
注册时间: 2019-02-16
已发帖子: 1
积分: 1

Re: openwrt下如何添加wifi指示灯和wan指示灯?

我添加了gpio-leds在dts文件里,但是在sys/class/leds下面却没有生成对应的目录,请问是什么原因呢?

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn