From Boundary Devices Wiki
Revision as of 15:49, 7 December 2021 by Gary.bisson
This page includes everything you need to know in order to use a GNU/Linux OS.
All the articles below are generic for all platforms and therefore apply whether you use Yocto, Buildroot, OpenWRT, Ubuntu, Debian and so on.
Init and init scripts
USB devices and gadgets
Serial interface (TTY)
This section will cover a few topics related to power management under Linux.
First, regarding the CPU frequencies, the Linux kernel offers the cpufreq (CPU Frequency scaling) subsystem.
This subsystem is supported on all our platforms and we will see below how it can be used.
You can see the different frequencies supported by the CPU as follows (tested on Nitrogen8MP):
# cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies 1200000 1600000 1800000
Values are in kHz so the above means that the CPU supports to run at 1.2, 1.6 or 1.8 GHz.
You can check the current CPU frequency:
# cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq 1200000
Then the CPU can use different scaling governors which implement algorithms to estimate the required CPU capacity. As a rule, each governor implements one, possibly parametrized, scaling algorithm.
# cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_governors conservative ondemand userspace powersave performance schedutil
The governors are defined by kernel:
- ondemand: uses CPU load as a CPU frequency selection metric
- conservative: uses CPU load as a CPU frequency selection metric like ondemand but with a different algorithm
- schedutil: uses CPU utilization data available from the CPU scheduler instead of the load
- performance: causes the highest frequency, within the scaling_max_freq policy limit, to be requested
- powersave: causes the lowest frequency, within the scaling_min_freq policy limit, to be requested
- userspace: allows user space to set the CPU frequency for the policy it is attached to
You can get/set the current governor as shown below:
# cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor ondemand # echo powersave > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor # cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor powersave
Another interesting metric is the time spent in each frequency:
# cat /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state 1200000 298542 1600000 47 1800000 118
In the above we can see that the CPU spends most of its time @1.2GHz which means its load is pretty low.
For more details about cpufreq, best is to go through the cpufreq kernel documentation.