Skip to content

Instantly share code, notes, and snippets.

@namuyan
Last active October 31, 2018 13:37
Show Gist options
  • Save namuyan/a90b85510c45b186469e956d6a44a227 to your computer and use it in GitHub Desktop.
Save namuyan/a90b85510c45b186469e956d6a44a227 to your computer and use it in GitHub Desktop.
Bananaの周波数を下げて落ちるのを下げる🍌
#!/bin/bash
#Script to quickly adjust the CPU clock rate of the Banana Pi M3
# ____ _____ _ __ __ ____
# | _ \ | __ (_) | \/ |___ \
# | |_) | __ _ _ __ __ _ _ __ __ _ | |__) | | \ / | __) |
# | _ < / _` | '_ \ / _` | '_ \ / _` | | ___/ | | |\/| ||__ <
# | |_) | (_| | | | | (_| | | | | (_| | | | | | | | | |___) |
# |____/ \__,_|_| |_|\__,_|_| |_|\__,_| |_| |_| |_| |_|____/
#Nargren, 2016.09.03.
############### NOTE ##############
#The following frequencies are available:
#2016000 1800000 1608000 1200000 1128000 1008000 912000 864000 720000 600000 480000
#All values are to be understood in kHz
#2 GHz requires special voltages and unlocking, it is NOT done by this
#script!
#Changing the clock frequency requires root permissions, hence you may
#be prompted to enter upon every run (depending on user settings).
#Above ~1.1 GHz a considerable amount of heat is being generated.
#Depending on the load, temperatures can reach the limiting 70 degrees Celsius.
############### CONFIG ############
#Maximum frequency
maxFreq=/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
############### MAIN ##############
# set crontab by root
# @reboot bash /home/pi/set-freq.sh 9 1>&2
if [ $# = "0" ]
then
echo ""
echo "Please select the desired CPU clock rate."
echo "1. 480 MHz"
echo "2. 600 MHz"
echo "3. 720 MHz"
echo "4. 864 MHz"
echo "5. 912 MHz"
echo "6. 1.0 GHz"
echo "7. 1.1 GHz"
echo "8. 1.2 GHz"
echo "9. 1.6 GHz"
echo "10. 1.8 GHz"
echo "Enter choice:"
read choice
else
choice=$1
echo "choose $choice"
fi
# work
if [ $choice = "1" ]
then
echo "Setting CPU clock frequency to 480 MHz"
echo '480000' | sudo tee $maxFreq
else if [ $choice = "2" ]
then
echo "Setting CPU clock frequency to 600 MHz"
echo '600000' | sudo tee $maxFreq
else if [ $choice = "3" ]
then
echo "Setting CPU clock frequency to 720 MHz"
echo '720000' | sudo tee $maxFreq
else if [ $choice = "4" ]
then
echo "Setting CPU clock frequency to 864 MHz"
echo '864000' | sudo tee $maxFreq
else if [ $choice = "5" ]
then
echo "Setting CPU clock frequency to 912 MHz"
echo '912000' | sudo tee $maxFreq
else if [ $choice = "6" ]
then
echo "Setting CPU clock frequency to 1 GHz"
echo '1008000' | sudo tee $maxFreq
else if [ $choice = "7" ]
then
echo "Setting CPU clock frequency to 1.1 GHz"
echo '1128000' | sudo tee $maxFreq
else if [ $choice = "8" ]
then
echo "Setting CPU clock frequency to 1.2 GHz"
echo '1200000' | sudo tee $maxFreq
else if [ $choice = "9" ]
then
echo "Setting CPU clock frequency to 1.6 GHz"
echo '1608000' | sudo tee $maxFreq
else if [ $choice = "10" ]
then
echo "Setting CPU clock frequency to 1.8 GHz"
echo '1800000' | sudo tee $maxFreq
else
echo "PEBKAC. Bye."
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment