Jump to content

Recommended Posts

Posted

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).

<
Posted

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?

Posted

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

Posted (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 by grixm
Posted

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.
Β 

Posted (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 by grixm
Posted

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?

Β 

Posted
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?

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Γ—
Γ—
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines