Implementation of Microwindows in an Embedded System

Source: Internet
Author: User
Article Title: Implementation of Microsoft Windows in an Embedded System. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   Preface
At present, with the rapid development of various handheld, wireless and embedded devices, the corresponding software and hardware design has also undergone great changes. Many devices use Intel, MIPS, Motorola's 32-bit microprocessor, and large-screen LCD. In the past 10 years, the desktop operation mode has achieved great success, so many developers began to use desktop-like operating systems in Embedded design. One of the better solutions is to use the Linux operating system. Linux has all the functions and features of a desktop computer on an embedded system. As an open source code, it allows various modifications and can be customized according to specific requirements of users.
  
   Microsoft Windows Overview
Microwindows is a well-known embedded GUI software with open source code. It aims to introduce the Modern Graphic Windows environment to small devices and platforms running Linux. As a substitute for X Window, Microwindows can use less RAM and file storage space (100 K-600 K) to provide functions similar to X Window. The architecture allows designers to easily add a variety of display devices, mouse, touch screen, and keyboard. The kernel code of Linux2.2 and later versions allows you to access the Graphic Display memory as a frame cache. This allows you to avoid operations on the memory ing area when writing and controlling the display device, therefore, you can develop graphics programs without understanding the underlying graphics hardware or using X Windows. This is why Microsoft Windows is widely used in embedded systems. Microwindows is very portable and basically implemented in C language. Only some key codes use Assembly to increase the speed. Microwindows supports Intel 16-bit, 32-bit CPU, MIPS R4000, and arm chips.
Microsoft Windows has been transplanted to some handheld computers. Its graphics engine is designed to run on any system that supports readpixel, writepixel, drawhorzline, drawvertline, and setpalette. With the support of underlying functions, the upper layer supports bitmap, Font, cursor, and color. Microwindows supports the new Linux kernel frame cache structure. Currently, it supports 1, 2, 4, 8, 16, 24, and 32 bits per pixel. It also supports Color Display and Gray Display, the color display includes two modes: true color (15, 16, and 32 bits per pixel) and color palette (1, 2, 4, and 8 bits per pixel. In color display mode, all colors are given in RGB format, and the system converts them to the most similar printable colors, in the monochrome mode, it is converted to different gray levels. Microwindows supports window coverage and subwindow concepts, complete window and customer area cutting, proportional and fixed font, and also provides the font and bitmap file processing tools. The system uses an optimized drawing function, so that users can provide better responses when moving the window. The memory drawing and movement make the Screen Drawing look smooth, which is especially useful for displaying animations, polygon painting, filling in any area, and cutting.
Although Microsoft Windows fully supports Linux, its internal portable structure is based on a relatively simple screen device interface that can run on many different RTOS and bare metal. The advantage of this feature is that a graphic program designed by the user can be shared by different projects without rewriting, or even run on different objects of different RTOS.
The Microwindows system supports the simulation Target Platform on the host platform graphically. In this way, the Microwindows application designed for Linux can be written and developed on the desktop without cross-compilation, and can be tested and run directly on the target platform. The target application running on the desktop host is displayed in X window, which is implemented by the X window Screen driver provided by Microwindows, rather than the frame cache driver. The driver can accurately simulate the display on the Target Platform in terms of pixel level and color depth, so that even if the desktop system is 24-bit color, it can also preview and display the 2bpp grayscale target application.
Microwindows uses a hierarchical design method. At the bottom layer, the screen, mouse/touch screen, and keyboard drivers provide access to physical devices. In the middle layer, a portable graphics engine is implemented, which supports line drawing, area filling, cutting, and color model. At the upper layer, multiple APIs are implemented to adapt to different application environments.
  
   Two APIs: Win32 and Nano-X
In Microsoft Windows, two popular Graphic programming interfaces are used: Microsoft Windows Win32/WinCE graphic display interface (GDI) and Xlib-like interface. The former applies to all Windows CE and Win32 applications, and the latter is like Nano-X, which is applied to the lowest layer of all Linux X plug-ins. This allows a large number of Windows programmers to develop graphics applications. Similarly, Linux graphic programmers can use the X interface to develop graphics applications.
  
   Nano-X program design
In this article, we will use the Nano-x api to design an application and discuss the design of the underlying Nano-X program. Nano-X allows applications to use client/server network protocols or local UNIX primary domain interfaces. This allows several applications to run on an embedded device or a remote host and connect to a Microwindows server. These features make Nano-X operations very similar to X Windows. The Nano-x api is similar to the Xlib library of X in terms of creating, deleting windows and Basic Drawing functions at the underlying layer. In addition, because Microwindows is designed very small, many options can be set using the configuration file in the resource package.
The following procedure creates a Nano-X server.
(1) initialization
Mcrowindows resource packages can be downloaded from the http://microwindows.org. First, build a Nano-X server for the host and the embedded target platform. Most of the setting options are in the configuration file. Therefore, after extracting the resource package, go to the microwin/src directory and edit the configuration file. The following are some of the most important ARCH options:
ARCH = LINUX-NATIVE
ARCH = LINUX-arm
ARCH = LINUX-MIPS
ARCH = LINUX-POWERPC
The purpose of setting the ARCH option for the LINUX-NATIVE is to notify the system to generate programs for the Linux System of the currently running host, while setting the ARCH for other options is to perform cross-compilation for a Windows Target Platform. In Microsoft Windows, use the Arch. rules file to determine a specific setting for each option.
The following settings are used to provide image support for the Nano-X Server:
Have_bmp _support = Y
HAVE_GIF_SUPPORT = Y
Have_cmd_support = Y
When setting the JPEG image option, the location of the external jpeg decompression library must be provided, for example, LIBJPEG =/usr/lib/libjpeg.. Most systems provide knowledge about the pressure library and can also be downloaded from the Microwindows website. Another important item is to choose whether to provide support for variable-size fonts. The default item is to provide a fixed-size bitmap font in drivers/genfont. c. To display larger fonts, such as running an embedded browser, you can add support for TrueType or Adobe Type 1 fonts. After the options are determined, you can specify the font file size and pixel size based on the display requirements. The corresponding Microwindows will generate a proper font size based on the external font file. The latest version also supports external Chinese fonts, all of which are determined by an 8-bit ASCII code, Unicode-16, or UTF-8. The UTF-8 is the byte stream encoding scheme of Unicode.
The supported character options are as follows:
HAVE_FREETYPE_SUPPORT = Y
HAVE_T1LIB_SUPPORT = Y
HAVE_HZK_SUPPORT = Y
FreeType and T1lib external libraries are used to support TrueType and Adobe Type 1 fonts respectively. These libraries must be pre-compiled and their locations should be specified in the configuration file. Download all library functions provided on the website of Microsoft Windows.
  
(2) configure the output Display Device
Because Microwindows can run in the frame cache system and X Windows, different settings are required for each display driver. If X is already running on the Linux desktop, you 'd better first use the X screen driver to create a system and then generate a frame cache for the embedded device. The following options are used to configure the X-screen DRIVER:
X11 = Y
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480
SCREEN_PIXTYPE = MWPF_TRUECOLOR0888
Microsoft Windows uses these options to generate a 640xlarge virtual window on the X desktop, and uses the 8-bit color mode (red, green, and blue are represented by 8-bit respectively. By changing the settings, you can control the simulation of the target embedded device on your desktop. For example, to simulate a 16-bit display per pixel, SCREEN_PIXTYPE = MWPF_TRUECOLOR565. The MWPF constant is explained in detail in the src/include/mwtypes. h header file.
Since the Linux kernel must support frame caching, it is complicated to set the frame caching display. The settings are as follows:
X11 = N
FRAMEBUFFER = Y
FBVGA = Y
VTSWITCH = Y
PORTRAIT_MODE = N
The FBVGA option introduces support for screen drivers in the 16-color VGA flat mode, but this option cannot be used in embedded systems. The VTSWITCH option allows Microwindows to run on the frame cache controller. Press the ALT key to open another virtual controller. Some embedded systems require this option to be disabled. The PORTRAIT_MODE option uses the L/R key to specify the system to operate on the left/right, which is similar to the iPAQ PDA produced by Compaq.
  
(3) Support for Linux kernel frame caching
If "Can't open/dev/fb0" is displayed when running the Nano-X server, it indicates that the frame cache is not enabled or the system kernel does not introduce the frame cache driver. The simplest way to identify is to check whether a penguin icon is displayed when the system is started. If there is no icon, check whether the following options are in the/usr/src/linux/. config file:
CONFIG_FB = y
CONFIG_FB_VGA16 = y
CONFIG_FBCON_VGA = y
CONFIG_FBCON_CFB4 = y
CONFIG_FBCON_CFB8 = y
If the system supports graphics cards rather than standard vintage VGA, you do not need to use the CONFIG_FB_VGA16 option. Before rebuilding the kernel, you need to back up the old kernel and specify the backup location in the lilo. conf file. Frame caching is a standard setting for most embedded systems.
The last important configuration is to specify the driver for mouse or touch screen input for Microsoft Windows. Currently, the mouse on Microsoft Windows uses the GPM tool or the serial port. Command GPMMOUSE = Y is to select GPM support, and then run the gpm tool, such as 'gpm? R? T ps2 '(PS/2 mouse supported); command SERMOUSE = Y is to select the serial port, but also set the MOUSE_TYPE and MOUSE_PORT environment variables in src/drivers/mou_ser.c.
  
(4) create a complete demo system
Once the options are set in the configuration file, the parameters remain unchanged as long as the user does not change them. At the same time, there are many sample configuration files for different platforms in the src directory. To create a Nano-X Server and run the demo program, first enter the microwin/src directory, and then type "make ". All programs are generated in the microwin/src/bin directory, and the customer Link Library is also stored in the microwin/src/lib directory. To run the demo program, first run the Nano-X Server (under bin/nano-X) and then run the application.
  
Bin/nano-X & sleep 1; bin/world
Run the off command before running the demonstration world ployer program.
Related Article

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.