Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netgear EX6100v2 #24

Open
trenchcoatjedi opened this issue Jul 19, 2023 · 10 comments
Open

Netgear EX6100v2 #24

trenchcoatjedi opened this issue Jul 19, 2023 · 10 comments

Comments

@trenchcoatjedi
Copy link

The Netgear EX6100v2 has a physical switch which controls GPIO pin 58. I'm not sure how to add this as code. Want to contribute any way I can. Here is the configuration:

Switch up
gpio58 : in high

Switch down
gpio58 : in low

@jefferyto
Copy link
Owner

Thanks for opening this - can you paste the content of /sys/kernel/debug/gpio with the switch in each position? Also what version of OpenWrt are you using?

@trenchcoatjedi
Copy link
Author

trenchcoatjedi commented Jul 19, 2023

Using OpenWRT snapshot

# cat /proc/version
Linux version 5.15.120 (builder@buildhost) (arm-openwrt-linux-muslgnueabi-gcc (OpenWrt GCC 12.3.0 r23565-8fb0c196e8) 12.3.0, GNU ld (GNU Binutils) 2.40.0) #0 SMP Fri Jul 14 09:44:21 2023

This is a two position switch. The up position is marked "extender" on the case silk screen and sets the device in extender mode under the stock firmware. Here is the info with the switch in the up position with gpio58 pulled high.

# cat /sys/kernel/debug/gpio 
gpiochip1: GPIOs 404-411, parent: spi/spi2.0, 74hc595, can sleep:
 gpio-404 (                    |red:router          ) out hi ACTIVE LOW
 gpio-405 (                    |green:router        ) out lo ACTIVE LOW
 gpio-406 (                    |red:client          ) out hi ACTIVE LOW
 gpio-407 (                    |green:client        ) out lo ACTIVE LOW
 gpio-408 (                    |blue:left           ) out hi ACTIVE LOW
 gpio-409 (                    |blue:right          ) out hi ACTIVE LOW
 gpio-410 (                    |green:power         ) out lo ACTIVE LOW
 gpio-411 (                    |amber:power         ) out hi ACTIVE LOW
