当前位置:网站首页>Research and implementation of embedded software framework based on multi process architecture

Research and implementation of embedded software framework based on multi process architecture

2022-06-21 10:39:00 Longcheng deficit

Abstract :

This paper aims at the development of high-end embedded software products , A multi process development framework is proposed . Using the framework , It can realize multi person parallel development , Speed up the product development cycle , Provide product stability , It is a useful attempt .

keyword : frame Multi process Embedded software

0 introduction

   With the development of computer software technology , Embedded software development is also changing and updating . The development of software is inseparable from the advancement of hardware . From the early 51 SCM to high performance dsp Chips are now based on ARM A high performance soc Chips are everywhere , The development of embedded hardware has experienced rapid development, high performance and low power consumption , Universalization , Multi core development , Even today's parts soc The performance of the chip is much higher than that of the early stage pc Upper x86 series cpu, And the use of memory is also towards universal PC In line with our goals . Attached to hardware , Embedded software technology is also experiencing rapid development . From the early c Add the way of assembly , Until now the android, It's all used Java Development of application software . On the whole , The development of software is becoming more and more complicated , Enlargement , From specialty to universality , The direction of deep customization . There are more and more hardware peripherals , Software management also tends to be perfect and unified . But as the cpu Continuous improvement of performance , Memory keeps growing , The price of the whole machine keeps decreasing , The development of embedded software is facing an awkward position . On the one hand, for low performance and low cost , Areas with low complexity requirements , Early research and software development , It's still applicable , On the other hand , For high performance , High complexity areas , A lot of development work has shifted to using android, use android+ Proprietary functions . The original main function now acts as an application . For this area , Use android It's a wise choice , On the premise that the hardware capability is satisfied , Use android There is a stable basic platform , Simplifies the management of peripherals , The product has many more functions and selling points . But there are many intermediate areas , On the one hand, hardware cpu Performance and memory cost constraints , Can't use android Huge system , On the other hand, the software function has a certain degree of complexity , The underlying operating system uses Linux, Some functions can use open source components completely , No need to crop , But the main functions of the upper software are designed and developed by ourselves , Here's the picture . Development in this field , This paper presents a software framework based on multi process architecture , Be able to build software prototypes according to different specific requirements , Quickly complete function development .

1 Constraints and goals

Software development in embedded system field , There are several areas that need special consideration . First, it is generally necessary to adapt the hardware . This is determined by the characteristics of the embedded system itself . Different fields , Address different needs , The hardware can be very different , Sometimes there may be a variety of peripherals , Therefore, understanding the characteristics of the hardware is the first requirement before the development work . secondly , Embedded software generally has real-time requirements . This is also an inherent characteristic of embedded systems , Because embedded devices generally have a single function , Follow PC The commonality of the platform is completely different , The software needs to be carefully designed for the problem domain , Give full play to hardware performance . There is also an embedded system software with customized features , The specific reasons have already been given . For these characteristics , Design a general software framework , There is some difficulty . Trying to design a framework to govern the world , Solve all the problems , It's impossible . Only part of the problem can be solved at one level , The goal is achieved . This is the design constraint to be mentioned here .

First , The framework is in Linux Based on the system , That is, the underlying operating system is Linux, The operation of the framework needs the support of the underlying system calls . This basically excludes hardware features , That is, the framework is completely based on pure software , No specific hardware support is involved . Choose here Linux operating system , Also based on the present Linux It is more and more widely used in the development of embedded systems .

