Network Configuration in Linux fedora 8 of qemu mini2440

Source: Internet
Author: User

(For Original Articles, please refer to the source for reprinting. Thank you .)

Recently, at the request of a friend, I studied the simulation of qemu mini2440. I thought there was nothing in this process. This research has found many problems and I will share them with you.

My system environment:

1. Use VMware 6.5 and host machine win 7

2. The system on Vmware 6.5 is Linux fedora 8.

3. RTEMS compilation environment 4.9

First, obtain the source code from the following website:

1. Obtain the source code of qemu: git clone git: // Repo. Or. cz/qemu/mini2440.git qemu

2. Obtain the uboot source code git clone git: // Repo. Or. cz/U-boot-openmoko/mini2440.git uboot

(Note: The version of qemu is submitted by michelpollet at 0:28:03, and the version submitted by uboot is 2010/4/26 23:47:44 michelpollet.

At the bottom, there are link resources for these two versions)

 

 

First compile qemu:

CD qemu

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

Make

Compile uboot. Note that I am using the RTEMS 4.9 arm compilation tool.

CD uboot

Gedit makefile # (Change cross_compile = arm-Linux-to cross_compile = arm-rtems4.9-In line 140 -)

Export Path =/opt/rtems-4.9/bin: $ path

Make mini2440_config

Make-j16

CP u-boot.bin ../qemu/mini2440

This process went smoothly, followed by a nightmare ......

Go to the qemu folder and enter:

./Mini2440/mini2440_start.sh

Here is a problem:

1. If it is not installed when qemu is compiled, that is, make install, You need to enable mini2440/mini2440_start.sh and change qemu-IMG of Line 1 to $ base/../qemu-IMG.

2. If qemu is installed during compilation, make install is enabled, regardless of this step.

Not yet. Replaced:

/Etc/qemu-IFUP: cocould not launch network script

Cocould not initialize device 'tap'

As a result, we started a long journey of searching for problems. Most of the online websites were based on Ubuntu and there were very few valuable solutions for Fedora 8:

1. Some websites say that the kernel does not have the Tun module, but I do. Enter the following command:

Modprobe Tun; lsmod | grep Tun

System display: Tun 11713 0

 

2. If the permission for/etc/NET/TUN is incorrect on the internet, enter the following command:

Ls-L/dev/NET/TUN

CrW-RW-1 Root 10,200 2011-03-16 07:05/dev/NET/TUN

Obviously, neither. Note that you can use the following command to solve the problem:

Mkdir/dev/Net

Mknod/dev/NET/tun c 10 10 200

Chmod 666/dev/NET/TUN

 

3. For the script permission of/etc/qemu-IFUP, enter the following command:

Chmod 777/etc/qemu-IFUP

Chmod 777/etc/qemu-ifdown

 

4. You need to install UML-utilies and bridge-utils:

For fedora 8, run the following command:

Yum install bridge-utils

It is easy to install.

(Bridge-utils-1.2-2.fc8.i386.rpm available for download

Use rpm-u bridge-utils-1.2-2.fc8.i386.rpm to install)

 

However, the installation of UML-utilies is not through Yum install UML-utilies, and this package does not exist.

But download: uml-utilities-20040406-75.i586.rpm,

Use command rpm-u uml-utilities-20040406-75.i586.rpm

Complete the installation. The tunctl and brctl commands are available in the system after the two packages are installed.

Still:/etc/qemu-IFUP: cocould not launch network script ......

This is dumb. I think it is a problem of qemu code.

So I tracked the Code a little and found that the net. C code in qemu contains 1,023rd rows

The static int launch_script (const char * setup_script, const char * ifname, int FD) function always returns-1.

It turns out to be execv (setup_script, argS) of 1,045th rows; the function failed to start the script,

When the print function is added, errno is 8, that is

 

Enoexec

The new process image file has the appropriate access permissions, but is not in the proper format.

 

The permission is correct, but the format is incorrect. Oh, is it because the exec function family cannot start the script directly?

Haha, bug, absolute bug.

The code is changed as follows:

Static int launch_script (const char * setup_script, const char * ifname, int FD)

{

Int PID, status;

Char * ARGs [4];/* bacon modified */

Char ** parg;

/* Try to launch network script */

PID = fork ();

If (pid> = 0 ){

If (pid = 0 ){

Char path [20];/* bacon add */

Int open_max = sysconf (_ SC _open_max), I;

For (I = 0; I <open_max; I ++)

If (I! = Stdin_fileno &&

I! = Stdout_fileno &&

I! = Stderr_fileno &&

I! = FD)

Close (I );

Parg = ARGs;

Strcpy (path, "/bin/bash");/* bacon add */

* Parg ++ = (char *) path;/* bacon add */

* Parg ++ = (char *) setup_script;

* Parg ++ = (char *) ifname;

* Parg ++ = NULL;

Status = execv (path, argS);/* bacon add */

Fprintf (stderr, "error: % d % S % s/n", status, errno, enoexec, setup_script, ifname);/* bacon add for debug. */

_ Exit (1 );

}

While (waitpid (PID, & status, 0 )! = PID );

If (! Wifexited (Status) |

Wexitstatus (Status )! = 0 ){

Fprintf (stderr, "% s: cocould not launch network script/N ",

Setup_script );

Return-1;

}

}

Return 0;

}

Type the following command:

Make;./mini2440/mini2440_start.sh

 

The script prompts that the tunctl and ifconfig commands cannot be found.

Haha, this means there is a problem with the path. I checked the path in the Code carefully and there is no problem. It can be considered that the path in the qemu-IFUP and qemu-ifdown Scripts has a problem.

Therefore, all commands use absolute paths. The content of my qemu-IFUP script is as follows:

/Usr/bin/tunctl-T $1

/Sbin/ifconfig $1 10.0.0.4 netmask running 255.255.0 up

Sleep 2

The content of my qemu-ifdown script is as follows:

/Sbin/ifconfig $1 down

/Usr/bin/tunctl-d $1

Sleep 2

10.0.0.4 is used to save time. The default server address of uboot is 10.0.0.4. Note that sleep is required. After fork, the sub-process exits after it completes running, and the parent process will get an error and the script fails to be executed.

I installed a TFTP server to test the network startup function of uboot.

(You can refer to the cattle http://fpcfjf.blog.163.com/blog/static/554697932009419103226814/ blog implementation)

Some friends may need qemu to access the Internet or the real LAN from the host network, and the configuration process is not complicated. I will write in subsequent blog posts. Finally, there is a picture of the truth ......

 

 

 

Finally, it is inconvenient to find out some friends who just started to do these things. I have already prepared a package for you and uploaded it to csdn. You can download it without any points. Enjoy it !!!

 

Http://download.csdn.net/source/3123021

Http://download.csdn.net/source/3124581

 

1. The code that contains qemu simulation mini2440 has been patched.
2. scripts containing qemu-IFUP and qemu-ifdown
3. Code containing a TFTP server and xinetd service
4. Contains the tunctl command for operating the virtual network card and the brctl command for operating the bridge.

5. uboot source code.
6. All the above tools are successfully debugged under Linux fedora 8

 

 

(For Original Articles, please refer to the source for reprinting. Thank you .)

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.