CPU Frequency Scaling¶
Introduction¶
CPU frequency scaling is a power management technique that adjusts the operating frequency of a processor based on system demands. On Raspberry Pi OS, the default configuration sets the CPU frequency to a fixed 700MHz, which provides consistent performance but may consume more power than necessary during periods of low activity.
By implementing dynamic frequency scaling, you can optimize your Raspberry Pi's power consumption and heat generation while still maintaining responsive performance when needed. This is particularly valuable for battery-powered projects, headless servers, and use cases where maximum processing power is only occasionally required.
GPU Configuration¶
/boot/firmware/config.txt is read by the GPU before the CPU starts up, and it contains settings for CPU frequency as well. Add the following lines:
A reboot is required for these changes to take effect.
For comprehensive information about GPU and CPU configuration options, the official documentation is available at: RPiconfig - eLinux.org
Linux Kernel Configuration¶
By modifying the GPU settings, the CPU gains frequency scaling capabilities. However, the Linux kernel has its own control mechanisms, which by default lock the CPU frequency at 100MHz.
You can check the current, maximum, and minimum CPU frequencies using the following commands:
- Current CPU frequency:
- Maximum CPU frequency:
- Minimum CPU frequency:
The Linux kernel includes a CPU frequency governor that determines how frequency changes occur. By default, Raspberry Pi OS uses the powersave governor.
Available governors:
- performance: Always runs at the maximum CPU frequency.
- powersave: Always runs at the minimum CPU frequency.
- ondemand: Adjusts frequency based on CPU load (Raspberry Pi OS toggles between min and max only).
- conservative: Smoothly adjusts frequency based on CPU load.
- userspace: Allows user-space daemons to control the CPU frequency.
These settings can be changed during runtime via sysfs:
To make this setting persist after reboot, there are two options:
-
Adding the command to
/etc/rc.local- This method executes the command after the kernel boots, which may result in a longer boot time.
-
Enabling kernel configuration options:
- Enable the following kernel options:
- This method requires rebuilding the kernel but ensures full CPU power during boot.
Monitoring CPU Frequency Changes¶
After implementing these settings, you can monitor the CPU frequency changes in real-time to observe how your Raspberry Pi adapts to different workloads:
Conclusion¶
CPU frequency scaling offers an effective way to balance performance and power consumption on your Raspberry Pi. By configuring both the GPU settings in /boot/firmware/config.txt and the Linux kernel's frequency governor, you can create a system that efficiently adapts to varying workloads.
While the power savings from frequency scaling may be modest compared to more aggressive power management techniques like disabling unused hardware components, it provides an excellent compromise that preserves functionality while reducing energy usage during idle periods. This approach is particularly beneficial for always-on systems or projects where consistent but not maximum performance is required.
For optimal results, consider combining CPU frequency scaling with other power management strategies outlined in the Power Saving guide. This comprehensive approach will maximize efficiency while ensuring your Raspberry Pi performs reliably for your specific use case.