Check the CPU Frequency
[Last Update — March 2015] The BBB has various governors that can be used to profile the performance/power usage ratio. For example, if you were to build a battery powered BBB application that required low processing requirements, you could reduce the clock frequency to conserve power. You can find out information about the current state of the BBB by typing cpufreq-info:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
molloyd@beaglebone:~$ cpufreq-info cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU 0: driver: generic_cpu0 CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 300 us. hardware limits: 300 MHz - 1000 MHz available frequency steps: 300 MHz, 600 MHz, 800 MHz, 1000 MHz available cpufreq governors: conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 300 MHz and 1000 MHz. The governor "ondemand" may decide which speed to use within this range. current CPU frequency is 300 MHz. cpufreq stats: 300 MHz:99.71%, 600 MHz:0.03%, 800 MHz:0.01%, 1000 MHz:0.25% (41) |
You can see at the bottom that the current CPU frequency is 300MHz.
If these tools are not installed on your BBB, you can install the cpufrequtils package.
However, the profile is on-demand, so if the CPU frequency is currently 300MHz and the average CPU usage between governor samplings is above the threshold (called the ‘up_threshold’) then the CPU frequency will be automatically increased. The ‘up_threshold’ can actually be adjusted using sysfs as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
root@beaglebone:/sys/devices/system/cpu/cpufreq/ondemand# ls -l total 0 -rw-r--r-- 1 root root 4096 Dec 18 12:59 ignore_nice_load -rw-r--r-- 1 root root 4096 Dec 18 12:59 io_is_busy -rw-r--r-- 1 root root 4096 Dec 18 12:59 powersave_bias -rw-r--r-- 1 root root 4096 Dec 18 12:59 sampling_down_factor -rw-r--r-- 1 root root 4096 Dec 18 12:59 sampling_rate -r--r--r-- 1 root root 4096 Dec 18 12:59 sampling_rate_min -rw-r--r-- 1 root root 4096 Dec 18 12:59 up_threshold root@beaglebone:/sys/devices/system/cpu/cpufreq/ondemand# cat up_threshold 95 root@beaglebone:/sys/devices/system/cpu/cpufreq/ondemand# echo 90 > up_threshold root@beaglebone:/sys/devices/system/cpu/cpufreq/ondemand# cat up_threshold 90 |
Here is an example OpenCV application running, where I am achieving 4.15 frames per second. During the execution of this program the CPU frequency will be automatically increased to cater for the increased processing demand. We will shortly examine this against other profiles. The code that I am running is available at: https://github.com/derekmolloy/boneCV
1 2 3 4 |
root@beaglebone:~/camera$ ./boneCVtiming It took 2.40531 seconds to process 10 frames Capturing and processing 4.15747 frames per second root@beaglebone:~/camera$ |
Set the CPU Frequency
However, it may be the case that you would like to increase or reduce the CPU Frequency to process data more quickly or to conserve power — for example, if you were to use a battery to power the BeagleBone. You can change the CPU frequency dynamically at run time on the Beaglebone using the cpufreq-set tool (See http://linux.die.net/man/1/cpufreq-set for information).
The cpufreq-set command must be executed with root privileges.
You can see in the output above that different governors are available, with the profile names conservative, ondemand, userspace, powersave, and performance . To enable a specific CPU frequency, type the following:
1 2 3 4 5 |
molloyd@beaglebone:~$ sudo cpufreq-set -f 600MHz molloyd@beaglebone:~$ cpufreq-info ... current CPU frequency is 600 MHz. cpufreq stats: 300 MHz:99.15%, 600 MHz:0.09%, 800 MHz:0.01%, 1000 MHz:0.75% (44) |
So, the BeagleBone CPU frequency is now 600 MHz. Alternatively, you can use the governor to set the CPU frequency profile to have another setting. For example, to set the powersave profile:
1 2 3 4 5 6 7 8 |
molloyd@beaglebone:~$ sudo cpufreq-set -g powersave molloyd@beaglebone:~$ cpufreq-info ... current policy: frequency should be within 300 MHz and 1000 MHz. The governor "powersave" may decide which speed to use within this range. current CPU frequency is 300 MHz. cpufreq stats: 300 MHz:93.90%, 600 MHz:5.37%, 800 MHz:0.01%, 1000 MHz:0.71% (45) |
And running the same program again:
1 2 3 |
root@beaglebone:~/camera# ./boneCVtiming It took 6.2799 seconds to process 10 frames Capturing and processing 1.59238 frames per second |
We see that I am only achieving 1.6 frames per second @ 300 MHz, which is slightly faster (on a proportional basis 300×4.16/1000 = ~1.25 fps); however, there is time required for the ondemand governor to change the CPU frequency, and to capture the image, which is more I/O than CPU intensive. Even at 1 GHz the AM335x is only slightly warm to the touch after processing a heavy load.
Setting the BBB CPU Frequency at Boot
[Thanks Kiyoshi in the comments below for this information] If you decide that you would like to permanently change the default governor profile of the BeagleBone you can do so by editing the file /etc/init.d/cpufrequtils and changing the entry GOVERNOR="ondemand"
to a different governor, such as conservative, userspace, powersave or performance. For example, you could set it to high-performance mode using the following steps (e.g., using nano to edit the file):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
molloyd@beaglebone:~$ cd /etc/init.d molloyd@beaglebone:/etc/init.d$ sudo nano cpufrequtils molloyd@beaglebone:/etc/init.d$ more cpufrequtils ... ENABLE="true" GOVERNOR="performance" MAX_SPEED="1000" MIN_SPEED="0" molloyd@beaglebone:/etc/init.d$ sudo reboot ... Last login: Sat Mar 28 11:35:39 2015 from homeoffice-pc.local molloyd@beaglebone:~$ cpufreq-info ... current policy: frequency should be within 300 MHz and 1000 MHz. The governor "performance" may decide which speed to use within this range. current CPU frequency is 1000 MHz. cpufreq stats: 300 MHz:0.00%, 600 MHz:0.00%, 800 MHz:0.00%, 1000 MHz:100.00% |
Hi and compliments for your nice tutorials on the BBB. Can you tell me if you use Armstrong OS or another distro? Do you think a good idea to install DebianARM or ArchLinuxARM for a headless nas,ssh home server or the performances of this board are low for the purpose?Thanks in advance,regards
Thanks, yes, I am using Angstrom for most of this content (I have used Ubuntu for one or two videos). The reason for that is that it is the standard distribution that comes with the BBB. Yes, Debian/Arch would be good too and I would imagine that the board would have no trouble with those distributions. The trick is finding a compatible distribution, unless you wish to build it yourself.
Hi and compliments for your nice tirtouals on the BBB. Can you tell me if you use Armstrong OS or another distro? Do you think a good idea to install DebianARM or ArchLinuxARM for a headless nas,ssh home server or the performances of this board are low for the purpose?Thanks in advance,regards
Thanks, yes, I am using Angstrom for most of this content (I have used Ubuntu for one or two vidoes). The reason for that is that it is the standard distribution that comes with the BBB. Yes, Debian/Arch would be good too and I would imagine that the board would have no trouble with those distributions. The trick is finding a compatible distribution, unless you wish to build it yourself.
Hi Derek, I follow you and your blog with interest. I use bbb with debian wheezy as a nfs/samba server and I notice slow transfer speed when cpu is in ondemand governor because it sems to be always at 300MHz of clock.When I set performance I can see a big improvement in video streaming and file transferring. I wonder if the beaglebone can operate 24/7 in performance mode at 58°C. Do you think it’s safe? Thanks in advance
Hi Marco, The AM3359 works in the range -40 to +90C so you should be okay at 58C. You could always add a small copper heatsink to the processor and keep it well ventilated. Derek.
Thank you very much for the info, I will follow your suggest and take a look around for an heatsink. Bye
When looking for a heatsink the size of the BBB CPU, you might want to look at RAM heatsinks (like Ave X3 ram heatsink)
Hello Derek, I like you site very much and follow the tutorials for the BeagleBone(black) with pleasure and have myself a BeagleBone Black. But know I have a problem, i’m busy to develop are own embedded board with the AM3352 @ 600Mhz(because of the price). On my BBB I have the recent Debian image and that works fine, now I like the use the same image for our embedded board, but the problem looks like the max CPU frequency, out AM3352 is max 600Mhz, must I set this some where, or will the image detects this on its own? Thanks in advance
Hi Patrick, I haven’t done that, but I assume that you will have to build Debian specifically for your hardware platform using its device tree description. My understanding is that the cpu frequencies and steppings are defined there. Good luck in designing your own board – that’s a brave step, Derek.
Hi Derek,
Again, thank you for all the useful tutorials and information about the BeagleBone platform. My BBB cpu is set at 300mhz by default. I can change it to 1000mhz via cpufreq-set –governor performance and it works fine. But when I reboot, the frequency goes back to 300mhz. I am running debian from an SD card (soon to be from a SSD) and powered via the USB from a 3a powered USB hub.
Thank you again for your amazing contributions!!
Hey Gary,
I know this is really late, but I thought I’d post the solution to your problem. I just figured it out.
You have to alter /etc/init.d/cpufrequtils
1. sudo nano /etc/init.d/cpufrequtils
2. Go to line 43. It should show this:
ENABLE=”True”
GOVERNOR=”ondemand”
MAX_SPEED=”0″
MIN_SPEED=”0″
3. Change GOVERNOR to performance and MAX_SPEED to 1000. It should look like this:
ENABLE=”True”
GOVERNOR=”performance”
MAX_SPEED=”1000″
MIN_SPEED=”0″
4. Reboot and check cpufreq-info to see it at 1000MHz.
I hope that helps
Kiyoshi
Thanks Kiyoshi, I have updated the post to include this information at: http://derekmolloy.ie/changing-the-beaglebone-cpu-frequency/. Kind regards, Derek.
Hello! Major thank you, for this great documentation.
My question is rather; is it possible to go beyond the 1000Mhz clock? I mean, say, I wanted to overclock it to 1200Mhz.
Thank you.
Hi there. I have seen the BeagleBone White overclocked but no, I have not seen any projects that have overclocked the BeagleBone Black. It may not be possible depending on the specs of the PMIC (TPS65217c). Kind regards, Derek.
I am planning to make a robotic car with opencv for real time image processing. I am caught between raspberry pi and beaglebone black. Can you please tell which will be better?
The RPi 2 is a great board for video using the on-board camera and its multi-core processor is powerful. You might look at the ValentFX Logi board/bone if you are looking at real-time imaging. It’s a very powerful FPGA board that extends either the RPi or the BBB. Good luck!
Hi Derek,
Do you know how to determine what processor ones BeagleBone is running on? (what the x in AM335x stands for)
Thank you for great learning material!
Edit the file etc / init.d to programs written in Qt app automatically with beaglebone
Derek,
Thanks for the tutorials.
I’ve built a beaglebone black that takes a joystick input and controls a Sony camera (VISCA). It runs. But I want it to run automatically from power up.
There are lots of instructions on the Internet but so far I haven’t been able to get any of them working. Can you Help?
How do I get my executable (compiled C code) or my script (that runs the executable) to run automatically on power up or restart.
It’s a beaglebone black running Debian Linux (because some of the resources wouldn’ t load in Angstrom.
Thanks,
Wayne
Hey Derek, Firstly, thank you for providing such great info about the beaglebone. In depth info on the boards has been are to come by. Secondly, I know this is an old article but I was exploring the cpu frequencies on my BBBW and the hardwar max shows 800 MHz. Shouldnt it have a max of 1000 just like the BBB? If so, is there a way to change that?