common:application_note:external_connector:alternative_heartbeat_led

'ODROID-N2' on this page refers to the ODROID-N2 series (N2, N2+, N2L).

Alternative Heartbeat LED

Test environments

HW Kernel
C2 3.14.79-117
C4 4.9.113+
N2 4.9.216+

You can remap the blue heartbeat LED to another pin.

Find `led` in the dts or `/proc/device-tree/`.

For example, C2 dts is as follows.

https://github.com/hardkernel/linux/blob/c3e4c730feb1750940971cae9ca1da3ca50f1d56/arch/arm64/boot/dts/meson64_odroidc2.dts#L768-L780

...
        leds: gpio_leds {
                compatible = "gpio-leds";

		pinctrl-names = "led_pins";
		pinctrl-0 = <&led_pins>;

                /* Blue LED */
                heartbeat {
                        label = "blue:heartbeat";
                        gpios = <&gpio_ao GPIOAO_13 GPIO_ACTIVE_LOW>;
                        linux,default-trigger = "heartbeat";
                };
        };
...

or

sudo find /proc/device-tree/ -name *led*
...
/proc/device-tree/gpio-leds
...

There is the heartbeat node in the gpio-leds node, and the gpios property in the gpio-leds node.

If you look for nodes related to `led` on another board like you found on c2, the result is:

HW node property
C2 /gpio-leds/heartbeat gpios
C4 /leds/blueled gpios
N2 /leds/blueled gpios

The gpios property has 3 parameters, &gpio_ao, GPIOAO_13, GPIO_ACTIVE_LOW in the C2.

  • &gpio_ao indicates a pin bank for a pin that would be used.
  • GPIOAO_13 indicates a pin for a heartbeat LED.
  • GPIO_ACTIVE_LOW is a flag for when the GPIO pin will be active. If in GPIO_ACTIVE_LOW, this GPIO pin is active when the output signal is 0.

GPIOAO_13 is connected with a blue LED on the C2 so that the LED is heartbeat-ing when C2 is running.

So if you want to use the other GPIO pin, change pin bank and number.

A tool, device-tree-compiler, can make you do that easier.

Install device-tree-compiler by the following commands.

target
sudo apt install device-tree-compiler

Now you can use fdtget and fdtput commands which makes us editing DTS without building a new kernel.

target
fdtget <dtb file path> /<node>/.../<node> <property>
target
fdtput [-t <type>] <dtb file path> /<node>/.../<node> <property> <value> [<value> ...]

* Find dtb file. * Find out setting values you want for gpios property. * Set the values.

Generally, .dtb file is in `/media/boot`.

sudo find / -name .dtb
...
/media/boot/meson64_odroidc2.dtb
...

pin bank

HW GPIO bank GPIO AO bank
C2 96 37
C4 19 17
N2 19 24

pin number

pin active-status

  • GPIO_ACTIVE_HIGH: 0
  • GPIO_ACTIVE_LOW: 1

If the positive(+) side of the LED is connected to 3.3V via a register, and the negative(-) side of the LED is connected to the GPIO pin you set, you should use GPIO_ACTIVE_HIGH.
Or if the positive(+) side of the LED is connected to the GPIO pin you set via a register, and the negative(-) side of the LED is connected to the ground, you should use GPIO_ACTIVE_LOW.
Actually it depends on your system, choose the proper one by the environment you're in.

Pick values

If you want to use pin 13(GPIOX_11 on C2) at the physical location and led active status is HIGH, pick GPIO bank(96), GPIOX_11(103), and GPIO_ACTIVE_HIGH(0) for values of `gpios` property.

To test, I've connected our Tinkering Kit to my C2.
And I've set the test environment with a register and a LED that sets with the positive(+) side of the LED is connected to the GPIO pin #13 via a 330Ω register, and the negative(-) side of the LED is connected to the ground.
Please see the picture below.


On C2, it does by simply enter the proper command.
Since I've connected the pin at the GPIO pin #13(GPIOX_11), I'll enter 96(pin bank) 103(pin number) as first two parameters.
And I need to add a parameter 0(GPIO_ACTIVE_LOW) to show the heartbeat properly.

Don't forget that you should reboot to have effect.

target
root@odroid64:~# fdtput /media/boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 96 103 0
root@odroid64:~# reboot

After the reboot, the LED heartbeats like a blue LED on the board before.

You can check whether the changes written in Device Tree well or not.

target
root@odroid64:~# fdtget /media/boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios
96 103 0

To back to the default, enter the following commands.

target
root@odroid64:~# fdtput /media/boot/meson64_odroidc2.dtb /gpio_leds/heartbeat gpios 37 13 1
root@odroid64:~# reboot


Surely you can use the other pin you want by following this guide.

  • common/application_note/external_connector/alternative_heartbeat_led.txt
  • Last modified: 2022/11/08 14:26
  • by luke.go