Build root file system (rootfs) based on Linux
- 1. Requirements
- 2. Install the cross-compilation chain
- 3. Download the Buildroot code package
- 4. Start buildroot to create the root file system
- 5. Configuration file system menuconfig
-
- 5.1.Target options —> Configuration instructions
- 5.2.Build options —> Configuration instructions
- 5.3.Toolchain —> Configuration instructions
- 5.4.System configuration —> Configuration instructions
- 5.5.Kernel —> Configuration instructions
- 5.6.Target packages —> Configuration instructions
- 5.7.Filesystem images —> Configuration instructions
- 5.8.Bootloaders —> Configuration instructions
- 6. Confirm and save the configuration
- 7. compile
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
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:
5.2.Build options —> Configuration instructions
Generation options: Choose according to your actual situation. Here I use the default configuration directly.
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.
1)Toolchain type () —>
The default is Buildroot toolchain (internal toolchain).
Here we choose External toolchain (external toolchain)
2)Toolchain () —>
Choose a custom toolchain
3)Toolchain origin () —>
Select the toolchain source, the default is to select Pre-installed toolchain (pre-installed toolchain)
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
5) ($(ARCH)-linux) Toolchain prefix ()
Configure cross-compilation tool chain prefix
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
Since we are on version 7.2.1, choose external cross-compilation tool chain version 7.x
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
Converting 264707 to hexadecimal is 40A03, and for decimal it is 4.10.3
Here we choose 4.10.X
8)External toolchain C library () —>
External toolchain C library
9) The tool chain supports C++ options
5.4.System configuration —> Configuration instructions
System configuration: This needs to be modified according to your actual situation. I have modified 5 places here.
1) Modify the system hostname
2) Modify the login prompt
3) Modify the device mounting method
4) Modify the login password
Note: The default login account name is root
5) Modify the system login serial number
TTY port is modified here to be the system login serial number of your own development board.
Baudrate Modify the serial port baud rate
5.5.Kernel —> Configuration instructions
Kernel configuration: We don't need to compile the kernel here, here we uncheck
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.
5.7.Filesystem images —> Configuration instructions
File system mirroring: Here I directly use the default configuration
5.8.Bootloaders —> Configuration instructions
System bootloader:
We don't need to compile u-boot here, we uncheck u-boot.
Don't care about anything else.
6. Confirm and save the configuration
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.