henryww
Posts: 7
Joined: Fri Aug 10, 2018 12:23 pm

Bash script for testing Raspberry pi stability after overclock

Sun Aug 12, 2018 5:59 am

Hi, I was inspired by explaining computers video on Extreme Raspberry pi cooling solutions and decided to make this stability test script, it is not complete yet but runs and I am looking to improve many things.
You can find the code on github here: https://github.com/HenryWait/Raspi_stability_test

I will also put a copy here:

Code: Select all

#!/bin/bash
# This script is for testing stability after overclock and cooling capability on Raspberry Pi(es).
# stress is a required program for this script to work so please install with: sudo apt-get install stress

# clear the screen.
clear

# print ascii art header.
echo "$(tput setaf 2)
   .~~.   .~~.
  '. \ ' ' / .'$(tput setaf 1)
   .~ .~~~..~.
  : .~.'~'.~. :
 ~ (   ) (   ) ~
( : '~'.~.'~' : )
 ~ .~ (   ) ~. ~
  (  : '~' :  ) $(tput sgr0) Stability Test$(tput setaf 1)
   '~ .~~~. ~'
       '~'
$(tput sgr0)" 
 

# Show CPU frequency and temperature function:
temp_freq () {
    local FREQ=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq) # measure current CPU frequency on raspberry pi.
    local TEMP=$(vcgencmd measure_temp | tail -c 7) # Measure current temperature on raspberry pi.
    echo "The CPU frequency is $(($FREQ / 1000))mhz"
    echo "The CPU temperature is $TEMP"
}


# Determine model of pi this script is running on function:
pi_model () {
    # Determine how many cores this system has, pi 1 and zero have 1 core, pi 2 and 3 have 4.
    local CORES=$(nproc)
    if [ $CORES == 4 ]
    then
        echo "Running stress test for Raspberry Pi 2 or 3"
    else
        echo "Running stress test for Raspberry Pi 1 or ZERO"
    fi
}

# GLXGears test function:
glx_gears () {
    # glxgears to put load on GPU too
    glxgears > /home/$USER/Desktop/glxgears.log & sleep $TIME ; kill $!
}

# stress test function:
stress_test () {
    local TIME=250 # how long the stress test runs for
    local CORES=$(nproc) # determine how many cores this system has
    # stress test, should make pi reach max temp if ran long enough:
    echo "Running stress and GLXgears for $TIME seconds"
    stress --cpu $CORES --timeout $TIME > /home/$USER/Desktop/stress.log &
    glx_gears
}

PS3='Please enter your choice: '
options=("Stress Test" "Show temperature" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Stress Test")
            # print pi model 
            pi_model 
            # print CPU frequency and temperature before running at full load:
            temp_freq
            # run the stress test
            stress_test
            # print CPU frequency and temperature after running at full load:
            temp_freq
            ;;
        "Show temperature")
            # print CPU frequency and temperature
            temp_freq
            ;;
        "Quit")
            # quit the program
            break
            ;;
        *) echo invalid option;;
    esac
done
If anyone wishes to use this or change it, I welcome you, all I ask is if you have any contributions that you please help improve my program.

LizardLad_1
Posts: 133
Joined: Sat Jan 13, 2018 12:29 am

Re: Bash script for testing Raspberry pi stability after overclock

Thu Aug 16, 2018 10:03 am

That is really cool! Keep up the good work!

User avatar
jahboater
Posts: 8760
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Bash script for testing Raspberry pi stability after overclock

Tue Aug 21, 2018 3:54 pm

Thanks for posting - great contribution.

I run mostly headless so glxgears cannot be used.
"stress --cpu 4" barely gets my Pi3B+ warm - 51C after an hour (28C ambient).

I use cpuburn

Code: Select all

wget https://raw.githubusercontent.com/ssvb/cpuburn-arm/master/cpuburn-a53.S
gcc -o cpuburn-a53 cpuburn-a53.S
./cpuburn-a53
which uses NEON on all four cores and gets Pi's hot very quickly (70C and throttling after a few minutes).
If your over clock cannot run this for an hour or so - its failed - don't trust it.

Also I use memtester (sudo apt install memtester).

sudo memtester 800m 10

or four instances of "sudo memtester 200m 10" in four windows.

Finally run cpuburn at the same time as the last test to check its stable when hot, again for an hour.

I monitor everything in another window with:

Code: Select all

#!/bin/bash
Counter=14
DisplayHeader="Time      Temp    CPU        Throttle        Vcore"
while true ; do
  let Counter++
  if [ ${Counter} -eq 15 ]; then
    echo -e "${DisplayHeader}"
    Counter=0
  fi
  Health=$(perl -e "printf \"%19b\n\", $(vcgencmd get_throttled | cut -f2 -d=)")
  Temp=$(vcgencmd measure_temp | cut -f2 -d=)
  RealClockspeed=$(vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )
  CoreVoltage=$(vcgencmd measure_volts | cut -f2 -d= | sed 's/000//')
  echo -e "$(date '+%H:%M:%S') ${Temp} $(printf '%4s' ${RealClockspeed})MHz $(printf '%019d' ${Healt
  sleep 10
done
Actually, the temperature of interest is the "delta-T" the difference between the SoC temp and the ambient temp.
Sadly people who quote temps here rarely state the ambient temperature, so the figures are meaningless.

ejolson
Posts: 11312
Joined: Tue Mar 18, 2014 11:47 am

Re: Bash script for testing Raspberry pi stability after overclock

Wed Aug 22, 2018 12:22 am

jahboater wrote:
Tue Aug 21, 2018 3:54 pm
Thanks for posting - great contribution.

I run mostly headless so glxgears cannot be used.
"stress --cpu 4" barely gets my Pi3B+ warm - 51C after an hour (28C ambient).

