Difference between revisions of "Raspberry Pi Userland (VCGENCMD)"

From Funtoo
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 10: Line 10:


Please read [[Raspberry Pi]] for general information about installing Funtoo Linux on Raspberry Pi Board (armv6j).
Please read [[Raspberry Pi]] for general information about installing Funtoo Linux on Raspberry Pi Board (armv6j).
The [https://github.com/raspberrypi/userland media-libs/raspberrypi-userland] is ebuild to compile Raspberry Pi userspace tools and libraries.


== Installation ==
== Installation ==
=== Install dependencies ===
{{console|body=
###i## emerge app-admin/sudo dev-util/cmake
}}


=== Raspberry Pi Userland ===


=== Compile Raspberry Pi Userland (recommended) ===
{{console|body=
###i## git clone https://github.com/raspberrypi/userland.git
###i## cd userland/ ; ./buildme
###i## echo '/opt/vc/lib' > /etc/ld.so.conf.d/vc.conf ; ldconfig
###i## echo -e '# /etc/env.d/00vcgencmd\n# Do not edit this file\n\nPATH="/opt/vc/bin:/opt/vc/sbin"\nROOTPATH="/opt/vc/bin:/opt/vc/sbin"\nLDPATH="/opt/vc/lib"' > /etc/env.d/00vcgencmd
###i## env-update
###i## ldconfig
}}
=== Precompiled Raspberry Pi Userland (optional) ===
Get Raspberry Pi userspace tools and libraries (VCGENCMD):
Get Raspberry Pi userspace tools and libraries (VCGENCMD):


<console>
{{console|body=
# ##i##cd /tmp/
###i## cd /tmp/
# ##i##git clone --depth 1 git://github.com/raspberrypi/firmware/
###i## git clone --depth 1 git://github.com/raspberrypi/firmware/
# ##i##cp -r firmware/hardfp/opt/vc /opt/
###i## cp -r firmware/hardfp/opt/vc /opt/
</console>
}}
 


Configure PATH and libs:
Configure PATH and libs:


<console>
{{console|body=
# ##i##echo -e '# /etc/env.d/00vcgencmd\n# Do not edit this file\n\nPATH="/opt/vc/bin:/opt/vc/sbin"\nROOTPATH="/opt/vc/bin:/opt/vc/sbin"\nLDPATH="/opt/vc/lib"' > /etc/env.d/00vcgencmd
###i## echo -e '# /etc/env.d/00vcgencmd\n# Do not edit this file\n\nPATH="/opt/vc/bin:/opt/vc/sbin"\nROOTPATH="/opt/vc/bin:/opt/vc/sbin"\nLDPATH="/opt/vc/lib"' > /etc/env.d/00vcgencmd
# ##i##env-update
###i## env-update
# ##i##ldconfig
###i## ldconfig
</console>
}}




Line 35: Line 56:
=== Amount of memory dedicated to the operating system and video ===
=== Amount of memory dedicated to the operating system and video ===


<console>
{{console|body=
# ##i##vcgencmd get_mem arm && vcgencmd get_mem gpu
###i## vcgencmd get_mem arm && vcgencmd get_mem gpu
</console>
}}


=== Frequency (clock) ===
=== Frequency (clock) ===


<console>
{{console|body=
# ##i##for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do echo -e "$src:\t$(vcgencmd measure_clock $src)" ; done
###i## for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do echo -e "$src:\t$(vcgencmd measure_clock $src)" ; done
</console>
}}


=== Volts ===
=== Volts ===


<console>
{{console|body=
# ##i##for id in core sdram_c sdram_i sdram_p ; do  echo -e "$id:\t$(vcgencmd measure_volts $id)" ;  done
###i## for id in core sdram_c sdram_i sdram_p ; do  echo -e "$id:\t$(vcgencmd measure_volts $id)" ;  done
</console>
}}


== Version ==
== Version ==
Show firmware version:
Show firmware version:


<console>
{{console|body=
# ##i##vcgencmd version
###i## vcgencmd version
</console>
}}


== Temperature ==
== Temperature ==
Try measure temperature:
Try measure temperature:


<console>
{{console|body=
# ##i##vcgencmd measure_temp
###i## vcgencmd measure_temp
</console>
}}


  temp=48.7'C
  temp=48.7'C
Line 70: Line 91:
Shows whether the specified codec is enabled, the codec can be one of '''H264''', '''MPG2''', '''WVC1''', '''MPG4''', '''MJPG''', '''WMV9'''. Please note that it was implemented in a Pi with licenses '''MPG2''' e '''VC1''' activated.
Shows whether the specified codec is enabled, the codec can be one of '''H264''', '''MPG2''', '''WVC1''', '''MPG4''', '''MJPG''', '''WMV9'''. Please note that it was implemented in a Pi with licenses '''MPG2''' e '''VC1''' activated.


<console>
{{console|body=
# ##i##for codec in H264 MPG2 WVC1 MPG4 MJPG WMV9 ; do echo -e "$codec:\t$(vcgencmd codec_enabled $codec)" ; done
###i## for codec in H264 MPG2 WVC1 MPG4 MJPG WMV9 ; do echo -e "$codec:\t$(vcgencmd codec_enabled $codec)" ; done
</console>
}}


== Performance analysis ==
== Performance analysis ==
Line 78: Line 99:
This analysis require "stress" ebuild:
This analysis require "stress" ebuild:


<console>
{{console|body=
# ##i##emerge app-benchmarks/stress
###i## emerge app-benchmarks/stress
</console>
}}


Measure the temperature and cause a 'stress' to measure heat dissipation:
Measure the temperature and cause a 'stress' to measure heat dissipation:


<console>
{{console|body=
# ##i##vcgencmd measure_temp && stress  --cpu 1 -t 300 &&  vcgencmd measure_temp
###i## vcgencmd measure_temp && stress  --cpu 1 -t 300 &&  vcgencmd measure_temp
</console>
}}


You may notice that "stress" the processor increases the temperature, but nowhere near 80 ° C. I always compile a lot of things in parallel so distributed with x86_64 hosts or other raspberry's cluster.
You may notice that "stress" the processor increases the temperature, but nowhere near 80 ° C. I always compile a lot of things in parallel so distributed with x86_64 hosts or other raspberry's cluster.
Line 94: Line 115:
For security reasons, add a script that will check the temperature every five minutes and turn off the Raspberry Pi if it exceeds 78 ° C.
For security reasons, add a script that will check the temperature every five minutes and turn off the Raspberry Pi if it exceeds 78 ° C.


<console>
{{console|body=
# ##i##vi /usr/bin/tempcheck
###i## vi /usr/bin/tempcheck
</console>
}}


<pre>
<pre>
Line 138: Line 159:
Give execute permission:
Give execute permission:


<console>
{{console|body=
# ##i## chmod +x /usr/bin/tempcheck
###i## chmod +x /usr/bin/tempcheck
</console>
}}


Set the Crontab to run the script every 5 minutes:
Set the Crontab to run the script every 5 minutes:

Latest revision as of 22:56, October 16, 2018

   Warning

In above mentioned guide installation is more detailed

The Raspberry Pi is an ARM device (BCM2835, ARMv6).

This document contains notes about install Userland for Raspberry Pi on Funtoo Linux. Most information is already available on other documents, so this document mostly explains how to get the information needed to perform the installation.

Please read Funtoo Linux Installation on ARM for general information about installing Funtoo Linux on ARM architecture.

Please read Raspberry Pi for general information about installing Funtoo Linux on Raspberry Pi Board (armv6j).

The media-libs/raspberrypi-userland is ebuild to compile Raspberry Pi userspace tools and libraries.


Installation

Install dependencies

root # emerge app-admin/sudo dev-util/cmake


Compile Raspberry Pi Userland (recommended)

root # git clone https://github.com/raspberrypi/userland.git
root # cd userland/ ; ./buildme
root # echo '/opt/vc/lib' > /etc/ld.so.conf.d/vc.conf ; ldconfig
root # echo -e '# /etc/env.d/00vcgencmd\n# Do not edit this file\n\nPATH="/opt/vc/bin:/opt/vc/sbin"\nROOTPATH="/opt/vc/bin:/opt/vc/sbin"\nLDPATH="/opt/vc/lib"' > /etc/env.d/00vcgencmd
root # env-update
root # ldconfig


Precompiled Raspberry Pi Userland (optional)

Get Raspberry Pi userspace tools and libraries (VCGENCMD):

root # cd /tmp/
root # git clone --depth 1 git://github.com/raspberrypi/firmware/
root # cp -r firmware/hardfp/opt/vc /opt/


Configure PATH and libs:

root # echo -e '# /etc/env.d/00vcgencmd\n# Do not edit this file\n\nPATH="/opt/vc/bin:/opt/vc/sbin"\nROOTPATH="/opt/vc/bin:/opt/vc/sbin"\nLDPATH="/opt/vc/lib"' > /etc/env.d/00vcgencmd
root # env-update
root # ldconfig


Commands

Amount of memory dedicated to the operating system and video

root # vcgencmd get_mem arm && vcgencmd get_mem gpu

Frequency (clock)

root # for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do echo -e "$src:\t$(vcgencmd measure_clock $src)" ; done

Volts

root # for id in core sdram_c sdram_i sdram_p ; do  echo -e "$id:\t$(vcgencmd measure_volts $id)" ;  done

Version

Show firmware version:

root # vcgencmd version

Temperature

Try measure temperature:

root # vcgencmd measure_temp
temp=48.7'C

Codecs

Shows whether the specified codec is enabled, the codec can be one of H264, MPG2, WVC1, MPG4, MJPG, WMV9. Please note that it was implemented in a Pi with licenses MPG2 e VC1 activated.

root # for codec in H264 MPG2 WVC1 MPG4 MJPG WMV9 ; do echo -e "$codec:\t$(vcgencmd codec_enabled $codec)" ; done

Performance analysis

This analysis require "stress" ebuild:

root # emerge app-benchmarks/stress

Measure the temperature and cause a 'stress' to measure heat dissipation:

root # vcgencmd measure_temp && stress  --cpu 1 -t 300 &&  vcgencmd measure_temp

You may notice that "stress" the processor increases the temperature, but nowhere near 80 ° C. I always compile a lot of things in parallel so distributed with x86_64 hosts or other raspberry's cluster.


Controlling the temperature of the Raspberry Pi

For security reasons, add a script that will check the temperature every five minutes and turn off the Raspberry Pi if it exceeds 78 ° C.

root # vi /usr/bin/tempcheck
#!/bin/sh
# This script reads the value of the SoC Broadcom temperature and turns off
# Exceeds a certain value.
# 80 ° C is the maximum allowed for a Raspberry Pi.

LOCK="/tmp/tempcheck.lock"
if [ -e ${LOCK} ]; then
        echo -e "SoC temperature check failure. Another process is in execution:\n\n"
        exit 1
fi

#####################################
# Creating LOCK
touch ${LOCK}

# Transforms the value read in integer
SENSOR="$(vcgencmd measure_temp | cut -d "=" -f2 | cut -d "'" -f1 | cut -d '.' -f1)"
TEMP="$(printf "%.0f\n" ${SENSOR})"
# Sets supported maximum temperature
MAX="78"

if [ "${TEMP}" -gt "${MAX}" ] ; then
        # Will be sent an email to the root if executed via cron
        echo "${TEMP}ºC is too hot!"
        # Logs an event in the system log
        /usr/bin/logger "Shutting down due to SoC temp ${TEMP}."
        # Halt hardware
        rm ${LOCK}
        /sbin/shutdown -h now
else
        # Remove lock
        rm ${LOCK}
        exit 0
fi


Give execute permission:

root # chmod +x /usr/bin/tempcheck

Set the Crontab to run the script every 5 minutes:

*/5 *   *   *   *    /usr/bin/tempcheck