After excluding hardware dependencies , Consider the limitations of the software . There is no specific content limitation here , For example, support wireless or camera , Or limit the number of specific applications created , Because in the face of complex problem areas and diverse needs , These limitations have no practical significance . Here are the following features to adapt to versatility and flexibility :

  a. To be able to meet the functional development needs . This is also the most basic requirement .

  b. To meet the modular requirements . That is, each function should be developed according to the module , Split up , Be able to develop one module by one , And design the module interface with high cohesion and low coupling .

  c. To meet scalability requirements . This is for the expansion of functions , It should be easy to add on the basis of the completion of some functions , And has little impact on existing modules .

  d. To meet the needs of parallel development . This is actually the synthesis of the previous several . On the basis of meeting the previous items , Minimize interdependencies , So as to speed up the research and development progress , Shorten product development cycle .

  e. Last , Strive for simple and clear structure , And efficient . On the one hand, it can reduce people's understanding deviation , In addition, it is also convenient for joint cooperative development .

  Brooks Said , Add people to projects that are behind schedule , It will only make the project more delayed . An important reason to support this view is that the training and communication of developers take a lot of time . therefore , Parallelization and simple and clear structure complement each other .

2 Framework implementations

2.1 Basic module construction

The basic modules mentioned here , That is, as a foundation , Some open source components that provide complete underlying support . Embedded software development , Although facing a variety of hardware peripherals and a variety of functional requirements , But some functions are relatively universal . Build basic modules , It is to add these general functions to the framework in the early stage , Tamp the bottom support . This piece is mainly composed of two parts , First, open source software , The second is the module with general functions developed by ourselves . With the growing popularity of the Internet , Many embedded devices have networking capabilities , This is like wireless connection management 、pppoe Dial up management 、 Data uploading and downloading can be completed by using open source software . In addition, data encryption and decryption , There are also ready-made open source software to realize . For the self-developed modules , Including encapsulation like operating system calls , Unified data management related to equipment configuration , Task management , Such as task start, pause and stop .

   It's important to point out that , Open source software migration here , It is different from the tailoring of open source software we have studied before . Here, the performance of our positioning system hardware is medium and high-end , Not an early memory constrained system , So there is no need to tailor the open source software or find a tailored version to replace it . Many functions can be used with Linux The distribution uses the same version .

   Use these common foundation modules as the underlying support , It will be easier to build upper layer applications , And more stable and efficient . All the upper applications can use the functions provided by the lower modules , So as to focus on the implementation of its own logic .

   An example of a basic module is shown in the following figure :

2.2 Application construction mode

After prototype construction , You need to consider the details of the application layer . Whether to adopt single process mode or multi process mode , It can be said that there is no perfection , Only better . Consider that the framework needs to meet concurrent development and be able to flexibly respond to a variety of requirements , The system adopts the structure of multi process and multi thread in the whole application layer . This can be called an application's build pattern . This design structure strongly supports what we mentioned in the constraints 5 Requirements . Simply speaking , All functions of the application body take the process as the running unit . A process consists of multiple sub threads , The main thread completes the main message receiving and control processing , Sub thread to complete auxiliary processing . Sub threads communicate with each other through message queues , Interprocess ( That is, the application room ) Communicate through interprocess messages . So on the whole , The system connects each part through two-level communication mechanism , The message communication mechanism between applications is adopted , The communication mechanism of message queue is adopted in the application . in addition , Use the multi process application development pattern , Multiple applications can be debugged and developed by multiple people at the same time , Speed up product development .

The importance of parallel development is emphasized here , For a number of reasons . Many tasks are developed with single linearity , The next round of development depends on the completion of previous tasks . therefore , If you can develop in parallel , It will be very beneficial to accelerate product development .

An application layer function development mode is shown in the following figure :

2.3 Apply the watchdog mechanism

    Stability cannot be overemphasized in embedded software development . Many embedded operating systems take stability as their own characteristics and vigorously promote it . Popular in embedded industry vxworks operating system , It is said that all functions have been fully tested , It's almost zero BUG. But software development is ultimately a product of ideas , As the saying goes, a wise man worries a lot , There must be a mistake . As the problem domain becomes larger and larger , More and more complex functions , There are inevitably some bug Hiding is very hidden . In order to ensure the stability of the software to the greatest extent , Refer to the hardware watchdog mechanism , The software watchdog mechanism is added to the framework . The basic principles apply at startup , Register yourself with the monitoring manager , The monitoring module continuously feeds each application dog , If an application does not respond for a period of time , Then the application is considered dead or dead , Restart it . On the other hand , Each application is designed to run as a separate process , Can be applied to down fall , Minimize the impact on other modules .

