Dietpi: "tvservice" and "vcgencmd" | $PATH and $LD_LIBRARY_PATH

Created on 19 Apr 2018  ·  5Comments  ·  Source: MichaIng/DietPi

A while ago I recognized that DietPi-Boot produces an error massage when trying to execute tvservice -o and me being unable to execute vcgencmd to get settings etc.: "command not found"

  • So I added full path /opt/vc/bin/vcgencmd|tvservice and ran into next error: "library not found"
  • So I added LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vc/lib /opt/vc/bin/vcgencmd|tvservice which worked then.

Since we use both commands within DietPi scripts, I guess this has something to do with me purging all raspberrypi-firmware (kernel, bootloader, vc library and libaries) packages, relying completely on rpi-update, which generally works fine. By this I have some additional free space, since documentation and stuff is skipped, compared with our solution to just set those packages on hold, when using G_RPI_UPDATE. But there seem to be other, more important things, missing as well 😅.

  • I guess the packages also add vc library and binaries to PATH/LD_LIBRARY_PATH, or add related symlinks for the binaries. Could someone verify this: echo $PATH and/or check bin/sbin folders, how those binaries are added to shell?
  • I learned that LD_LIBRARY_PATH should/cannot be set just as exported variable. Also it is empty for me, when I try echo, even that default libc and armhf libraries are obviously inside. The method to add those to system, is adding them via /etc/ld.so.conf.d/, where also the ones for libc and armhf are found. Could someone check if on RPi with firmware packages installed, there is an additional entry for RPi/videocore: ls -al /etc/ld.so.conf.d/?

I use bashrc/dietpi-globals to add aliases for the needed commands, but this excludes all the other binaries and aliases are not available from within scripts (needs additional edit there), so would be good to know, how this is officially implemented:

[ -f /opt/vc/bin/vcgencmd ] && alias vcgencmd="LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vc/lib /opt/vc/bin/vcgencmd"
[ -f /opt/vc/bin/tvservice ] && alias tvservice="LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vc/lib /opt/vc/bin/tvservice"
Question RPi

All 5 comments

Fresh RPi install:

root@DietPi:~# vcgencmd
root@DietPi:~# tvservice -o
Powering off HDMI
root@DietPi:~# tvservice -oecho $PATH^C
root@DietPi:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
root@DietPi:~# echo $LD_LIBRARY_PATH

root@DietPi:~# which vcgencmd
/usr/bin/vcgencmd
root@DietPi:~# which tvservice
/usr/bin/tvservice

libraspberrypi-bin is the package which contains these programs:

The following packages will be REMOVED:
  libraspberrypi-bin*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 1,264 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 16943 files and directories currently installed.)
Removing libraspberrypi-bin (1.20180417-1) ...
root@DietPi:~# which tvservice
root@DietPi:~# which vcgencmd
root@DietPi:~#

Interesting, RPi firmware has it in /opt/vc as you mentioned:
https://github.com/raspberrypi/firmware/tree/master/opt/vc/bin

Another option, we could just move /opt/vc/bin/vcgencmd etc to /usr/bin after G_RPI_UPDATE?
Ah, then the library issue. So your original solution is probably ideal LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vc/lib /opt/vc/bin/vcgencmd|tvservice

LD_LIBRARY_PATH+=':/opt/vc/lib';PATH+=':/opt/vc/bin'

@Fourdee
Ahh, the APT package puts them into /usr/bin/, okay that explains it. Are those symlinks to /opt/vc/bin? Otherwise updated binaries by rpi-update would be ignored Oo. Did you check ls -al /etc/ld.so.conf.d/ if there is an entry to add the library?

If everything is as above (library link + symlinks), then I think we do not need to adjust anything and I would leave the packages in place. There might be other things missing when purging them and just using rpi-update. Maybe I find some time to analyse those more closely or open issue at rpi-update for clarification.

@MichaIng

Seems its a direct symlink, interesting:

root@DietPi:~# ls -lha /usr/bin/vcgencmd
lrwxrwxrwx 1 root root 20 Apr 17 13:07 /usr/bin/vcgencmd -> /opt/vc/bin/vcgencmd

root@DietPi:~# ls -lha /usr/bin/tvservice
lrwxrwxrwx 1 root root 21 Apr 17 13:07 /usr/bin/tvservice -> /opt/vc/bin/tvservice
root@DietPi:~# cat /etc/ld.so.conf.d/00-vmcs.conf
/opt/vc/lib

@Fourdee
Nice, thanks for checking this. So it's handled more less as expected and for my impression this is also the method that makes most sense: I guess all binaries from within /opt/vc/bin are linked then to allow global access.

I am already asking at an open issue on rpi-update if other important things are done by the APT packages that need to be done manually when just using rpi-update (and purging APT packages). I will experiment with this, but as said: On DietPi we should stay with the packages to be on the secure side. There are other ways to prevent most man/info pages from being installed 😉.

I added the symlinks and 00-vmcs.conf to my system and everything works fine without aliases or some other things 👍.

Just for completeness: device-tree-compiler needs to be marked manual as well, when purging raspberrypi-firmware APT packages, if someone wants to test.

But again, I don't think this is a good idea for end users, as I am not sure if something else is missing for GPU depending software e.g.. So I mark as closed for now.


€: Package installation scripts can be found here: https://github.com/RPi-Distro/firmware/tree/debian/debian

  • What does hardfp/opt/vc/bin/* /opt/vc/bin/ inside raspbarrypi-bin:armhf install script do?
  • Binary links: https://github.com/RPi-Distro/firmware/blob/debian/debian/libraspberrypi-bin.links
  • ld.so.conf.d entry: https://github.com/RPi-Distro/firmware/blob/debian/debian/libraspberrypi0.install.armhf
    => A lot of steps are done all together, proves assumption that it is no good idea to skip these packages at all, if GPU/vc depending software is used. Just bootloader/kernel is uncritical, works fine with rpi-update only.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

bhaveshgohel picture bhaveshgohel  ·  3Comments

1021683053 picture 1021683053  ·  3Comments

Fourdee picture Fourdee  ·  3Comments

Fourdee picture Fourdee  ·  3Comments

pgferr picture pgferr  ·  3Comments