[HOW-TO] Turn off all LEDs on R7000P

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
apacheguy
DD-WRT User


Joined: 26 Jun 2008
Posts: 88

PostPosted: Fri Apr 22, 2022 1:31    Post subject: [HOW-TO] Turn off all LEDs on R7000P Reply with quote
For some reason, the mods decided the lock the original thread by this same name, preventing me from replying with useful info.

On the latest April 2022 build, I found that the below settings work to disable LEDs on a Netgear R7000P. Hope this is helpful.

Code:
for i in 1 2 7 8 9 10 14 15 ; do gpio enable $i ; done
for i in 11 13 ; do gpio disable $i ; done
Sponsor
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Sun May 22, 2022 14:05    Post subject: Reply with quote
Thank you for the share, I slapped a HOW-TO onto the topic title.
_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Sun May 22, 2022 18:27    Post subject: Reply with quote
Just because I like linked info for giggles.

Original (now locked) thread.

'et robowr' Ethernet LED commands for R7xxx* don't work.

mod edit: removed DT thread and updated this reply to so reflect.

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
Hapi12021
DD-WRT User


Joined: 22 Jul 2021
Posts: 84

PostPosted: Tue Aug 02, 2022 6:11    Post subject: Reply with quote
Prefacing this post with a caveat: certain GPIO toggles will erase the NVRAM and reset the device. This is normal, but it is not standardized across models. IIRC it is GPIO 6 on some and 5 on others, or even 10 or 11, so some experimentation is necessary for what I describe below, and no guarantees are made that taking what is presented verbatim won’t brick or reset your device if the triggers are different.

I don’t know about the R7000P’s specific GPIO toggles, but the “et” binary from the above referenced thread was useful on my R8000 to get the LAN LEDs to turn off. The in-built “et,” if it’s even still part of the firmware, will not perform that function.

I was able to also poll /dev/gpio/in to watch for the specific bytes when toggling the LED on / off hardware switch on the R8000, and tying it to GPIO 19 to have the switch function like stock firmware makes it.

The code for the switch script is below. I have Optware installed, for “bash,” and it’s loopback mounted on /jffs and /opt (but resides on jffs), so doesn’t need an extra thumb drive. You might be able to get these to work with the in-built shell, but if you need “bash,” then you also need to install Optware, somewhere.

(stealth.sh)

Code:
#!/bin/bash

# close all input and output so we can run as a background process
exec 0>&- # close stdin
exec 1>&- # close stdout
exec 2>&- # close stderr

if [ "$1" != "-s" ]
then
  silent=0
else
  silent=1
fi

init() {
  # assume inital state of off
  old=00

  if [ "$silent" = "0" ]
  then
    /usr/bin/logger -t "LED INFO" -p user.info "Starting Stealth LED script /opt/etc/stealth.sh"
    /usr/bin/logger -t "LED INFO" -p user.info "Stealth LED script /opt/etc/stealth.sh GPIO 19: disabled (Off)"
  fi

  /opt/etc/leds.sh 00
}

gpio() {
  gpio_result=`/usr/bin/head -c4 /dev/gpio/in | /usr/bin/hexdump -v -e '/1 "%u\n"' | /usr/bin/tail -2 | /usr/bin/head -1`
}

shutdown() {
  /usr/bin/logger -t "LED INFO" -p user.info "Stealth LED script /opt/etc/stealth.sh received SIGINT: exiting"
  exit 0
}

trap 'shutdown' SIGINT

init

while [ 1 ]
do
  # call our "gpio" because the internal one is not streamable
  gpio

  if [ $gpio_result = "7" ] || [ $gpio_result = "6" ]
  then
    new=00
  else
    new=01
  fi

  if [ "$old" != "$new" ] && [ ! -z "$old" ] && [ ! -z "$new" ]
  then
    /opt/etc/leds.sh "$new"

    if [ "$new" = "00" ]
    then
      /usr/bin/logger -t "LED INFO" -p user.info "Stealth LED script /opt/etc/stealth.sh GPIO 19: disabled (Off)"
    else
      /usr/bin/logger -t "LED INFO" -p user.info "Stealth LED script /opt/etc/stealth.sh GPIO 19: enabled (On)"
    fi
  fi

  old=$new

  sleep 1
done


The above script will detect the switch changing state and calls the LED script to toggle the lights.

(leds.sh)

Code:
#!/bin/sh

exec 2>/dev/null

usb=$(nvram get usb_enable)

case "$1" in

enable|01)
  gpio disable 2
  gpio enable 3
  gpio enable 8
  gpio disable 9
  gpio disable 12
  gpio disable 13
  gpio enable 14
  gpio enable 15
  gpio disable 16

  if [ $usb ]
  then
    noop=1
    #
    # leave the USB leds disabled as plugging in a
    # device will turn them back on
    #
    # should really test the state of the USB port
    # so that the leds only get enabled if there is
    # device plugged in on that port
    #
    #gpio disable 17
    #gpio disable 18
    #
  fi

  /opt/bin/et robowr 0x0 0x18 0x1ff
  /opt/bin/et robowr 0x0 0x1a 0x1ff
  echo
  echo "LEDs Enabled"
  ;;

