Hello Together,
I have recently purchased the Beaglebone black board.
I am looking for the on board four USER LED’s existing source code file path (.c and .h).
(Heartbeat, MMC0, CPU0, MMC1)
I am trying to understand how the device tree source(4-LED’s) and actual .c / .h files(4-LED’s) mapped((Heartbeat, MMC0, CPU0, MMC1)).
Could you please reply if anyone of you know anything.
Thanks and Regards
Thank you @silver2row . I am looking for the existing .c and .h file which contains heartbeat/MMC0/MMC1/CPU0 source code. I am trying to understand how the device tree source(4-LED’s) and actual .c / .h files(4-LED’s (Heartbeat, MMC0, CPU0, MMC1)) mapped.
1 Like
There are links to gitlab and in gitlab for beagleboard.org called openbeagle.org, one would look up BeagleBoard-DeviceTrees and then it is up to you (I think) to handle the code for C/C++ or whatever language you choose to use for the patterning.
Also, @aminpragnesh3 , the four heartbeat pattern can be found on the boards…
Now where, I do not remember. Probably a mix of locations and files is what I remember.
I may find time soon. I will try to reply once I have confirmed the locations of the files.
Seth
The leds are defined in am335x-bone-common.dtsi -
The code that actually does the toggling will be somewhere in the Linux kernel source. Probably a search on linux triggers and leds will find you something and it will likely differ depending on the kernel version.
If you want to toggle the leds in user-land the link Seth gave is appropriate, but uses the newer libgpiod calls which is for newer kernels, so won’t work on older kernels.
leds {
pinctrl-names = "default";
pinctrl-0 = <&user_leds_s0>;
compatible = "gpio-leds";
led2 {
label = "beaglebone:green:usr0";
gpios = <&gpio1 21 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "heartbeat";
default-state = "off";
};
led3 {
label = "beaglebone:green:usr1";
gpios = <&gpio1 22 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "mmc0";
default-state = "off";
};
led4 {
label = "beaglebone:green:usr2";
gpios = <&gpio1 23 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "cpu0";
default-state = "off";
};
led5 {
label = "beaglebone:green:usr3";
gpios = <&gpio1 24 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "mmc1";
default-state = "off";
};
};
@benedict.hewson @silver2row thank you for quick reply. I want the repository where both am335x-bone-common.dtsi which you provided above plus the working USER LED’s source code .c / .h file (heartbeat/MMC0/MMC1/CPU0) . I am not looking for specific version I just want to analyze the source files for better understanding. Any available repository version is fine for me because I am not going to flash the SW on board.
https://git.beagleboard.org/beagleboard/linux
But the devicetree files are on the BBB I think, probably somewhere in /opt/ to make customisation easier, although may need an apt install if they are not there. Been a while since I checked.
The kernel is flashing the leds so you will need to find the relevant code in the kernel source.
What exactly are you trying to do ? Are you wanting to write a kernel driver that will flash an LED or flash an LED from userspace ?
Turning on the LED’s from userspace is going to be different to how the kernel does it and not much point looking at the kernel code.
Thank you again @benedict.hewson .
I am new to the embedded linux world. I understood the am335x-bone-common.dtsi and dependent .dts. I want to also see the already available source code .c files to know how this two files .dts/.dtsi and .c/.h connected with each other. That’s why single repository where both these files are present.
You are going to have to search the kernel drivers to find what you are looking for.
As a starting point search for the text in the compatible string in the devicetree. This text will appear in the driver source somewhere.
For example in the case of the leds
leds {
pinctrl-names = "default";
pinctrl-0 = <&user_leds_s0>;
compatible = "gpio-leds";
Searching for the string “gpio-leds” in the drivers directory of the kernel source finds
leds/leds-gpio.c
That is your starting point.
This is a kernel thing and not BBB specific. The same leds-gpio driver will likely be in any board that has leds.
@benedict.hewson Thank you. I will try your inputs. I mentioned BBB because 4 User LED’s are specific to BBB board. For this LED’s source code I am looking (heartbeat/MMC0/MMC1/CPU0).
@lranders Thank you for reply.