[Solved] Wifi on/off slider Archer C7 V2

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

Where is the kernel config? How did you manage to get it for the mod I am using? I made kernel compilations quite often on Linux, but with this router firmware I have no clue how I would call 'make menuconfig' etc.
I would be grateful for a short description how to get there. I read a lot about this "built environment" without understanding a single word .... hope this is not the required procedure :confounded:

This is the .config file of the build from your used custom image.

I assume you have setup build environment as here

The procedure to build this custom image by yourself is:

  • git clone https://github.com/openwrt/openwrt.git
  • git clone https://github.com/infinitnet/lede-ar71xx-optimized-archer-c7-v2.git
  • cd openwrt
  • ./scripts/feeds update -a && ./scripts/feeds install -a
  • patch -p1 < $(find ../lede-ar71xx-optimized-archer-c7-v2/patches -name "*.patch" | sort)
  • cp -r ../lede-ar71xx-optimized-archer-c7-v2/files .
  • cp ../lede-ar71xx-optimized-archer-c7-v2/config.seed ./.config
  • make defconfig
  • make menuconfig # optional: enable debugfs and probably other stuff
  • make download world -j4

If you are afraid of building your image yourself... You could try my ath79 C7v2 build...
Don´t think your used "optimized" image is much faster than the ath79 build!
Here you will have flow offload and debugfs... No need for this shortcut fe enabled build and you could install all packages you want with opkg.

1 Like

Also, enabling debugfs won't fix your first problem. That's probably related to another build option.

1 Like

The author of this "optimized" image has disabled this:
# CONFIG_PACKAGE_kmod-gpio-button-hotplug is not set

If i do a clean config for ath79 or ar71xx this config option is enabled!

From a clean ath79 config:

  │ Symbol: PACKAGE_kmod-button-hotplug [=n]                                                                                                                                                                   │  
  │ Type  : tristate                                                                                                                                                                                           │  
  │ Prompt: kmod-button-hotplug................................ Button Hotplug driver                                                                                                                          │  
  │   Location:                                                                                                                                                                                                │  
  │     -> Kernel modules                                                                                                                                                                                      │  
  │ (1)   -> Other modules                                                                                                                                                                                     │  
  │   Defined at tmp/.config-package.in:12820                                                                                                                                                                  │  
  │   Selects: PACKAGE_kmod-input-core [=n]                                                                                                                                                                    │  
  │   Selected by: MODULE_DEFAULT_kmod-button-hotplug [=n] && TARGET_PER_DEVICE_ROOTFS [=n] && m && MODULES [=y]                                                                                               │  
  │                                                                                                                                                                                                            │  
  │                                                                                                                                                                                                            │  
  │ Symbol: PACKAGE_kmod-gpio-button-hotplug [=y]                                                                                                                                                              │  
  │ Type  : tristate                                                                                                                                                                                           │  
  │ Prompt: kmod-gpio-button-hotplug............... Simple GPIO Button Hotplug driver                                                                                                                          │  
  │   Location:                                                                                                                                                                                                │  
  │     -> Kernel modules                                                                                                                                                                                      │  
  │ (2)   -> Other modules                                                                                                                                                                                     │  
  │   Defined at tmp/.config-package.in:12891                                                                                                                                                                  │  
  │   Selected by: MODULE_DEFAULT_kmod-gpio-button-hotplug [=n] && TARGET_PER_DEVICE_ROOTFS [=n] && m && MODULES [=y]

:sweat_smile: but he enabled:

1 Like

I am not that kind of person that gets fascinated by figure comparisons. The reason for using that image is just the assumption that someone has taken a great deal of time to tailor the firmware to this particular router. The discussion on this image is pretty much focussed on speed, too much for me in fact. I will check your build ... only 2 days old ... a little challenge.

Nope. This has always been the part that I did not understand. In a virtual machine, or just on a Linux (Debian) Desktop? A quick check of your link did not improve my knowledge, but I shall check more in depth tomorrow.

Flow offloading in the ath79 target makes the out-of-tree optimizations in that build pretty much obsolete.

You may be right, as previously it was enabled also in my installations (moved to an update few weeks ago only). However, as reported earlier in this thread, the allocation of the switch to gpio.23 has been fixed recently. So cross fingers, I'll find out tomorrow.