gpiochip0: GPIOs 412-511, parent: platform/1000000.pinctrl, 1000000.pinctrl:
 gpio0   : in  high func0 4mA pull up
 gpio1   : out high func0 2mA pull up
 gpio2   : in  high func0 2mA pull up
 gpio3   : in  low  func0 2mA no pull
 gpio4   : out high func0 4mA pull up
 gpio5   : out low  func0 4mA pull up
 gpio6   : in  high func0 2mA pull up
 gpio7   : in  high func0 2mA pull up
 gpio8   : in  low  func0 2mA pull down
 gpio9   : in  low  func0 2mA pull down
 gpio10  : in  high func0 2mA pull up
 gpio11  : in  high func0 2mA pull up
 gpio12  : in  high func0 2mA pull up
 gpio13  : in  high func0 2mA pull up
 gpio14  : in  low  func0 2mA pull down
 gpio15  : in  high func0 2mA pull up
 gpio16  : in  low  func0 2mA pull down
 gpio17  : in  low  func0 2mA pull down
 gpio18  : in  low  func0 2mA pull down
 gpio19  : in  high func1 2mA pull down
 gpio20  : in  high func0 2mA pull up
 gpio21  : in  high func0 2mA pull up
 gpio22  : in  high func0 2mA pull up
 gpio23  : in  high func0 2mA pull up
 gpio24  : in  high func0 2mA pull up
 gpio25  : in  high func0 2mA pull up
 gpio26  : in  high func0 2mA pull up
 gpio27  : in  high func0 2mA pull up
 gpio28  : in  high func0 2mA pull up
 gpio29  : in  high func0 2mA pull up
 gpio30  : in  high func0 2mA pull up
 gpio31  : in  high func0 2mA pull up
 gpio32  : in  high func0 2mA pull up
 gpio33  : in  high func0 2mA no pull
 gpio34  : in  high func0 2mA pull up
 gpio35  : in  high func0 2mA pull up
 gpio36  : in  low  func0 2mA pull down
 gpio37  : in  low  func0 2mA pull down
 gpio38  : in  low  func0 2mA pull down
 gpio39  : in  high func0 2mA pull up
 gpio40  : in  high func0 2mA pull up
 gpio41  : in  low  func0 2mA pull down
 gpio42  : in  low  func0 2mA pull down
 gpio43  : in  low  func0 2mA pull down
 gpio44  : in  low  func0 2mA pull down
 gpio45  : in  low  func0 2mA pull down
 gpio46  : in  low  func0 2mA pull down
 gpio47  : in  low  func0 2mA pull down
 gpio48  : in  low  func0 2mA pull down
 gpio49  : in  low  func0 2mA pull down
 gpio50  : in  high func0 2mA pull up
 gpio51  : in  low  func0 2mA pull down
 gpio52  : in  high func2 2mA pull up
 gpio53  : in  high func2 2mA pull up
 gpio54  : out high func0 2mA no pull
 gpio55  : in  low  func2 12mA no pull
 gpio56  : in  low  func2 12mA no pull
 gpio57  : in  high func2 12mA no pull
 gpio58  : in  high func0 2mA pull up
 gpio59  : out high func0 2mA no pull
 gpio60  : out low  func2 2mA no pull
 gpio61  : out low  func2 2mA no pull
 gpio62  : in  high func2 2mA pull down
 gpio63  : in  high func0 4mA pull up
 gpio64  : in  low  func0 2mA pull down
 gpio65  : in  low  func0 2mA pull down
 gpio66  : in  low  func0 2mA pull down
 gpio67  : in  low  func0 2mA pull down
 gpio68  : in  low  func0 2mA pull down
 gpio69  : in  low  func0 2mA pull down
 gpio70  : in  low  func0 2mA pull down
 gpio71  : in  low  func0 2mA pull down
 gpio72  : in  low  func0 2mA pull down
 gpio73  : in  low  func0 2mA pull down
 gpio74  : in  low  func0 2mA pull down
 gpio75  : in  low  func0 2mA pull down
 gpio76  : in  low  func0 2mA pull down
 gpio77  : in  low  func0 2mA pull down
 gpio78  : in  low  func0 2mA pull down
 gpio79  : in  low  func0 2mA pull down
 gpio80  : in  low  func0 2mA pull down
 gpio81  : in  low  func0 2mA pull down
 gpio82  : in  low  func0 2mA pull down
 gpio83  : in  low  func0 2mA pull down
 gpio84  : in  low  func0 2mA pull down
 gpio85  : in  low  func0 2mA pull down
 gpio86  : in  low  func0 2mA pull down
 gpio87  : in  low  func0 2mA pull down
 gpio88  : in  low  func0 2mA pull down
 gpio89  : in  low  func0 2mA pull down
 gpio90  : in  low  func0 2mA pull down
 gpio91  : in  low  func0 2mA pull down
 gpio92  : in  low  func0 2mA pull down
 gpio93  : in  low  func0 2mA pull down
 gpio94  : in  low  func0 2mA pull down
 gpio95  : in  low  func0 2mA pull down
 gpio96  : in  low  func0 2mA pull down
 gpio97  : in  low  func0 2mA pull down
 gpio98  : in  low  func0 2mA pull down
 gpio99  : in  low  func0 2mA pull down

The down position is marked "access point" on the case silk screen and sets the device in access point mode under the stock firmware. Here is the info with the switch in the down position with gpio58 pulled low.

# cat /sys/kernel/debug/gpio 
gpiochip1: GPIOs 404-411, parent: spi/spi2.0, 74hc595, can sleep:
 gpio-404 (                    |red:router          ) out hi ACTIVE LOW
 gpio-405 (                    |green:router        ) out lo ACTIVE LOW
 gpio-406 (                    |red:client          ) out lo ACTIVE LOW
 gpio-407 (                    |green:client        ) out lo ACTIVE LOW
 gpio-408 (                    |blue:left           ) out hi ACTIVE LOW
 gpio-409 (                    |blue:right          ) out hi ACTIVE LOW
 gpio-410 (                    |green:power         ) out lo ACTIVE LOW
 gpio-411 (                    |amber:power         ) out hi ACTIVE LOW
