Jump to content

Use a GPIO to turn on LED right from booting


Recommended Posts

Posted

I like to attach an additional LED to my Core on any GPIO that is also going to switch on as soon as the Core boots (similar to the red one).

This way I can give the user a feedback that the core is now booting.

Is there a way to achieve this?

Posted

I'm not sure what device you have, but on the board I have this is used on the device tree

leds {
 compatible = "gpio-leds";
 user_led: led-1 {
  label = "ctf-blue";
  linux,default-trigger = "default-on";
  default-state = "on";
  gpios = <&gpio2 RK_PB0 1>;
 };
};

and lights up the led as it boot, it's not an activity led tho.

Posted
vor 4 Stunden schrieb mhel:

I'm not sure what device you have, but on the board I have this is used on the device tree

leds {
 compatible = "gpio-leds";
 user_led: led-1 {
  label = "ctf-blue";
  linux,default-trigger = "default-on";
  default-state = "on";
  gpios = <&gpio2 RK_PB0 1>;
 };
};

and lights up the led as it boot, it's not an activity led tho.

 

hmm thx

I use a NanoPi NEO Core

 

I now decopiled sun50i-h5-nanopi-neo-core2.dtb and have does entries:

	leds {
		compatible = "gpio-leds";

		pwr {
			label = "nanopi:red:pwr";
			gpios = <0x38 0x00 0x0a 0x00>;
			linux,default-trigger = "default-on";
		};

		status {
			label = "nanopi:green:status";
			gpios = <0x0c 0x00 0x0a 0x00>;
			linux,default-trigger = "heartbeat";
		};
	};

 

 

So i don't won't to brick my core so can I just add this:

ledBoot {
  label = "ctf-red";
  linux,default-trigger = "default-on";
  default-state = "on";
  gpios = ????;
 };

 

but how do I define the GPIOS?

Posted

You can use whatever gpio is available.

And you can group it with your leds.

 

leds {
		compatible = "gpio-leds";

		pwr {
			label = "nanopi:red:pwr";
			gpios = <0x38 0x00 0x0a 0x00>;
			linux,default-trigger = "default-on";
		};

		status {
			label = "nanopi:green:status";
			gpios = <0x0c 0x00 0x0a 0x00>;
			linux,default-trigger = "heartbeat";
		};
              
       ledBoot {
  		label = "just_a_name";
  		linux,default-trigger = "default-on";
  		default-state = "on";
  		gpios = <3 7 0 0>; // Gpio3 pin 7 ? ? 
 	 };       
	};

Whatever gpio is available for you.

If you use a gpio not used anywhere, you won't brick your board.
Why did you have to decompile the dtb? if the source is available
for your board then you can look for the dts file an you can see how the gpios
are defined.

Posted

So your dts files appear to have this:

leds {
		compatible = "gpio-leds";

		status {
			label = "nanopi:blue:status";
			gpios = <&pio 0 10 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "heartbeat";
		};

		pwr {
			label = "nanopi:green:pwr";
			gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>;
			default-state = "on";
		};
	};

So you have to do it like gpios = <&pio 3 7 0>; // gpio3 pin 7 active_high or maybe 1 for active high.

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines