Use Skyeye Simulation

Source: Internet
Author: User
Tags gtk socket error

Skyeye is a hardware simulation tool that can run embedded operating systems, so that you can develop embedded systems without hardware conditions. The following operations are performed in Fedora Core 1.0.

Skyeye project resource list
Http://gro.clinux.org/projects/skyeye/

Document Summary:
1. What is Skyeye?

2. What can Skyeye do?

3. Install Skyeye

4. Install the arm-elf Cross Compiler
5. Test your arm-elf-GCC compiler.

6. Execute your hello program
7. An Application Development Instance
Compile and run uclinux-dist-20030909.tar.gz
9. Network Addition
10. What will I do next after installing Skyeye?


1. What is Skyeye?

Skyeye is an item of open source software.
Objective: Skyeye aims to provide a complete simulation environment in Linux and Windows operating systems. The Skyeye simulation environment is equivalent to an embedded computer system.
Skyeye runs some embedded Linux operating systems such as armlinux, uClinux, uC/OS-II (uCOS-II) and can analyze and debug their source
Code.

For more information about Skyeye and embedded systems, visit the following website:
Www.skyeye.org

Http://www.skyeye.org/index_cn.html

Use Skyeye to simulate the following hardware:
CPU core: ARM7TDMI, arm720t, arm9, Strongarm, XScale
CPU:
ATMEL at91/X40, cirrus Cirrus Logic EP7312, Intel sa1100/sa1110, Intel
XScale PXA 250/255, cs89712, Samsung 4510b, and Samsung 44b0 (incomplete)
Memory: Ram, Rom, flash
Peripheral devices: timer, UART, ne2k network chip, LCD, touch screen, etc.

Currently, the following operating system and system software can be run on Skyeye:
UC/OSII-2.5.x (Support Networks)
UClinux (based on linux2.4.x kernel, network supported)
ARM Linux 2.4.x/2.6.x
LWIP on uC/osii
Applications Based on uC/osii, uClinux, and ARM Linux


2. What can Skyeye do?

1. Skyeye can help you learn embedded systems and learn and analyze uClinux and other embedded operating systems, such as ucoⅱ, without additional hardware.
2. Skyeye can be used for embedded system teaching.
3. We hope to use Skyeye to promote the research of the operating system, such as ucoⅱ, uClinux + rtai, and uclinux2.5.x.
4. You can use Skyeye to simulate specific hardware modules.
5. Skyeye can be used as an embedded integrated development environment to develop embedded systems (of course, a lot of work needs to be done on Skyeye ).
Note: This document is based on Chen Yu's Skyeye project FAQ.


3. Install Skyeye

To http://gro.clinux.org/projects/skyeye/
Download the skyeye-0.7.0.tar.bz2 package:

Tar jxvf skyeye-v0.7.0.tar.bz2

Go to the extracted Skyeye directory. if the version of Skyeye is earlier than 0.6.0, run the following command:

./Configure -- target = arm-elf -- prefix =/usr/local -- without-GTK-Prefix -- without-GTK-Exec-Prefix -- disable-gtktest

If the version of Skyeye is higher than 0.6.0, run the following command:

./Configure -- target = arm-elf -- prefix =/usr/local

Run the following command:

Make
Make install

Run Skyeye

Note:
A. If you are using the Mandrake Linux release, you will encounter an error during Skyeye compilation and the error is related to Readline, ncurse, termcap, etc. You can try the following method:

Ln-S/usr/include/ncurses/termcap. h/usr/local/include/termcap. h

Then make and make install to check whether the operation is successful!
B. If your Linux release is Debian Linux, do not use GCC 2.95 or GCC 3.0. Use GCC 3.2 +
C. The GCC version must be 2.96 or later.
D. if the version of Skyeye is later than 0.6.0, you need to install GTK software in Linux for LCD simulation.


4. Install the arm-elf Cross Compiler

Download arm-elf-tools-20030314.sh
FTP: // 166.111.68.183/pub/embed/uClinux/soft/tools/ARM

Or
FTP: // 166.111.8.229/OS/embeded

Run:
Chmod A + x arm-elf-tools-20030314.sh
Then:
/Arm-elf-tools-20030314.sh

Ls/usr/local/bin/

You should be able to see executable files starting with arm-elf. Among them, arm-elf-GCC is used to compile the compiler of your target platform. Of course, there are also some gadgets, I will discuss it one by one later.


5. Test your arm-elf-GCC compiler.

First write a small program Hello. c

# Include <stdio. h>
Int main (void)
{
Int I;
For (I = 0; I <6; I ++ ){
Printf ("I = % d", I );
Printf ("Hello, embedded Linux! /N ");
}
Return 0;
}
Then execute:

Arm-elf-gcc-wl,-elf2flt-O hello. c

