QEMU simulation vexpress-a9 and U-boot boot Linux

Source: Internet
Author: User
Tags parent directory

Foreword
This article describes the use of qemu to simulate the vexpress-a9 development board, and also introduces the process of booting linux using u-boot. Sit down and have a general understanding of how qemu and u-boot and embedded linux work

qemu basics
Here's how to use tap for network interconnection

First install some tools to configure the network

apt-get install bridge-utils # virtual bridge tool
apt-get install uml-utilities # UML (User-mode linux) tool
Mainly introduce several commands

Add a virtual bridge br0

brctl addbr br0
Create a tap0 interface to allow only root users to access

tunctl -t tap0 -u root
Add a tap0 interface to the virtual bridge

brctl addif br0 tap0
Set the address of the tap0 port

sudo ifconfig tap0 192.168.1.111
See details

58624063
Compile linux kernel
First install the cross compilation toolchain

sudo apt-get install gcc-arm-linux-gnueabi
Compile the kernel (using the 3.12.54 kernel, 4.x seems to be too new to load)

export ARCH = arm
export CROSS_COMPILE = arm-linux-gnueabi-
make vexpress_defconfig
make zImage
make modules
make dtbs
Then a zImage file will be generated in the arch / arm / boot directory

At this time, you can try to run

sudo qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/haclh/vmdk/linux-3.12.54/arch/arm/boot/zImage -nographic -append "console = ttyAMA0"
If appears

input: ImExPS / 2 Generic Explorer Mouse as / devices / mb: kmi1 / serio1 / input / input2
VFS: Cannot open root device "(null)" or unknown-block (0,0): error -6
Please append a correct "root =" boot option; here are the available partitions:
Kernel panic-not syncing: VFS: Unable to mount root fs on unknown-block (0,0)
CPU: 0 PID: 1 Comm: swapper / 0 Not tainted 3.12.54 # 1
[<8001535c>] (unwind_backtrace + 0x0 / 0xec) from [<80011ad0>] (show_stack + 0x10 / 0x14)
[<80011ad0>] (show_stack + 0x10 / 0x14) from [<8037d680>] (dump_stack + 0x74 / 0x84)
[<8037d680>] (dump_stack + 0x74 / 0x84) from [<8037b7c4>] (panic + 0x9c / 0x1dc)
[<8037b7c4>] (panic + 0x9c / 0x1dc) from [<804a2110>] (mount_block_root + 0x1e0 / 0x274)
[<804a2110>] (mount_block_root + 0x1e0 / 0x274) from [<804a22b4>] (mount_root + 0x110 / 0x118)
[<804a22b4>] (mount_root + 0x110 / 0x118) from [<804a240c>] (prepare_namespace + 0x150 / 0x188)
[<804a240c>] (prepare_namespace + 0x150 / 0x188) from [<804a1d00>] (kernel_init_freeable + 0x21c / 0x22c)
[<804a1d00>] (kernel_init_freeable + 0x21c / 0x22c) from [<80379e40>] (kernel_init + 0x8 / 0x13c)
[<80379e40>] (kernel_init + 0x8 / 0x13c) from [<8000e280>] (ret_from_fork + 0x14 / 0x34)
The kernel has been compiled and the file system is constructed next.

Building a file system with busybox
The 1.24 version of busybox used here. Execute in the busybox directory

make menuconfig
Set static compilation and cross compilation toolchain

Busybox Settings --->
    Build Options --->
        [*] Build BusyBox as a static binary (no shared libs)
        (arm-linux-gnueabi-) Cross Compiler prefix
Then compile

make
make install
Then go to the parent directory of busybox and execute a script

#! / bin / bash

sudo rm -rf rootfs
sudo rm -rf tmpfs
sudo rm -f a9rootfs.ext3

sudo mkdir rootfs
sudo cp busybox / _install / * rootfs / -raf

sudo mkdir -p rootfs / proc /
sudo mkdir -p rootfs / sys /
sudo mkdir -p rootfs / tmp /
sudo mkdir -p rootfs / root /
sudo mkdir -p rootfs / var /
sudo mkdir -p rootfs / mnt /

sudo cp etc rootfs / -arf

sudo cp -arf / usr / arm-linux-gnueabi / lib rootfs /

sudo rm rootfs / lib / *. a
sudo arm-linux-gnueabi-strip rootfs / lib / *

sudo mkdir -p rootfs / dev /
sudo mknod rootfs / dev / tty1 c 4 1
sudo mknod rootfs / dev / tty2 c 4 2
sudo mknod rootfs / dev / tty3 c 4 3
sudo mknod rootfs / dev / tty4 c 4 4
sudo mknod rootfs / dev / console c 5 1
sudo mknod rootfs / dev / null c 1 3

