Power and status led question.

Post Reply
Konami
Posts: 62
Joined: Wed Jul 13, 2016 7:10 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Power and status led question.

Post by Konami »

Hello

first things first, I would just like to say i recieved my C2 in the post two days ago after sending my pi 3 back
wow. the performance is incredible in comparison! great work - very happy with it!

I am going to be using it for building a Carputer or double din head unit for my car.

i would like to extend the status and power led to the front panel, does anybody know a way i can do this by using the gpio header to send signals, is this possible?

(i am new to pi gpio and odroid gpio but very computer literate so i can learn easily and the code shall not be a problem for me) just wondering if it is hardware capable of doing such a thing.


i am using android currently, but can switch back to ubuntu if the gpio functions are at a loss with android. everything is perfect with this device otherwise.

i just ask because i would prefer not to desolder and extend the current LED's that are on the board unless that is the only way.
it's a work of art and i would prefer to keep it that way ^.^

Thanks in advance.
Last edited by Konami on Wed Aug 17, 2016 11:23 pm, edited 1 time in total.

endecotp
Posts: 231
Joined: Sun May 08, 2016 12:30 am
languages_spoken: english
ODROIDs: c2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by endecotp »

The power LED is easy, connect an LED to any of the power pins on the header.
The blue LED is a bit more difficult. Choose one of the GPIOs, connect it to an LED, and then arrange for it to be used as a "heartbeat" by writing something to an appropriate /sys file during early boot. That will make it behave like the blue LED, except before the kernel starts when u-boot is in control. You can probably find advice about how to control the GPIOs via /sys in the wiki; if not post again.
I don't know much about Android, but I would expect that this all works the same.

Konami
Posts: 62
Joined: Wed Jul 13, 2016 7:10 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Konami »

great thanks for the reply.
it was more so the blue led i was concerned about sounds like it could be possible from what you say, i will have a mess around
and see what i can get working.

Thanks again!

paulcrawford
Posts: 176
Joined: Tue May 10, 2016 11:51 am
languages_spoken: english
ODROIDs: c2 and n2
Has thanked: 26 times
Been thanked: 4 times
Contact:

Re: Power and status led question.

Post by paulcrawford »

I have done this on my C2. I edited the device tree file with fdtput to change which gpio the heartbeat goes to.

This is the command:

Code: Select all

$ sudo fdtput /boot/dtbs/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 30 92 0
That will set gpio 5 pin 29 as the heartbeat pin.

fdtput is in the dtc program which you will need to download to your C2.

You need to go to this page:

https://github.com/hardkernel/linux/blo ... pio/gxbb.h

to get the equivalent of "92", which is the right value for gpio 5, to get the value for the one that you select.

Konami
Posts: 62
Joined: Wed Jul 13, 2016 7:10 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Konami »

Great! Thank-you that is very helpful :)
I may have to switch back to Linux but I have just been playing with /sys/class/leds/blue:heartbeat on Android
Seems to work well changing to SD card which for my use is more practical

I shall have more of a play around once I build up some leds and connectors over the weekend so I can test out linking them to gpio
Appreciated

Colin
Posts: 51
Joined: Mon Mar 06, 2017 2:33 am
languages_spoken: english
ODROIDs: ODROID-C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Colin »

How can I change the GPIO pin back to original?

paulcrawford
Posts: 176
Joined: Tue May 10, 2016 11:51 am
languages_spoken: english
ODROIDs: c2 and n2
Has thanked: 26 times
Been thanked: 4 times
Contact:

Re: Power and status led question.

Post by paulcrawford »

How can I change the GPIO pin back to original?
Simply edit the device tree back to the original state.

Colin
Posts: 51
Joined: Mon Mar 06, 2017 2:33 am
languages_spoken: english
ODROIDs: ODROID-C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Colin »

I want the hearbeat on GPIOX.BIT11. When I read the https://github.com/hardkernel/linux/blo ... pio/gxbb.h I see "define GPIOX_11 103"

So I use:

Code: Select all

sudo fdtput /boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 30 103 0
After reboot the blue hearbeat led is turned on (not blinking anymore). But my led on GPIOX.BIT11 does nothing…

When I want to set the hearbeat back to the blue led by:

Code: Select all

sudo su
echo heartbeat > /sys/class/leds/blue\:heartbeat/trigger
I receive the error: bash: /sys/class/leds/blue:heartbeat/trigger: No such file or directory. And if I see into the directory /sys/class/leds/ it is empty.

I don’t know if it matter. But I use Debian…