-The elf2flt parameter converts the ELF file format to the flat file format. This tool is generated when you install the cross compiler. Or you can write a makefile and execute:

Make

Here is my MAKEFILE file for your reference only:

# Begin
Cc = arm-elf-gcc
Cflags =-d1_pic _-FPIC-msingle-pic-base-O2-pipe-wall-G
Ldflags =-wl,-elf2flt
Libs =
Objs = Hello. o
ALL: Hello
Hello: $ (objs)
$ (CC) $ (cflags) $ (ldflags)-O hello $ (objs) $ (libs)
Clean:
Rm-RF *. O *. elf *. GDB hello
# End
If the code is compiled, a hello executable file is generated. Run the following command:

File hello

You will find that it is bflt (Binary flat), the file format supported by your target platform.


6. Execute your hello program

Here, we will use the genromfs tool to complete the test. This tool is generated when you install the cross compiler and you can use it directly.

To http://gro.clinux.org/projects/skyey...-1.0.4.tar.bz2
Package:

Tar jxvf skyeye-binary-testutils-1.0.4.tar.bz2
CD testsuits/at91/uclinux2 (of course you can use another one)
Mkdir romfs (create a directory and use it later)
Mount-o loop boot. Rom/mnt/xxx
CP-r/mnt/XXX/* romfs

In addition, copy the compiled executable program to the/romfs/bin directory. Here is hello!

Genromfs-F boot. Rom-D romfs/

Note: You can use genromfs-H for help!

OK! Run the following command:

Skyeye Linux
(Skyeye) Target Sim
(Skyeye) Load
(Skyeye) Run
Kernel start .....

Familiar with it...

CD/bin
Hello

Can you see the result? In fact, at this step, you can develop your own program!


7. An Application Development Instance

The program described below is mainly used to complete a network application. The standard network application model is the client-server model. Its main execution process is as follows:
(1) The system starts the server for execution. The server completes some initialization operations, then enters the sleep state, waiting for client requests;
(2) On a machine on the network, the user executes the client program;
(3) establish a connection between the client process and the server process;
(4) After the connection is established, the client sends a request to the server over the network to request a certain service;
(5) After receiving the client request, the server processes the request according to the client request content and then returns the result;
(6) The server disconnects from the client and continues to sleep, waiting for requests from other clients;

In Linux, many servers are started at the beginning of the system, such as the time server, printing server, file transfer server, and email server. Most of the time, these server processes are
Sleep Status, waiting for client requests. The following two client-server programs are relatively simple, mainly because they have a general impression on the actual running of the network client-server model. This client-server operation has been performed
The process is very simple: after the client establishes a connection with the server, the server returns a message to the client. The source code of the server program is as follows:

/* Tcpserver. C */
# Include <stdlib. h>
# Include <stdio. h>
# Include <errno. h>
# Include <string. h>
# Include <netdb. h>
# Include <sys/types. h>
# Include <netinet/in. h>
# Include <sys/socket. h>

# Define waitbuf 10

