tegra throttling monitor
DESCRIPTION
The implementation of nVidia Tegra throttling mechanism monitor with customized script/tool.TRANSCRIPT
Design Spec. of
nVidia Throttling Monitor(nTM)
PurposeThis program was created to monitor CPU related behavior, by reporting result
after thermal management mechanism starts with information such as throttled
CPU temperature, frequency and trigger flag.
Preparation1. Ubuntu/Linux environment is recommended to run this tool.
2. This tool will be functional in any kind of product on Android platform by
adb shell, including Smart phone (S500) and Tablet
(A720/A510/A700/A210/A100).
Contributions1. Help User (RD/TE) to be familiar with the basic operation of CPU throttling
mechanism no matter on platform nVidia Tegra or QCT 8X series.
2. Customized configuration of testing count, timing and throttling threshold
are done within this tool to fit with different need in specified project.
3. Automatically report for the result of successfully CPU throttled by
customized messages such as, “Normal”, “PASS” or “Failed”.
4. Can be logged to text file for developer’s reference when problems need to
be traced or solved.
Concept1. All related source code was created with shell script under GPL agreement .
2. Several arguments, variables or path may need to be fixed or adjusted by
specified project.
3. By regularly reporting routines, it will show the current platform
information (CPU frequency/temperature/flag, etc.), once the customized
threshold was reached, the information will changed to show messages
related to throttled result.
4. This tool will be automatically shutdown once the goal (successfully
throttled) was done, otherwise the process will keep going on monitoring.
Operation1. Copy tool “run_nTM.sh” to path where adb resides.
cp run_nTM.sh /the/path/of/your/adb
2. Change permission by the following command,
chmod 755 run_nTM.sh
3. Execute by the following command,
./run_nTM.sh
4. Console will show message as follow, please input with decimal number.
5. Input customized Throttling threshold with decimal number.
6. Daemon will start to monitor as the following message, Status item will
keep showing “Normal” when one any threshold was reached.
7. Daemon starts analyze the latest status once Throttling threshold was
reached by the following message, If DUT is still getting hot, the
monitoring daemon will keep working as usual by show “Failed, try again!”
as below:
8. The “PASS” message will be popup to user when any one of cooling
condition was reached, including the lower of CPU frequency, temperature,
or Throttling flag was dismissed. Daemon will be automatically killed once
the result is PASS within 10 seconds. (customizable)
ImplementationSource code is presented at the bottom of this document.
#!/bin/bash
#
# Program: nVidia Throttling Monitor (nTM)
# This program was created to monitor CPU temperature
# and clock, reporting result after throttle mechanism starts.
#Arthor:
# History:
# 2012/10/25 v0.2
#Sysfs node:
# CPU Temperature: /sys/devices/platform/tegra-i2c.4/i2c-4/4-004c/temperature
# CPU Frequency: /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
# CPU Frequency: /d/clock/cpu/rate
# Throttle Flag: /sys/devices/system/cpu/cpu0/cpufreq/throttle
# Throttle Flag: /d/cpu-tegra/throttle
count=0
cpu_tp=0
cpu_ck=0
new_ck=0
cpu_tl=2
tl_level=0
st_level=90
bat_tp=0
chg_cr=0
tmp_lv=0
echo -n "Please Input Testing Count : "
read count
if [ "$count" = 0 -o "$count" = "" ]; then
echo "Invalid count, input AGAIN! "
read count
fi
echo -n "Please Input Throttle Threshold (>0) : "
read tl_level
if [ "$tl_level" = 0 -o "$tl_level" = "" ]; then
echo "Invalid threshold, input AGAIN! "
read tl_level
if [ "$tl_level" = 0 -o "$tl_level" = "" ]; then
echo "Wrong Threshold again, program terminated. "
exit 0
fi
fi
echo "-----------------------------"
for (( x=1 ; x<=count ; x=x+1 ))
do
today=`date`
echo $today
echo "nTM Getting data count [$x]"
echo " "
tmp_lv=$(./adb shell cat /sys/class/i2c-dev/i2c-4/device/4-
004c/temperature_alert)
echo "Alert_limit: $tmp_lv"
cpu_tp=$(./adb shell cat /sys/class/i2c-dev/i2c-4/device/4-
004c/ext_temperature)
echo "CPU_now_tmp: $cpu_tp"
cpu_ck=$(./adb shell cat /d/clock/cpu/rate)
echo "CPU_cur_feq: $cpu_ck"
cpu_tl=$(./adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/throttle)
# echo "Throt_state: $cpu_tl"
bat_tp=$(./adb shell cat /sys/dev-info_battery/Temperature)
echo "Bat_now_tmp: $bat_tp"
chg_cr=$(./adb shell cat /sys/dev-info_battery/Charge_current)
echo "Chg_current: $chg_cr"
echo " "
if [ "$cpu_tl" = 1 -o "$cpu_tp" \> $tl_level ]; then
echo "Status: Over Threshold $tl_level"
echo "Action: Start Throttling"
for (( y=1 ; y<=5 ; y=y+1 ))
do
new_ck=$(./adb shell cat /d/clock/cpu/rate)
echo "CPU_cur_feq: $new_ck"
sleep 2
cpu_tp=$(./adb shell cat /sys/class/i2c-dev/i2c-4/device/4-
004c/ext_temperature)
if [ "$cpu_tp" \< $tl_level -o $new_ck \< $cpu_ck ]; then
echo "Result: Throttle Completed"
cpu_ck=$(./adb shell cat /d/clock/cpu/rate)
cpu_tp=$(./adb shell cat /sys/class/i2c-dev/i2c-4/device/4-
004c/ext_temperature)
echo " "
echo "??Info after Throttling "
echo "??CPU_now_tmp: $cpu_tp"
echo "??CPU_cur_feq: $cpu_ck"
echo "??Bat_now_tmp: $bat_tp"
echo "??Chg_current: $chg_cr"
sleep 2
echo " "
echo "Report: Function PASS!"
echo "nTM will auto terminate in 10 seconds..."
echo " "
sleep 10
exit 0
else
if [ $y = 5 ]; then
echo "Result: Failed, try again!"
else
echo "Result: cooling stage $y"
fi
fi
done
else
echo "Status: Normal"
fi
echo "-----------------------------"
sleep 3
done
echo "nTM complete with $count times"
echo "-----------------------------"