disable|00)
  gpio enable 2
  gpio enable 3
  gpio enable 8
  gpio enable 9
  gpio enable 12
  gpio enable 13
  gpio disable 14
  gpio disable 15
  gpio enable 16

  if [ $usb ]
  then
    gpio enable 17
    gpio enable 18
  fi

  /opt/bin/et robowr 0x0 0x18 0x0
  /opt/bin/et robowr 0x0 0x1a 0x0
  echo
  echo "LEDs Disabled"
  ;;

*)
  echo
  echo "Usage: $(basename $0) [enable|disable]"
  exit 1
  ;;

esac

exit 0


I have noticed that sometimes the stealth (switch) script will exit or abort, so have a cron job that calls the following script every minute to watch for the script aborting and restart it if necessary.

(cron script fragment)

Code:
#!/bin/sh

if [ -z "`/bin/pidof stealth.sh`" ]; then
  /bin/bash -c "/opt/etc/stealth.sh" > /dev/null 2>&1 &
fi


Since it runs from cron, when the router boots, it will start the script shortly after and ensure it stays running.
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6388
Location: UK, London, just across the river..

PostPosted: Tue Aug 02, 2022 6:50    Post subject: Reply with quote
yep some of the LED scripts behave funny on hit apply button or reboots...my experience

that's the one i use on my R7000, but it gets funny if you set your radio to turn on off by time, the wifi led appears and stays on after.....or you hit apply button and it re executes...it also slows down the boot time for some reason...

for i in 2 3 8 9 12 13 17 18 ; do gpio enable $i ; done
for i in 14 15 ; do gpio disable $i ; done

for best results, just use a black scotch tape Laughing Laughing Laughing

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,AP Isolation,Ad-Block,Firewall
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear R7800 --DD-WRT 55363 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55363 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Tue Aug 02, 2022 7:59    Post subject: Reply with quote
@Hapi12021

Regarding gpio which resets device, no experimentation required, if you run nvram show |grep gpio it will tell you which gpio is assigned to reset from the list shown, so yu only need to read.

Also keep in mind polarity, some gpios have reversed polarity, so enabling them will disable them and vice versa, now that requires experimentation.

also, saving script as firewall on commands sub tab will execute when APPLY button is clicked and services restart, also it will run at every boot.

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
strange
DD-WRT User


Joined: 18 Jun 2006
Posts: 228

PostPosted: Tue Aug 02, 2022 14:45    Post subject: Reply with quote
Alozaros wrote:

for best results, just use a black scotch tape Laughing Laughing Laughing


Black electrical tape works best on my 6700v3 Wink

_________________
Netgear XR500 - Gateway
R6700 v3 - Station Bridge
Hapi12021
DD-WRT User


Joined: 22 Jul 2021
Posts: 84

PostPosted: Tue Aug 02, 2022 17:05    Post subject: Reply with quote
the-joker wrote:
@Hapi12021

Regarding gpio which resets device, no experimentation required, if you run nvram show |grep gpio it will tell you which gpio is assigned to reset from the list shown, so yu only need to read.


Code:
hapi12021s_router:~# nvram show |grep gpio
size: 50106 bytes (15430 left)
gpio0=usbport1



Apparently not. Maybe I need to flash a newer build, I'm about a month behind current.

the-joker wrote:
also, saving script as firewall on commands sub tab will execute when APPLY button is clicked and services restart, also it will run at every boot.


I have a firewall script running there already, and the switch script runs as a continual process, so in my case I would probably just add another cron entry to run the LED script at around the same time I would turn the radio on / off.

I generally don't "Apply" settings, only save and reboot, which is the safer method when testing. Otherwise, I'm not in the settings very often and the scripts do exactly as needed, no black-tape required.
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Tue Aug 02, 2022 17:16    Post subject: Reply with quote
Code:
~# nvram show | grep gpio
size: 39604 bytes (25932 left)
reset_gpio=11
gpio7=wps_button
gpio9=usbport1

~# nvram show | grep reset
size: 39604 bytes (25932 left)
reset_gpio=11
resetbutton_enable=1


So I guess we know at least one difference between r7000P and asus RT-AC68U which technically are identically except for CFE.

So much for things common sense then, So, in that case, experimentation needed or check the sysinit file on source code.

Well certainly APPLY clicking isn't necessary, if you save and reboot (as you do), if you dont for instance changing interfaces settings then settings dont reload, but reboot is a long way around it, each to their own whatever works I guess.

So, we going for black tape or a permanent marker and paint eyes and a smile over the LEDS?

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
dale_gribble39
DD-WRT Guru


Joined: 11 Jun 2022
Posts: 1889

PostPosted: Tue Aug 02, 2022 17:51    Post subject: Reply with quote
Some GPIOs were probably never mapped when devices were ported to DD-WRT. OR, they may be hidden elsewhere besides nvram variables.
_________________
"The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep." - Robert Frost

"I am one of the noticeable ones - notice me" - Dale Frances McKenzie Bozzio

<fact>code knows no gender</fact>

This is me, knowing I've ruffled your feathers, and not giving a ****
Some people are still hard-headed.

--------------------------------------
Mac Pro (Mid 2012) - Two 2.4GHz 6-Core Intel Xeon E5645 processors 64GB 1333MHz DDR3 ECC SDRAM OpenSUSE Leap 15.5
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum