8,367
edits
Changes
→The method of installing the kernel header file
<ol style="list-style-type: decimal;">
<li><p>The linux image released by OPI defaults to the DEB package of the kernel header file. The location is'''/opt/'''</p>{| class="wikitable" style="width:800px;" |-|
<p>orangepi@orangepi5plus:~$ '''ls /opt/linux-headers*'''</p>
<p>/opt/linux-headers-legacy-rockchip-rk3588_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="background-color:#ffffdc;width:800px;" |-| <big><p>'''The name of the kernel file deb package needs to be replaced with the actual name, please don’t don't copy it。it.'''</p></big>|} {| class="wikitable" style="width:800px;" |-|<p>orangepi@orangepi:~$ '''sudo dpkg -i /opt/linux-headers-legacy-rockchip-rk3588_1.x.x_arm64.deb'''</p>|}</li>
<li><p>After installation, you can see the folder where the kernel header file is located under the'''/usr/src'''</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:~$ '''ls /usr/src'''</p>
<p>linux-headers-5.10.110-rockchip-rk3588</p>|}</li>
<li><p>Then you can write a Hello kernel module to test the kernel header file</p>
<ol style="list-style-type: lower-alpha;">
<li><p>First write the code of the Hello kernel module, as shown > below:</p>{| class="wikitable" style="width:800px;" |-|
<p>orangepi@orangepi:~$ '''vim hello.c'''</p>
<p>#include <linux/init.h></p>
<p>#include <linux/module.h></p>
<p>static int hello_init(void)</p>
<p>{</p>
::<p>printk("Hello Orange Pi -- init\n");</p> ::<p>return 0;</p>
<p>}</p>
<p>static void hello_exit(void)</p>
<p>{</p>
::<p>printk("Hello Orange Pi -- exit\n");</p> ::<p>return;</p>
<p>}</p>
<p>module_init(hello_init);</p>
<p>module_exit(hello_exit);</p>
<p>MODULE_LICENSE("GPL");</p>|}</li><li><p>Then write a makefile file that compiles the Hello kernel > module, as shown below:</p>{| class="wikitable" style="width:800px;" |-|
<p>orangepi@orangepi:~$ '''vim Makefile'''</p>
<p>ifneq ($(KERNELRELEASE),)</p>
<p>PWD :=$(shell pwd)</p>
<p>all:</p>
:<p>make -C $(KDIR) M=$(PWD) modules</p>
<p>clean:</p>
:<p>rm -f *.ko *.o *.mod.o *.mod *.symvers *.cmd *.mod.c *.order</p><p>endif</p>|}</li><li><p>Then use the make command to compile the Hello kernel module, > and the output of the compilation process is shown below:</p>{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big><p>'''If you compile the code you copy here, if you have any problems, go to the [http://www.orangepi.online/html/hardWare/computerAndMicrocontrollers/service-and-support/Orange-Pi-5-plus.html '''official tool '''] to download the source code and upload it to the Linux system of the development board for testing'''</p></big>
<p>[[File:media/image416.png|253x41px]]</p>
|}
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:~$ '''make'''</p>
<p>make -C /lib/modules/5.10.110-rockchip-rk3588/build M=/home/orangepi modules</p>
<p>make[1]: Entering directory '/usr/src/linux-headers-5.10.110-rockchip-rk3588'</p>
:<p>CC [M] /home/orangepi/hello.o</p>:<p>MODPOST /home/orangepi/Module.symvers</p>:<p>CC [M] /home/orangepi/hello.mod.o</p>:<p>LD [M] /home/orangepi/hello.ko</p><p>make[1]: Leaving directory '/usr/src/linux-headers-5.10.110-rockchip-rk3588'</p>|}</li><li><p>After compiling, the '''hello.ko''' kernel module will be > generated</p>{| class="wikitable" style="width:800px;" |-|
<p>orangepi@orangepi:~$ '''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:~$ '''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:~$ '''dmesg | grep "Hello"'''</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:~$ '''sudo rmmod hello'''</p>
<p>orangepi@orangepi:~$ '''dmesg | grep "Hello"'''</p>
<p>[ 2871.893988] Hello Orange Pi -- init</p>
<p>[ 3173.800892] '''Hello Orange Pi -- exit'''</p>|}</li></ol>
</li></ol>
<span id="how-to-use-10.1-inch-mipi-lcd-screen"></span>
== How to use 10.1 inch MIPI LCD screen ==