Int main (INT argc, char * argv [])
{
Int sockfd, new_fd;
Struct sockaddr_in server_addr;
Struct sockaddr_in client_addr;
Unsigned int sin_size, portnumber;
Char Hello [] = "Hello! Socket communication world! /N ";

If (argc! = 2)
{
Fprintf (stderr, "Usage: % s portnumber/A/N", argv [0]);
Exit (1 );
}

If (portnumber = atoi (argv [1]) <0)
{
Fprintf (stderr, "Usage: % s portnumber error/A/N", argv [0]);
}

If (sockfd = socket (af_inet, sock_stream, 0) =-1)
{
Fprintf (stderr, "socket error: % s/n/a", strerror (errno ));
Exit (1 );
}

Bzero (& server_addr, sizeof (struct sockaddr_in ));
Server_addr.sin_family = af_inet;

Server_addr.sin_addr.s_addr = htonl (inaddr_any );
Server_addr.sin_port = portnumber;

If (BIND (sockfd, (struct sockaddr *) (& server_addr), sizeof (struct sockaddr) =-1)
{
Fprintf (stderr, "BIND error: % s/n/a", strerror (errno ));
Exit (1 );
}

If (Listen (sockfd, waitbuf) =-1)
{
Fprintf (stderr, "Listen error: % s/n/a", strerror (errno ));
Exit (1 );
}

While (1)
{
Sin_size = sizeof (struct sockaddr_in );
If (new_fd = accept (sockfd, (struct sockaddr *) (& client_addr), & sin_size) =-1)
{
Fprintf (stderr, "Accept error: % s/n/a", strerror (errno ));
Exit (1 );
}
Fprintf (stderr, "server get connection from % s/n", inet_ntoa (client_addr.sin_addr ));
If (send (new_fd, hello, strlen (Hello), 0) =-1)
{
Fprintf (stderr, "write error: % s/n", strerror (errno ));
Exit (1 );
}

Close (new_fd );
}
Close (sockfd );
Exit (0 );
}

Write a MAKEFILE file for the server program as follows:

# Start
Cc = arm-elf-gcc
Cflags =-d1_pic _-FPIC-msingle-pic-base-O2-pipe-wall-G
Ldflags =-wl,-elf2flt
Libs =
Objs = tcpserver. o
ALL: tcpserver
Tcpser: $ (objs)
$ (CC) $ (cflags) $ (ldflags)-O tcpserver $ (objs) $ (libs)
Clean:
Rm-RF *. O *. elf *. GDB hello
# End

The source code of the client program is as follows:

/* Tcpclient. C */
# Include <stdlib. h>
# Include <stdio. h>
# Include <errno. h>
# Include <string. h>
# Include <netdb. h>
# Include <sys/types. h>
# Include <netinet/in. h>
# Include <sys/socket. h>

# Define recvbufsize 1024

Int main (INT argc, char * argv [])
{
Int sockfd;
Char buffer [recvbufsize];
Struct sockaddr_in server_addr;
Int portnumber, nbytes;

If (argc! = 3)
{
Fprintf (stderr, "Usage: % s hostname portnumber/A/N", argv [0]);
Exit (1 );
}

If (portnumber = atoi (argv [2]) <0)
{
Fprintf (stderr, "Usage: % s hostname portnumber/A/N", argv [0]);
Exit (1 );
}

If (sockfd = socket (af_inet, sock_stream, 0) =-1)
{
Fprintf (stderr, "socket error: % S/A/N", strerror (errno ));
Exit (1 );
}

Bzero (& server_addr, sizeof (server_addr ));
Server_addr.sin_family = af_inet;
Server_addr.sin_port = portnumber;
Server_addr.sin_addr.s_addr = inet_addr (argv [1]);

If (connect (sockfd, (struct sockaddr *) (& server_addr), sizeof (struct sockaddr) =-1)
{
Fprintf (stderr, "Connect error: % S/A/N", strerror (errno ));
Exit (1 );
}

If (nbytes = Recv (sockfd, buffer, recvbufsize, 0) =-1)
{
Fprintf (stderr, "read error: % s/n", strerror (errno ));
Exit (1 );
}
Buffer [nbytes] = '/0 ';
Printf ("I have received: % s/n", buffer );
Close (sockfd );
Exit (0 );
}

Extracted from skyeye-binary-testutils-1.1.0.tar.bz2/at91x40/uclinux1
Boot. Rom, put the tcpserver program in the bin directory of boot. Rom in step 6, and run tcpserver on the target board.
2000. Run./tcpclient 10.0.0.2 2000 on the host and check the result!

The comments of the program source code are not provided here. You can refer to some Linux Network Programming books. I will also update some materials on my homepage. If you need them, you can download them.


Compile and run uclinux-dist-20030909.tar.gz

To ftp: // 166.111.68.183/pub/embed/uClinux/soft/

Or to FTP: // 166.111.8.229/OS/embeded/uClinux/pub/uClinux/Dist
Download
UClinux-dist-20030909.tar.gz

Assume that you download it to the/usr/src/directory, and then execute the following commands in sequence:

Tar zxvf uClinux-dist-20030909.tar.gz
CD uClinux-Dist/

Run make xconfig in graphical mode.
Or
Run make menuconfig in the command line mode.

Select GDB/armulator in vender/product
Select kernel 2.4
Then save and exit

Run the following two tasks:
Make Dep
Make

The executable file Linux is generated in the/usr/src/uClinux-Dist/linux-2.4.x directory
In/usr/src/uClinux-Dist/images/, romfs. IMG and other files are generated.

Create the Skyeye configuration file Skyeye. conf for simulating at91 In the uClinux-Dist directory. The content is as follows:
CPU: ARM7TDMI
Mach: at91
Mem_bank: Map = m, type = RW, ADDR = 0x00000000, size = 0x00004000
Mem_bank: Map = m, type = RW, ADDR = 0x01000000, size = 0x00400000
Mem_bank: Map = m, type = r, ADDR = 0x01400000, size = 0x00400000, file = images/romfs. img
Mem_bank: Map = m, type = RW, ADDR = 0x02000000, size = 0x00400000
Mem_bank: Map = m, type = RW, ADDR = 0x02400000, size = 0x00008000
Mem_bank: Map = m, type = RW, ADDR = 0x04000000, size = 0x00400000
Mem_bank: Map = I, type = RW, ADDR = 0xf0000000, size = 0x10000000

At this time, you can use Skyeye to debug and run the kernel. Run the following command in/usr/src/uClinux-Dist:

Skyeye linux-2.4.x/Linux
(Skyeye) Target Sim
(Skyeye) Load
(Skyeye) Run
Kernel start .....

Note:
To execute the Skyeye linux-2.4.x/Linux in the directory where Skyeye. conf is located


9. Network Addition

A. perform the operation with the root user.
B. Check whether tun. O is in your/lib/modules/'uname-R'/kernel/Drivers/NET/directory.
If not, you need to compile your Linux kernel to obtain tun. O.
C. (1) run the Tun device module:

# Insmod/lib/modules/'uname-R'/kernel/Drivers/NET/TUN. o

If you do not have this device, use the following command to create it:

# Mkdir/dev/Net
# Mknode/dev/NET/tun c 10 200

(2) run the vnet (Virtual Hub) Device Module (this step is not required ):
Obtain the source code of vnet and create a device:

# Mknod/dev/NET/vnet C 10 201
# Chmod 666/dev/NET/vnet

Create vnet. o
# Make vnet. o

Insert module vnet. o
# Insmod vnet. o

Go to the test directory and use test to measure vnet. O.
# Cd Test
# Make
#./Testvnet1

D. Configure the Skyeye. conf file.

CPU: ARM7TDMI
Mach: at91
Mem_bank: Map = m, type = RW, ADDR = 0x00000000, size = 0x00004000
Mem_bank: Map = m, type = RW, ADDR = 0x01000000, size = 0x00400000
Mem_bank: Map = m, type = r, ADDR = 0x01400000, size = 0x00400000, file = images/romfs. img
Mem_bank: Map = m, type = RW, ADDR = 0x02000000, size = 0x00400000
Mem_bank: Map = m, type = RW, ADDR = 0x02400000, size = 0x00008000
Mem_bank: Map = m, type = RW, ADDR = 0x04000000, size = 0x00400000
Mem_bank: Map = I, type = RW, ADDR = 0xf0000000, size = 0x10000000
# Format: State = On/Off MAC = XX: XX ethmod = tuntap/vnet hostip = dd. dd
Net: State = on, Mac = 0: 4: 3: 2: 1: F, ethmod = Tun, hostip = 10.0.0.1

The preceding parameters are described as follows:
State = On/Off indicates whether the simulated NIC (Network Interface Board) is wired or wireless;
MAC = MAC address of the simulation adapter;
Ethmod = Virtual devices used by tuntap/vnet in the host environment;
Hostip = indicates the IP address used for the interaction between the host environment and keyeye.
Format: State = On/Off MAC = XX: XX ethmod = tuntap/vnet hostip = dd. dd

For example:
# Set Nic info state = on/off MAC = XX: XX ethmod = tuntap/vnet hostip = dd. dd
Net: State = on, Mac = 0: 4: 3: 2: 1: F, ethmod = Tun, hostip = 10.0.0.1
Or
Net: State = on, Mac = 0: 4: 3: 2: 1: F, ethmod = vnet, hostip = 10.0.0.1

Note:
If you want to run two or more skyeyes at the same time, use different Skyeye. conf for each Skyeye.

E. Run Skyeye linux-2.4.x/Linux


10. What will I do next after installing Skyeye?

  1. For beginners and beginners of embedded operating systems, they can read some textbooks and books on operating systems and embedded operating systems, such
    Books related to UC/OS, minix, uClinux, and Linux. Then, you can develop some simple application examples (such as inter-process communication, process priority,
    Deadlocks, network applications, and so on. Some operating system functions (such as process scheduling, memory management, network subsystem, and file subsystem) are modified and extended, run and tune through Skyeye
    Try to see what will happen.
  2. For software engineers with some experience, it is worthwhile to develop application system prototypes on Skyeye.
    Situation. For example, porting or developing a file subsystem or network subsystem to a specific operating system is easier than developing on a real development board. Perform some operating system operations on Skyeye
    Porting and development (such as porting RTLinux, rtai, and other operating systems to Skyeye) is also very challenging.
  3. For hardware engineers, Skyeye is expanded and new hardware simulation (such as USB and IDE hard disks) is designed to make Skyeye hardware simulation more powerful and support more functional software, is very meaningful.

Refer:
A Chinese document in the Skyeye project site;
Chen Yu's Skyeye project FAQ;
Readme document in skyeye-0.7.0.

Postscript:
In order to help you get started quickly and carry out actual development work, I have collected a document, which is very rough. However, I firmly believe that with the addition of more experienced people, we will continue to improve.
Higher, there will be more and better articles. Let's hurry up! Finally, I suggest you read the book embedded Linux technology and application. The network is not completely resolved,
Now it's just the NIC line between the host and Skyeye, but the NIC in uClinux is not. I think it is necessary to re-compile the uClinux kernel. Please advise.

This document is not complete, but it is still posted. Let's discuss it together. I think the Skyeye simulation environment is very good. This post is an introduction. You can start from this place first.

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.