1

What is the best way to check at run time if a device tree overlay is loaded?

I've found info about checking individual GPIO pin status, and info about how to load the overlay (via config.txt), but I'm not finding info about how to check if the actual device tree overlay is loaded. I am specifically interested in knowing if the dpi24 overlay is active.

EDIT: There are 2 reasons I asked this question:

  1. I have an OpenGL program that runs on a RPi, and it needs to display differently depending on whether video is going directly to a monitor or it has been redirected to the GPIO pins (via the dpi24 overlay). Sure, I could add a command line switch or some other type of config parameter, but that violates the DRY principle, as well as introducing the possibility of the user choosing the wrong answer and then there is an inconsistency to resolve.

  2. I searched and read thru a bunch of info and didn't find the answer. It should be possible to do this, but appears to be undocumented (or not easy to find). So in addition to the DRY reason, I'm now also curious about it.

4
  • 1
    Smells like an XY problem.
    – goldilocks
    Mar 6, 2017 at 7:38
  • question edited to explain the reasons.
    – djulien
    Mar 7, 2017 at 1:56
  • I'd dig into sysfs; all or most hardware is represented in there somewhere somehow. A simple way to check it out would be to boot a pi with the overlay on, then save the output of sudo ls -R /sys to a file. Reboot it without the overlay applied, do the same thing, diff the files. This should at least give you a starting point for poking around. If you figure it out and have time, please leave an answer of your own.
    – goldilocks
    Mar 9, 2017 at 10:14
  • I suppose you could check if the compatible statement has loaded the specified module.
    – PaulF8080
    Mar 11, 2017 at 18:18

2 Answers 2

1

The output of sudo ls -R /sys contains a reference to dpi24_pins when it is loaded, so that will solve the problem - I can check it with a script. Thanks goldilocks!

0

1/ Using uboot

If installed, use fw_printenv it displays the uboot environment variables.

In my case here, I added an overlay and clearly see the variables associated to it in the uboot env:

# The output has been simplified for clarity
> fw_printenv 
baudrate=115200
board_name=DART-MX8M-MINI
bootdir=/boot
...
fdt_addr=0x43000000
fdt_file=imx8mm-var-dart-dt8mcustomboard.dtb
fdto_addr=0x43040000
fdto_file=test-overlay-cs-on-gpio1-11.dtbo
...

2/ Using Raspian special case

Look the content of the file /boot/config.txt it shows the currently loaded overlays at boot time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.