<Linux development> System porting - of - A detailed record of the Linux kernel porting process (Part 1)

<Linux development> System porting - of - A detailed record of the Linux kernel porting process (Part 1)

Preface: This series of articles mainly explains some records of the development process of the Punctual Atom Linux development board;
this chapter mainly explains the migration of the linux officially provided by NXP to the Punctual Atomic Linux development board;
generally, the design and development of a Linux development board will Refer to the demo board of the original chip manufacturer, and the original chip manufacturer will provide a complete set of information for the demo board. Therefore, when using a development board designed by a third party or a circuit board made by yourself, you will refer to the design of the remote demo board of the chip; in terms of software, the tools supporting the demo board will also be transplanted. After all, the data provided by the original chip manufacturer matches compatibility. Definitely better than the others.

This part mainly introduces, related design software, and NXP original linux compilation test.

For uboot porting, please refer to:

<Linux development> -The detailed record of the uboot transplantation process of system transplantation (Part 1)
<Linux development> -The detailed record of the uboot transplantation process of system transplantation (Part 2) <Linux development> -The detailed record of
the uboot transplantation process of system transplantation Records (Part 3) (Completed uboot porting)

Next, explain the migration process record:

1. Preliminary preparations for linux transplantation
Note: For the following preparations, please refer to the Punctual Atomic Linux Development Manual
1. Install virtual machine and ubuntu; (usually, it is convenient to use with the window environment)
2. Install cross-compilation tools; (for compilation)
3. Install FileZillaClient; (convenient to transfer files with window)
4. Install vscode; (convenient for some modifications of uboot source code)
5. Punctual atomic Linux development board; (or IMX6ULL same series of development boards. The general operation process is similar, after all NXP)
6. Install TFTP-> TFTP install operation.
7. Ubuntu installs the lzop library. Compilation requires: Command: sudo apt-get install lzop

After the tool is ready, like uboot, first verify the direct use of linux provided by NXP, and see how.

2. NXP original Linux test
1. Transfer the NXP original linu to ubuntu, decompress it, and rename it to: linux-imx-rel_imx_4.1.15_2.1.0_ga_onefu.
(1) Transfer linux-imx-rel_imx_4.1.15_2.1.0_ga.tar.bz2 to the corresponding directory of ubuntu through FileZillaClient.
insert image description here
(2) Use the command: "tar -vxjf linux-imx-rel_imx_4.1.15_2.1.0_ga.tar.bz2" to decompress the compressed package.
insert image description here
(3) Use the command: "mv linux-imx-rel_imx_4.1.15_2.1.0_ga linux-imx-rel_imx_4.1.15_2.1.0_ga_onefu" to rename the folder name.
insert image description here
2. Write a running script
(1) Create the "imx6ull_onefu_emmc.sh"
command in the decompressed root directory: "touch imx6ull_onefu_emmc.sh"
insert image description here
(2) Open the script with VScode and enter the following:

#!/bin/sh
#清理工程
make ARCH=arm CROSS_COMPILE=arm-gnueabihf- distclean
#使用默认配置文件imx_v7_mfg_defconfig来配置Linux内核
make ARCH=arm CROSS_COMPILE=arm-gnueabihf- imx_v7_mfg_defconfig
#打开Linux的图形配置界面
make ARCH=arm CROSS_COMPILE=arm-gnueabihf- menuconfig
#编译Linux
make ARCH=arm CROSS_COMPILE=arm-gnueabihf- all -j16
#注1: ARCH=arm  设置目标为arm架构
#注2: CROSS_COMPILE=arm-linux-gnueabihf-    指定编译工具链前缀
#注3-j16 使用16核编译

(3) Give the script executable permission

chmod 777 imx6ull_onefu_emmc.sh //给予可执行权限 

insert image description here
(4) Run the script

./imx6ull_onefu_emmc.sh //执行shell脚本编译内核