sudo dd if = / dev / zero of = a9rootfs.ext3 bs = 1M count = 32
sudo mkfs.ext3 a9rootfs.ext3

sudo mkdir -p tmpfs
sudo mount -t ext3 a9rootfs.ext3 tmpfs / -o loop
sudo cp -r rootfs / * tmpfs /
sudo umount tmpfs
Files in the etc directory

http://t.cn/R3IOFVM
First unzip it, then execute the above script

Then a a9rootfs.ext3 file system will be created in the current directory.

Plus a wave of file system operations

sudo qemu-system-arm -net nic -net tap, ifname = tap0, script = no, downscript = no -M vexpress-a9 -m 512M -kernel /home/haclh/vmdk/linux-3.12.54/arch/arm / boot / zImage -nographic -append "root = / dev / mmcblk0 console = ttyAMA0" -sd /home/haclh/vmdk/a9rootfs.ext3
You can enter linux.

reference

http://www.cnblogs.com/pengdonglin137/p/5023342.html
Compile u-boot
First download u-boot (used version u-boot-2016.05), then enter u-boot directory to compile

export ARCH = arm
export CROSS_COMPILE = arm-linux-gnueabi-
make vexpress_ca9x4_defconfig
make
Then boot u-boot

sudo qemu-system-arm -M vexpress-a9 -kernel /home/haclh/vmdk/LKDemo/u-boot-2016.05/u-boot -nographic -m 512M -net nic -net tap, ifname = tap0, script = no , downscript = no
If successful, the following will appear.

U-Boot 2016.05 (May 12 2018-22:56:24 -0700)

DRAM: 512 MiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC: MMC: 0
*** Warning-bad CRC, using default environment

In: serial
Out: serial
Err: serial
Net: smc911x-0
Hit any key to stop autoboot: 0
=>
reference

54945726
Install tftpd
I plan to use u-boot to boot the linux kernel through tftp, so first install tftpd on ubuntu.

apt install vsftpd
Then modify the tftpd configuration file

 sudo vim /etc/vsftpd.conf
Mainly modify two

anon_root = / home / haclh / vmdk / linux-3.12.54 / arch / arm / boot # Add an entry to set the root directory
anonymous_enable = YES #
/home/haclh/vmdk/linux-3.12.54/arch/arm/boot is the linux kernel compilation result directory

Then modify the xinted configuration file

08:03 [email protected]: boot $ cat /etc/xinetd.d/tftp
service tftp
{
   protocol = udp
   port = 69
   socket_type = dgram
   wait = yes
   user = nobody
   server = /usr/sbin/in.tftpd
   server_args = -s /home/haclh/vmdk/linux-3.12.54/arch/arm/boot
   disable = no
}
Then restart the xinted service

sudo service xinetd restart
u-boot boot linux
To boot linux with u-boot, you must first compile linux UImage mirroring

export ARCH = arm
export LOADADDR = 0x60003000
export CROSS_COMPILE = arm-linux-gnueabi-
make vexpress_defconfig
make uImage
First enter u-boot

sudo ifconfig tap0 192.168.1.111
sudo qemu-system-arm -M vexpress-a9 -kernel /home/haclh/vmdk/LKDemo/u-boot-2016.05/u-boot -nographic -m 512M -net nic -net tap, ifname = tap0, script = no , downscript = no -sd /home/haclh/vmdk/a9rootfs.ext3
U-Boot 2016.05 (May 12 2018-22:56:24 -0700)

DRAM: 512 MiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC: MMC: 0
*** Warning-bad CRC, using default environment

In: serial
Out: serial
Err: serial
Net: smc911x-0
Hit any key to stop autoboot: 0
=>
Then set the IP and host IP

setenv ipaddr 192.168.1.120
setenv serverip 192.168.1.111
Then load the image into memory

tftp 0x60003000 uImage
Last boot

setenv bootargs ‘root = / dev / mmcblk0 console = ttyAMA0’
bootm 0x60003000
Then it's ok

EXT3-fs (mmcblk0): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) on device 179: 0.
Freeing unused kernel memory: 196K (804a1000-804d2000)
Please press Enter to activate this console. [[Email protected]] #
[[email protected]] #
[[email protected]] #
[[email protected]] # ifconfig
lo Link encap: Local Loopback
          inet addr: 127.0.0.1 Mask: 255.0.0.0
          UP LOOPBACK RUNNING MTU: 65536 Metric: 1
          RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0
          TX packets: 0 errors: 0 dropped: 0 overruns: 0 carrier: 0
          collisions: 0 txqueuelen: 0
          RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)

[[email protected]] # ifconfig -a
reference

http://www.cnblogs.com/pengdonglin137/p/5023704.html
qemu simulate vexpress-a9 and u-boot boot linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.