Build root file system (rootfs) based on Linux

1. Requirements

Development environment: Ubuntu16.04
Development platform: f1c100s

2. Install the cross-compilation chain

1. Create a new folder: mkdir toolchain and enter: cd toolchain

2. Download the compilation chain: wget https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabi/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar .xz

Note: If there is a corresponding cross-compiler compressed package, just copy it to the corresponding directory and decompress it yourself.

3. Decompress: xz -d file.tar.xz Decompress again: tar -xvf file.tar

4. Copy to the corresponding directory (I put it in /usr/local/arm-gcc/, you can choose the path according to your own needs, you will need it later)

5. Open .bashrc: vim .bashrc and add the bin file path of the compilation chain (similar to adding environment variables under windows):
add the following content at the end of the file

PATH="$PATH:/usr/local/arm-gcc/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi/bin/"

Then save and exit, and finally update the environment variables: source .bashrc

3. Download the Buildroot code package

1. You can download the latest code package at the link https://buildroot.org/download.html (the web page opens very slowly, unless you can... well, you know, "Over the wall").

4. Start buildroot to create the root file system

1) Copy the downloaded buildroot-2021.02.6.tar.gz compressed package to ubuntu, unzip it and enter the buildroot-2021.02.6 directory (it is recommended to create a new directory).

mkdir make_rootfs
tar -xzvf buildroot-2021.02.6.tar.gz 
cd buildroot-2021.02.6

5. Configuration file system menuconfig

1) Enter the graphical configuration interface

make menuconfig

Insert image description here

5.1.Target options —> Configuration instructions

1) Since we are using f1c100s and the CPU architecture is ARM9, we need to change the configuration content, as follows:

Insert image description here

5.2.Build options —> Configuration instructions

Generation options: Choose according to your actual situation. Here I use the default configuration directly.
Insert image description here

5.3.Toolchain —> Configuration instructions

Compilation tool chain selection: This needs to be modified according to your actual situation. A total of 9 places have been modified here.

Insert image description here

1)Toolchain type () —>
The default is Buildroot toolchain (internal toolchain).
Insert image description here
Here we choose External toolchain (external toolchain)

Insert image description here

2)Toolchain () —>

Choose a custom toolchain
Insert image description here

3)Toolchain origin () —>
Select the toolchain source, the default is to select Pre-installed toolchain (pre-installed toolchain)
Insert image description here
4)Toolchain path ()

Cross-compilation tool chain path
Find the path of your own cross-compilation tool chain and fill it in. When you installed the cross-compilation chain above, you already knew the path: /usr/local/arm-gcc/gcc-linaro-7.2.1-2017.11-x86_64_arm -linux-gnueabi
Insert image description here
5) ($(ARCH)-linux) Toolchain prefix ()

Configure cross-compilation tool chain prefix

Insert image description here

My cross-compilation tool chain is: arm-linux-gnueabi so we fill it in as: $(ARCH)-linux-gnueabi

6)External toolchain gcc version () —>
Select the external cross-compilation toolchain version

arm-linux-gnueabi-gcc -v

Insert image description here
Since we are on version 7.2.1, choose external cross-compilation tool chain version 7.xInsert image description here

7)External toolchain kernel headers series () —>

External tool chain kernel header series, here we enter the cross-compilation tool chain directory and look for the version information file,

The path is where we just installed the cross-compilation tool chain:

vim /usr/local/arm-gcc/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi/arm-linux-gnueabi/libc/usr/include/linux/version.h

Insert image description here
Converting 264707 to hexadecimal is 40A03, and for decimal it is 4.10.3

Insert image description here

Here we choose 4.10.X

Insert image description here
8)External toolchain C library () —>

External toolchain C library

Insert image description here

9) The tool chain supports C++ options

Insert image description here

5.4.System configuration —> Configuration instructions

System configuration: This needs to be modified according to your actual situation. I have modified 5 places here.

Insert image description here
1) Modify the system hostname

Insert image description here
2) Modify the login prompt

Insert image description here

3) Modify the device mounting method

Insert image description here
4) Modify the login password

Note: The default login account name is root
Insert image description here

5) Modify the system login serial number

Insert image description here

TTY port is modified here to be the system login serial number of your own development board.
Insert image description here

Baudrate Modify the serial port baud rate
Insert image description here

5.5.Kernel —> Configuration instructions

Kernel configuration: We don't need to compile the kernel here, here we uncheck

Insert image description here
Insert image description here

5.6.Target packages —> Configuration instructions

Target package: file system package and library file installation package, this needs to be modified according to your actual situation. Here I just use the default configuration.

Insert image description here
Insert image description here

5.7.Filesystem images —> Configuration instructions

File system mirroring: Here I directly use the default configuration

Insert image description here
Insert image description here

5.8.Bootloaders —> Configuration instructions

System bootloader:

Insert image description here

We don't need to compile u-boot here, we uncheck u-boot.
Insert image description here

Don't care about anything else.

6. Confirm and save the configuration

Insert image description here

7. compile

1) Execute the compilation command:

make

2) Start compiling. The first compilation will automatically download the exact dl file. The whole process will take some time.

3) After compilation, the rootfs.tar file will be generated in buildroot-2019.02.2/output/images. At this point, Buildroot compilation is completed.

Guess you like

Origin blog.csdn.net/qq_39721016/article/details/123876398