I am a poor person, can I stop buying a development board? ---QEMU analog arm system

Preface

  • I have always admired the kind of open-minded feelings of the ancients, just like the ending sentence in the documentary of "Adventure Detective Mine": "Everyone is a busy person, busy growing up, losing innocence; busy making money , Ignoring thoughts; busy with success, missed the scenery, the nutrition of the years, and ate fast food in a hurry. Those stories that should have been unforgettable in the time, just hurriedly hurried, failed to catch our shadow . "
  • Just like Zhao Bingwen’s words in "Green Myolie":
    "Wind and rain take care of flowers. After wind and rain, flowers should rest. Advise you not to be drunk before flowers. The flowers will die this year, and the flowers will die next year, and their heads will be white. . Picking up mountains and rivers is good for chasing. But if you have wine, you have nothing to do, whether you have flowers or no flowers, choose spring and autumn.
  • I think I can find a time like this, put aside the trivial things, and record the scenery around you. If you walk too fast, you will become impetuous, and occasionally stop to look at the surrounding scenery and listen to the stories of strangers. , Experience all kinds of life, is it not a harvest .
  • At the end of 2019, in the face of the raging epidemic, the school was hopeless and was forced to be trapped at home; Yu still missed the Linux driver avenue and did not dare to forget one or two; however, the development board was placed in school and there was no way to get it; People, poor family, no fertile fields, and jewels, there is no way to practice. There are many thoughts, and suddenly looking back, the journey of QEMU is not impossible.

Ready to work

  • (1) Linux kernel: I chose Linux-4.9.8. Other versions of the Linux kernel can be obtained at this link: https://www.kernel.org/
  • (2) U-Boot: I chose u-boot-2017.07, see the following link for other versions: ftp://ftp.denx.de/pub/u-boot/
  • (3) The busybox used to build the root file system: I am using busybox-1.27.0, other versions are obtained: https://busybox.net/downloads/

QEMU started

Linux kernel

  • (1) Enter the root directory of Linux-4.9.8 and modify the architecture and cross-compiler of Makefile:
    Insert picture description here

  • (2) Then enter the arch/arm/configs/ directory, you can see the vexpress_defconfig configuration, and then configure the .config file in the Linux kernel root directory: execute:

make vexpress_defconfig
  • (3) Execute make menuconfig to configure the linux kernel to support NFS (Network File System), as follows:
    Insert picture description here
    Insert picture description here
  • (4) Execute after configuration
make LOADADDR=0X60003000 uImage
make modules
make dtbs

Generate uImge kernel module and device tree files respectively, and copy the uImage file vexpress-v2p-ca9.dtb into the tftp directory (about the installation and configuration of the tftp server under Ubuntu, you can Baidu, too many, so I won’t introduce it Up)

uImage在arch/arm/boot/ 目录下
vexpress-v2p-ca9.dtb 在arch/arm/boot/dts/ 目录下

At this point, the compilation of the Linux kernel is complete.

U-boot modification and compilation

  • (1) First, modify the Makefile and config.mk in the root directory of Uboot, if the following problems occur during the compilation of
    Makefile
    Insert picture description here
    config.mk
    Insert picture description here
cc1: error: bad value (‘armv5’) for-march=switch
cc1: note: valid arguments to ‘-march=switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 bonnell atom silvermont slm knl x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 btver1 btver2

It can be solved by executing in the root directory of Uboot:

export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
  • (2) Secondly, add the following content in include/configs/vexpress_common.h to configure uboot's kernel image, device tree download address, virtual development board IP address and tftp server address, nfs directory information, etc.: The
    Insert picture description here
    specific IP address can be based on Modify the tftp server configured by yourself:
#define CONFIG_BOOTCOMMAND \
    "tftp 0x60003001 uImage;tftp 0x60500000 vexpress-v2p-ca9.dtb;setenv          bootargs 'root=/dev/nfs rw nfsroot=192.168.44.128:/home/zhangbin/miniTest/      rootfs init=/linuxrc ip=192.168.44.121 console=ttyAMA0';bootm 0x60003000 -      0x60500000;"

#define CONFIG_IPADDR 192.168.44.121
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_SERVERIP 192.168.44.128

  • (3) Then execute make to compile uboot to generate target file u-boot
    Insert picture description here
    Insert picture description here
    and copy u-boot to a directory defined by yourself

Although the root file system has not been built now, the kernel, device tree and uboot can now be tested

  • (1) qemu installation:
sudo apt-get install qemu
  • (2) The command to write qemu is as follows:
echo "start run system!!!" 
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"

qemu-system-arm \
     -M vexpress-a9 \
     -kernel /home/zhangbin/miniTest/QEMU/u-boot \
     -nographic \
     -m 512M \
     -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \

  • (3) Then use sudo to execute this script to
    Insert picture description here
    Insert picture description here
    prove that uboot and uImage and the device tree file are easy to use, and then you can build the root file system with peace of mind.

Build the root file system

Busybox configuration and installation

  • (1) Enter busybox-1.27.0 and modify Makefile
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-gnueabi-
  • (2) Then execute the graphical configuration, make menuconfig
    amended as follows: compile into a static library
    Insert picture description here
  • (3) configuration, run make and make install, complete the following files and then _install directory (folder)
    -Insert picture description here

Make the root file system

  • Create directories and copy files generated by busybox
  • Insert picture description here
  • Then you can create
cd rootfs
mkdir etc
cd etc
mkdir init.d
cd init.d
touch rcS
chmod a+X rcS

You can write some shell statements in the rcS file as a startup prompt

Start the QEMU simulation arm development board

Start script:

echo "start run system!!!"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"

qemu-system-arm \
      -M vexpress-a9 \
      -kernel /home/zhangbin/miniTest/QEMU/u-boot \
      -nographic \
      -m 512M \
      -net nic,vlan=0 -net tap,vlan=0,ifname=tap0

Interface:
Insert picture description here
This is the simplest root file system, and other content will be configured later.

The problem

  • The root file system cannot be mounted: VFS: Cannot open root device “nfs” or unknown-block(2,0): error -6 NFS
  • Solution:
    (1) Modify the CONFIG_BOOTCOMMAND parameter in the vexpress_comman.h file under UBOOT: add V3
    Insert picture description here
#define CONFIG_BOOTCOMMAND \
   "tftp 0x60003000 uImage;tftp 0x60500000 vexpress-v2p-ca9.dtb;\
    setenv bootargs 'root=/dev/nfs rw \
    nfsroot=192.168.44.128:/home/zhangbin/miniTest/rootfs,v3 init=/linuxrc \
    ip=192.168.44.121 console=ttyAMA0';\     
     bootm 0x60003000 - 0x60500000;"

(2) Under the /dev/ directory, create an nfs directory node and give full permissions to the root file system (rootfs)

sudo mkdir /dev/nfs
sudo chmod 777 rootfs

Concluding remarks

  • How a person lives depends on several important choices. When people feel tired, it is because they are doing things they don’t like, but they will feel tired after doing things they like for a long time. Then you need to change the things you like. To achieve a great thing, you also need to develop something, otherwise you will end up disliking anything.
  • QEMU's exploration is still going on. I hope we can all find our dream that we can stick to. LInux drives a long road, walk slowly and accumulate slowly. Don't let the rush of life make us forget our original intention.

Guess you like

Origin blog.csdn.net/qq_41782149/article/details/107012943