In the current post-PC (Post-PC) era with the rapid development of digital information technology and network technology, embedded systems have widely penetrated into scientific research, engineering design, military technology, various industries, commercial culture and art, and people’s daily life. In all aspects. With the further development and promotion of various embedded products at home and abroad, embedded technology is increasingly closely integrated with people's lives.
Around 1970, the concept of embedded systems appeared. At this time, many embedded systems did not use operating systems. They only used a simple loop control to process control requests from the outside world to achieve a certain control function. When the application system becomes more and more complex and the scope of use becomes wider and wider, every time a new function is added, it may be necessary to design from scratch. Not having an operating system has become one of the biggest drawbacks.
The emergence of C language makes operating system development easier. Since the 1980s, various commercial embedded operating systems have been contending. The more famous ones are VxWorks, pSOS and Windows CE, etc. Most of these operating systems are developed for proprietary systems. In addition, the open-source embedded Linux, due to its powerful network functions and low cost, has recently been used more and more.
1 Technical characteristics of embedded systemAn embedded system usually includes two parts, the hardware and the operating system that constitute the basic operating environment of the software. The operating environment and application occasions of the embedded system determine that the embedded system has some characteristics different from other operating systems.
(1) Embedded processor
Embedded processors can be divided into three categories: embedded microprocessors, embedded microcontrollers, and embedded DSP (Digital Signal Processor). The embedded microprocessor is the CPU corresponding to the microprocessor of a general-purpose computer. In the application, the microprocessor is generally assembled on a specially designed circuit board, and only the functions related to the embedded embedded system can be reserved on the motherboard. This can meet the requirements of small size and low power consumption of the embedded system. The current embedded processors mainly include: PowerPC, Motorola 68000, ARM series and so on.
Embedded microcontroller is also called single-chip microcomputer, which encapsulates CPU, memory (a small amount of RAM, ROM or both) and other peripherals in the same integrated circuit. The common one is 8051.
Embedded DSP is specially used to perform extremely fast processing calculations on discrete-time signals to improve compilation efficiency and execution speed. In the fields of digital filtering, FFT, spectrum analysis, image processing, etc., DSP is entering the embedded market in large numbers.
(2) Microkernel structure
Most operating systems are divided into at least two levels, the kernel layer and the application layer. The kernel only provides basic functions, such as establishing and managing processes, providing file systems, and managing devices. These functions are provided to users in the form of system calls. Some desktop operating systems, such as Windows and Linux, introduce many functions into the kernel, and the kernel of the operating system becomes larger and larger. The larger the kernel makes it take up more resources and it is troublesome to tailor.
Most embedded operating systems use a micro-kernel structure, and the kernel only provides basic functions, such as task scheduling, communication and synchronization between tasks, memory management, clock management, etc. Other application components, such as network functions, file systems, GUI systems, etc., all work in user mode and work in the form of system processes or function calls. Therefore, the system can be cut down, and users can choose the corresponding components according to their needs.
(3) Task scheduling
In embedded systems, tasks are threads. Most embedded operating systems support multitasking. The realization of multi-task operation actually depends on the CPU to switch and schedule between multiple tasks. Each task has its priority, and different tasks may have the same or different priority. There are three ways to schedule tasks: preemptible scheduling, non-preemptive scheduling, and time slice round-robin scheduling. Non-preemptible scheduling means that once a task obtains the CPU, it will run exclusively on the CPU, unless for some reason it decides to give up the right to use the CPU; preemptible scheduling is based on task priority, and the currently running task can be used at any time Bits are given to other tasks in the ready state with higher priority; when two or more tasks have the same priority, different tasks use the CPU in rotation until the CPU time slice allocated by the system is used up, which is the time slice rotation Scheduling.
At present, most embedded operating systems use priority-based preemptive scheduling for tasks with different priorities, and time slice round-robin scheduling for tasks with the same priority.
(4) Hard real-time and soft real-time
Some embedded systems have higher requirements for time and are called real-time systems. There are two types of real-time systems: hard real-time systems and soft real-time systems. The soft real-time system does not require that a certain task must be completed within a certain time. It only requires that each task run as quickly as possible; the hard real-time system has strict requirements on the system response time. Once the system response time cannot be met, it may Errors that cause system crashes or fatal errors are generally used in industrial control.
(5) Memory management
Some desktop operating systems designed for processors with memory management unit (MMU), such as Windows and Linux, use the concept of virtual memory. The virtual memory address is sent to the MMU. Here, the virtual address is mapped to a physical address, the actual memory is divided into pages of the same size, and the process is loaded in a paging manner. Before a program is run, it is not necessary to load all the pages into memory, but to load only those partial pages that are currently to be run into memory.
Most embedded systems are designed for processors without MMU and cannot use the processor's virtual memory management technology. Instead, they use real memory management strategies. Therefore, the access to the memory is direct. The access to the address does not need to go through the MMU, but is directly sent to the address line for output. The addresses accessed in all programs are the actual physical addresses; moreover, most embedded operating systems There is no protection for the memory space, and each process actually shares a running space. Before a process is executed, the system must allocate sufficient contiguous address space for it, and then load all the contiguous space of the main memory.
This shows that the developers of embedded systems have to participate in the memory management of the system. Starting from compiling the kernel, the developer must tell the system how much memory the development board has; when developing applications, they must consider the memory allocation and pay attention to the size of the space the application needs to run. In addition, due to the real memory management strategy, the user program is in the same address space as the kernel and other user programs. When developing the program, ensure that it does not infringe on the address space of other programs, so that the program will not damage the normal operation of the system or cause other programs. The operation of the embedded system is abnormal; therefore, the developers of embedded systems should be extra careful with some memory operations in the software.
(6) Kernel loading method
The embedded operating system kernel can run directly on Flash, or it can be loaded into memory to run. The operating mode of Flash is to burn the executable image of the kernel to Flash, and execute from a certain address in Flash when the system starts. This method is actually the method adopted by many embedded systems. The kernel loading method is to store the compressed file of the kernel in Flash, read the compressed file when the system starts, decompress it in the memory, and then start execution. This method is relatively complicated, but it may run faster because the access rate of RAM is higher than that of Flash.
Because of the memory management mechanism of the embedded system, the embedded operating system adopts the form of static link to the user program. In the embedded system, the application program and the operating system kernel code are compiled and linked to generate a binary image file to run.
2 Embedded system development related technologiesCompared with the development of applications in the Windows environment, there are many differences in the development of embedded systems. Different hardware platforms and operating systems bring a lot of additional development complexity.
2.1 Embedded development process
In the embedded development process, there are the roles of the host machine and the target machine: the host machine is the computer that executes the compiling, linking, and addressing process; the target machine refers to the hardware platform that runs the embedded software. First, the application must be converted into binary code that can be run on the target machine. This process consists of three steps: compiling, linking, and addressing. The compilation process is implemented by a cross compiler. The so-called cross compiler is a compiler that runs on one computer platform and generates code for another platform. Commonly used cross compilers are GNU C/C++ (gcc). All object files produced by the compilation process are linked into an object file, which is called the linking process. The addressing process assigns a physical memory address to each relative offset of the target file. The files generated by this process are binary files that can be executed on the embedded platform.
Another important step in the embedded development process is to debug the application on the target machine. Embedded debugging adopts a cross-debugger, which generally adopts a host-target debugging method, and they are connected by a serial port line or an Ethernet or BDM line. Cross-debugging includes task-level, source-level and assembly-level debugging. When debugging, you need to download the application program and operating system kernel on the host computer to the RAM of the target machine or burn it directly into the ROM of the target machine. The target monitor is the debugger agent (Debugger Agent) that the debugger controls the application running on the target machine. It is solidified in the flash and ROM of the target machine in advance, and automatically starts after the target machine is powered on, and waits for the host-side debugger to send The command that comes, cooperate with the debugger to complete the download, run and basic debugging functions of the application, and return the debugging information to the host.
2.2 Porting software to embedded platforms
The software development model chosen by most embedded developers is to write the software on the PC first, and then to transplant the software. When writing software on a PC, pay attention to the portability of the software, choose a programming language with high portability (such as C language), call operating system functions as little as possible, and pay attention to shielding the byte order and wording caused by different hardware platforms. Issues such as section alignment. The following are some of our experience in the process of porting the protocol stack.
2.2.1 Byte order
Byte order refers to the storage order of data that occupies more than one byte type in the memory. There are usually two byte orders, little endian and big endian. Little-endian byte order means that the low-byte data is stored at the low address of the memory, and the high-byte data is stored at the high address of the memory; the big-endian is that the high byte data is stored at the low address and the low byte data is stored at High address. PCs based on the X86 platform are little-endian, while some embedded platforms are big-endian. Therefore, the storage order of int, uint16, uint32 and other types of data with more than 1 byte should be changed on these embedded platforms. We usually think that the order of bytes transmitted in the air, that is, the network byte order, is the standard order. Considering the agreement with the protocol and the intercommunication with other similar platform products, when sending data packets in the program, the host byte order is converted It is the network byte order, and the network byte order is converted to the host byte order at the receiving data packet.
2.2.2 Byte alignment
The addressing mode of some embedded processors determines that int16, uint16 and other types of data that occupy 2 bytes in memory can only be stored at even-numbered memory addresses, and int32, uint32 and other types of data that occupy 4 bytes can only be stored in The memory address that is an integer multiple of 4; the type data that occupies 8 bytes can only be stored at the memory address that is an integer multiple of 8, and the type data that occupies only 1 byte in the memory can be stored at any address. Due to these limitations, programming on these platforms is quite different. First of all, there will be holes between the members of the structure, such as such a structure:
typedef struct test{
char a;
uint16 b;
}TEST
The structure TEST occupies three bytes of memory on a single-byte aligned platform, but on the embedded platform described above, it may occupy three or four bytes, depending on the storage address of member a. When a storage address is an even number, the structure occupies four bytes, and there is a byte hole between a and b. For both communication parties, both parties operate on the structure members. There is no error in this case, but if one party reads the content byte by byte (most communication protocols are like this), the content of other bytes will be read incorrectly. Secondly, if the data in the memory is read by forced type conversion, the difference in byte alignment will cause data reading errors. Because if the pointer points to the base memory address, we want to get the data that occupies two bytes of memory and store it in a uint16 variable. The result of the coercion is to get the data at the address pointed to by the pointer and the previous address. We did not take the data at the address pointed to by the pointer and the next address according to our wishes, which resulted in data reading errors.
There are many ways to solve byte alignment. For example, you can add the compilation option --pack-struct in the GCC project management file MakeFile; but this method can only remove the holes in the structure, and cannot solve the errors caused by forced type conversion. In order to enhance the portability of the software and the interoperability with other platform products of the same kind, we have added a function for unpacking at the place of receiving data packets, and a function of grouping at the place of sending data packets. These two functions solve the problem of endianness and also solve the problem of byte alignment. That is, when the package is assembled, a certain piece of data of different data types in the memory is placed at the specified address according to the format string in the parameter, and the package is formed and sent to the lower layer; when unpacking, the memory received according to the format string in the parameter The data in is stored in different types of variables or structure members. In the function for different data types for different processing.
2.2.3 Bit segment
Because the space allocation direction of the bit segment differs depending on the hardware platform, for the X86 platform, the bit segment is allocated from right to left; while for some embedded platforms, the bit segment is allocated from left to right. The difference in the allocation order leads to data access errors. One way to solve this problem is to use conditional compilation to define bit segments in different sequences for different platforms; you can also add bit segment processing to the two functions described above.
2.2.4 Code optimization
Embedded systems have higher requirements for the quality of application software, so special attention must be paid to the optimization of the code in embedded development, so as to improve the efficiency of the code as much as possible and reduce the size of the code. Although modern C and C++ compilers provide a certain degree of code optimization, most of the optimization techniques performed by the compiler only involve the balance of execution speed and code size. It is impossible to make the program fast and small, so it must be embedded in the writing Take necessary measures when installing software.
(1) Improve the efficiency of the code
â‘ switch-case statement. Switch-case statements are often used in programs. Each test and jump implemented by machine language is just to decide what to do next, which wastes processor time. In order to increase speed, you can sort specific situations according to their relative frequency. That is, put the most likely scenario first and the least likely scenario last, which will reduce the average code execution time.
â‘¡ Global variables. Using global variables is more efficient than passing parameters to functions. This eliminates the need for parameters to be pushed into the stack before the function is called and parameters to be popped after the function is completed. Of course, the use of global variables will have some negative effects on the program.
(2) Reduce the size of the code
Embedded system programming should avoid the use of standard library routines, because many large library routines try to handle all possible situations, so they occupy a huge memory space, so the use of standard library routines should be reduced as much as possible.
(3) Avoid memory leaks
User memory space (heap) is the remaining space after both global data and task stack space in RAM are allocated. In order to make the program have enough memory to run, it must be released in time after the requested memory is not used to ensure that it is applied again There can be space. If there is a memory leak in the program (that is, the memory is not released in time after applying for it), the program will eventually fail to run because there is not enough memory space.
3 Wide application of embedded systemThe application prospects of embedded systems are very wide. People will be exposed to embedded products all the time and everywhere, from washing machines and refrigerators at home, to bicycles and cars as vehicles, to remote conference systems in offices. and many more. Especially the emergence of the small-range wireless access protocol represented by Bluetooth, the concept of embedded radio has quietly emerged. When the price of the embedded radio chip is acceptable, its application may be ubiquitous. In homes, offices, and public places, people may use dozens or more of these embedded radio chips to form some electronic information equipment and even electrical equipment into a wireless network; in the car and on the road, people use such embedded radio chips. The radio chip can realize remote office, remote control, and truly carry the network with you. Several specific applications are introduced below.
(1) Embedded mobile database
The so-called mobile database is a database that supports mobile computing. It has two meanings: â‘ Users can access database resources online during the movement. â‘¡ Users can move with the database. A typical application is to query the nearest hospital in a driving ambulance. The system is composed of a foreground mobile terminal and a background synchronization server. The mobile terminal has an embedded real-time operating system and an embedded database. The Renmin University of China is developing this system. They cooperated with Hopen to develop the mobile terminal "Pixie".
(2) Application of embedded system in smart home network
Smart home network (E-Home) refers to the establishment of a communication network in a home to provide the necessary access for home information; under the control of the home network operating system, through the corresponding hardware and implementing agencies, all home appliances on the home network And equipment control and monitoring. The composition of its network structure must have a home gateway. The home gateway mainly realizes the signal synthesis of the control network and the information network and interfaces with the outside world for remote control and information exchange. Whether it is a gateway or a control module on each home appliance, an embedded operating system is required. These operating systems must have the characteristics of embedded, good real-time, and multi-user. The intelligent multimedia home gateway developed by Nanjing Dongda Mobile Internet Technology Co., Ltd. uses embedded Linux as the operating system of the embedded device. The mutual communication between the devices complies with the Bluetooth communication protocol, which can support multiple devices to connect to the fixed at the same time. Other external networks such as the telephone network and the Internet.
(3) Embedded voice chip
Embedded voice chip is based on embedded operating system, adopting technologies such as speech recognition and speech synthesis, phonetic hierarchical structure system and text processing model; it can be applied to handheld devices, smart home appliances and other fields, giving these devices a humanized interaction method It can also be used in toys to realize voice-activated toys, simulated pets, and toys that communicate with people; it can also be used in vehicle-mounted communication equipment to realize human-machine communication. The chip is used in mobile communication devices. For example, when a short message comes on a mobile phone, we don't have to look at it, but can hear the sound.
(4) Embedded products based on small-range wireless communication protocols
The combination of a small-range wireless access protocol represented by Bluetooth and embedded systems will surely promote the widespread application of embedded systems. Recently, embedded products based on these protocols have emerged in endlessly, including various telephone systems, wireless briefcases, various digital electronic devices, and applications in e-commerce. These products have opened up broad prospects for their applications in home and office automation, e-commerce, industrial control, intelligent buildings and various special occasions due to their miniaturization and low-cost characteristics.
The State Key Laboratory of Mobile Communications in Southeast University and Nanjing Dongda Mobile Internet Technology Co., Ltd., established by the laboratory, have been tracking Bluetooth technology since 1998, and have participated in the Hong Kong Special Administrative Region Government’s Innovation and Technology Fund, Jiangsu’s Tenth Five-Year With the funding of the "Tenth Five-Year Plan" scientific and technological research, a variety of embedded products based on Bluetooth technology have been designed and developed. These include embedded PSTN gateways and voice terminals that comply with the Bluetooth V1.1 standard. They are based on the bluetooth "three-in-one phone" application model, choose Hopen OS provided by the Chinese Academy of Sciences Kaisi Haopeng Software Technology Engineering Co., Ltd. as the software platform for embedded development, and choose Winbond W90221 as the hardware platform. Voice terminals can access the PSTN network in a wireless manner through the PSTN gateway to realize intercommunication with PSTN network users. There is also an embedded LAN access point that conforms to the Bluetooth V1.1 standard. It is based on the Bluetooth "LAN access" application model, using the embedded Linux operating system as the software platform, and Motorola's CodeFire 5272 as the hardware platform. Through this access point, end users can freely access the Internet, and can support multiple end users to connect to the Internet at the same time. Some other embedded products include smart multimedia home gateways, remote meter reading systems, information appliances, etc.
ConclusionThe above focuses on the characteristics of embedded systems, the development and application of embedded products. We realized during the development process: Embedded system development is essentially the same as the previous development work. The only change is that each hardware platform is unique. This difference leads to a lot of additional development complexity. Therefore, pay special attention to the software creation process in the embedded development process; moreover, before developing embedded products, you must have a better understanding of the embedded hardware platform selected, have the corresponding hardware knowledge, and work closely with hardware engineers; When choosing an embedded operating system and hardware platform, the appropriate system and platform should be selected according to the needs of the application to be developed and the consideration of cost.
With the rapid development of technology today, embedded products will be more and more widely used. We believe that as long as we follow the development rules of embedded products and adapt to the needs of the market, we will be able to develop more and more embedded products.
The 16 -port fast charger with 16 USB ports, up to 16 devices at one time. The total power of the total amount of the built -in charger of the 16 -port C -shaped 1U, the output 5V3A/9V2.1A/12V1.7A, supports PD/QC/HuaweiIFCP/PFC, LED turns on the green light, and the red light is charged. Full of electric light.
16 port USB-C hub charges and synchronization up to 16 pieces, smartphones and
Other types of C are equipped with C device. Recommended for schools, office and other
Using a variety of C devices, this unit can provide up to 5V, 3A (15W) power for each port-for charging battery-intensive devices, such as iPad®, iPod®, iPhone®, iPhone® and Android® Tablet computer and smartphone.
16 port USB-C ports can transmit data at a speed of up to 10 GBPS, and the speed of the data is twice as much as USB 3.1 Gen 1. If all ports are used at the same time, each port provides a power of up to 0.9 amp. Because the port conforms to the limitation of BC 1.2, they can pass the charging power of 2.4 Ampel to the mobile device (connected to the power supply).
16-Port USB-C charges, Cabinet type 16 Ports Type C Charger,16 Ports Type-c 1Ucabinet Charger,16 Port USB Hubs,16-port Type-C fast charger
shenzhen ns-idae technology co.,ltd , https://www.szbestchargers.com