Jump to content

Use a GPIO to turn on LED right from booting


Andy

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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