gpiochip0: GPIOs 412-511, parent: platform/1000000.pinctrl, 1000000.pinctrl:
 gpio0   : in  high func0 4mA pull up
 gpio1   : out high func0 2mA pull up
 gpio2   : in  high func0 2mA pull up
 gpio3   : in  low  func0 2mA no pull
 gpio4   : out high func0 4mA pull up
 gpio5   : out low  func0 4mA pull up
 gpio6   : in  high func0 2mA pull up
 gpio7   : in  high func0 2mA pull up
 gpio8   : in  low  func0 2mA pull down
 gpio9   : in  low  func0 2mA pull down
 gpio10  : in  high func0 2mA pull up
 gpio11  : in  high func0 2mA pull up
 gpio12  : in  high func0 2mA pull up
 gpio13  : in  high func0 2mA pull up
 gpio14  : in  low  func0 2mA pull down
 gpio15  : in  high func0 2mA pull up
 gpio16  : in  low  func0 2mA pull down
 gpio17  : in  low  func0 2mA pull down
 gpio18  : in  low  func0 2mA pull down
 gpio19  : in  high func1 2mA pull down
 gpio20  : in  high func0 2mA pull up
 gpio21  : in  high func0 2mA pull up
 gpio22  : in  high func0 2mA pull up
 gpio23  : in  high func0 2mA pull up
 gpio24  : in  high func0 2mA pull up
 gpio25  : in  high func0 2mA pull up
 gpio26  : in  high func0 2mA pull up
 gpio27  : in  high func0 2mA pull up
 gpio28  : in  high func0 2mA pull up
 gpio29  : in  high func0 2mA pull up
 gpio30  : in  high func0 2mA pull up
 gpio31  : in  high func0 2mA pull up
 gpio32  : in  high func0 2mA pull up
 gpio33  : in  high func0 2mA no pull
 gpio34  : in  high func0 2mA pull up
 gpio35  : in  high func0 2mA pull up
 gpio36  : in  low  func0 2mA pull down
 gpio37  : in  low  func0 2mA pull down
 gpio38  : in  low  func0 2mA pull down
 gpio39  : in  high func0 2mA pull up
 gpio40  : in  high func0 2mA pull up
 gpio41  : in  low  func0 2mA pull down
 gpio42  : in  low  func0 2mA pull down
 gpio43  : in  low  func0 2mA pull down
 gpio44  : in  low  func0 2mA pull down
 gpio45  : in  low  func0 2mA pull down
 gpio46  : in  low  func0 2mA pull down
 gpio47  : in  low  func0 2mA pull down
 gpio48  : in  low  func0 2mA pull down
 gpio49  : in  low  func0 2mA pull down
 gpio50  : in  high func0 2mA pull up
 gpio51  : in  low  func0 2mA pull down
 gpio52  : in  low  func2 2mA pull up
 gpio53  : in  high func2 2mA pull up
 gpio54  : out high func0 2mA no pull
 gpio55  : in  low  func2 12mA no pull
 gpio56  : in  low  func2 12mA no pull
 gpio57  : in  high func2 12mA no pull
 gpio58  : in  low  func0 2mA pull up
 gpio59  : out high func0 2mA no pull
 gpio60  : out low  func2 2mA no pull
 gpio61  : out low  func2 2mA no pull
 gpio62  : in  high func2 2mA pull down
 gpio63  : in  high func0 4mA pull up
 gpio64  : in  low  func0 2mA pull down
 gpio65  : in  low  func0 2mA pull down
 gpio66  : in  low  func0 2mA pull down
 gpio67  : in  low  func0 2mA pull down
 gpio68  : in  low  func0 2mA pull down
 gpio69  : in  low  func0 2mA pull down
 gpio70  : in  low  func0 2mA pull down
 gpio71  : in  low  func0 2mA pull down
 gpio72  : in  low  func0 2mA pull down
 gpio73  : in  low  func0 2mA pull down
 gpio74  : in  low  func0 2mA pull down
 gpio75  : in  low  func0 2mA pull down
 gpio76  : in  low  func0 2mA pull down
 gpio77  : in  low  func0 2mA pull down
 gpio78  : in  low  func0 2mA pull down
 gpio79  : in  low  func0 2mA pull down
 gpio80  : in  low  func0 2mA pull down
 gpio81  : in  low  func0 2mA pull down
 gpio82  : in  low  func0 2mA pull down
 gpio83  : in  low  func0 2mA pull down
 gpio84  : in  low  func0 2mA pull down
 gpio85  : in  low  func0 2mA pull down
 gpio86  : in  low  func0 2mA pull down
 gpio87  : in  low  func0 2mA pull down
 gpio88  : in  low  func0 2mA pull down
 gpio89  : in  low  func0 2mA pull down
 gpio90  : in  low  func0 2mA pull down
 gpio91  : in  low  func0 2mA pull down
 gpio92  : in  low  func0 2mA pull down
 gpio93  : in  low  func0 2mA pull down
 gpio94  : in  low  func0 2mA pull down
 gpio95  : in  low  func0 2mA pull down
 gpio96  : in  low  func0 2mA pull down
 gpio97  : in  low  func0 2mA pull down
 gpio98  : in  low  func0 2mA pull down
 gpio99  : in  low  func0 2mA pull down

GPIO52 changes constantly because it's assigned to the wifi radio. It has no bearing on the switch which only changes GPIO58 from what I can tell by running watch -n 0.01 -d cat /sys/kernel/debug/gpio and moving the switch up and down several times. GPIO58 is the only change that correlates to the switch position.

This script predicts the correct physical switch position 100% of the time:

#!/bin/sh 

while :
do
cat /sys/kernel/debug/gpio | grep -q 'gpio58  : in  high' #check if switch is up
if [ "$?" -eq 0 ]; then
  echo Switch is already up!  && exit 0
