SHARE
TWEET

BananaPiM3_FrequencyChanger.sh

Nargren Sep 11th, 2016 116 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. #Script to quickly adjust the CPU clock rate of the Banana Pi M3
  3.  
  4. #  ____                                  _____ _   __  __ ____  
  5. # |  _ \                                |  __ (_) |  \/  |___ \
  6. # | |_) | __ _ _ __   __ _ _ __   __ _  | |__) |  | \  / | __) |
  7. # |  _ < / _` | '_ \ / _` | '_ \ / _` | |  ___/ | | |\/| ||__ <
  8. # | |_) | (_| | | | | (_| | | | | (_| | | |   | | | |  | |___) |
  9. # |____/ \__,_|_| |_|\__,_|_| |_|\__,_| |_|   |_| |_|  |_|____/
  10. #Nargren, 2016.09.03.
  11.  
  12.  
  13. ############### NOTE ##############
  14.  
  15. #The following frequencies are available:
  16. #2016000 1800000 1608000 1200000 1128000 1008000 912000 864000 720000 600000 480000
  17. #All values are to be understood in kHz
  18. #2 GHz requires special voltages and unlocking, it is NOT done by this
  19. #script!
  20.  
  21. #Changing the clock frequency requires root permissions, hence you may
  22. #be prompted to enter upon every run (depending on user settings).
  23.  
  24. #Above ~1.1 GHz a considerable amount of heat is being generated.
  25. #Depending on the load, temperatures can reach the limiting 70 degrees Celsius.
  26.  
  27. ############### CONFIG ############
  28.  
  29. #Maximum frequency
  30. maxFreq=/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
  31.  
  32. ############### MAIN ##############
  33. echo ""
  34. echo "Please select the desired CPU clock rate."
  35. echo "1. 480 MHz"
  36. echo "2. 600 MHz"
  37. echo "3. 720 MHz"
  38. echo "4. 864 MHz"
  39. echo "5. 912 MHz"
  40. echo "6. 1.0 GHz"
  41. echo "7. 1.1 GHz"
  42. echo "8. 1.2 GHz"
  43. echo "9. 1.6 GHz"
  44. echo "10. 1.8 GHz"
  45.  
  46. echo "Enter choice:"
  47. read choice
  48. echo ""
  49.  
  50. if [ $choice = "1" ]
  51. then
  52. echo "Setting CPU clock frequency to 480 MHz"
  53. echo '480' | sudo tee $maxFreq
  54.  
  55. else if [ $choice = "2" ]
  56. then
  57. echo "Setting CPU clock frequency to 600 MHz"
  58. echo '600000' | sudo tee $maxFreq
  59.  
  60. else if [ $choice = "3" ]
  61. then
  62. echo "Setting CPU clock frequency to 720 MHz"
  63. echo '720000' | sudo tee $maxFreq
  64.  
  65. else if [ $choice = "4" ]
  66. then
  67. echo "Setting CPU clock frequency to 864 MHz"
  68. echo '864000' | sudo tee $maxFreq
  69.  
  70. else if [ $choice = "5" ]
  71. then
  72. echo "Setting CPU clock frequency to 912 MHz"
  73. echo '912000' | sudo tee $maxFreq
  74.  
  75. else if [ $choice = "6" ]
  76. then
  77. echo "Setting CPU clock frequency to 1 GHz"
  78. echo '1008000' | sudo tee $maxFreq
  79.  
  80. else if [ $choice = "7" ]
  81. then
  82. echo "Setting CPU clock frequency to 1.1 GHz"
  83. echo '1128000' | sudo tee $maxFreq
  84.  
  85. else if [ $choice = "8" ]
  86. then
  87. echo "Setting CPU clock frequency to 1.2 GHz"
  88. echo  '1200000' | sudo tee $maxFreq
  89.  
  90. else if [ $choice = "9" ]
  91. then
  92. echo "Setting CPU clock frequency to 1.6 GHz"
  93. echo '1608000' | sudo tee $maxFreq
  94.  
  95. else if [ $choice = "10" ]
  96. then
  97. echo "Setting CPU clock frequency to 1.8 GHz"
  98. echo '1800000' | sudo tee $maxFreq
  99.  
  100. else
  101.     echo "PEBKAC. Bye."
  102. fi
  103. fi
  104. fi
  105. fi
  106. fi
  107. fi
  108. fi
  109. fi
  110. fi
  111. fi
RAW Paste Data
Top