Embedded real-time operating system VxWorks entry (favorites)

Source: Internet
Author: User

Introduction to embedded real-time operating system VxWorks

Author: Song Baohua Source: Tianji Development

Embedded real-time operating system (VxWorks)-Development Environment Construction

The VxWorks Operating System is an embedded real-time operating system (RTOs) designed and developed by WinDriver in 1983 ), it is widely used in fields with extremely high real-time requirements, such as communication, military, aviation, and aerospace, with its excellent reliability and excellent real-time performance, such as satellite communication, military drills, ballistic guidance, and aircraft navigation. On F-16, FA-18 fighter, B-2 stealth bomber and patriotic missiles in the United States, and even in April 1997 on the Mars surface landing on the Mars rover also used VxWorks. VxWorks was originally banned from sales in China. Since its release, it has been widely used in military, communication, industrial control, and other fields.

The real-time performance of VxWorks is reflected in the ability to complete the required functions within a limited period of time, and to respond to external asynchronous events within a limited period of time. Therefore, real-time systems are mainly used in time-sensitive scenarios such as process control, data collection, communication, and multimedia information processing. This article will provide an entry-level and comprehensive introduction to this operating system. The full text is divided into five chapters to show the full picture:

(1) Build the VxWorks embedded development environment;

(2) Brief introduction to the basic components of VxWorks and the basic structure of the kernel;

(3) An overview of the concept of VxWorks board-level support package (BSP) and the START process of VxWorks;

(4) introduce the architecture and Writing Method of the VxWorks device driver;

(5) Specify the concept of VxWorks application development, task scheduling and synchronization, interruption, and synchronization of tasks.

The above chapters will cover many examples. As this article is positioned as an entry-level tutorial, the examples in this article will be very simple. Next we will go to the first chapter to explain the content.