else
   echo Switch is down! && exit 0
fi
done

I have built a custom image where I modified https://github.com/openwrt/openwrt/blob/main/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-ex61x0v2.dtsi to add these lines under keys:

          switch {
			label = "switch";
			gpios = <&tlmm 58 GPIO_ACTIVE_LOW>;
			linux,input-type = <EV_SW>;
			linux,code = <BTN_0>;
		};

but this made no difference. Hope that info helps.

@trenchcoatjedi
Copy link
Author

Any pointers you could provide on how to add this code to the snapshot would be helpful.

@jefferyto
Copy link
Owner

jefferyto commented Jul 27, 2023

The second gpio table (produced by pinctrl instead of gpiolib), with lines like:

 gpio0   : in  high func0 4mA pull up

is not something I have encountered before. The script will need to be updated to read this. The difficulty isn't in the actual code change, is it how to change it while maintaining compatibility with other devices.

@jefferyto
Copy link
Owner

I believe updating the devicetree description for the device will be necessary in addition to updating the switch-data.json data file.

Can you try:

  • Boot using your custom image (with the switch block added to qcom-ipq4018-ex61x0v2.dtsi)
  • Create /etc/slide-switch/slide-data.json and add this to the file:
    {
        "netgear,ex6100v2": {
            "mode": {
                "keys": [ "switch" ],
                "positions": {
                    "lo" : "ap",
                    "hi" : "extender"
                }
            }
        }
    }
    

@trenchcoatjedi
Copy link
Author

trenchcoatjedi commented Jul 31, 2023

Thank you for the message. I built a new snapshot image and created /etc/slide-switch/slide-data.json containing the code you pasted above. When I run slide-switch this is the error:
user.warn slide-switch[5073]: load_switch_data: board "netgear,ex6100v2" not found in /usr/share/slide-switch/switch-data.json

I then also added the above code to /usr/share/slide-switch/switch-data.json which gets rid of this error however when I attempt to run slide-switch init, this error prints:
# slide-switch init [err] populate_switches_details: key "switch" of switch "mode" is not a valid gpio key

@jefferyto
Copy link
Owner

I built a new snapshot image and created /etc/slide-switch/slide-data.json containing the code you pasted above.

Sorry that should have been /etc/slide-switch/switch-data.json.

when I attempt to run slide-switch init, this error prints:

Hmm can you post the directory listing of /proc/device-tree/keys (or /sys/firmware/devicetree/base/keys, /proc/device-tree should be a symlink to /sys/firmware/devicetree/base)?

Also do the other buttons (wps, reset) work correctly? I suggest temporarily replacing the scripts in /etc/rc.button with ones that log button presses and releases to syslog (see https://openwrt.org/docs/guide-user/hardware/hardware.button for more) for testing.

@trenchcoatjedi
Copy link
Author

# ls /proc/device-tree/keys 
compatible  name        reset       wps

/sys/firmware/devicetree/base/keys has the same directory contents. The switch does not seem to show up. Reset and WPS work properly. Here is the log (only pressed WPS for this example but results are same with reset):

Tue Aug  1 09:44:28 2023 user.notice root: the button was wps and the action was pressed
Tue Aug  1 09:44:28 2023 user.err slide-switch[7656]: populate_switches_details: key "switch" of switch "mode" is not a valid gpio key
Tue Aug  1 09:44:28 2023 user.notice root: the button was wps and the action was released
Tue Aug  1 09:44:28 2023 user.err slide-switch[7720]: populate_switches_details: key "switch" of switch "mode" is not a valid gpio key
Tue Aug  1 09:44:29 2023 user.notice root: the button was wps and the action was pressed
Tue Aug  1 09:44:29 2023 user.err slide-switch[7734]: populate_switches_details: key "switch" of switch "mode" is not a valid gpio key
Tue Aug  1 09:44:30 2023 user.notice root: the button was wps and the action was released
Tue Aug  1 09:44:30 2023 user.err slide-switch[7797]: populate_switches_details: key "switch" of switch "mode" is not a valid gpio key

@jefferyto
Copy link
Owner

Not sure why the "switch" key isn't appearing in /proc/device-tree/keys... were there any compile errors when you built the custom image, or any boot errors/warnings? (And just to be sure, you are booting with your custom image?)

@trenchcoatjedi
Copy link
Author

After your post, I began again from scratch using the imagebuilder for SNAPSHOT (r23684-881235c713). The results are the same. Adding just that switch block to the .dtsi file makes no difference. I tried this with the image builder for 22.03.5 stable with the same results. No build errors either time with the updated .dtsi file. The device boots perfectly and is fully functional otherwise. I'm not sure what else would need to be added to the .dtsi file to make the key populate in the OS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants