[Solved] Wifi on/off slider Archer C7 V2

Hello there,
The TP-Link Archer C7/C5 have a slider on the backside to manually turn on/off wifi. Very practical, as the most flexible approach to control wifi.

However, it is not working on OpenWrt/LEDE as it is connected to a different gpio than the one rfkill works on: gpio-13 (RFKILL switch) is set, but the switch is connected to gpio-23. This has been discussed here and the outcome was a patch that was provided by user ninno. It appears that also kmod-input-polldev is required in addition to the reallocation to gpio-23.

However, kmod-input-polldev is no longer available in the repo. I have read the openwrt wiki on gpio, but it has been written in a local Swahili dialect in terms of clarity to me.

The goal is to have:

cat /sys/kernel/debug/gpio |grep gpio-13
gpio-13 (RFKILL switch ) in lo

changed into

cat /sys/kernel/debug/gpio |grep gpio-23
gpio-23 (RFKILL switch ) in lo

Can any body advise? I am very surprised that almost nobody is complaining about this long lasting bug for this quite common Router.


yea, seems the use cases are somewhat rare.

Maybe this particular use case is rare, but not so the usage of gpios. The procedure to make use of them is just staggering incomprehensible, so I am hoping one of the gurus might help

you ca propose a patch here it seems that no gpio is defined, maybe adding one will solve the problem, at least on ath79 target

It is a pity that my information given on top is either not clear enough or not read: I have no clue what to do with a patch, despite spending 2 days reading all informations I could get.

That was the only outcome of this approach.

What I am looking for is somebody instructing me how to allocate RFKill to gpio-23 in a foolproof manner. I am familiar with Linux since many years, but this router stuff is very particular and for beginners poorly documented

Noticed the "backwardness" of the switch several years ago and asked about it a bit back. I've thought of patching it for my local builds, but hasn't bothered me enough to change.

Thinking about upgrade makes it a challenge -- think about flashing a new image on a device that is not wired (many of mine are only accessed through 802.11s) that all of a sudden goes off line because the sense of the switch changes. "Release notes" would certainly help, if that were part of the OpenWRT release process.

The file qca9558_tl-archer-c7-v2.dts does define the gpio pin 23, so would be the correct one for V2...
Think he defined this in the v2 dts because there is a C7 with everything the same apart from the wifi switch.

Perhaps the change to the ath97 target would be a "safe" point to make the change (that "off" as labeled on the switch really means "off", not "on" as it does today), being a "major version" upgrade.

If i flash a ar71xx device or a ath79 with a clean config and the switch is set to wifi on then the wifi is still off after boot...
If i set the switch to wifi off while the router is powered down and power it on with enabled wifi in config, the wireless will be on after boot up.

Possible there will be no misleading powered off wifi after a sysupgrade with corretcly defined switch gpio...
I thing the rfkill trigger is only triggered on a edge (transition from high to low or low to high) an not on a high or low.

Yeah that's exactly the reason why the GPIO-pin is defined in the v2 dts and not the dtsi.

Regarding the trigger: openwrt does not use the RFKILL subsystem of the linux kernel. Instead openwrt uses a userspace script (located at /etc/rc.button/rfkill) that triggers on a 'button press' and disables the radios in /etc/config/wireless. It does not seem to check the position of the switch at boot time.

@ jeff, @juppin, @hitch: are you indicating that you managed to get the on/off switch working on an Archer c7 v2? In that case, I would appreciate some advice how this can be achieved.

Yes, but only partially. On both ar71xx and ath79 builds the behavior is the same.

As @juppin said, if I boot the device with the switch in the off position, the wifi will be on after boot. If I then flip the switch (from off to on), the wifi will be 'turned on' by the script (which it already was). After another toggle the wifi will be switched off.

The script which checks the status of GPIO 23 only runs when the switch is changed, not on boot!

Are you running a recent version of openwrt? Because even 17.01 has the correct GPIO pin defined in the mach file. (See here)

I am running a customised version: OpenWrt SNAPSHOT r7314-c4aadbdaf6 / LuCI Master (git-18.176.34901-0d9a64b). Description can be found here. I installed the latest snapshot factory.bin (18-06) and then did a sysupgrade with the customised version. I used to do cat /sys/kernel/debug/gpio to see whether gpio is listed (I switched only recently to 18-06, before it had been 17-01). The slider never had an effect as you described. The file and its debug-directory in 18-06 do no longer exist.

I have no clue how to see the files like the script you linked. How is it possible to "extract" a .bin file?

I flashed the router with the 17.0.1 firmware (factory), before that I did a complete reset, so that everything is clean.

There is no /sys/kernel/debug/gpio file (the debug directory is missing).
Switching the slider does not do anything. I am entirely lost.

Please, so far I have received replies that indicate that some people know what and how to address this issue, but the language was...cryptic to me.

binwalk will do the parsing and extraction

At least in ar71xx builds, the switch is semi-functional in that switching it after boot will shut off the radios. From /etc/rc.button/rfkill is this code segment that looks for the transition of the switch, not the position of the switch:

case "${TYPE}" in
	[ "${ACTION}" = "released" ] && rfkill_state=1
	config_foreach wifi_rfkill_check wifi-device
config_foreach wifi_rfkill_set wifi-device

I have stated several times, including flashing with the stable release image, the switch does not do anything. The problem lies with the gpios, not with the rfkill script.

Unfortunately, I cannot see the allocations of the gpios any longer, since this file "/sys/kernel/debug/gpio" is no longer available.Please see here for the entire story of the problem, which persists on Archer C7 v2 at least.

Thanks for the advice, seems very helpful. I get back after testing tomorrow, have to leave for now.

Do you have a debugfs mounted at /sys/kernel/debug? You can check by:

mount | grep debugfs

This should give the following output:

root@router:/etc/rc.button# mount | grep debugfs
nodev on /sys/kernel/debug type debugfs (rw,relatime)

If not, maybe try mounting it manually?

mount -t debugfs nodev /sys/kernel/debug

No, because there is no directory /sys/kernel/debug. Tried to create it, but "operation not permitted".
fstab is empty and mtab contains:

cat /etc/mtab 
/dev/root /rom squashfs ro,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,noatime 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,noatime 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev,noatime 0 0
/dev/mtdblock3 /overlay jffs2 rw,noatime 0 0
overlayfs:/overlay / overlay rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,size=512k,mode=755 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,mode=600,ptmxmode=000 0 0

o no chance to mount it manually. Something wrong here?

Ah well that explains. Those images are built with:

# Kernel build options

Whereas my .config contains: (which are the default)

# Kernel build options

So that's why you do not have the file "/sys/kernel/debug/gpio".

I just tried the build you named. You are correct, the switch does not work on that build.

1 Like