Difference between revisions of "Linux"

From Boundary Devices Wiki

(Created page with "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...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
This page includes everything you need to know in order to use a GNU/Linux OS.
 
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.
 +
 +
 +
== Kernel ==
 +
 +
 +
== Init and init scripts ==
 +
 +
 +
== Simple commands ==
  
All the articles below are generic for all platforms and therefore apply whether you use Yocto, Buildroot, OpenWRT, Ubuntu, Debian and so on.
 
  
 +
== Connectivity interfaces ==
  
1. Kernel
 
  
 +
== Multimedia interfaces ==
  
2. Init and init scripts
 
  
 +
==  USB devices and gadgets ==
  
3. Simple commands
 
  
 +
==  GPIO interface ==
  
4. Connectivity interfaces
 
  
 +
==  SPI interface ==
  
5. Multimedia interfaces
 
  
 +
== I2C interface ==
  
6. USB devices and gadgets
 
  
 +
== Serial interface (TTY) ==
  
7. GPIO interface
 
  
 +
== PCIe ==
  
8. SPI interface
 
  
 +
== SDIO ==
  
9. I2C interface
 
  
 +
== Power management ==
  
10. 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 [https://www.kernel.org/doc/html/latest/admin-guide/pm/cpufreq.html cpufreq] (CPU Frequency scaling) subsystem.
  
11. PCIe
+
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):
 +
<pre># cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
 +
1200000 1600000 1800000</pre>
 +
Values are in '''kHz''' so the above means that the CPU supports to run at 1.2, 1.6 or 1.8 GHz.
  
12. SDIO
+
You can check the current CPU frequency:
 +
<pre># cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq
 +
1200000</pre>
  
 +
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.
 +
<pre># cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_governors
 +
conservative ondemand userspace powersave performance schedutil </pre>
 +
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
  
13. Power management
+
You can get/set the current governor as shown below:
 +
<pre># 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</pre>
 +
Another interesting metric is the time spent in each frequency:
 +
<pre># cat /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state
 +
1200000 298542
 +
1600000 47
 +
1800000 118</pre>
 +
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 [https://www.kernel.org/doc/html/latest/admin-guide/pm/cpufreq.html cpufreq kernel documentation].
  
14. Display management
+
== Display management ==
  
  
15. GUI interfaces
+
== GUI interfaces ==

Latest revision as of 15:49, 7 December 2021

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.


Kernel

Init and init scripts

Simple commands

Connectivity interfaces

Multimedia interfaces

USB devices and gadgets

GPIO interface

SPI interface

I2C interface

Serial interface (TTY)

PCIe

SDIO

Power management

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.

Display management

GUI interfaces