[Solved] How to change the behaviour of board LED at boot

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
munecito
Posts: 3
Joined: 2024-09-19 13:25

[Solved] How to change the behaviour of board LED at boot

#1 Post by munecito »

Hello.

I am currently using Debain Bookworm on an Orange Pi Zero2 to run pihole and just general testing.

The board is on my desk in an acrylic case and by default the green LED blinks when the system is running.

Orange Pi provides guides to alter the behaviour of the LEDs but they are discarded on boot. So I have to run the command every time I reboot the machine.
The method of setting the green light on/off and flashing is as follows:

Note that the following operations should be performed under the root user.

First enter the setting directory of the green light

root@orangepi:~# cd /sys/class/leds/green_led

The command to set the green light to stop flashing is as follows

root@orangepi:/sys/class/leds/green_led# echo none > trigger

The command to set the green light to be on is as follows

root@orangepi:/sys/class/leds/green_led# echo default-on > trigger

root@orangepi:/sys/class/leds/green_led# echo default-on > trigger

The command to set the green light to flash is as follows

root@orangepi:/sys/class/leds/green_led# echo heartbeat > trigger
So the behaviour is set to heartbeat by default and it goes back to it after reboot.

Is there a way that I can run the instructions at boot or login so they stick? Or is there a file that I could modify?

The system is running headless so I operate via SSH.

Thank you for any help you could provide me on this.

Kind regards.
Last edited by munecito on 2024-10-03 14:59, edited 3 times in total.

Aki
Global Moderator
Global Moderator
Posts: 4036
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 112 times
Been thanked: 532 times

Re: [Hardware] How to change the behaviour of board LED at boot

#2 Post by Aki »

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

munecito
Posts: 3
Joined: 2024-09-19 13:25

Re: [Hardware] How to change the behaviour of board LED at boot

#3 Post by munecito »

Thank you Aki.

I have a play but I will do a backup first.

I am fairly new so I have not really understood totally what command to include so the echo instruction runs.

If I try to call it from root without entering the subdirectory then it fails.

I tried a few ways but they all failed.

echo /sys/class/leds/green_led\default-on > trigger

-bash /sys/class/leds/green_led\echo default-on > trigger

bash /sys/class/leds/green_led\echo default-on > trigger

/sys/class/leds/green_led\echo default-on > trigger

So I am sure that it is the syntax that is wrong but I just need to understand how to run it either by creating a script or a config file.

What is hard to understand is how to place the instruction in the folder as root in any of those cases.

Kind regards.

Aki
Global Moderator
Global Moderator
Posts: 4036
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 112 times
Been thanked: 532 times

Re: [Hardware] How to change the behaviour of board LED at boot

#4 Post by Aki »

Hello,
munecito wrote: 2024-09-20 08:33 I am fairly new so I have not really understood totally what command to include so the echo instruction runs.

If I try to call it from root without entering the subdirectory then it fails.

I tried a few ways but they all failed.

Code: Select all

echo /sys/class/leds/green_led\default-on > trigger 

-bash /sys/class/leds/green_led\echo default-on > trigger

bash /sys/class/leds/green_led\echo default-on > trigger

/sys/class/leds/green_led\echo default-on > trigger
So I am sure that it is the syntax that is wrong but I just need to understand how to run it either by creating a script or a config file.

What is hard to understand is how to place the instruction in the folder as root in any of those cases.

Kind regards.
Yes, unfortunately the syntax is wrong for a bash script.

According to the example in your first post, it should be (probably logged in as "root" user):

Code: Select all

# turn green led on (this is a comment)
echo default-on > /sys/class/leds/green_led

# turn green led off (this is a comment)
echo none > /sys/class/leds/green_led
Hope this helps.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

munecito
Posts: 3
Joined: 2024-09-19 13:25

Re: [Hardware] How to change the behaviour of board LED at boot

#5 Post by munecito »

@aki Thank you so much.

I managed to make it work modifying a bit the code you gave me.

The way I was able to run this on startup is by creating a cron job according to the page you linked and making a script based on your code:

Code: Select all

# turn green led on (this is a comment)
cd /sys/class/leds/green_led
echo default-on > trigger #/sys/class/leds/green_led

# turn green led off (this is a comment)
#echo none > /sys/class/leds/green_led
When I ran the code the way you gave me nothing happened, even after I commented out the turn green led off code.

There is something that I noticed and that is that even from the terminal I can't run the instruction if I am not inside the folder.

Code: Select all

sudo /sys/class/leds/green_led#echo default on > trigger
sudo: /sys/class/leds/green_led#echo: command not found
So I thought that if I was to change to the folder inside the script before running the echo instruction I would have had a better chance, hence I changed your code to

Code: Select all

# turn green led on (this is a comment)
cd /sys/class/leds/green_led
echo default-on > trigger #/sys/class/leds/green_led
I commented out the path instead of deleting just in case it did not work so I could play with it in the original way you supplied. I also had to add the > trigger part to make it run.

Thank you so very much. Now I think I can even use cron to create a time based job so the LEDs are fully turned off at night, although even staying on all the time is better than the blinking.

Aki
Global Moderator
Global Moderator
Posts: 4036
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 112 times
Been thanked: 532 times

Re: [Hardware] How to change the behaviour of board LED at boot

#6 Post by Aki »

I'm glad you sorted it out. :)

Please, mark the discussion as "solved" manually adding the text tag "[Solved]" at the beginning of the subject of the first message (after other tags).

Thanks.

Happy Debian ! :)
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

Post Reply