Deep embedding of QNX

Source: Internet
Author: User
Tags vector font
The embedding process of QNX is generally:

Build buildfile-> compile buildfile to generate the system image file-> Start the target system-> Design the embedded system software.

The key is to build buildfile [19]. Generally, an embedded system requires an operating system image file that can be started ). For a QNX-based embedded application system, the embedded system is customized based on the selected CPU type and the operating system modules required by the application. The process of building buildfile is the process of configuring the operating system image. To put it simply, buildfile is a set of rules and guidelines for generating image files. Buildfile consists of three parts. Its structure is as follows:

L Bootstrap script (boot script)

L STARTUP script (STARTUP script)

L file list (File List)
1.1.1 Bootstrap script)

Different CPUs have different boot methods. Bootstrap script is used to configure the CPU-compatible microkernel. A typical Boot guide script is as follows:

[Virtual = x86, BIOS + compress]. Bootstrap = {

Startup-BIOS-S 64 K-D 8250.3f8.57600-

Path =/proc/boot procnto

}

In this example, the first line indicates that it is a boot file. "Virtual" indicates that the buildfile constructs a startup image corresponding to the virtual address space generated at startup. The key words "x86, BIOS" refer to the processor (x86) and machine type (started through BIOS) respectively ). "+ Compress" compresses image files to produce smaller image files. Startup-BIOS is an executable program running on a BIOS-compatible PC system. It is mainly used to detect PC hardware resources by using bios. Here, it mainly extracts images, place it in the corresponding location of RAM, perform basic configuration and run the kernel. In this example, "-S 64k" indicates that the first 64 K video BIOS in the Rom is copied to ram for faster execution, that is, the so-called rom bios ing. The second parameter indicates that the first serial port is opened at a 57600 baud rate as a debugging channel, and its debugging output can be captured on another PC connected by a null modem cable. The last parameter is a typical case in a real-time system. It is used to restart the system immediately after any abnormal kernel is terminated. "Path =/proc/Boot" determines the PATH environment variable. "Procnto" is a micro-kernel and Process Manager, including QNX 6 micro-kernel, process management, memory management, and path name management. Each startup Image Using mkifs tool must have procnto. Note that in Bootstrap, the first executable program must be startup-*, and the last one must be procnto!
1.1.2 Startup Script)

The STARTUP script is a list of commands to be executed after the process management is started. A simple script is as follows:

[+ Script]. Script = {

Devc-Con &

Reopen/dev/con

+ Session] Sh

}

You can configure the network and set the display card here. We usually write programs that need to be automatically executed at startup here. For details, see the development case.
1.1.3 file list)

The file list is the list of files required for execution of system programs and user programs, especially some shared libraries. Because your program is developed in C language, you must include at least one standard C Shared library. For example, (the content after "#" is a comment ):

# Include the C Shared Library

Libc. So

# Create a symlink called ldqnx. so.2 to it

[Type = link]/usr/lib/ldqnx. so.2 =/proc/boot/libc. So

The [type = link] line uses a ldqnx. so.2 to reposition libc. So. If you do not know which shared libraries are required in the image file, you can use the "objdump" utility (utility) to display the required information. If the ping command is used, run the following command on the terminal:

# Objdump-x 'which ping' | grep needed

Press enter to display the following information:

Objdump:/usr/bin/Ping: no symbols

Needed libsocket. so.2

Needed libc. so.2

It indicates that the Ping Command requires libsocket. so.2 and libc. so.2, And the objdump command is used.

# Objdump-x/lib/libsocket. so.2 | grep needed

Needed libc. so.2

# Objdump-x/lib/libc. so.2 | grep needed

That is to say, libsocket. so.2 requires libc. so.2, while libc. so.2 does not require any other libraries. If Ping is included in the image, libsocket. so.2 and libc. so.2 must be listed in the file list.

With buildfile, we can use the "mkifs" utility to generate the startup image file. The syntax format is:

# Mkifs [optional parameter] target file of the source file

For example:

# Mkifs-V mydoc. Build mydoc. Ifs

The image file mybuild. IFS is obtained.

After the image file is generated, it can be embedded into the target system, started to prepare for further system development. For detailed examples, see the following development case 1.
1.1.4 QNX embedded Case Analysis

Target System: PC104 board, DOC (diskonchip) memory.

Purpose: To start the graphic interface program and implement resource mutual access through the network.

1. Build buildfile. Our mydoc. Build is as follows:

