Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile the official version of Linux kernel for raspberry pie

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to compile the official version of the Linux kernel for raspberry pie. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

There are many articles about compiling the Linux kernel for raspberry pie online, but most of the articles are about pulling the official repository directly from the GitHub and then compiling the Linux kernel with a complete set of official tool chains. no one has ever tried to download the source code directly from the Linux Kernel official website and compile the Linux kernel. It took me some time to compile the Linux kernel source code on the kernel official website, and it was successful, so I would like to record the process of the research.

All the operations below are in the / home/test/RPI/ directory, and the raspberry pie hardware version is 3B.

First, download the cross-compilation tool chain from here, and then extract it:

Wget-c http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/arm-linux-gnueabihf/gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf.tar.xzxz-d gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf.tar.xztar xvf gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf.tar

Then configure the cross-compilation environment:

Sudo apt-get install libncurses-dev build-essentialexport PATH=$PATH:/home/test/RPI/gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf/bin/

Among them, ncurses is the interface library under the terminal and the dependency of the compilation menuconfig phase; build-essential is mainly used to provide compile-time make commands.

Then, download the kernel source code and extract it:

Wget-c https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.104.tar.xzxz-d linux-4.19.104.tar.xztar xvf linux-4.19.104.tar

Then go to the source directory to configure the kernel:

Cd linux-4.19.104/make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2835_defconfigmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Here we mainly use the bcm2835_defconfig configuration that comes with the kernel source code, which is the key to compiling the official kernel source code.

During the menuconfig compilation phase, the kernel configuration window pops up, where you can configure the kernel:

Here, to demonstrate, directly use the default configuration, select "Exit" and press enter to save and exit.

Then you can start compiling the kernel:

Make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf--j4 zImage modules dtbs

In order to speed up the compilation of the kernel, the-j parameter is added here, depending on the computer configuration.

After the kernel is compiled, the zImage file can be processed to produce a file that can be booted directly by the raspberry pie:

Cd arch/arm/boot/wget-c https://raw.githubusercontent.com/raspberrypi/linux/rpi-4.19.y/scripts/mkknlimgchmod + x mkknlimg./mkknlimg zImage kernel.img

Start the installation process:

Cd.. / mkdir installmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=/home/test/RPI/linux-4.19.104/install/

This step is mainly used to create the lib directory, so that you can directly copy the modules directory to the memory card system directory.

Unplug the memory card from the raspberry pie, plug in the computer, and start copying files:

Mv / media/test/boot/kernel7.img / media/test/boot/kernel7.img.1cp / home/test/RPI/linux-4.19.104/arch/arm/boot/kernel.img / media/test/boot/kernel7.imgcp / home/test/RPI/linux-4.19.104/arch/arm/boot/dts/*.dtb / media/test/boot/sudo cp-r / home/test/RPI/linux-4.19.104/install/lib/ / media/test/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/

After the copy is completed, unplug the memory card, plug it into the raspberry pie, boot it up, connect ssh to the raspberry pie, and use the following command to check the kernel version information:

Uname-a

This is the kernel version information of the previous system:

This is the version information after using the new kernel:

It is obvious that the kernel has been replaced with a newly compiled kernel, and the kernel has been replaced successfully.

According to the actual test, the raspberry pie can start normally after replacing the new kernel, and it has not been tested as to which on-board functions have been affected. In addition, this test is only carried out on 3B, and further testing may be needed as to whether this method is feasible on other hardware versions.

On how to compile the official version of the Linux kernel for raspberry pie to share here, I hope the above can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report