Build a simulated environment of mini2440 using qemu

Source: Internet
Author: User

My compilation platform is Ubuntu 11.10.

Follow

Http://www.cnblogs.com/jinmu#/archive/2011/03/21/1990698.html 《

Build a simulated environment of mini2440 using qemu

You will encounter the following errors:

1. When the following

./Configure -- target-list = arm-softmmu

The following error occurs when the statement is used to compile qemu.

The error log from compiling the libsdl test is:
/Tmp/qemu-conf -- 3170-. C: 1: 17: Fatal error: SDL. h: no such file or directory
Compilation terminated.
Error: qemu requires SDL or cocoa for graphical output
To build qemu without graphical output configure with -- disable-GFX-Check
Note that this will disable all output from the virtual graphics card
Certificate T through VNC or curses.

You can use the following statement to fix the problem:
Sudo apt-Get install libsdl-Dev
When you use make-J4, the compilation is successful.

2. During uboot compilation, you can change the code for setting the initial IP address to the desired IP address, such as a network segment with the IP address of your host, to facilitate future experiments. Also, be sure to remember to copy the compiled u-boot.bin to the qemu/mini2440 folder, otherwise the subsequent execution of mini2440/mini2440_start.sh will encounter the following error:

Copy code

  1. Qemu mini2440_reset: loaded default U-boot from nandqemu
    Mini2440_reset: loaded mini2440/uimage (size 1f7000)
    Qemu: Fatal: trying to execute code outside Ram or ROM at 0x34000000
    R00 = 00000000 R01 = 00000000 r02 = 00000000 r03 = 20.20.r04 = 00000000 r05 = 00000000 r06 = 00000000 r07 = 00000000r08 = 00000000 R09 = 00000000 R10 = 00000000 R11 = 00000000r12 = 00000000 R13 = 00000000 R14 = 00000000 R15 = 34000000psr = 400001d3-z -- A svc32
    Aborted


