Changes

Jump to: navigation, search

Orange Pi Zero 3

553 bytes added, 18:04, 11 July 2023
How to install the kernel header file
== How to install the kernel header file ==
{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big>'''The Debian 11 system with the <span style="color:#FF0000">Linux6.1 </span> kernel will report a GCC error when compiling the kernel module. So if you want to compile the kernel module, please use Debian12 or Ubuntu22.04'''</big>|}
<ol style="list-style-type: decimal;">
<li><p>The Linux image released by OPi comes with the deb package of the kernel header file by default, and the storage location is '''/opt/'''</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:~$ '''ls /opt/linux-headers*'''</p>
<p>/opt/linux-headers-xxx-sun50iw9_x.x.x_arm64.deb</p>|}</li>
<li><p>Use the following command to install the deb package of the kernel header file</p>
{| class="wikitable" style="width:800px;" |-| <p>orangepi@orangepi:~$ '''sudo dpkg -i /opt/linux-headers*.deb'''</p>|}</li>
<li><p>After installation, you can see the folder where the kernel header files are located under '''/usr/src'''</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:~$ '''ls /usr/src'''</p>
<p>linux-headers-x.x.x</p>|}</li>
<li><p>Then you can compile the source code of the hello kernel module that comes with the Linux image. The source code of the hello module is in '''/usr/src/hello'''. After entering this directory, use the make command to compile.</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:~$ '''cd /usr/src/hello/'''</p>
<p>orangepi@orangepi:/usr/src/hello$ '''sudo make'''</p>
<p>make -C /lib/modules/5.4.125/build M=/usr/src/hello modules</p>
<p>make[1]: Entering directory '/usr/src/linux-headers-5.4.125'</p>
:<p>CC [M] /usr/src/hello/hello.o</p>:<p>Building modules, stage 2.</p>:<p>MODPOST 1 modules</p>:<p>CC [M] /usr/src/hello/hello.mod.o</p>:<p>LD [M] /usr/src/hello/hello.ko</p><p>make[1]: Leaving directory '/usr/src/linux-headers-5.4.125'</p>|}</li>
<li><p>After compiling, the '''hello.ko''' kernel module will be generated</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:/usr/src/hello$ '''ls *.ko'''</p>
<p>hello.ko</p>|}</li>
<li><p>Using the '''insmod''' command, you can insert the '''hello.ko''' kernel module into the kernel</p>
{| class="wikitable" style="width:800px;" |-| <p>orangepi@orangepi:/usr/src/hello$ '''sudo insmod hello.ko'''</p>|}</li>
<li><p>Then use the '''demsg''' command to view the output of the '''hello.ko''' kernel module. If you can see the output instructions below, the '''hello.ko''' kernel module is loaded correctly</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:/usr/src/hello$ '''dmesg | grep &quot;Hello&quot;'''</p>
<p>[ 2871.893988] '''Hello Orange Pi -- init'''</p>|}</li>
<li><p>Use the '''rmmod''' command to uninstall the '''hello.ko''' kernel module</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:/usr/src/hello$ '''sudo rmmod hello'''</p>
<p>orangepi@orangepi:/usr/src/hello$ '''dmesg | grep &quot;Hello&quot;'''</p>
<p>[ 2871.893988] Hello Orange Pi -- init</p>
<p>[ 3173.800892] '''Hello Orange Pi -- exit'''</p>|}</li></ol>
<span id="some-programming-language-tests-supported-by-linux-system"></span>
 
== Some programming language tests supported by Linux system ==

Navigation menu