Recently, at the request of a friend, I studied the simulation under QEMU MINI2440. I thought this process was nothing, but I found a lot of problems in this study. I wrote it down to share with you.
The system environment I used:
1. VMware 6.5 is used, and the host machine uses Windows 7
2. The system on VMWare 6.5 is Linux
Fedora
8
3. RTEMS compilation environment 4.9
First, I got the source code from the following website:
1. Get the source code of QEMU: git clone git://repo.or.cz/qemu/mini2440.git qemu
2. Get the source code of UBOOT: git clone git://repo.or.cz/u-boot-openmoko/mini2440.git uboot
(Note: The version of QEMU is the version submitted by Michel Pollet on 2009/5/21 0:28:03, and the version of uboot is the version submitted by Michel Pollet on 2010/4/26 23:47:44
At the bottom, there are links to these two versions)
First compile QEMU:
cd qemu
./configure --target-list=arm-softmmu
make
Compile UBOOT. Note that I use the ARM compilation tool of RTEMS 4.9. Use
cd uboot
gedit Makefile #(Change CROSS_COMPILE=arm-linux- in line 140 to CROSS_COMPILE=arm-rtems4.9-)
export PATH=/opt/rtems-4.9/bin:$PATH
make mini2440_config
make -j16
cp u-boot.bin ../qemu/mini2440The
process went smoothly, but then the nightmare came...
Enter the qemu folder and enter:
./mini2440/mini2440_start.shThere
is a problem here:
1. If QEMU was not installed when compiling, that is, make install, then you need to open mini2440/mini2440_start.sh and change qemu-img in line 16 to: $base/../qemu-img
2. If QEMU was installed when compiling, that is, make install, ignore this step.
The expected screen did not appear. Instead, it was:
/etc/qemu-ifup: could not launch network script
Could not initialize device 'tap'So
began a long journey to find the problem. Most of the solutions on the Internet were based on
Ubuntu
. There were few valuable solutions for Fedora 8:
1. Some on the Internet said that the kernel did not have a tun module, but I did have it, so I entered the following commands:
modprobe tun; lsmod | grep tun
The system displayed: tun 11713 0
2. Some people on the Internet say that the permissions of /etc/net/tun are incorrect. Enter the following command:
ls -l /dev/net/tun
crw-rw-rw- 1 root root 10, 200 2011-03-16 07:05 /dev/net/tun
Obviously, it is not. Please note that if some friends have this problem, you can use the following command to solve it:
mkdir /dev/net
mknod /dev/net/tun c 10 200
chmod 666 /dev/net/tun
3. Regarding the script permissions of /etc/qemu-ifup, the following command has been entered:
chmod 777 /etc/qemu-ifup
chmod 777 /etc/qemu-ifdown
4. You need to install uml-utilies and bridge-utils:
For fedora 8, use the command:
yum install bridge-utils
to install it easily.
(bridge-utils-1.2-2.fc8.i386.rpm is available for download
Install using rpm -U bridge-utils-1.2-2.fc8.i386.rpm)
But uml-utilities is not installed through yum install uml-utilities, there is no such package.
Instead, I downloaded: uml-utilities-20040406-75.i586.rpm,
and used the command rpm -U uml-utilities-20040406-75.i586.rpm
to complete the installation. After these two packages are installed, the tunctl and brctl commands are available in the system.
It is still: /etc/qemu-ifup: could not launch network script ...
This is dumbfounded. After careful consideration, I think it is a problem with QEMU's own code.
So I traced the code a little bit and found that the static int launch_script(const char *setup_script, const char *ifname, int fd) function on line 1023 in the net.c code in qemu
always returns -1.
It turns out that the execv(setup_script, args); function on line 1045 did not successfully start the script.
The print function was added and errno was 8, that is,
ENOEXEC
The new process image file has the appropriate access permissions, but is not in the proper format.
This means that the permissions are fine, but the format is wrong. Oh, could it be that the exec function family cannot directly start the script?
Haha, BUG, absolutely BUG.
So change the code 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 = sys conf (_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 %d %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: could not launch network script/n",
setup_script);
return -1;
}
}
return 0;
}
Type the command:
make;./mini2440/mini2440_start.sh
The script prompts that the tunctl command and ifconfig command cannot be found.
Haha, this means that 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 there is a problem with the path in the scripts qemu-ifup and qemu-ifdown.
So 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 255.255.255.0 up
sleep 2The
content of my qemu-ifdown script is as follows:
/sbin/ifconfig $1 down
/usr/bin/tunctl -d $1
sleep 2Using
10.0.0.4 is to save trouble. The address of the uboot default server is 10.0.0.4. Haha, you don’t have to type a lot of commands in uboot. Note that sleep is required. After fork, the child process will exit as soon as it finishes running, and the parent process will get an error result, thinking that the script has not been executed and failed.
I also installed a tftp server to test the network boot function of uboot, which was completed successfully.
(You can refer to the great person
http://www.linuxidc.com/Linux/2011-09/42196.htm
to achieve)
Some friends may need qemu to access the Internet or real LAN from the host network, and the configuration process is not complicated. I will write about it in the subsequent blog post. Finally, there are pictures and truth...
Finally, considering that some friends are just starting to do these things and it is inconvenient to find them, I have packaged them for you. Enjoy it!!!
The download address of relevant files is in the No. 1 FTP server of Linux Commune, download address:
FTP address: ftp://www.linuxidc.com
Username: www.linuxidc.com
Password: www.muu.cc
Network configuration under Linux Fedora 8 on QEMU MINI2440 in LinuxIDC.com September 2011
Download method can be found here http://www.linuxidc.net/thread-1187-1-1.html
Previous article:GUI porting on MINI2440 QEMU's eCos
Next article:eCos network function test in mini2440 Qemu
Recommended ReadingLatest update time:2024-11-16 09:30
- Popular Resources
- Popular amplifiers
- Network Operating System (Edited by Li Zhixi)
- Microgrid Stability Analysis and Control Microgrid Modeling Stability Analysis and Control to Improve Power Distribution and Power Flow Control (
- MATLAB and FPGA implementation of wireless communication
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Filter capacitor value after bridge rectification
- Please look at this circuit, why is the output signal like this, the DC operating point is fine
- Three-phase watt-hour meter transformer wiring
- How to export the sensor data on sensorile?
- Power amplifier application in the production of piezoelectric vibration-driven rotating soft robots
- Application of Doherty amplifier in 450W digital TV transmitter
- #Idle Market# is open, you sell your idle items and I'll give you gifts!
- Research on integrated navigation algorithm in case of GPS signal loss.pdf
- I want to build a data access platform for NB-IOT devices based on the COAP protocol. In addition to LIBCOAP, what other technologies are used?
- Beijing's first bicycle lane, 6.5 kilometers, 20 minutes, check-in successful