3. When compiling the kernel, the following problems may occur:
(I will add: the download address for Linux kernel for mini2440 is:
Http://repo.or.cz/w/linux-2.6/mini2440.git/snapshot/HEAD.tar.gz)

"Mkimage" command not found-
U-boot images will not be built

Then, execute the following statement:
Sudo apt-Get install uboot-mkimage
Run the following statement again:
Make-J4 arch = arm cross_compile = arm-None-Linux-gnueabi-uimage
OK!
Note: I did not mention the most important point in the article I referenced at the beginning: that is to copy the u-boot.bin compiled from uboot to the mini2440 folder under the qemu directory, or after executing the command starting with the third, in the qemu simulator, nothing is executed.

3. When executing the following statements: (use the root user to execute the following statements)
Sh mini2440/mini2440_start.sh
You may encounter the following problems:

Starting in mini2440
Mini2440/mini2440_start.sh: Creating empty snapshot image: mini2440/mini2440_snapshots.img
Qemu-IMG: Invalid image size you may use K, M, G or t suffixes
Qemu-IMG: kilobytes, megabytes, gigabytes and terabytes.
Mini2440 /.. /ARM-softmmu/qemu-system-arm-M mini2440-drive file = mini2440/mini2440_snapshots.img, snapshot = on-serial stdio-kernel mini2440/uimage-mtdblock mini2440/mini2440_nand.bin-show-cursor-USB device keyboard-USB device mouse-net Nic, VLAN = 0-Net
Tap, VLAN = 0, ifname = tap0-monitor telnet: 5555, server, Nowait
Warning: cocould not configure/dev/NET/TUN: No virtual network emulation
Cocould not initialize device 'tap'

It is really difficult. I searched this article online: solution: Run qemu prompt "Warning: cocould not open/dev/NET/TUN: No virtual network emulation"
Http://blog.csdn.net/swangbucknell/article/details/5423187
It looks a little eye-catching. Later, when I compiled the kernel module according to the above method, I encountered the following problems:
Make [2]: *** you can create the target "kernel/bounds. c" required by "kernel/bounds. s" without rules ". Stop.
At this time, I was very discouraged and later found the problem with unremitting efforts, it turns out to be the/lib/modules/'uname-R'/build folder (that is,/usr/src/Linux-headers-'uname-R'-generic-PAE /) the following kernel code is incomplete. You need to download the kernel source code package of this version online again, decompress the package, and then compile the package to solve this problem. The command is as follows:
Sudo apt-Get install linux-Source
Go to Linux-source-'Your version' and run the following command again. For example, my version is as follows:

Make menuconfig details please see "qemu two ways to access the Internet" http://www.linuxdiyf.com/viewarticle.php? Id = 40202

CD/usr/src/linux-source-2.6.38/
Tar xjvf linux-source-2.6.38.tar.bz2
CD linux-source-2.6.38
Sudo-S
Make & sudo make modules_install
Modprobe Tun
Lsmod | grep Tun

In fact, there is another method that does not need to use modules_install, which is also included in the article "qemu two ways of surfing.
Note the following three points:
1. the source code of the kernel must be exactly the same as that of the current kernel version. Otherwise, the compiled modules cannot be used.
2. Note that only make modules (compilation module) does not have make modules_install (the module is automatically installed under/lib/modules)
3. Run depmod before loading the newly compiled module. Otherwise, modprobe cannot find it.
With the Tun file, the next problem occurs.

4. To enable the NFS server, follow the instructions in the previous article. When the NFS command is restarted, the following statement appears in the latest ubuntu11.10:

Exportfs:/etc/exports [3]: Neither 'subtree _ check' or 'no _ subtree_check 'specified for export "*:/opt/friendlyarm/mini2440/root_qtopia ".

Assuming default behaviour ('no _ subtree_check ').

Note: This default has changed since nfs-utils version 1.0.x

In fact, you don't need to worry about it. This does not matter if you use NFS to mount the file system later, but you should note that in/etc/exports, if you want to use a friendly rootfs_qtopia_qt4 file system, because the current qemu simulator only supports 64 m NAND (or it may be that the U-boot compiled from the first article is a 64 M version, further research is required here ). Therefore, we recommend that you use the old version of the root_qtopia file system. Otherwise, the qemu Mount fails.

5. For the mini2440_start.sh file, you only need to modify the following content:
-Net Nic, VLAN = 0 \
-Net tap, VLAN = 0, ifname = tap0 \
To:
-Net Nic, VLAN = 0-net tap, VLAN = 0, ifname = tap0, script =./qemu-IFUP, downscript =./qemu-ifdown \

6. When you encounter the following problems,

Copy code

  1. ./Qemu-IFUP: cocould not launch network scriptcocould not initialize device 'tap'


Run the following command: chmod A + x qemu-IFUP qemu-ifdown

For the qemu-IFUP and qemu-ifdown files, you can replace the IP address 10.0.0.1 with the IP address of an IP address segment on your host, not necessarily the IP address, and the IP address of U-boot in the first article is 10.0.0.4. In fact, when compiling uboot, find the code to change the initial IP address to the desired IP address.

7. After running the mini2440 command in qemu according to the steps in the beginning of the article, you will find the following error and the NFS file system cannot be mounted:

VFS: mounted root (NFS filesystem) on device 0: 13.
Freeing init memory: 132 k
NFS: Server 10.66.3.4 not responding, still trying

To solve this problem
"After U-boot is started successfully, enter the boot parameters for setting Linux kernel.
Set bootargs noinitrd root =/dev/nfs RW nfsroot = 10.0.0.1:/home/lizhao/ARM-Pro/nfs/rootfs IP = 10.0.0.10: 10.0.0.1: 255.255.255.0
Console = fig, 115200
"
In the U-boot parameter, change the content in nfsroot =... To the NFS environment on your machine.


On the other hand, I found that the solution (as shown below) provided at the beginning of the article is only a prompt and does not work:

"
The qtopia file system provided by the friendly arm initializes the NIC during mounting, but we are a file system mounted by NFS, which causes the NFS connection to be interrupted and the mounting fails, therefore, before mounting NFS, you need to cancel the NIC initialization process. The corresponding file is/etc/init. d/if-config: Clear the file content. Enjoy yourself!
"
Instead, comment out the following two statements in the file "etc/init. d/RCS" in the root_qtopia File System:
#/Sbin/ifconfig lo 127.0.0.1
#/Etc/init. d/ifconfig-eth0
After finishing the above modification, you can really enjoy the qemu-mini2440 to bring us the development and debugging fun!

Cyx8648
You have noticed that the above qemu can only simulate the mini2440 of 64 M and M.

Large page mode (In 2048 byte/Page)

NAND Flash, you need to modify the qemu code to support the NAND flash with the model k9f2g08 and the size of 256m.



(The old version is k9f1208 and the size is 64 Mbyte.

Small page (512 byte/Page) NAND Flash

In fact, this m is also

Large-page mode (2 k/Page) NAND Flash

)



Due to my limited energy and ability, I hope that you will be interested in the experts, if you have time, study how to make the above qemu support large capacity such as m of NAND Flash, so that, you can continue learning and experimenting without a Development Board!

Kasim
Thank you for sharing.
I used this qemu-mini2440 + virtual SD card image at the beginning, as long as you have enough space on your hard disk, how much you want to have much :)

Cyx8648
Okay. Thank you for your suggestion. I will take a closer look at the usage of the virtual SD card!

597569905
Underfloor

Cyx8648
This post http://www.arm9home.net/read.php? Tid = 17331 also mentioned some problems during qemu installation.

Cyx8648
The URLs for "qemu-mini2440 + virtual SD card images" are as follows:

