8,367
edits
Changes
→Compile the Linux kernel
# Run the build.sh script, remember to add sudo permission
::{| class="wikitable" style="width:800px;"
|-
|
test@test:~/orangepi-build$ '''sudo ./build.sh'''
|}
<ol start="2" style="list-style-type: decimal;">
<li>Select '''Kernel package''', then enter</li></ol>
<div class="figure">
[[File:cm4-img397.png]]
</div></ol>
<ol start="3" style="list-style-type: decimal;">
<li>Then select the model of the development board</li></ol>
<div class="figure">
[[File:cm4-img393.png]]
</div></ol>
<ol start="4" style="list-style-type: decimal;">
<li>Then it will prompt whether to display the kernel configuration interface. If you do not need to modify the kernel configuration, select the first one. If you need to modify the kernel configuration, select the second one.</li></ol>
[[File:cm4-img398.png]]
</ol>
<ol start="5" style="list-style-type: decimal;">
<li>If you choose to display the kernel configuration menu (the second option) in step 4, the kernel configuration interface opened by '''make menuconfig''' will pop up. At this time, you can directly modify the kernel configuration, save and exit after modification. Yes, after exiting, the kernel source code will be compiled</li></ol>
[[File:cm4-img399.png]]
<ol style="list-style-type: lower-alpha;">
<li>If you do not need to modify the configuration options of the kernel, when running the build.sh script, pass in '''KERNEL_CONFIGURE=no''' to temporarily block the pop-up kernel configuration interface</li></ol>{| class="wikitable" style="width:800px;" |-|
test@test:~/orangepi-build$ '''sudo ./build.sh KERNEL_CONFIGURE=no'''
|}</ol>
<ol start="2" style="list-style-type: lower-alpha;">
<li><p>You can also set '''KERNEL_CONFIGURE=no''' in the '''orangepi-build/userpatches/config-default.conf''' configuration file, which can permanently disable this function</p></li>
<li><p>If the following error is displayed when compiling the kernel, it is because the terminal interface of the Ubuntu PC is too small to display the '''make menuconfig''' interface. Please maximize the terminal of the Ubuntu PC and run the build.sh script again</p></li></ol>
[[File:cm4-img400.png]]
</ol></ol>
<ol start="6" style="list-style-type: decimal;">
<li><p>Part of the information prompted when compiling the kernel source code is as follows</p>
<ol style="list-style-type: lower-alpha;">
<li>The version of the Linux kernel source code</li></ol></li></ol>{| class="wikitable" style="width:800px;" |-|
[ o.k. ] Compiling current kernel [ '''5.10.160''' ]
|}</ol>
<ol start="2" style="list-style-type: lower-alpha;">
<li>The version of the cross-compilation toolchain used</li></ol>{| class="wikitable" style="width:800px;" |-|
[ o.k. ] Compiler version [ '''aarch64-none-linux-gnu-gcc 11.2.1''' ]
|}</ol>
<ol start="3" style="list-style-type: lower-alpha;">
<li>The configuration file used by the kernel by default and the path where it is stored</li></ol>{| class="wikitable" style="width:800px;" |-|
[ o.k. ] Using kernel config file [ '''config/kernel/linux-rockchip-rk356x-legacy.config''' ]
|}</ol>
<ol start="4" style="list-style-type: lower-alpha;">
<li>The path of the deb package related to the kernel generated by compiling</li></ol>{| class="wikitable" style="width:800px;" |-|
[ o.k. ] Target directory [ '''orangepi-build/output/debs/''' ]
|}</ol>
<ol start="5" style="list-style-type: lower-alpha;">
<li>The package name of the compiled kernel image deb package</li></ol>{| class="wikitable" style="width:800px;" |-|
[ o.k. ] File name [ '''linux-image-legacy-rockchip-rk356x_1.0.0_arm64.deb''' ]
|}</ol>
<ol start="6" style="list-style-type: lower-alpha;">
<li>The time used for compilation</li></ol>{| class="wikitable" style="width:800px;" |-|
[ o.k. ] Runtime [ '''5 min''' ]
|}</ol>
<ol start="7" style="list-style-type: lower-alpha;">
<li>Finally, the compilation command to repeatedly compile the kernel selected last time will be displayed. Use the following command to start compiling the kernel source code directly without selecting through the graphical interface</li></ol>{| class="wikitable" style="width:800px;" |-|
[ o.k. ] Repeat Build Options [ '''sudo ./build.sh BOARD=orangepi3b BRANCH=legacy BUILD_OPT=kernel KERNEL_CONFIGURE=no''' ]
|}</ol></li></ol>
<ol start="7" style="list-style-type: decimal;">
<li><p>View the deb package related to the kernel generated by compilation</p>
<li><p>'''linux-dtb-legacy-rockchip-rk356x_1.0.0_arm64.deb''' Contains dtb files used by the kernel</p></li>
<li><p>'''linux-headers-legacy-rockchip-rk356x_1.0.0_arm64.deb''' Include kernel header files</p></li>
<li><p>'''linux-image-legacy-rockchip-rk356x_1.0.0_arm64.deb''' Contains kernel images and kernel modules</p></li></ol></li></ol>{| class="wikitable" style="width:800px;" |-|
test@test:~/orangepi-build$ '''ls output/debs/linux-*'''
output/debs/linux-headers-legacy-rockchip-rk356x_1.0.0_arm64.deb
|}</ol></li></ol>
<ol start="8" style="list-style-type: decimal;">
<li><p>The files contained in the generated Linux-image deb package are as follows</p>
<ol style="list-style-type: lower-alpha;">
<li>Use the following command to decompress the deb package</li></ol></li></ol>{| class="wikitable" style="width:800px;" |-|
test@test:~/orangepi-build$ '''cd output/debs'''
'''boot etc lib''' linux-image-legacy-rockchip-rk356x_1.0.0_arm64.deb '''usr'''
|}</ol>
<ol start="2" style="list-style-type: lower-alpha;">
<li>The decompressed file is as follows</li></ol>{| class="wikitable" style="width:800px;" |-|
test@test:~/orangepi-build/output/debs/test$ '''tree -L 2'''
└── usr
:├── lib
:└── share|}</ol></li></ol><ol start="9" style="list-style-type: decimal;"><li>The orangepi-bulid compilation system will first synchronize the Linux kernel source code with the Linux kernel source code of the github server when compiling the Linux kernel source code, so if you want to modify the Linux kernel source code, you first need to turn off the update function of the source code '''(You need to fully compile the Linux kernel source code before turning off this function. Otherwise, you will be prompted that the source code of the Linux kernel cannot be found. If you download the source code package from Baidu cloud disk, there is no such problem, because the source code of Linux has been cached.)''', otherwise the The changes made will be reverted as follows:</li>
test@test:~/orangepi-build$ '''vim userpatches/config-default.conf'''
IGNORE_UPDATES="'''yes'''"
|}</ol>
<ol start="10" style="list-style-type: decimal;">
<li><p>If the kernel has been modified, the following method can be used to update the kernel and kernel modules of the development board Linux system</p>
<ol style="list-style-type: lower-alpha;">
<li>Upload the deb package of the compiled Linux kernel to the Linux system of the development board</li></ol></li></ol>{| class="wikitable" style="width:800px;" |-|
test@test:~/orangepi-build$ '''cd output/debs'''
'''linux-image-legacy-rockchip-rk356x_1.0.0_arm64.deb [email protected]:/root'''
|}</ol>
<ol start="2" style="list-style-type: lower-alpha;">
<li>Then log in to the development board and uninstall the deb package of the installed Linux kernel</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~# '''apt purge -y linux-image-legacy-rockchip-rk356x'''
|}</ol>
<ol start="3" style="list-style-type: lower-alpha;">
<li>Install the deb package of the new Linux kernel just uploaded</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~# '''dpkg -i linux-image-legacy-rockchip-rk356x_1.0.0_arm64.deb'''
|}</ol>
<ol start="4" style="list-style-type: lower-alpha;">
<li>Then restart the development board, and then check whether the kernel-related modifications have taken effect</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~# '''reboot'''
|}</ol></li></ol>
<ol start="11" style="list-style-type: decimal;">
<li><p>Other useful information</p>
<ol style="list-style-type: lower-alpha;">
<li><p>The storage location of the kernel configuration file is as > follows, please do not go to the kernel source code to find > the kernel configuration file used by the development board</p></li><li><p>{| class="wikitable" style="width:800px;" |-| [https://github.com/orangepi-xunlong/orangepi-build/blob/next/external/config/kernel/linux-rockchip-rk356x-legacy.config '''orangepi-build/external/config/kernel/linux-rockchip-rk356x-legacy.config''']|}<li><p>The > location of the dts file used by the development board is</p></li>{| class="wikitable" style="width:800px;" |-| [https://github.com/orangepi-xunlong/linux-orangepi/blob/orange-pi-5.10-rk35xx/arch/arm64/boot/dts/rockchip/rk3566-orangepi-cm4.dts '''orangepi-build/kernel/orange-pi-5.10-rk35xx/arch/arm64/boot/dts/rockchip/rk3566-orangepi-cm4.dts''']|}</ol>
</li></ol>
<span id="compile-rootfs"></span>
== Compile rootfs ==