Linux kernel porting


Migration target

1. Obtain the Linux kernel source code;
2. Modify the kernel so that the root file system rootfs can be mounted correctly (i.e. select the file system format supported by the kernel);
3. Modify the driver and cut the kernel;
4 compile and generate uimage and download experience.

Setting environment variables

Before configuring or compiling the kernel, first determine the target CPU architecture and what tool chain to use during compilation.
Method 1: modify arch and cross in makefile under the root directory_ Compile value.
Method 2: modify the environment variable. Modify the / etc / profile file to take effect for all users. It takes effect immediately after executing source / etc / profile; Or modify ~ /. Bashrc to be effective for the current user (this method is recommended). After modification, execute source ~ /. Bashrc to take effect immediately.
For example: VIM ~ /. Bashrc, add at the end of the file,
export ARCH=arm
export CROSS_COMPILE=/usr/local/arm-linux-gcc/bin/arm-linux-
Execute instruction: source ~ /. Bashrc
View environment variable: echo $arch
Linux kernel porting

Download and unzip the kernel

The official Linux website ishttps://www.kernel.orgGenerally, chip manufacturers will download a certain version of Linux kernel from the official website and transplant it to their own CPU. Therefore, it can also be transplanted from the Linux kernel provided by the manufacturer to its own products. For example, ATMEL’s at91 series kernel can be used in download.
Download and unzip. There is a problem with the zip software under Ubuntu. A file name too long error may pop up during compilation. You can execute “sudo apt get install p7zip full” and “7za x XXXX. Zip” to unzip.

Configure and compile the kernel

1. Kernel configuration, which supports the file system format. Change the kernel file to sama5 in the / arch / arm / configurations directory_ Copy the defconfig configuration file to the first level directory of the kernel file. Open the command line terminal and enter the “make sama5_defconfig” command to compile it.
Linux kernel porting

2. Execute the make menuconfig command to enter the configuration interface. The file system we use is in ramdisk format. We need to modify the kernel to support the file system. Enter the “general setup” directory and select the “initial ram file system and RAM disk (initramfs / initrd) support” option (press the spacebar to select), as shown below:
Linux kernel porting

3. Modify the version information of the kernel. Enter the “general setup” directory, select the “local version – append TP kernel release” option, and enter the version information.
Linux kernel porting

4. Set the ramdisks compilation format to bzip2: select “general setup” – > “support initial ramdisks compressed using bzip2”.

5 set the number of ramdisks to 1 and the size to 128M.
Linux kernel porting

6. Execute make uimage under the root directory (generate a special image file for uboot. Now the new uboot supports zimage); Generate the uimage file in the arch / arm / boot directory, which is the kernel image file.
Linux kernel porting

After compiling and downloading, you can see that uboot has started the kernel correctly
Linux kernel porting

If you want to know more technical knowledge, scan the code and pay attention to me.
Linux kernel porting

Recommended Today

Detailed steps for installing Perl and Komodo IDE for windows

Perl official website: document: address: The installation package of Perl Windows version is divided into activestate Perl and strawberry Perl. For the difference between the two, see: Note: the download speed of activestate Perl is slow. You may need KX to surf the Internet I have uploaded all the versions of […]