There is an important step in the http://code.google.com/p/mini2440/wiki/QEmuSDCardImage is ignored, that is, after the disk/boot is created, you must copy the uimage, otherwise it will not start after

Http://project4fun.com/node/33
The content of the second webpage is written by a Thai. You can use Google's browser to translate it into English, so that you can understand it very well.

And I used in the mini2440 physical development board above the SD card experiment: http://www.arm9home.net/read.php? Tid-15866.html
Later, I combined this experiment to mount the file system to the SD card on qemu. However, there are also some problems in the process:

Copy code

  1. Sudo:/usr/sbin/brctl: Command not found
    Mini2440_init: Boot Mode: nands3c: CLK = 240 hclk = 240 pclk = 240 uclk = 57
    Qemu: ee24c08_initdm9000: init qemu Mac: 52: 54: 00: 12: 34: 56
    Qemu mini2440_reset: loaded default U-boot from NAND
    Qemu mini2440_reset: loaded override U-boot (size 3b800)
    Floating Point exception

For this problem, it is very simple. Because my host uses Ubuntu, after running the command whereis brctl, we found that brctl is in/sbin/brctl, so you only need to change the brctl in qemu-IFUP mentioned in the http://project4fun.com/node/33 to the correct address, and then re-execute the network. SH and start. sh.

Cyx8648
Recently, I have studied the qemu-uboot-kernel code and found that qemu can support m and above NAND Flash with only two modifications,

I,

# Vim qemu_src/HW/mini2440.c

Find the following 372nd lines of code:

/* Check the Boot Mode */
Switch (mini-> boot_mode ){
Case boot_nand:
Sram_base = maid;
Int size = bdrv_getlength (drives_table [nand_idx]. bdrv );
Switch (size ){
Case 2*65536*(512 + 16 ):
Nand_cid = 0x76;
Break;
Case 4*65536*(512 + 16 ):
Nand_cid = 0xf1;
Break;
Default:
Printf ("% s: Unknown NAND size/ID % d (% DMB) defaulting to old 64mb \ n ",
_ FUNC __, size, (size/(512 + 16) * 512)/1024/1024 );
Break;
}
Break;

Add the following three rows above the default: Statement:

Case 8*65536*(512 + 16 ):
Nand_cid = 0xda; // 256 MB flash = 0xda
Break;

To support NAND Flash with a capacity of 512 MB, You can imitate the above Code and add the following three lines:

Case 16*65536*(512 + 16 ):
Nand_cid = 0xdc; // 512 MB flash = 0xdc
Break;

As to why is it 512 + 16, you can look at this page: http://bbs.eeworld.com.cn/thread-305322-1-1.html

For what 0xda is, see the following content in qemu_src/NAND. C:
/* Information Based on Linux Drivers/MTD/NAND/nand_ids.c */
Static const struct {
Int size;
Int width;
Int page_shift;
Int erase_shift;
Uint32_t options;
} Nand_flash_id [0x100] = {
................................
[0x76] = {64, 8, 9, 5, 0 },
................................
/*
* These are the new chips with large page size. The pagesize and
* Erasesize is determined from the extended ID bytes
*/
# Define lp_options (nand_samsung_lp | nand_no_readrdy | nand_no_autoincr)
# Define lp_options16 (lp_options | nand_buswidth_16)
........................................ ..............................
/* 1 Gigabit */[0xa1] = {128, 8, 0, 0, lp_options}, [0xf1] = {128, 8, 0, 0, lp_options }, [0xb1] = {128, 16, 0, 0, lp_options16}, [0xc1] = {128, 16, 0, 0, lp_options16 },
/* 2 Gigabit */
[0xaa] = {256, 8, 0, 0, lp_options },
[0xda] = {256, 8, 0, 0, lp_options },
........................................ ........................

II,
You need to modify an object, that is

Vim qemu_src/mini2440/mini2440_start.sh

Modify to the following:
Echo starting in $ Base
# Name_nand = "$ base/mini2440_nand64.bin"
# Name_nand = "$ base/mini2440_nand128.bin"
Name_nand = "$ base/mini2440_nand256.bin"
If [! -F "$ name_nand"]; then
Echo $0: Creating NAND empty image: "$ name_nand"
# Dd If =/dev/Zero of = "$ name_nand" BS = 528 COUNT = 131072
# Dd If =/dev/Zero of = "$ name_nand" BS = 2112 COUNT = 65536
Dd If =/dev/Zero of = "$ name_nand" BS = 135168 COUNT = 2048

........................................ ..................
As to why BS and count are taking those values, you can look at this http://blog.163.com/chenfang7977@yeah/blog/static/128274196201008101048689/.

Three, modify the above two files, and then re-compile qemu again, you can use the command sudo sh mini2440/mini2440_start.sh to restart the qemu-uboot-mini2440

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.