Triggering a single LED for phy0 and phy1

Hi, I'm currently working on adding OpenWrt support for a new device, the ipTIME AX3000SE. I'm almost ready to send a pull request, but I've run into an issue with the WLAN LED.

This router has a single LED for all WLAN activity, unlike other routers.

I was trying to set a configuration for WLAN on dts file:

leds {
    compatible = "gpio-leds";
    ...
    /* LED GPIO configuration for WLAN */
    led-1 {
        color = <LED_COLOR_ID_BLUE>;
        function = LED_FUNCTION_WLAN;
        gpios = <&pio 7 GPIO_ACTIVE_LOW>;
    };
    ...
};

Then, I added uci settings to 01_leds:

iptime,ax3000se)
    ucidef_set_led_netdev "wlan2g" "wlang2g" "blue:wlan" "phy0-ap0"
    ucidef_set_led_netdev "wlan5g" "wlang5g" "blue:wlan" "phy1-ap0"
    ;;

However, this only triggers the LED for phy1-ap0 activity. Setting this in LuCI produces the same result.

Is there a way to trigger the LED for activity on both phy0 and phy1? Or does OpenWrt not support this feature? (I was assuming this because I saw this article: Multiple devices/ports status - single LED)

Use the patch from https://github.com/openwrt/openwrt/pull/19903

Change led configuration to:

led-1 {
        color = <LED_COLOR_ID_BLUE>;
        function = LED_FUNCTION_WLAN;
        gpios = <&pio 7 GPIO_ACTIVE_LOW>;
        linux,default-trigger = "network";
    };

Do not define anything in the 01_leds file.

Thanks for the reply. I'm going to try it and let you know.

Yes, it works like a charm.

Also I can see the logs that the ledtrig_network handles phy0 and phy1:

// During boot process
[    3.166853] ledtrig_network: LED blue:wlan - trigger wlan attached

// These two logs show up when enabling phy0-ap0 and phy1-ap0
[  463.694613] ledtrig_network: wlan - interface phy0-ap0 registered
[  484.914116] ledtrig_network: wlan - interface phy1-ap0 registered

// The router prints these two messages when disabling phy0-ap0 and phy1-ap0
[  499.927820] ledtrig_network: wlan - interface phy0-ap0 unregistered
[  506.716187] ledtrig_network: wlan - interface phy1-ap0 unregistered

I'll just leave it as a known limitation while sending the pull request, and apply the fix later after the ledtrig_network patch is merged. And one more question, are you the one who created the pull request for this patch? If so, please let me know if you need other tests. I would be happy to help test the patch further.

Yes, that's my PR.

Try new updated version. Add kmod-ledtrig-network to DEVICE_PACKAGES in your router definition in the mk file.

Hi, I tested the updated version, and it works fine.

I added the kmod-ledtrig-network to DEVICE_PACKAGES in my router definition.

define Device/iptime_ax3000se
  DEVICE_VENDOR := ipTIME
  DEVICE_MODEL := AX3000SE
  DEVICE_DTS := mt7981b-iptime-ax3000se
  DEVICE_DTS_DIR := ../dts
  BLOCKSIZE := 128k
  PAGESIZE := 2048
  IMAGE_SIZE := 32768k
  KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
  KERNEL_INITRAMFS := kernel-bin | lzma | \
	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
  IMAGES := sysupgrade.bin
  IMAGES := factory.bin sysupgrade.bin
  IMAGE/factory.bin := sysupgrade-tar | append-metadata | check-size | iptime-crc32 ax3kse
  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
- DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware
+ DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware kmod-ledtrig-network
  SUPPORTED_DEVICES += mediatek,mt7981-spim-snand-rfb
endef
TARGET_DEVICES += iptime_ax3000se

I checked the OpenWrt configuration (make menuconfig) and verified that the module is included and ready to be compiled.

And it loads perfectly fine and triggers the LED on both phy0 and phy1 activities.

// During boot process
[    8.240658] kmodloader: loading kernel modules from /etc/modules.d/*
[    8.276810] ledtrig_network: LED blue:wlan - trigger wlan attached

// Enable phy0 and phy1
[  295.745587] ledtrig_network: wlan - interface phy0-ap0 registered
[  302.173854] ledtrig_network: wlan - interface phy1-ap0 registered

// Disable phy0 and phy1
[  313.694158] ledtrig_network: wlan - interface phy0-ap0 unregistered
[  320.272658] ledtrig_network: wlan - interface phy1-ap0 unregistered

Also, I double checked that the module is installed by searching it in the LuCI.

1 Like

Came to state kmod-ledtrig-network also works great on the WAVLINK WL-WN536AX6 as well.