1. the debugging method for embedded systems is generally to cross-compile the program for a specific circuit board (target machine) through the integrated development environment on the PC (host machine, then, the program is downloaded to the target board through the JTAG, serial port, or network port of the target board. Therefore, in order to construct a learning environment for an embedded system, it is often necessary to have a target circuit board containing CPU, memory, and I/O circuits (to construct a computer system. Although many integrated development environments come with simulation software, but only the simulation of instruction sets cannot simulate the hardware platform of the physical target machine. Therefore, only symbolic Simulation Development of applications can be performed on them. However, not everyone can have a physical circuit board. In this case, how do we construct a simulated development environment, and the learning effect is just like having a completely real circuit board? This article attempts to answer this question. The subject content includes four aspects:

(1) Use VMware and other software to simulate a real target machine;

(2) Build the VxWorks BSP on the VMware Virtual PC and build the bootrom and OS images;

(3) Modify tornado settings, connect the host machine to the target machine, and establish a debugging channel;

(4) write a simple application and download it to the target system for running.

Figure 1 embedded system debugging

The ultimate goal of this chapter is:

(1) VxWorks was successfully started and run smoothly in VMware, and 2;

Figure 2 VxWorks running in VMware
(2) Compile and debug the program for the target board on tornado. (3.
Figure 3 establish a debugging channel tornado with the target machine

1. Simulate the target machine

PC also has all the characteristics of the target machine. In fact, we can use PC as the target machine of the embedded system to construct the development model shown in 4:

Figure 4 PC as the target machine

Unfortunately, this method is actually very troublesome. If you start debugging two PCs at the same time, you and your roommate will be suffering. Since it is so geothermal that it is switched to games and surfing the Internet. Therefore, we can use VMware to virtualize another PC on the local machine.

VMware is indeed a work of genius! Almost all operating systems can be installed using VMWare on the same PC, and switching between operating systems does not require restarting the computer. Virtual Machine (VM) is a logical computer that provides a virtual PC system environment based on Intel CPU, including CPU, memory, bios, hard disk, and other peripheral hardware devices.

The following describes how to use VMware to establish a virtual PC:

(1) download and install VMware;

(2) Use the VMware Wizard to create a VM for VxWorks;

In this step, select "other" in the operating system, 5:

Because the target machine is eventually started through a floppy disk, your computer is required to have a soft drive. Unfortunately, the floppy disk used in the past has become antique and few computers are equipped with a soft drive. Therefore, we will create a fake and shoddy product, and a soft drive. Ramdisknt, another talented tool, provides us with this convenience. Figure 6 shows how to use ramdisknt to virtualize a m floppy disk.

It is not enough to virtualize a soft drive. Adding this soft drive to the created virtual machine is regarded as a success. Figure 7 shows the virtual machine hardware settings after the soft drive is added.
Figure 7 virtual machines with a soft drive

2.Create BSP

2.1 Download and compile the NIC Driver

VMware provides support for virtual NICs for operating systems running on them, an AMD PC-NET that is included in the tornado development kit with drivers for this type of NICs, however, after testing, the driver does not work properly in the VMware environment, so you can download the latest driver from the amd website. Download an executable Installer. Run the package and a help file to release the package to the Tornado directory. If you are prompted whether to overwrite the file, select allow.

Follow these steps to compile and replace the driver:

(1) Open a console window and run the batch processing program:

C:/tornado2.2/host/x86-win32/bin/torvars. BAT;

The batch processing file is used to set environment variables. Its content is:

Rem command line build environments

Sets wind_host_type = x86-win32

Set wind_base = C:/tornado2.2

Set Path = % wind_base %/host/% wind_host_type %/bin; % PATH %

If not, you can manually set these environment variables.

(2) locate the C:/tornado2.2/target/src/drv/end directory and run:

Make CPU = Pentium tool = GNU ln97xend. o

(3) locate the C:/tornado2.2/target/lib/Pentium/common directory, and copy the file ln97xend. O generated in the previous step to this directory. Back up the file libdrv. A in this directory;

(4) run the arpentium-D libdrv. A ln97xend. O command to delete the original ln97xend module of libdrv.;

(5) run the command arpentium-ra iolicomend. O libdrv. A ln97xend. O to add the newly created ln97xend module.

2.2 modify the configuration file

We need to modify the config header file for compiling VxWorks. some parameters defined in H make the compiled system boot program and the image of VxWorks meet our requirements, and also modify sysln97xend. c.

(1) locate the directory c:/tornado2.2/target/config/pcpentium and open the config. h file in the directory;

(2) locate the default_boot_line macro definition, and modify the pre-processing condition CPU = the definition of the Pentium branch as follows:

# Define default_boot_line/

"Lnpci (0, 0) your_host_name: e: // VxWorks H = 192.168.80.100 E = 192.168.80.80 u = target PW = target Tn = target"

Where:

  • Lnpci (0th) specifies that 0th NICs and processors are used. The lnpci identifier varies depending on the driver used, but lnpci can be used here;
  • Host specifies the name of your host. You can use host;
  • E: // VxWorks specifies the complete download path of the VxWorks image (which will be described later );
  • H = 192.168.80.169 is the IP address of the host machine, which can be modified according to the actual situation;
  • E = 192.168.80.254 is the IP address of the target machine, which can be modified according to the actual situation;
  • U = target specifies the FTP server user name, which is used to download the VxWorks image;
  • PW = target is the password of the FTP server and the username target;
  • Tn = target: specify the name of the target machine.

(3) Specify the NIC Driver

First, locate the text "Network Driver options" to ensure that the two macros include_end and include_ln_97x_end are in the defined State (define), and the other macros are in the UNDEF state, that is:

The following is a reference clip:
/* Network Driver options */
# Define include_end/* Enhanced Network Driver Support */
# UNDEF include_dec21x40_end/* (end) DEC 21x4x PCI interface */
# UNDEF include_el_3c90x_end/* (end) 3Com fast etherlink xl pci */
# UNDEF include_elt_3c509_end/* (end) 3Com etherlink III interface */
# UNDEF include_ene_end/* (end) Eagle/Novell ne2000 interface */
# UNDEF include_fei_end/* (end) Intel 8255 [7/8/9] PCI interface */
# UNDEF include_gei8254x_end/* (end) intel 82543/82544 PCI interface */
# Define de_ln_97x_end/* (end) amd 79c97x PCI interface */
# UNDEF include_ultra_end/* (end) SMC elite16 ultra interface */
# UNDEF include_bsd/* BSD/netif Driver Support (Deprecated )*/
# UNDEF include_eex/* (BSD) intel etherexpress interface */
# UNDEF include_eex32/* (BSD) intel etherexpress flash 32 */
# UNDEF include_elc/* (BSD) SMC elite16 interface */
# UNDEF include_esmc/* (BSD) SMC 91c9x Ethernet interface */
(4) include pc_console

By default, the Vxworks system does not accept input from external input devices (such as keyboards) or output data to external output devices (such as monitors. To facilitate debugging, we must change its default status, including support for the PC console. Find and locate the macro include_pc_console to make sure it is in the defined State (define), that is:

The following is a reference clip:
# Define include_pc_console/* PC keyboard and VGA console */
# Ifdef include_pc_console
# Define pc_console (0)/* console number */
# Define n_virtual_cmdles (2)/* shell/application */
# Endif/* include_pc_console */
(5) Modify sysln97xend. c

Open sysln97xend in the C:/tornado2.2/target/config/pcpentium directory. in the c file, first locate the text "memory-mapped Io base", and then set the preceding parameters to pcirsrc [endunit]. modify bar [1] to none and save it. That is:

The following is a reference clip:
Sprintf (paramstr, paramtemplate,
Endunit,/* end unit number */
None,/* memory-mapped Io base */
Pcirsrc [endunit]. BAR [0],/* IO address space base */
Pci2dram_base_adrs,/* Host PCI mem. Base */
Pcirsrc [endunit]. irqvec,/* IRQ vector */
Pcirsrc [endunit]. IRQ,/* IRQ Number */
Ln97x_csr3_value,/* csr3 register value */
Ln97x_offs_value,/* offset */
Ln97x_rsvd_flags,/* flags (Reserved )*/
& Ln97xstrdesc [typeidx]/* Device Description */
);
2.3 compile bootrom and VxWorks Images

Compile bootrom

Open tornado development tool, select build boot Rom under the build menu, choose BSP as pcpentium, the image type is bootrom, and the tool is GNU, 8. Click OK to compile bootrom.

Compile the VxWorks Image

After bootrom is compiled and generated, A VxWorks image is created, that is, the code of the VxWorks operating system. The steps are as follows:

(1) create a "bootable VxWorks image" project, and choose Pentium for bsp;

(2) Select the required VxWorks component

10. In this example, we need to include two important components: Telnet Server and target shell. The former allows us to log on to the VxWorks operating system through the Telnet protocol; the latter allows us to control the Vxworks system through command lines. In addition, all c ++ related options must be included.

After the selection, you can start to compile the program. At this point, we have generated the system boot program and runtime code image of VxWorks. After modifying the system configuration information (for example, config. h), you must re-create a project to compile the VxWorks image. Copy the generated file named "VxWorks" to D. This path is determined by the path parameters in the default_boot_line macro we set above, and must be consistent between the two.

2.4 create a boot floppy disk

Since the target machine starts from a floppy disk, we need to create a VxWorks boot disk for guiding the image of the VxWorks operating system. Go to the C:/tornado2.2/target/config/pcpentium directory, insert a formatted floppy disk, and run:

Mkboot A: bootrom

This command will create a boot partition for the VxWorks System on the floppy disk and copy the boot program to the floppy disk.

3.Create a debugging environment

3.1 configure the FTP server

The FTP server on the host machine is used to download the running image of VxWorks after the system is successfully guided. It is best to use the FTP service software that comes with the tornado development environment.

11. Open tornado FTP server, select the "users/rights" sub-menu under the "Security" menu, set the user name to "target", and change "home directory" to "E: /"(that is, the VxWorks image directory specified in the default_boot_line parameter), change the username to" target ", set the password to" target ", and click" done "to complete the modification, the FTP service is started.

To check whether the boot program has downloaded the VxWorks image from ftp, you are advised to enable the log function of the FTP server. Select the "logging options" sub-menu under the "logging" menu, in which all the other options are enabled except "Winsock CILS. Keep the FTP server window open to ensure that the FTP server is running.

The virtual machine starts from a floppy disk. Next, the E:/VxWorks image on the server will be downloaded. the FTP server will have related logs, 12:

Figure 12 FTP Server

3.2 configure target server

13. Open your tornado development environment, select the "tools-> target server-> Configure" menu, and enter any name in "Description". Here is "net00 "; in "available back", select "wdbrpc" and fill in the IP address of the target machine in the following IP Address box. Here is "192.168.80.80" (determined by the default_boot_line parameter ); change the "target server properties" drop-down box to "Core File and symbols", and select the full path of your image in the "file path" field. Here is "D: /VxWorks "(determined by the default_boot_line parameter ).

Figure 13 configure target server

If the target machine has been started, click the "launch" button to start the target server.

Return to the tornado development environment and select "192.168.80.80 @ host" in the target server drop-down list on the toolbar ". At this time, you will find some of the tool buttons in the "disabled" status in the toolbar, and they are now in the "active" status.

Try it. Open tshell and run the "I" command to check the task currently running on the target machine. effect 14:
Figure 14 run commands in tshell

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.