insert image description here
3. Generate the zImage image file in the directory arch/arm/boot and the imx6ull-alientek-emmc.dtb file in the arch/arm/boot/dts directory, copy it to the tftp directory, restart the development board, and use it in the uboot command mode The tftp command downloads these two files and starts.
(1) Copy the zImage and imx6ull-alientek-emmc.dtb
commands:

cp  /home/water/water/kernel/linux-imx-rel_imx_4.1.15_2.1.0_ga_onefu/arch/arm/boot/zImage  .
cp  /home/water/water/kernel/linux-imx-rel_imx_4.1.15_2.1.0_ga_onefu/arch/arm/boot/dts/imx6ull-14x14-evk.dtb .

insert image description here
(2) Grant all permissions
Command:

 chmod 777 *

insert image description here
(3) Open the CRT and enter the uboot interface
insert image description here
(4) Download Linux and device tree through TFTP
Command:

tftp 80800000 zImage 
tftp 83000000 imx6ull-14x14-evk.dtb 

The first sentence is to download the linux image to address 0x80800000.
The second sentence is to download the device tree to address 0x83000000.

The following figure shows the linux image download process.
insert image description here
The figure below shows the device tree download process.
insert image description here
(5) After running the linux
download, enter the command: "bootz 80800000 - 83000000" and run.
insert image description here
As can be seen from the above figure, the linux kernel has been started, indicating that linux can run normally.

If there is a root file system in EMMC, you can enter the linux system and use the command line to operate, as shown in the figure below, press Enter, you can see the corresponding command line output switch.
insert image description here
3. Analysis of the operating phenomenon of the original NXP linux
1. The root file system is missing error
. After the Linux kernel starts, the root file system is required. Where the root file system exists is specified by the bootargs environment variable of uboot, and the bootargs will be passed to the Linux kernel as a command line. parameter. For example, set root=/dev/mmcblk1p2 in the previous section, which means that the root file system is stored in /dev/mmcblk1p2, which is partition 2 of EMMC. This is because the root file system has been programmed in partition 2 of the EMMC when the EMMC version development board of Punctual Atom leaves the factory, so set root=/dev/mmcblk1p2. What happens if we don't set the root filesystem path, or if the root filesystem path is set incorrectly? This problem is very common. We are developing a product in actual work. After the first version of the hardware of this product comes out, we do not have the corresponding root file system available, so we must make our own root file system. Before the corresponding root file system is built, the Linux kernel has no root file system available. What problems will occur after the Linux kernel is started? With this problem, we changed the bootargs environment variable in uboot to "console=ttymxc0,115200", that is, without filling in the content of root, the command is as follows:

setenv bootargs 'console=ttymxc0,115200' //设置
bootargs saveenv //保存

insert image description here

After the modification is completed, restart from the network. After startup, there will be an error as shown in the following figure:
insert image description here
At the end of the above figure, there will be the following line:

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)  

That is to say, the kernel crashes, because the VFS (virtual file system) cannot mount the root file system, because the root file system directory does not exist. Even if the root file system directory exists, if the root file system directory is empty, it will still prompt a kernel panic. This is the kernel crash caused by the absence of the root file system, but the kernel is started, but the root file system does not exist.

2. When there is a root file system, enter linux normally.

4. Summary:
At this point, the NXP original linux compilation and running test is completed. It can be seen from the above phenomenon that the original Linux kernel can be compiled and run normally. However, due to the differences between the hardware circuit design of the Linux development board of Punctual Atom and the design of the original demo board, such as network, LCD and so on. These parts need to be modified in the original Linux to match the Linux development board of Punctual Atom. So the next part of the explanation is the operation of transplanting the entire NXP original Linux to the Punctual Atomic Linux development board.

To sum up, if there are any deficiencies, errors or omissions, please contact the author to modify or supplement.
Only by communicating with each other can we promote common progress.

Author contact QQ: 759521350

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324493683&siteId=291194637