[Virtual = x86, BIOS + compress]. Bootstrap = {

Startup-BIOS-ntarget # name the target machine as target

Path =/proc/boot:/bin:/sbin:/usr/bin:/usr/sbin:/usr/photon/bin LD_LIBRARY_PATH =/proc/boot: /dev/shmem:/lib/dll:/usr/lib/DLL procnto

}

[+ Script]. Script = {

Devc-Con & # open a console in the background.

Reopen/dev/con1

Display_msg welcome to QNX-DOC world!

PCI-bios &

Waitfor/dev/PCI

DEVB-Doc BLK automount = hd0t77: // & # Run the doc driver in the background

# Set the network below

Io-net-d rtl-ptcpip-pqnet &

Ifconfig en0 192.168.1.1 # IP Address

Route add default 192.168.1.2 # gateway IP Address

Waitfor/dev/socket # Waiting for setting

Waitfor/bin 15 # Wait for calling other commands

# Run other programs in the background

Pipe &

Mqueue &

Devc-Pty-N 32 &

Waitfor/sbin

Waitfor/usr/sbin

# Setting Environment Variables

Sysname = nto

Term = VT100

# Start sh

Reopen/dev/con1

[+ Session] Sh

}

[Type = link]/tmp =/dev/shmem # Set/tmp to the shared memory Zone

[Type = link]/usr/lib/ldqnx. so.2 =/proc/boot/libc. So # Add the Runtime Library

Libc. So # Standard C library

Libsocket. So # socket Library

Devn-rtl.so # NIC Driver

Npm-tcpip.so # TCP/IP protocol

Npm-qnet.so # qnet Protocol

Libcam. So # contains the disk file so that we can access the file on the doc.

Io-blk.so

Cam-disk.so # shared libraries required for file systems

Fs-qnx4.so

Devc-con # console driver

DEVB-doc # Doc driver

Io-net # list of executable files

Ifconfig

Pipe

Mqueue

Devc-Pty

PCI-BIOS

2. compile and generate mydoc. Ifs

3. Boot floppy disk

Put the floppy disk on the development machine and run it on the terminal:

# Dinit/dev/fd0

# Mount/dev/fd0/mnt/fd0

# Cp /... /Mydoc. Ifs/mnt/fd0/. boot

Assume that mydoc. IFS is in the directory /... /Bottom

4. Start the target system and format the doc

# DEVB-Doc &

# Fdisk/dev/hd0 Delete-

# Fdisk/dev/hd0 add-S 1 QNX all

# Fdisk/dev/hd0 boot-S 1

# Fdisk/dev/hd0 loaderfds

Note that all the original data on the doc no longer exists, so be careful.

5. Restart the disk to start the target machine and initialize the QNX file system.

# Dinit-H/dev/hd0t77

# Dinit-HB/dev/hd0t77

# Mount/dev/hd0t77/

Run "# ls/net" on the development machine to view the target and host (assuming the development machine name is host ).

# Cp /... /Mydoc. Ifs/NET/target/. boot

At this point, the doc target machine can be started on its own, instead of relying on a floppy disk.
1.2

Photon
Embedding Process

In the desktop environment, photon runs [35] using the script "PH". The pH script mainly performs the following tasks:

L start the photon Service

L detection of Input hardware devices

L start the driver of the Input hardware device

L start the video card driver and initialize the Video hardware as the appropriate mode

L start the font Manager

L start Windows Manager

L start various desktop service programs, such as shelf and desktop background manager.

In an embedded environment, you must manually start the above services. There are many advantages to doing so. For example, you can decide the files required by the system and reasonably configure your embedded runtime environment. The following describes the embedded process of photon in detail:

1. Set the photon_path environment variable

The photon_path environment variable is used to save the basic directory of photon installation. The default value is/usr/photon. This directory usually contains at least a few subdirectories:

L bin: executable program for storing photon

L font_repository: Specifies the font and font configuration file (OS independent) of photon)

L palette: graphic palette (OS independent)

L translations: Support for photon language translation (OS independent)

The setting of the photon_path environment variable can be performed through export, as shown below:

Export photon_path =/usr/photon

2. Start the photon Server

If you do not need to pass any parameters to the photon service process, you can simply start the process as follows:

Photon &

However, if there is a touch screen in the embedded environment, you need to add the photon parameter-D,-R,-u, and so on. Because human fingers are much larger than a pixel, You need to specify the-u option to prevent any changes in the touch position. Note that photon must be included in the PATH environment variable. In QNX neutrino, the location is/usr/photon/bin. You can use

Export Path =:/bin:/usr/photon/bin

To set the PATH environment variable.

3. Start the driver of the input device.

