Run U-boot and Linux using QEMU emulation cortex-a9

Source: Internet
Author: User

Reprint: http://blog.chinaunix.net/uid-20273473-id-3267337.html

My development environment: Ubuntu-12.04 All packages are up to date 1. Installing the GNU tool chain
sudo apt-get insatll gcc-arm-linux-gnueabisudo apt-get insatll G++-arm-linux-gnueabi

The library files, header files, and so on will be generated in the/usr/arm-linux-gnueabi/directory after the installation is complete. The GCC version I installed is:
    1. ARM-LINUX-GNUEABI-GCC (Ubuntu/linaro 4.6.3-1ubuntu5) 4.6.3
    2. Copyright (C) Free Software Foundation, Inc.
2. Installing the QEMU Emulator
    1. sudo apt-get install QEMU Qemu-system qemu-utils
You should already be able to run the Qemu-system-arm command with the following version:
    1. Qemu-system-arm--version
    2. QEMU emulator version 1.0.50 (Debian 1.0.50-2012.03-0ubuntu2), Copyright (c) 2003-2008 Fabrice Bellard
3. Compile and run U-boot: to ftp://ftp.denx.de/pub/u-boot/Download the latest version of U-boot source code, I use the latest version u-boot-2012.04.tar.bz2 extracted into the source code directory, Add two lines to the makefile:
    1. ARCH? = Arm
    2. Cross_compile? = arm-linux-gnueabi-
It is actually telling it to compile using the arm compiler.
    1. Make Ca9x4_ct_vxp_config
    2. Make
This configures the target board for Cortex-a9x4 Vexpress. The choice of this configuration can be seen from the Boards.cfg file, Vexpress is an arm company using CORTEXT-A9 a development Board, the relevant code in the board/armltd/vexpress/directory, the configuration file is include/  Configs/ca9x4_ct_vxp.h. And the key thing is that QEMU already supports this board card. The U-boot file runs when the compilation is complete:
    1. Qemu-system-arm-m vexpress-a9-m 256m-nographic-kernel U-boot
Or
    1. Qemu-system-arm-m vexpress-a9-m 256m-serial Stdio-kernel u-boot
found that if you do not specify-nographics, you must add-serial stdio to print. The parameter-M 256M is the specified memory size. -m Specifies the name of the board, the supported boards can be viewed with-M, as follows:
    #qemu-system-arm-m?     supported machines is:    Beagle Beagle Board (OMAP3530)    BEAGLEXM Beagle Board XM (OMAP3630)    ............    VERSATILEPB Arm Versatile/PB (arm926ej-s)    Versatileab arm Versatile/ab (arm926ej-s)    Vexpress for cortex-A9    vexpressfor Cortex-a15

Results of normal operation:
  1. Qemu-system-arm-m vexpress-a9-m 256m-nographic-kernel U-boot
  2. U-boot 2012.04 (Jul 08 2012-00:14:08)
  3. dram:256 MiB
  4. Warning:caches not enabled
  5. Flash: # Unknown flash on Bank 1-size = 0x00000000 = 0 MB
  6. # # Unknown Flash on Bank 2-size = 0x00000000 = 0 MB
  7. Failed * * *
  8. mmc:mmc:0
  9. Warning-bad CRC, using default environment
  10. In:serial
  11. Out:serial
  12. Err:serial
  13. net:smc911x-0
  14. Hit any key to stop autoboot:0
  15. vexpress#
  16. vexpress# printenv
  17. baudrate=38400
  18. Bootcmd=run Bootflash;
  19. bootdelay=2
  20. Bootflash=run Flashargs; CP ${ramdisk_addr} ${ramdisk_addr_r} ${maxramdisk}; Bootm ${kernel_addr} ${ramdisk_addr_r}
  21. Console=ttyama0,38400n8
  22. 。。。。。
Note: If you stop running after detecting flash failed, it is because the arch/arm/lib/board.c inside the Board_init_r () function to detect the flash failure after calling hang (), temporarily remove hang () can be run. 4. Compile and run the Linux kernel: to http://www.kernel.org/download the latest Linux kernel source code, I downloaded the linux-3.4.4.tar.bz2. Modified makefile after decompression, ARCH = arm, cross_compile=arm-linux-gnueabi-
    1. Make Vexpress_defconfig
(You can see all your own configuration files in the arch/arm/configs/directory, we use the Vexpress card default profile) and make Menuconfig--and System Type to Enable the l2x0 outer The cache controller cancels, otherwise QEMU will not get up, and for the time being do not know why. Then you can make it.  Finally, the Arch/arm/boot/zimage file is generated, which is the kernel image we need. 5. Make the root file system: This part of the network has a lot of introduction, it will not elaborate. Probably the process is: first create a standard Linux directory structure, to http://www.busybox.net/download the latest BusyBox source code compiled installation to the directory you just created, copy arm library files to the corresponding directory, in etc/ The directory creates several mandatory startup scripts and configuration files. Let's talk about how to generate a file system image in EXT3 format:
    1. DD If=/dev/zero OF=A9ROOTFS.EXT3 bs=1m count=32//Create an empty 32M file
    2. MKFS.EXT3 A9ROOTFS.EXT3//formatted as EXT3
    3. sudo mount-t ext3 a9rootfs.ext3 a9rootdir/-O loop//mount to A9rootdir directory
    4. CP path/to/your/rootfs/* a9rootdir/-RF//Copy files to this directory, relative to the a9rootfs.ext3 inside
    5. sudo umount a9rootdir/
At this point a9rootfs.ex3 contains the root filesystem content we created and is in the ext3 format. 6. Run Linux with Qemu:
    1. Qemu-system-arm-kernel zimage-serial stdio-m vexpress-a9-append "root=/dev/mmcblk0 console=ttyAMA0 console=tty0"-sd A 9rootfs.ext3
QEMU can simulate SD card, we put A9ROOTFS.EXT3 as an SD device, the corresponding device file is/dev/mmcblk0, which is started as the root file system.  Ttyama0:serial console; Tty0:framebuffer Console. Finally, put a post-boot image:

Run U-boot and Linux using QEMU emulation cortex-a9

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.