2.4 Event notification chain mechanism

The event notification chain mechanism in the framework , Refer to the Linux Some practices of the kernel . If an application is interested in an event , You can register yourself on the notification chain of this event . When the corresponding event occurs , The event generator sends a message back to the notification link , In this way, all applications connected to the notification will receive events . In embedded systems , Some common events include remote control and key input , Plug and unplug peripherals , Such as network cable and usb. In addition to this , There are other events .

2.5 A unified debug Collection module

   Debug The module is used to complete the collection of debugging information , It also includes the software execution process and some error messages . Embedded software development , Due to its diverse platforms , Unlike PC On the development program , There is a very convenient integrated development environment , It can be easily debugged , Many times, printing has become a simple and effective way to debug programs . In order to facilitate the debugging of the program , The framework designs a unified debug Collection module . Application development , call debug The interface provided by the module serves as the printing interface , You can easily do :a Display the printed information on the serial port output ;b Send the printing information to the remote monitoring terminal , Realize remote debugging ;c The printout level and output module can be controlled remotely , So as to filter the printing of unnecessary levels and the printing of unnecessary modules . This will reduce the amount of printing information , Convenient debugging .

    On the basis of existing functions , Developers can extend this module , Realize your own unique printing control .

2.6 Framework based system construction

    Using the framework , The construction of the system is shown in the figure below .

   xxxxxxxxxxxxxxxxxxxx

    The bottom layer is the hardware layer , Include cpu, Memory flash And various peripherals .

    The operating system layer , Use Linux operating system , With a variety of peripheral drivers .

    Provide framework layer based on operating system , Encapsulate some system call interfaces , Provide management, support and some expansion modules for the upper .

    The top layer is the development of the application layer , It can be an application developed by yourself , It can also be said that the integration of middleware . Development of the entire application layer , According to the multi process multi thread module development . The main thread registers the message communication system , Register the event receiving system, etc , receive messages , Process the message . Receiving events , Handling events , Complete message communication between processes . The sub thread completes the implementation of application functions .

    Based on this framework , Developers can easily add new features , Encapsulation interface , Add messages to complete communication with other modules . An example of framework based development is shown in the following figure :

2.7 Key technologies and bottlenecks

    On the whole , The system is a message driven system , Contains a complex and diverse flow of messages . There are messages generated by the application itself , It also includes such things as timing 、 System messages such as keys and network . And for messages generated by the application itself , Also very different , How little , Big and small . It's like the brain and nerves of the human body , Each module is a variety of viscera , There are different organ structures , Through the unity and coordination of the brain and nerves . The specific message content is like blood , Flow throughout the body . The whole system can be summarized through the message network . Well designed message network , Is the key technology .

As a framework of embedded software development , Real time is a basic feature that it needs to guarantee . In this framework , Real time performance is mainly limited by message communication , Including message communication between processes and between threads , Relatively speaking, inter process message communication is more important . therefore , The bottleneck mentioned here is how to achieve efficient interprocess communication . Inter process communication Linux There are many ways to achieve , Frame socket Mode to complete . But this is not the focus of this article , Its specific implementation can also be based on different requirements , It is very convenient to change , Not much here . For details, please refer to Linux Information about interprocess communication .

3 Conclusion

   This paper discusses a method based on Linux Design and implementation of embedded software framework based on operating system . The framework is based on practical development , And successfully applied to iptv And video monitoring system . In addition, many modules based on the framework can be reused . Based on this framework , Developers can quickly build system prototypes , And focus on the development of application logic .

   Using this framework reduces the development cycle , It improves the stability of the system , Good results were achieved . Of course , It is not perfect . First, it is limited to the use of Linux Embedded as an operating system , The second is message based communication , Need an efficient communication mechanism , To meet the specific requirements of embedded real-time .

   in general , The framework has good generality and portability . Wide application , Simple, efficient and stable .

原网站

版权声明
本文为[Longcheng deficit]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221440142765.html