paulcrawford
Posts: 176
Joined: Tue May 10, 2016 11:51 am
languages_spoken: english
ODROIDs: c2 and n2
Has thanked: 26 times
Been thanked: 4 times
Contact:

Re: Power and status led question.

Post by paulcrawford »

There is an error in your fdtput command:

Code: Select all

sudo fdtput /boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 30 103 0
should be:

Code: Select all

sudo fdtput /boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 18 103 0
That should get GPIOX.BIT11 blinking.

To get the blue heartbeat led running again you need to reset the device tree back to the original with ftdput like this:

Code: Select all

sudo fdtput /boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 36 13 1
I got the decimal values "36 13 1" from the very latest meson64_odroidc2.dtb file by doing a kernel build yesterday.

Colin
Posts: 51
Joined: Mon Mar 06, 2017 2:33 am
languages_spoken: english
ODROIDs: ODROID-C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Colin »

Thanks, yes it is working. But where get you the value 18 from? And how can I read the values 36 13 1 from the meson64_odroidc2.dtb.

paulcrawford
Posts: 176
Joined: Tue May 10, 2016 11:51 am
languages_spoken: english
ODROIDs: c2 and n2
Has thanked: 26 times
Been thanked: 4 times
Contact:

Re: Power and status led question.

Post by paulcrawford »

The value "18" is the group number for the gpio pin 13 which is GPIOX.BIT11.

If you execute:

Code: Select all

fdtget /boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios


it should return 36 13 1 (in decimal notation) if you have a fresh copy of meson64_odroidc2.dtb. If you have changed the device tree, you will get back what you put in.

Every time there is update to the kernel, there is a revised copy of the device tree as well. Right now the latest device tree contains 36 13 1. In a few days, weeks or months it will be different.

Since you want that output transferred to a gpio pin of your choice, you really do not care what the original values were, only what you need to change them to. Unless of course you want to put them back the way they were, then you need to know what they were.

See this thread for more detail: http://forum.odroid.com/viewtopic.php?f=141&t=24373

Colin
Posts: 51
Joined: Mon Mar 06, 2017 2:33 am
languages_spoken: english
ODROIDs: ODROID-C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Colin »

Hi Paul,

Thanks for the explenation. I get it almost. Only one question. Where can I find that the value "18" is the group number for the gpio pin 13.

paulcrawford
Posts: 176
Joined: Tue May 10, 2016 11:51 am
languages_spoken: english
ODROIDs: c2 and n2
Has thanked: 26 times
Been thanked: 4 times
Contact:

Re: Power and status led question.

Post by paulcrawford »

Where can I find that the value "18" is the group number for the gpio pin 13.
That is an excellent question, and one that I tried to get the answer to from @odroid but basically unsucessfully.

It seems that for now the GPIOX group (14 of the 40 pin header) is group 18 while I believe that the GPIOY group (5 of the 40 pin header) is likely another group. I definitely do not know for sure on that or what it may be as fortunately the only pins that I had to change from default were both in the GPIOX group for 1-wire and the heartbeat led. I do actually use 3 of the GPIOY group but only as ordinary pins.

I got into this situation because I started using a Raspberry Pi 2 and had wired a hat (shield) to go to the outside world for 1-wire and heartbeat. I could have rewired for 1-wire to use the C2 default rather than how I had done it but the heartbeat had to be done in software to get it to a pin that I had wired to an external LED, so it seemed easier to do both in software.

You might want to ask @odroid again about this group numbering.

Colin
Posts: 51
Joined: Mon Mar 06, 2017 2:33 am
languages_spoken: english
ODROIDs: ODROID-C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Colin »

Thanks for the detailed explanation

paulcrawford
Posts: 176
Joined: Tue May 10, 2016 11:51 am
languages_spoken: english
ODROIDs: c2 and n2
Has thanked: 26 times
Been thanked: 4 times
Contact:

Re: Power and status led question.

Post by paulcrawford »

Glad to help. You seem to have resolved most of your issues now. Good luck with your future development...

Tihass1975
Posts: 1
Joined: Sun Mar 19, 2017 12:55 am
languages_spoken: german,english
ODROIDs: Odroid-C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Tihass1975 »

paulcrawford wrote:There is an error in your fdtput command:

Code: Select all

sudo fdtput /boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 30 103 0
should be:

Code: Select all

sudo fdtput /boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 18 103 0
That should get GPIOX.BIT11 blinking.

To get the blue heartbeat led running again you need to reset the device tree back to the original with ftdput like this:

