grixm Posted December 1, 2024 Posted December 1, 2024 Hi guys, I created another device tree overlay that I needed, to enable two user leds on GPIO. Specifically GPIO0_B7 and GPIO0_C0, which is pins 27 and 28 on the header. Posting it here in case someone needs it, like I did with with the SPIdev overlay too. Here it is: rk3308-user-leds.dts What I needed this for is ethernet port LEDs, since the original connector does not include them. To get standard ethernet LED behavior on these newly defined LEDs, you can do this (you need su access): modprobe ledtrig-netdev echo "netdev" > /sys/class/leds/rock-s0\:orange\:user1/trigger echo "netdev" > /sys/class/leds/rock-s0\:green\:user2/trigger echo "1" > /sys/class/leds/rock-s0\:orange\:user1/rx echo "1" > /sys/class/leds/rock-s0\:green\:user2/link echo "end0" > /sys/class/leds/rock-s0\:orange\:user1/device_name echo "end0" > /sys/class/leds/rock-s0\:green\:user2/device_name (Change end0 to eth0 in the last two lines if you use ubuntu-based image instead of debian-based (minimal). 0 Quote
Meestor_X Posted January 6 Posted January 6 Very cool! I didn't even know that would be possible to send triggers to GPIOs like that. I'd love to learn more about what's possible with GPIOs. Are these LEDs already on the S0 or they're ones you are connecting to the header? 0 Quote
grixm Posted January 7 Author Posted January 7 They are not on the board, you must connect to the header. If you want to use the led on the board, you don't need the overlay 1 Quote
Meestor_X Posted February 3 Posted February 3 How did you figure this out? I can't really understand anything that's in the dts file or what you've got going in that script... as per the info here: https://github.com/armbian/build/pull/7157 I should be able to get the LEDs working for the ethernet connection on the E20C. Not sure if I need an overlay, or a script like yours or both? 0 Quote
grixm Posted February 7 Author Posted February 7 (edited) @Meestor_X From what I can see in the schematic for the E20C, the Ethernet LEDs are wired directly to the Ethernet controller chip. Can not be accessed by the SoC/OS via GPIO, therefore there is nothing you can do to control their behavior. However I would think that it should just work out of the box, so there is nothing you need to do either. If it doesn't work then I dunno, ask Radxa or something Edited February 7 by grixm 0 Quote
Meestor_X Posted February 7 Posted February 7 TY for your reply. They definitely can be controlled by echoing values to the `/sys/class/leds/` and even though the "trigger" is set to "netdev" and tx and rx files appear, I'm not seeing any activity on those LEDs with network activity. I can manually make the LEDs blink by doing something like echo heartbeat > /sys/class/leds/lan-led/trigger cat /sys/class/leds/lan-led/trigger will show the available triggers, and a [] around the currently selected one. cat trigger none usb-gadget usb-host rc-feedback bluetooth-power rfkill-any rfkill-none kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock mmc0 timer oneshot disk-activity disk-read disk-write ide-disk mtd nand-disk heartbeat backlight gpio cpu cpu0 cpu1 cpu2 cpu3 activity default-on transient flash torch panic [netdev] mmc1 It looks very configurable, just doesn't seem to be "automatically" working to show network activity. 0 Quote
grixm Posted February 7 Author Posted February 7 (edited) Guess I misread the schematic in that case. If the LED is already defined in linux and you know it works because you can change trigger to heartbeat, then you don't need the device tree overlay, the LED device is already defined correctly. I don't know what is wrong with the network trigger module in your case, but focus on that. You ran all the other commands in my first post too? It's not enough to set the trigger, you also need to write 1 to tx/rx/link etc and also write the network adapter name like "end0" or "eht0" or whatever you have to device_name. Check the actual device name with "ip addr" command. Edited February 7 by grixm 0 Quote
Meestor_X Posted February 8 Posted February 8 Oh! I thought those commands were needed for your custom dts. What do you know! All I had to do was: echo enp1s0 > device_name echo 1 > rx And it "just works"! Also, this "just works": root@radxa-e20c:/dev/input# cat event0 To see when the user button is pressed. Although, I'm not sure what data is being produced from it! root@radxa-e20c:/dev/input# cat event0 | hexdump -C 00000000 8b 8a a7 67 00 00 00 00 5c 14 0f 00 00 00 00 00 |...g....\.......| 00000010 01 00 b9 00 01 00 00 00 8b 8a a7 67 00 00 00 00 |...........g....| 00000020 5c 14 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 |\...............| 00000030 8c 8a a7 67 00 00 00 00 3e 65 01 00 00 00 00 00 |...g....>e......| 00000040 01 00 b9 00 00 00 00 00 8c 8a a7 67 00 00 00 00 |...........g....| 00000050 3e 65 01 00 00 00 00 00 00 00 00 00 00 00 00 00 |>e..............| I had no idea it was that easy. Is this a Linux thing? Armbian thing? Radxa thing? Where can I read up on this kind of hardware control? 0 Quote
Torte Posted February 8 Posted February 8 You can use "evtest /dev/input/event0" to analyze its output. Docs for gpio-leds: https://www.kernel.org/doc/Documentation/devicetree/bindings/leds/common.yaml https://www.kernel.org/doc/Documentation/devicetree/bindings/leds/leds-gpio.txt 1 Quote
Meestor_X Posted February 8 Posted February 8 Thank you so much, @Torte! I'll have to bookmark this as my next rabbithole. 🙂 0 Quote
Meestor_X Posted February 8 Posted February 8 1 hour ago, Torte said: You can use "evtest /dev/input/event0" to analyze its output NB - evtest does not come with Armbian Bookworm. A quick "apt install evtest" and we're away! root@radxa-e20c:~# evtest /dev/input/event0 Input driver version is 1.0.1 Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100 Input device name: "gpio-keys" Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 185 (KEY_F15) Key repeat handling: Repeat type 20 (EV_REP) Repeat code 0 (REP_DELAY) Value 250 Repeat code 1 (REP_PERIOD) Value 33 Properties: Testing ... (interrupt to exit) Event: time 1739040710.916095, type 1 (EV_KEY), code 185 (KEY_F15), value 1 Event: time 1739040710.916095, -------------- SYN_REPORT ------------ Event: time 1739040711.050330, type 1 (EV_KEY), code 185 (KEY_F15), value 0 Event: time 1739040711.050330, -------------- SYN_REPORT ------------ Do you know where I can find information on how to change settings for this button? 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.