Posts: 1
Joined: Fri Apr 27, 2018 5:07 pm

Change max CPU freq without rebooting

Fri Apr 27, 2018 5:17 pm

I have a use case where the RPi will be running boinc and I would like to change the max cpu frequency, ie overclock, without rebooting. More specifically, a cluster of RPis will also work as a small heater, and if an external termometer shows too low temperature, a shell script shall increase the power consumption of the RPis. I've searched online and only found suggestions to change files in the /boot/ directory, which require a reboot to active. I would prefer to change the speed without rebooting.

Any suggestions are welcome!

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

Re: Change max CPU freq without rebooting

Sun Aug 12, 2018 2:20 pm

My suggestion is to find the highest stable overclock for your Raspberry pi and set that in the config.txt, then use different CPU governors to adjust the clock rate.

BOINC is running all the time and if you need your Raspi to heat your room you set the governor to performance and if you do not need it to heat your room you set it to powersave.

Performance Governor: Sets CPU to highest clock rate
e.g. overclocked Raspi runs at 1500Mhz and no lower

Powersave Governor: Sets CPU to minimum clock rate
e.g. Raspi will run at 600mhz and go no higher (minimum clock rate can also be specified in config.txt )

There are many other governors but these two are probably the most useful to you.

I don't believe raspbian has alternative governors baked into the kernel so you will have to recompile the kernel with the governors you need. You may also need some other utilities to change the governor when you need.

Code: Select all

cpupower frequency-set -g performance

Code: Select all

cpupower frequency-set -g powersave

Code: Select all

cpupower frequency-set -g ondemand

Posts: 28
Joined: Tue Feb 19, 2013 5:31 pm

Re: Change max CPU freq without rebooting

Sun Oct 07, 2018 5:51 pm

As already mentioned, the various govenors can be used to affect the CPU frequency changes. In Raspbian there is a more direct way, which can be done without reboot.

The files in /sys/devices/system/cpu/cpu0/cpufreq directly control the kernel's turbo mode, which is what changes the CPU clock frequency in response to processing demands. On the RPi this affects all cores, not just cpu0. This keeps the CPU clock at its lowest frequency:

Code: Select all

sudo cp /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
I have not tried it, but interchanging min and max ought to do what you want. Beware of overheating.

Note that letting the kernel change the CPU clock frequency has some problems. In particular, the SPI clock changes frequency, and on some models the UART baud rate changes. Moreover, the 1 MHz clock glitches. So I always disable turbo mode as above.

Return to “Advanced users”