I was wondering if it would be possible to control the Raspberry Pi's CPU frequency on-the-fly, allowing me to adjust for temperature. (I would be using this for overclocking.)
Assuming you mean being able to overclock it and have the effects applied instantly, without a reboot, I don't think it's possible - most full computers can't even do this yet. There are a couple programs that can do it for desktops, but they tend to be rather finicky, and they would almost definitely not work on the pi anyways.
1Allot of desktop computers can be over clocked from the OS now using vendor specific software even GPU's. Also Intel use speed stepping built into processors. So I don't agree with that but on the Pi side, it only seems to be adjustable during boot, for now. Dec 10, 2014 at 21:02
@ppumkin - I am aware of this. I have used a couple of these programs myself. However I have noticed that you don't get as much fine control over them as you do from BIOS, and the system is generally more unstable when you overclock from the OS as opposed to from BIOS. Dec 10, 2014 at 22:52
adjust for temperature
When you describe adjusting for temperature, it sounds to me like you have one of two goals:
- Prevent the temperature from climbing to dangerous levels (ex. 80 C) when the Pi has a workload saturating its CPU.
- Prevent the temperature from climbing like this when the Pi is running at idle.
For #1, the way the Pi's base frequency and boosting work should be enough to ensure this goal is met with you just leaving the Pi's settings to their default. You could even overclock your Pi's boost CPU frequency and still achieve this goal.
This is because the Pi will run at its configured base CPU frequency (which is quite low, below 1 GHz) until it needs to boost to run a workload. When it has a workload, it will boost up to the configured boost frequency for as long as it needs to complete the workload or until its detected temperature reaches about 80 C. Then the CPU clocks back down to base when the workload is complete, allowing the temperature to reduce.
So there's no need to adjust the CPU frequencies on the fly. Simply set a boost frequency high enough for your expected workload and rely on the CPU throttling to ensure the temperature doesn't climb beyond 80 C. It will already be adjusted "on the fly". If 80 C is too high for your liking, this value can be adjusted too. You can make it lower.
For #2, you could adjust the base frequency so it's lower than default. This should allow your Pi to settle down to a lower frequency when it needs to because it detected that even running at idle, the CPU temperature climbed too high.