Changes

Jump to: navigation, search

Orange Pi Zero 2W

553 bytes added, 15:56, 26 September 2023
How to install kernel header files
== How to install kernel header files ==
{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big>'''Debian11 system with <span style="color:#FF0000">Linux6.1 </span> kernel will report GCC error when compiling 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 file is 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, then 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 compilation, 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>Use the '''insmod''' command to 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 following output, it means that 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="testing-of-some-programming-languages-supported-by-linux-system"></span>
 
== Testing of some programming languages supported by Linux system ==

Navigation menu