Windows CE is a compact, efficient, and scalable operating system designed for a variety of embedded systems and products.
This article focuses on the installation of wireless network cards in Windows CE environment, and proposes a solution to automatically install wireless network cards when the system is powered off and restarted; it also introduces the system customization, application development and system packaging of Windows CE. Since Windows CE and Windows are of the same origin and similar, it is easy to learn Windows CE, which shortens the development cycle of the application.
1 Introduction to Windows CE
The operating system customization tools include Windows CE Platform Builder (PB for short), and the application development tools include the embedded development toolkit Embedded Visual Tools, including Embedded Visual C++ (EVC for short) and Embedded Visual Basic (EVB for short).
2 Development of Windows CE operating system for specific hardware platforms
After having a specific embedded hardware platform, you can develop a Windows CE system that meets specific functional needs. In short, it can be divided into three steps: customization of the operating system, development of specific functional application modules, and packaging of functional modules into
operating system.
2.1 Initial customization of the operating system
Figure 2 shows the general process of customizing the Windows CE operating system in PB [3].
First, select the basic configuration of the operating system, and select the corresponding microprocessor and platform support package BPS (Board Support Packet) for the specific platform. The BSP provided by PB is CEPC (WinCE hardware development platform based on PC). Developers can choose one or customize the BPS for a specific platform. Secondly, formulate the platform. At this stage, you can develop device drivers, appropriately cut and add components, and modify some configuration files if necessary. Then, encapsulate the required functional modules and compile to generate the OS image file. If the device is a customized target device, you need to develop OAL (OEM Adaptation Layer), BPS and BootLoader. Then, download the image file to the target device for debugging; if necessary, repeat configuration, encapsulation, download and debugging, if necessary, repeat configuration, encapsulation, download and debugging until the requirements are met and the platform is created.
Finally, the corresponding SDK (Software Development Kit) is exported and added to the EVC after running, so that application development can be carried out on a specific hardware platform. The SDK contains program libraries, header files, sample program source code and library function usage documents, as well as programming guidance and API participation and device driver kit (DDK).
Developing application modules with specific functions means writing applications in EVC to meet the needs of system function expansion. The key tasks are as follows:
(1) Select the corresponding microprocessor for the specific platform, such as WCE THUMB or WCE x86em.
(2) Write applications. The methods of EVC and VC running on PCs are not much different. The main differences between the two are: the API of the former is a subset of the API of the latter, and some modifications or alternative functions need to be found for incompatible functions; the former is a Unicode environment, all characters are two bytes, while the latter is the ANSI American standard, each character is one byte, so data type conversion must be performed between the two when necessary; there are also some differences in user interface programming and memory management.
(3) Compile and debug the program. When compiling, be sure to select a specific hardware platform. When debugging, you can use the Microsoft Activesync tool provided by the micro software package to establish a connection between the PC and the target machine, download the system image from the PC to the target machine for debugging; in addition, EVC has a simulator that can simulate most of the functions on the target platform on the PC.
2.3 Functional modules are encapsulated into the system
OEM developers usually package necessary applications and operating systems together and release them to users, so it is necessary to package the applications into the initially developed operating system. There are two main tasks to be done:
(1) Copy the compiled executable file to the corresponding folder of the Windows CE system.
(2) Modify the corresponding system configuration files in PB. The configuration files provided by PB include four file types: .bib, which describes the Windows CE files that need to be packaged into the image file; .dat, which describes the file system, directory, and file allocation table; .db, which describes the Windows CE object storage database; and .reg, which is the system registry. The most commonly used configuration files in the development process are: Platform.bib, Platform.reg, Platform.dat, and Config.bib. Platform.bib defines the files and modules required for packaging into the OS image file; Platform.reg defines the registry key values loaded when the target platform is cold started; Platform.dat defines the system files, directories, and links loaded when the target platform is cold started; Config.bib defines the available physical addresses and performs some property settings.
After completing the above two steps, recompile, download, and debug the operating system to finally obtain a fully functional system image.
3 Development Example - Automatic Installation of Wireless Network Card in Windows CE Environment
3.1 Project Introduction
[page]
The project requires the implementation of an independent embedded wireless communication module to access the wireless LAN through the existing IEEE80211b wireless network card.
3.2 Problems and solutions for wireless network card installation
Windows
The project needs to install the driver for the existing wireless network card. Because the Windows CE system is based on RAM storage when running, and ROM is equivalent to a read-only hard disk, once the system is powered off or cold-started, the information in the RAM will be lost, especially some registry information, so the RAM must be continuously powered. However, since the hardware power supply of this system cannot guarantee continuous power supply, after the wireless network card driver is installed, the information is stored in the RAM. After the system is powered off or cold-started, the relevant information will be lost. Moreover, the target machine has no display screen and keyboard in actual use. Therefore, the wireless network card driver needs to be automatically reinstalled when the power is off and restarted.
The solution is to read the network card driver xi825.dll and TCP/IP attribute configuration file config.txt from the system persistent storage SM card, and then install the driver for the wireless network card according to the configuration file device registry key value. If you need to update the TCP/IP attribute value according to the specific application environment, you can overwrite the old file in the SM card with the new configuration file, re-set the device attribute value after cold restart, and then install the network card driver.
Use EVC to write an application to automatically install the wireless network card driver. Figure 3 shows the general flow of the application.
First, copy the two files from the storage card folder of the SM card to the Windows directory of the Windows CE system; after the copy is successful, operate the registry according to the content of config.txt to set the TCP/IP property values under the specific environment; after the system detects the wireless network card, the program automatically enters the network card driver name in the pop-up dialog box named "Unidentified PCCard Adapter" to complete the automatic installation of the wireless network card.
3.3 Solutions to Several Specific Problems
Next, we will discuss the solutions to several specific problems in this solution, including the operation of the registry, the realization of the automatic installation function, the overall control of the program flow, and the method of packaging the program into the operating system.
3.3.1 Operations on the registry
Windows CE has a series of API functions that can operate the registry, such as opening and closing the registry, reading or modifying key values, etc. In addition, the value type in the Windows CE registry is Unicode; while the configuration file config.txt is generated on the PC and is of the ANSI type. To set the registry value according to the value read from cogfing.txt, it is necessary to convert the data type, which can be achieved using the function MultiByteToWideChar() [4]. The key code is as follows:
RegOpenKeyEx(HKEY_LOCAL_MACHINE, //root key TEXT("Commxi8251ParmsTcpIP"),
//open subkey 0 under the root key
, //reserved value, must be set to 0
0, //this item is not supported, must be set to 0
&hKey //the handle pointer of the final opened key
);
RegSetValueEx(hKey, //Handle for key operation
0, //Reserved value, must be set to 0
REG_GZ, //Type of the value in the data item
(CONST BYE*)((LPCTSTR)regData), //Buffer for storing the data item value
dwDataSize //Number of bytes of the value
); //Modify the value of the "IpAddress" data item, that is, change the IP value
3.3.2 Implementation of automatic installation function
Use the FindWindows() function to determine the appearance of the dialog window; use the keybd_event() function to simulate keyboard input. The key code is as follows:
TCHAR g_szTitle[80]=TEXT("Unidentified PCCard Adapter"); //Specify the title of the dialog box
HWND hWnd=..FindWindows(NULL,g_szTitle); //Judge whether the window with this title name has appeared, regardless of whether it is the foreground window
if (hWnd! =NULL) //If the window has appeared
{..SetForegroundWindows(hWnd); //Set this window as the foreground window
keybd_event(0x58,0,0,0); //Press the x key
keybd_event(0x58,0,KEYEVENTE_KEYUP,0); //Lift the x key
//After completing the two actions of pressing and lifting the x key, the keyboard input character x is simulated.
............//Use the same method to input \'i825.dll\'
keybd_event(0x0d,0,0,0);
keybd_event(0x0d,0,KEYEVENTF_KEYUP,0); //Finally enter the confirmation key
}
After entering correctly, you can see the display light of the wireless network card start to flash, indicating that the network card has been installed successfully and is ready for wireless communication.
3.3.3 Overall control of program flow
In order to ensure the order of the program flow, an administrator who monitors and controls the entire program is also required. This monitoring function can be achieved by sending and receiving specific messages to the main control function, waiting for specific event objects, or using timer query methods. In view of the simplicity of the method and the small occupation of system resources, the timer query method is selected here, and the flag is set to distinguish different stages of work and perform corresponding operations. The key codes of the department are listed below:
flag=0; //The initial flag is set to 0, that is, copy the required files first
m_nTimer=SetTimer(1,2000,NULL); //Start the timer
KillTimer(m_nTimer); //When the time is up, turn off the timer first, and make corresponding judgments and operations.
3.3.4 Application packaging into the system
The above article has described the general method of packaging an application into an operating system, which is divided into two steps: copying the application and modifying the system configuration file. In this project, the application monitor.exe is packaged and packaged into the operating system. Here we focus on the specific modifications of several configuration files in the system.
(1) Add the following code to the Files section of the Platform.bib file
Among them, monitor.lnk is the link program (shortcut) of monitor.exe. The production method is very simple and can be written through an ASCII code editor. The format is: #20.exe.
The code in this configuration file indicates that monitor.exe and monitor.lnk are loaded into a memory area named NK (NK is defined in the memory section of the config.bib file), and the file attribute is U (uncompressed file). This completes the "declaration" of encapsulating the application developed by the user and its linker into the operating system.
(2) Add the following code to the Platform.dat file:
Directory ("):-File("monitor.lnk",".lnk")
Since Platform.bib has declared that these two files will be mapped to the directory after the operating system is started, this is the default directory. Therefore, the additional code indicates that monitor.exe will be automatically run when Windows CE is started.
After completing the above work, compile the operating system and encapsulate the application into the Windows CE operating system. After the system starts, the application will run to complete the function of automatically installing the wireless network card.
Previous article:Network communication design based on uCLinux and ARM7
Next article:Application example of touch screen on S3C2410
Recommended ReadingLatest update time:2024-11-16 14:38
- Popular Resources
- Popular amplifiers
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
- Multiplexer Problem
- CC2541 serial port 1 position 1 problem? ? ? ?
- How to analyze and design active filters---Thank you very much! ! !
- 【Ufan Learning】Learning Part 4: "Basic Routine 3 - Buzzer Control"
- How to set device diagram symbols to be read-only in AD schematics
- Graduated and sold various development boards and electronic products
- AD installation component library video tutorial
- Is it OK to use 74HC164 like this?
- Share an open source architecture of ethercat-based on XMC4800
- (Transfer) bluetooth abbreviation