Code: Select all

sudo fdtput /boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 36 13 1
I got the decimal values "36 13 1" from the very latest meson64_odroidc2.dtb file by doing a kernel build yesterday.
Hello,

If I understand this right, when I use this command:

Code: Select all

sudo fdtput /boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 18 103 0
I put the LED between Header Pin 13 and Pin 14 ? Sorry for my stupid Question i am a beginner !


Tihass

paulcrawford
Posts: 176
Joined: Tue May 10, 2016 11:51 am
languages_spoken: english
ODROIDs: c2 and n2
Has thanked: 26 times
Been thanked: 4 times
Contact:

Re: Power and status led question.

Post by paulcrawford »

The software side is correct for using pin 13 for a heartbeat signal with your fdtput command, but the hardware side is not correct.
I put the LED between Header Pin 13 and Pin 14 ? Sorry for my stupid Question i am a beginner !
On the hardware side, you need to connect the + (positive) side of the LED to pin 17 (3.3v) via a 1K Ω resistor to limit the current taken from pin 17. The - (negative) side of the LED needs to be connected to pin 13.

Once you do that, the LED will flash with the heartbeat signal.

Good luck.

Colin
Posts: 51
Joined: Mon Mar 06, 2017 2:33 am
languages_spoken: english
ODROIDs: ODROID-C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Colin »

Probable a stupid question. But is it possible to get the hearbeat to two gpio pins? And one gpio port blink and the other just turned on (or off when the system is shutdown)

paulcrawford
Posts: 176
Joined: Tue May 10, 2016 11:51 am
languages_spoken: english
ODROIDs: c2 and n2
Has thanked: 26 times
Been thanked: 4 times
Contact:

Re: Power and status led question.

Post by paulcrawford »

Colin wrote:Probable a stupid question. But is it possible to get the hearbeat to two gpio pins? And one gpio port blink and the other just turned on (or off when the system is shutdown)
Seems unlikely that you could get the heartbeat to two gpio pins. One blinking is what has been done already. One that is on or off only is similar to the power led but not exactly. I looked at the device tree file and there was nothing obvious to me that would allow moving the power led function to a specific gpio pin. Perhaps @odroid can shed more light on this.

Do not forget that the power led only senses the presence of 5V and when the system is shutdown, the power led may still be on. You may be looking for more of a "watchdog" pin that only is on if the system keeps kicking it.

What use will you be making of these gpio pins?

Colin
Posts: 51
Joined: Mon Mar 06, 2017 2:33 am
languages_spoken: english
ODROIDs: ODROID-C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Colin »

When you move the heartbeat to a gpio then the blue led is on when the odroid startup. And it is off when you shutdown. On that state the red led is still on.

And I would use this signal to complete shutdown (power off) the odroid. I need this because the gpio pins doesn’t change from state like the raspberry pi pins do to detect the shutdown.

Briefly: I need a gpio pin that give me the running / shutdown state.

rooted
Posts: 7755
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 721 times
Been thanked: 210 times
Contact:

Re: Power and status led question.

Post by rooted »

You need a pin that is high until the board is is fully shutdown and then becomes low?

Colin
Posts: 51
Joined: Mon Mar 06, 2017 2:33 am
languages_spoken: english
ODROIDs: ODROID-C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by Colin »

Yes, preferred just the other way low until the board is fully shutdown and then becomes hi. But that is simple to change.

belliash
Posts: 15
Joined: Tue Jul 11, 2017 9:02 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Power and status led question.

Post by belliash »

Hello,

How can I get this working on CoreElec? I have checked that /flash/dtb.img is specified in boot.ini as to be used.

Code: Select all

fdtget /flash/dtb.img /gpio_leds/heartbeat gpios
62 13 1

Code: Select all

CoreELEC:/flash # cat /proc/device-tree/le-dt-id
gxbb_p200_2g_odroid_c2
So I tried to do it as described:

Code: Select all

fdtput /flash/dtb.img /gpio_leds/heartbeat gpios 18 103 0
reboot
And after a reboot heartbeat blue led is solid on all the time - it stopped blinking. But my led attached to PIN13 is off. I have connected the led positive to PIN1 and led negative to PIN13.
What do I do wrong? Are the GPIO settings ok for this DTB?

User avatar
odroid
Site Admin
Posts: 34655
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 826 times
Been thanked: 713 times
Contact:

Re: Power and status led question.

Post by odroid »

@belliash,
Post your CoreELEC specific question on the *ELEL sub-forum.
viewforum.php?f=144

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest