Dragonboard : rfkill trigger for leds

rfkill mappings to leds only works as root user. after reboot we need to set again.

even in the kernel rfkills set to trigger, it does not take effect.
Why does rfkill mapping to led:trigger not getting set ?

arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
led@5 {
label = “apq8016-sbc:yellow:wlan”;
linux,default-trigger = “rfkill0”;


vinaysimha@localhost:/sys/class/leds/apq8016-sbc:yellow:wlan$ rfkill list
0: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no

vinaysimha@localhost:/sys/class/leds/apq8016-sbc:yellow:wlan$ echo rfkill0 > trigger
-bash: trigger: Permission denied

vinaysimha@localhost:/sys/class/leds/apq8016-sbc:yellow:wlan$ sudo echo rfkill0 > trigger
-bash: trigger: Permission denied

vinaysimha@localhost:/sys/class/leds/apq8016-sbc:yellow:wlan$ ls
brightness device max_brightness power subsystem trigger uevent

vinaysimha@localhost:/sys/class/leds/apq8016-sbc:yellow:wlan$ cat trigger
[none] rc-feedback kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock usb-gadget usb-host mmc0 mmc1 timer oneshot heartbeat backlight gpio cpu0 cpu1 cpu2 cpu3 default-on rfkill0 rfkill1 phy0rx phy0tx phy0assoc phy0radio

vinaysimha@localhost:/sys/class/leds/apq8016-sbc:yellow:wlan$ sudo su

root@localhost:/sys/devices/platform/soc/soc:leds/leds/apq8016-sbc:yellow:wlan# echo rfkill0 > trigger

root@localhost:/sys/devices/platform/soc/soc:leds/leds/apq8016-sbc:yellow:wlan# cat trigger
none rc-feedback kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock usb-gadget usb-host mmc0 mmc1 timer oneshot heartbeat backlight gpio cpu0 cpu1 cpu2 cpu3 default-on [rfkill0] rfkill1 phy0rx phy0tx phy0assoc phy0radio

you need to either use tee or sudo -s (to switch to a complete root shell).

when using “sudo echo “1234” > foo” the sudo applies to the echo, but not to the redirect …

see

cd /sys/class/leds/apq8016-sbc:yellow:wlan
echo rfkill0 | sudo tee trigger

this works only at that moment, after reboot i need to set again.

But this is not problem with mmc0-trigger. normal user able to set the trigger. it is having problem with the rfkill trigger mapping.

if we set in kernel-src-driver. Earlier used ubuntu/debian able to set. No issues for the rfkill triggers for leds.

i can not really parse the last two paragraphs, can you re-phrase that ?

regarding the setting on boot, the default from the devicetree will apply after boot. if you want the yellow led to default to be triggered by rfkill0 all the time you should set it in your devicetree of the kernel snap.

alternatively, you can indeed create a snap that echos the value into the sysfs node on boot, similar to the mac-spoofer snap …

this is my device tree, i had configured the rfkill0 trigger for wlan led

arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
led@5 {
label = “apq8016-sbc:yellow:wlan”;
linux,default-trigger = “rfkill0”;

similarly i had configured for mmc0 trigger for user1 led

led@1 {
label = “apq8016-sbc:green:user1”;
default-state = “mmc0”;

by default mmc0 is getting set, but rfkill0 is not getting set.
if rfkill0 are not able to set. mmc0 should also not set by default.

so looks like rfkill0 need some special permission.

by default same changes done in kernel , i had earlier used Ubuntu 15.04 (vivid) and Debian 8.0 (jessie), i did not face this issue
of rfill0 not mapping for trigger

@ppisati do you have any idea why the dtsi change does not work ?

Does the dtb used to boot the board really have this modification?

Copy the dtb to your computer, decompile it and check the trigger for the wlan led:

$ dtc -I dtb -O dts apq8016-sbc.dtb > apq8016-sbc.dts

there is also a snap of dtc:

$ snap info devicetree-compiler
name:      devicetree-compiler
summary:   Simple snap to provide the devicetree compiler command
publisher: ogra
description: |
  The linux devicetree compiler as a snap
snap-id: WGxPWZeOd71BikDKEH9Jm63eQclMaDJ2
commands:
  - devicetree-compiler
tracking:    stable
installed:   0.1 (7) 372kB -
refreshed:   2017-08-12 14:08:49 +0200 CEST
channels:            
  stable:    0.1 (7) 372kB -
  candidate: 0.1 (7) 372kB -
  beta:      0.1 (7) 372kB -
  edge:      0.1 (7) 372kB -

so you can do it on the board via:

devicetree-compiler -I dtb -O dts apq8016-sbc.dtb > apq8016-sbc.dts

Edit: oops, sorry, i just noticed i didnt provide an arm64 build … fixing that now…

Edit2: fixed:

$ snap install devicetree-compiler
$ snap connect devicetree-compiler:home
$ cp /boot/uboot/dragonboard-kernel_35.snap/dtbs/qcom/apq8016-sbc-snappy.dtb .
$ devicetree-compiler -I dtb -O dts apq8016-sbc-snappy.dtb > apq8016-sbc.dts

vinaysimha@localhost:~$ snap install devicetree-cmpiler
error: snap “devicetree-cmpiler” not found
vinaysimha@localhost:~$ snap install devicetree-cmpiler --edge
error: snap “devicetree-cmpiler” not found (at least in channel “edge”)

i pulled your git and build for arm64, installed the snap in devmode

apq8016-sbc.dtshost:~$ sudo devicetree-compiler -I dtb -O dts apq8016-sbc.dtb >
/snap/devicetree-compiler/x1/bin/dtc: 1: /snap/devicetree-compiler/x1/bin/dtc: Syntax error: “(” unexpected
vinaysimha@localhost:~$

root@localhost:/# find . -name apq8016-sbc.dtb
./boot/uboot/ifc6309-kernel_x1.snap/dtbs/qcom/apq8016-sbc.dtb
./boot/uboot/ifc6309-kernel_x1.snap/dtbs/apq8016-sbc.dtb
./snap/ifc6309-kernel/x1/dtbs/apq8016-sbc.dtb
./snap/ifc6309-kernel/x1/dtbs/qcom/apq8016-sbc.dtb
./writable/system-data/snap/ifc6309-kernel/x1/dtbs/apq8016-sbc.dtb
./writable/system-data/snap/ifc6309-kernel/x1/dtbs/qcom/apq8016-sbc.dtb

copied this /boot/uboot/ifc6309-kernel_x1.snap/dtbs/qcom/apq8016-sbc.dtb to host machine
dtc -I dtb -O dts apq8016-sbc.dtb > apq8016-sbc.dts

i do not see my changes.

since in the snapcraft.yaml using apq8016-sbc-snappy.dtsi
In my kernel patch i am modifying in this file ubuntu-xenial/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi, i need to modify this file apq8016-sbc-snappy.dtsi.
i will check and update

ARRGH … sorry, typo … indeed that should be “compiler” (fixed in my post now)

snap install devicetree-compiler

if i install without --devmode, it gives :permission denied message if i try to run the device-compiler.
is this know issue?

after modifying apq8016-sbc-snappy.dtsi and rebuilding kernel and installing kernel snap, rfkill0 mapped to default-trigger.

thanks.

1 Like

did you connect the home interface and copy the dtb into your home ?

snap connect devicetree-compiler:home

sorry, i missed this command.
Now no permission problem.

1 Like