easy option is to use cpu-frequtils
sudo apt install cpufrequtils
With cpufreq-info
you will get an info on what frequencies and governors are possible for your cpu.
Then set the governor to powersave to have the cpu running at the lowest frequency all the time. (according to this governor description)
sudo cpufreq-set -g powersave
or if you wanna have more control, just set the frequency settings for min (-d) and max (-u) (here both set to 600 MHz - the min frequency for a raspberry 4).
sudo cpufreq-set -u 600MHz -d 600MHz
check again with cpufreq-info
if your settings been applied the way you wanted to. Also note the limits of the governor 'userspace', which will be applied when you use this command (at least on the RaspPi).
See this How To on the other possible parameters.
Set the frequency at boot
To set the setting at boot time you can use the deamon cpufreqd
(seperate package, see its manpage) or use sysfsutils
(I copied this info from here)
apt install sysfsutils
The sysfs values will be configured in /etc/sysfs.conf.
Here is an example for the conservative governor:
# by default it's 444, so we have to change permissions to be able to change values
mode devices/system/cpu/cpufreq/conservative = 644
devices/system/cpu/cpufreq/conservative/freq_step = 10
devices/system/cpu/cpufreq/conservative/up_threshold = 45
devices/system/cpu/cpufreq/conservative/ignore_nice_load = 1
devices/system/cpu/cpufreq/conservative/sampling_down_factor = 10
I myself wrote a small python script to change my cpu-frequency with just a click. Give me a shout if you'd like to have it.
Info
As I've just seen here: cpufrequtils will be replaced in the future by `linux-cpupower' - at least in Debian.
So you might consider using this instead. (no idea yet how to use it though)
config.txt
, you couldarm_freq=600
andarm_freq_min=600
/boot/config.txt
and setarm_freq=600
as shown.