In a desktop environment, the inputtrap tool is generally used to automatically search for input devices (such as the mouse, keyboard, and touch screen) and start appropriate drivers for them. In an embedded environment, inputtrap is generally not used because of storage space restrictions, because inputtrap is large and the input device in the embedded environment may be in a special location or not supported by an existing Devi-* driver. Of course, you can also use inputtrap if possible, which is convenient and easy to handle. You need to use the Devi-* series driver to manually load the driver. For details, see the following example. The position of the Devi-* series driver is/usr/photon/bin.

4. Start the font Manager

When establishing an embedded system, you must determine the font to support and whether the vector font is required based on your own situation. The determination of font mainly includes the following aspects:

L generally, cursor font (phcursor. PHF) is required ).

L if the embedded system includes pterm (a terminal program of photon), PC terminal (pcterm *. PHF), PC serif (PCs *. PHF), or PC sanserif (pcss *. PHF) font family. Create a $ home/. photon/pterm. RC file or $ photon_path/config/pterm. RC file to configure the terminal font.

L most widgets-based applications require the following alias fonts defined in the fontmap file:

N textfont

N menufont

N fixedfont

N balloonfont

N titlefont

L Web browsers require the following fonts:

N Body font (for example, primasans BT, Dutch 801 rm bt, etc)

N heading font (for example, swis721 BT)

N nonproportional fonts (such as courier10 Bt and primasansmono BT)

The font manager of QNX photon mainly includes the following types:

L phfontphf: only supports bitmap fonts.

L phfontpfr: supports scalable bitstream PFR and TrueType collection fonts.

L phfontff: supports scalable TrueType, type 1, type 2, bitstream Speedo (retail encryption), bitstream stroke, and other fonts.

L phfontfa: supports all the above fonts.

We need to select a proper font Manager based on the actual font we use. The font manager is easy to start, such:

/Usr/photon/bin/phfontphf &

If the font file used is not included in the startup image, you must specify the path to the font file when starting the font manager. For example:

/Usr/photon/bin/phfontphf-D/my_dir/font_repository

Note that my_dir must be consistent with $ photon_path.

5. Start the video card driver

The startup of the photon graphics subsystem is implemented through io-graphics. For example:

Io-graphics-g640x480x8-dldevg-vga.so-P/usr/photon/palette/vga4.pal

Io-graphics-g1024x768x16-dldevg-vesabios.so

Io-graphics-g1024x768x16-dldevg-rage.so-d0x1002, 0x4755-I0

-G indicates the display resolution and color depth of the image,-DL indicates the hardware driver, and-D indicates the driver uniquely identifies the PCI manufacturer and device ID required by the hardware, if there are two graphics cards with the same manufacturer and ID, use-I to specify the card and-P to specify the palette file used.

The main files required for this part are:

L/usr/photon/bin/IO-graphics: starts the graphics subsystem.

L/lib/dll/devg-*: Device Driver

L/usr/lib/libdisputil. so.2: library used by the devg * driver

L/usr/lib/libffb. so.2: library used by the devg * driver

L/usr/lib/libgui. So: library used by io-graphics

L/lib/dll/gri-photon.so: photon DLL

L/usr/lib/libphrender. So: The software rendering routines.

6. Start Windows Manager (optional)

QNX photon window manager is a PWM (the photon Window Manager) that provides standard window management functions, including move, resize, minimize, maximize, raise, lower, and close. Applications can customize the standard Windows framework provided by PWM as needed. In QNX, you can use ctrl-alt-backspace to end the graphical mode and return to terminal mode. However, in an embedded operating environment, end users are often not recommended to do so. We can block this situation through PWM. For example:

/Usr/photon/bin/PWM-K

7. Start your own GUI Program

If the self-designed graphic interface program is a single executable program without the window manager, it can be statically compiled. If you need a window manager or more than one photon program running, you 'd better connect to the dynamic link library for compilation.

As long as you have a good grasp of the above seven steps, it is easy to customize an excellent QNX graphics operating system. Next, modify the buildfile in development case 1 so that the graphic interface program can be executed on the target system. Add the following part to buildfile, recompile buildfile, copy mydoc. Ifs to/. altboot of the target system, and restart the target system. Note: Press ESC when starting to enable the system to start with altboot.

Waitfor/usr/photon

Photon &

Waitfor/dev/photon

Phfontfa &

Io-graphics-g800x600x15-dldevg-geode.so-I0-d0x100b, 0x504 &

Devi-hirun KBD kbddev PS2 mousedev & # ps/2 keyboard and mouse drive

Myph-Program # execute your own graphic interface program

Libm. so.2 # contains a graphic display file

Devg-geode.so # graphics card driver

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.