I use cpuburn

Code: Select all

wget https://raw.githubusercontent.com/ssvb/cpuburn-arm/master/cpuburn-a53.S
gcc -o cpuburn-a53 cpuburn-a53.S
./cpuburn-a53
which uses NEON on all four cores and gets Pi's hot very quickly (70C and throttling after a few minutes).
If your over clock cannot run this for an hour or so - its failed - don't trust it.

Also I use memtester (sudo apt install memtester).

sudo memtester 800m 10

or four instances of "sudo memtester 200m 10" in four windows.

Finally run cpuburn at the same time as the last test to check its stable when hot, again for an hour.

I monitor everything in another window with:

Code: Select all

#!/bin/bash
Counter=14
DisplayHeader="Time      Temp    CPU        Throttle        Vcore"
while true ; do
  let Counter++
  if [ ${Counter} -eq 15 ]; then
    echo -e "${DisplayHeader}"
    Counter=0
  fi
  Health=$(perl -e "printf \"%19b\n\", $(vcgencmd get_throttled | cut -f2 -d=)")
  Temp=$(vcgencmd measure_temp | cut -f2 -d=)
  RealClockspeed=$(vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )
  CoreVoltage=$(vcgencmd measure_volts | cut -f2 -d= | sed 's/000//')
  echo -e "$(date '+%H:%M:%S') ${Temp} $(printf '%4s' ${RealClockspeed})MHz $(printf '%019d' ${Healt
  sleep 10
done
Actually, the temperature of interest is the "delta-T" the difference between the SoC temp and the ambient temp.
Sadly people who quote temps here rarely state the ambient temperature, so the figures are meaningless.
I believe "stress --cpu 4" was designed to test the operating system software scheduler rather than the reliability of the hardware.

From what I understand, cpuburn is great for verifying whether your thermal management solution is sufficient, but of little use for over clocking because only catastrophic events leading to a full system crash are detectible. In particular, cpuburn doesn't actually check whether the computer malfunctioned during the run.

If over clocking, I would recommend running the Linpack benchmark as described here and also here to determine whether the CPU makes arithmetic errors with the over-clock settings.

User avatar
jahboater
Posts: 8760
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Bash script for testing Raspberry pi stability after overclock

Wed Aug 22, 2018 7:35 am

ejolson wrote:
Wed Aug 22, 2018 12:22 am
From what I understand, cpuburn is great for verifying whether your thermal management solution is sufficient, but of little use for over clocking because only catastrophic events leading to a full system crash are detectible. In particular, cpuburn doesn't actually check whether the computer malfunctioned during the run.

If over clocking, I would recommend running the Linpack benchmark as described here and also here to determine whether the CPU makes arithmetic errors with the over-clock settings.
Yes agreed.

Its not as good I know, but memtester does do extensive validation of memory access (and its trivial to install).
I found in the past that running four instances of it (testing 1/4 of main memory each), possibly combined with cpuburn (which uses NEON) to heat the SoC up, would show errors early on.

It is perhaps naive but I would hope at low temps the results would be correct.
My cooling is good - on a hot day I can run a very heavy load for extended periods and the temp might just peak at 60C (so it runs at 1400MHz the entire time). I have had inexplicable build failures on old Pi3's in the early days before they fixed the voltages, but never on the 3B+.

Could you point to some recent and simple/complete instructions for running the Linpack benchmark on a 3B+ ?

User avatar
bensimmo
Posts: 6284
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Bash script for testing Raspberry pi stability after overclock

Wed Aug 22, 2018 8:59 am

Do any of them test the VC4 and interfaces?

Why not just run all of them at once?

Or install the desktop and do a simple loop program in scratch 3 in chromium.
That makes the interface laggy, juddery and painful and gets it damn hot until throttling kills everything to a snails pace. On a 3B+
;-)
Stretch the instructions through the ARM and VC4* and Memory and interfaces all at once.

ejolson
Posts: 11312
Joined: Tue Mar 18, 2014 11:47 am

Re: Bash script for testing Raspberry pi stability after overclock

Wed Aug 22, 2018 7:35 pm

jahboater wrote:
Wed Aug 22, 2018 7:35 am
Could you point to some recent and simple/complete instructions for running the Linpack benchmark on a 3B+ ?
Since the 3B+ is still running in 32-bit ARMv7 compatibility mode, the instructions posted here by Dr Weaver (deater) are still current. There is also a good chance that the binary posted there still works, but I haven't tried it.

User avatar
jahboater
Posts: 8760
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Bash script for testing Raspberry pi stability after overclock

Thu Aug 23, 2018 6:15 am

ejolson wrote:
Wed Aug 22, 2018 7:35 pm
jahboater wrote:
Wed Aug 22, 2018 7:35 am
Could you point to some recent and simple/complete instructions for running the Linpack benchmark on a 3B+ ?
Since the 3B+ is still running in 32-bit ARMv7 compatibility mode, the instructions posted here by Dr Weaver (deater) are still current. There is also a good chance that the binary posted there still works, but I haven't tried it.
Thanks.
The pre built binary works fine on the 3B+ ( 6.78 Gflops ).
The temp didn't rise much - 46C maximum and obviously it didn't throttle, so I don't think Linpack a particularly difficult task for the new model. The idle temp is 39C so the temp rose by only 7C during the run. Shows how much extra thermal inertia the 3B+ has!
I ran it a second time with cpuburn-a53 running in another window and it still passed at 69C peak temp.

That has helped confirm my Pi is stable.

Not that it is really over-clocked, just the sdram and core.
Having never achieved stability over 14025MHz, the CPU speed remains at stock.
I am sceptical of 1500MHz claims.

core_freq=500
sdram_freq=500
temp_soft_limit=70

Return to “Other programming languages”