Architecture system applied to embedded system development

By using the application layer developed by Lua scripts and a unified hardware access interface in the embedded system, the cross-platform portability problem caused by direct programming in C language is solved, and the efficient portability of the embedded system is achieved.

CN120371268APending Publication Date: 2025-07-25CHINA TOWER CO LTD

Patent Information

Application Number
CN202510517217.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-23
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

In embedded system development, direct programming of C language leads to difficulties in cross-platform porting, increasing the complexity and cost of development work, and limiting the portability of software.

Method used

The application layer developed by Lua scripts is adopted, combining the hardware abstraction layer and the virtualization interface layer, providing a unified hardware access interface and system services, and executing Lua scripts through a virtual machine to achieve cross-platform portability.

Benefits of technology

Improves the portability of code in embedded systems, simplifies the development and deployment process, and reduces the complexity and cost of cross-platform porting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371268A_ABST
    Figure CN120371268A_ABST
Patent Text Reader

Abstract

The invention discloses an architecture system applied to embedded system development, and relates to the field of embedded system development, and the architecture system comprises an application layer which is used for executing business logic in an embedded system and managing the configuration of the embedded system, and the application layer is developed by adopting a Lua script; the hardware abstraction layer provides a unified hardware access interface; and the virtualization interface layer is used for providing a uniform interface for the application layer, so that the application layer can access the hardware resources of the hardware abstraction layer and call the system service in the embedded system. According to the method and the device, the problem that cross-platform transplantation is difficult due to the fact that a C language direct programming mode is adopted in an embedded system in the related technology is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of embedded system development. Specifically, it relates to an architecture system applied to embedded system development. Background Art

[0002] In embedded system development, the C language has long been the mainstream programming language due to its advantages such as high efficiency, direct memory control, and precise control of hardware resources. However, with the rapid development of the Internet of Things and intelligent devices, embedded systems in different application scenarios increasingly adopt different types of hardware platforms. Although these hardware platforms have similarities in basic functions, there are significant differences in core features such as instruction sets, register layouts, peripheral interfaces, and interrupt management. Therefore, when directly programming in the C language, developers have to write specific driver programs and system control codes for each hardware platform. This not only increases the complexity and workload of development work but also limits the portability of software. When the software needs to be ported from one hardware platform to another, in addition to modifying the hardware-related code, it is also necessary to reconfigure the compilation environment, adjust compilation parameters, and even change the entire software architecture, which greatly extends the development cycle and increases project costs.

[0003] Regarding the problem that the direct programming method using the C language in the embedded system in the related art makes cross-platform porting difficult, no effective solution has been proposed yet. Summary of the Invention

[0004] The main purpose of this application is to provide an architecture system applied to embedded system development to solve the problem that the direct programming method using the C language in the embedded system in the related art makes cross-platform porting difficult.

[0005] To achieve the above objective, according to one aspect of this application, an architecture system applied to embedded system development is provided. The system includes: an application layer for executing business logic and managing the configuration of the embedded system in the embedded system, and the application layer is developed using Lua scripts; a hardware abstraction layer providing a unified hardware access interface; a virtualization interface layer for providing a unified interface to the application layer so that the application layer can access the hardware resources of the hardware abstraction layer and call the system services in the embedded system.

[0006] Furthermore, the application layer further includes: a service management module for dynamically loading and unloading modules in the application layer; a configuration management module for parsing configuration files in JSON format; a remote upgrade module for remotely updating Lua scripts; a log management module for recording the running logs of the embedded system at different levels.

[0007] Furthermore, the virtualization interface layer further includes: a virtual machine for reading Lua scripts, parsing Lua scripts, and executing Lua scripts; a hardware control interface for encapsulating the interfaces of the hardware abstraction layer into Lua functions for the application layer to call; a system service interface for providing system services such as timers and message queues; a data conversion interface for converting data types between C language and Lua scripts; and a debugging interface for providing debugging functions such as breakpoints and single-stepping.

[0008] Furthermore, the hardware abstraction layer further includes: a basic driver module for driving the underlying microcontroller unit peripherals in the embedded system and providing driver interfaces; an interrupt handling module for registering, distributing, and handling interrupts in the embedded system and managing interrupt priorities; a task scheduling module for performing task scheduling based on priorities; and a memory management module for allocating, reclaiming, and defragmenting memory in the embedded system.

[0009] Furthermore, the virtual machine further includes: a garbage collection module for performing garbage collection using the generational garbage collection algorithm; a memory management module for reclaiming and allocating memory; and an exception handling module for catching and handling exceptions when the Lua script is running.

[0010] Furthermore, the development environment of the embedded system includes: an integrated development management module for providing functions such as code editing, compilation, and debugging; a simulation debugging tool for online simulation of the hardware in the embedded system; a performance analysis tool for analyzing metrics such as processor occupancy and memory usage in the embedded system; and a remote maintenance tool for remotely debugging devices applying the embedded system and updating programs in the embedded system.

[0011] To achieve the above object, according to another aspect of the present application, a method for running an embedded system is provided. The method includes: initializing the virtual machine in the virtualization interface layer; initializing the basic driver module, the interrupt handling module, the real-time task scheduling module, and the memory management module of the hardware abstraction layer, where the basic driver module is used to drive the underlying microcontroller unit peripherals in the embedded system and provide driver interfaces, the interrupt handling module is responsible for registering, distributing, and handling interrupts in the embedded system and managing interrupt priorities, the task scheduling module is used to perform task scheduling based on priorities, and the memory management module is used to allocate, reclaim, and defragment memory in the embedded system; starting the virtual machine and running the Lua script of the application layer; and through the virtual machine, the application layer calls the basic driver module, the interrupt handling module, the real-time task scheduling module, and the memory management module in the hardware abstraction layer.

[0012] According to another aspect of the present application, there is provided a computer-readable storage medium, which includes a stored program. When the program runs, it controls the device where the computer-readable storage medium is located to execute any one of the running methods of the embedded system.

[0013] According to another aspect of the present application, there is provided an electronic device, including: one or more processors, a memory, and one or more programs. Among them, the one or more programs are stored in the memory and are configured to be executed by the one or more processors. The one or more programs include those for executing any one of the running methods of the embedded system.

[0014] According to another aspect of the present application, there is provided a computer program product, including computer instructions. When the computer instructions are executed by a processor, the steps of the running method of the embedded system in any one of the above are implemented.

[0015] In an embodiment of the present application, there is provided an architecture system applied to the development of an embedded system, including an application layer for executing business logic and managing the configuration of the embedded system in the embedded system. The application layer is developed using Lua scripts; a hardware abstraction layer providing a unified hardware access interface; and a virtualization interface layer for providing a unified interface to the application layer, enabling the application layer to access the hardware resources of the hardware abstraction layer and call the system services in the embedded system, thereby achieving the technical effect of improving the portability of the code in the embedded system and further solving the technical problem that the direct programming method using the C language in the embedded system makes cross-platform transplantation difficult. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings constituting a part of this application are used to provide a further understanding of this application. The schematic embodiments of this application and their descriptions are used to explain this application and do not constitute an improper limitation of this application. In the drawings:

[0017] Figure 1 is a schematic diagram of an architecture system applied to the development of an embedded system provided according to an embodiment of the present application;

[0018] Figure 2 is a flowchart of a running method of an embedded system provided according to an embodiment of the present application;

[0019] Figure 3 is a block diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0020] To enable those skilled in the art to better understand the solution of this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application.

[0021] It should be noted that the terms "first", "second", etc. in the description and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of this application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0022] Embodiment 1

[0023] As Figure 1 shown, the embodiment of the present invention provides an architecture system applied to embedded system development, including:

[0024] An application layer, which is used to execute business logic in the embedded system and manage the configuration of the embedded system, and the application layer is developed using Lua scripts.

[0025] Optionally, the above-mentioned business logic refers to the program logic for implementing specific functions in the embedded system, such as data acquisition, analysis and processing, device control, etc., which is the core function embodiment of the embedded system. The above-mentioned application layer is the key layer in the embedded system responsible for implementing its specific business logic and functions. This layer is used to process the specific tasks and algorithms executed when the embedded system interacts with the end user or external system, and provides various functions and services, such as device control, data processing, network communication, etc.

[0026] Optionally, the above Lua script is a lightweight scripting language that is widely used in embedded systems and game development. The Lua script provides rich programming interfaces and libraries, enabling the rapid construction of complex applications while consuming relatively few resources. The application layer uses the Lua scripting language for development because Lua has the advantages of being lightweight, executing quickly, and being easily embedded in embedded systems. The Lua script can provide a more flexible and efficient code implementation while reducing the code volume and development time. The Lua scripting language allows for dynamic loading and modification of code, enabling the addition or update of functions during the runtime of the embedded system without the need to recompile and restart the entire embedded system. This is particularly beneficial in scenarios of remote maintenance and software updates, reducing the need for on-site maintenance and saving costs. In the prior art, it is written in the C language. Once the program is compiled, modifying the function requires recompiling the entire program, which may mean reprogramming the firmware in an embedded system, increasing the complexity and cost of maintenance.

[0027] The hardware abstraction layer provides a unified hardware access interface.

[0028] Optionally, the above hardware abstraction layer can provide a unified interface for accessing and controlling hardware resources in the embedded system, such as processors, memory, peripherals, etc. The hardware abstraction layer encapsulates the differences in hardware platforms, enabling the application layer to perform hardware operations in a general way independent of the hardware platform, ensuring the portability and compatibility of the application layer code across different hardware architectures.

[0029] Optionally, the hardware abstraction layer is usually implemented in the C language because the C language can directly operate on hardware and provide high-performance operations. The hardware abstraction layer provides a set of application programming interfaces (Application Programming Interface, abbreviated as API) for each hardware resource. The API hides the specific details of the hardware, enabling the upper-layer software to be called in a unified manner.

[0030] The virtualization interface layer is used to provide a unified interface to the application layer, enabling the application layer to access the hardware resources of the hardware abstraction layer and call the system services in the embedded system.

[0031] Optionally, the above virtualization interface layer can provide a standardized, virtual interface, enabling the application layer to access the hardware resources and system services provided by the hardware abstraction layer through these interfaces. The above system services in the embedded system refer to a series of underlying functions provided by the hardware abstraction layer, such as task scheduling, interrupt management, file system operations, network communication, etc.

[0032] Optionally, to avoid difficulties in cross-platform migration, the virtualization interface layer can abstract the underlying hardware resources and encapsulate all hardware resources (such as GPIO, UART, I2C, etc.) and system services (such as task scheduling, interrupt handling, memory management, etc.) into a set of unified API interfaces. These interfaces should be as consistent and standardized as possible, enabling the application layer to access resources on different hardware platforms using the same methods, thereby improving the portability of the code in the embedded system.

[0033] In summary, the architecture system provided in the embodiments of the present application for embedded system development includes an application layer for executing business logic and managing the configuration of the embedded system in the embedded system, and the application layer is developed using Lua scripts; a hardware abstraction layer that provides a unified hardware access interface; and a virtualization interface layer for providing a unified interface to the application layer, enabling the application layer to access the hardware resources of the hardware abstraction layer and call the system services in the embedded system, solving the technical problem of difficult cross-platform migration in the embedded system using the direct programming method in C language, and thus achieving the technical effect of improving the portability of the code in the embedded system.

[0034] Optionally, in the architecture system provided in the embodiments of the present application for embedded system development, the application layer further includes:

[0035] A service management module for dynamically loading and unloading modules in the application layer.

[0036] Optionally, by interacting with the virtualization interface layer, the service management module can request to load specific modules in the application layer or unload existing modules in the application layer. When loading a module, it will parse the dependency relationships of the Lua scripts to ensure that all dependent modules and libraries are ready, and then load the module into the runtime environment of the Lua virtual machine. When unloading a module, the service management module will ensure the safe exit of the module and release all allocated resources, including memory, file handles, network connections, etc.

[0037] A configuration management module for parsing configuration files in JSON format.

[0038] Optionally, the configuration management module reads and parses configuration files in JSON format, and can convert the key-value pairs therein into data structures that the embedded system can understand. During the operation of the embedded system, the configuration management module will provide APIs for other modules to query configuration information. At the same time, the configuration management module is also responsible for monitoring updates to the configuration file. Once an update is detected, it will reload and parse the configuration file to update the configuration information in the embedded system.

[0039] A remote upgrade module for remotely updating Lua scripts.

[0040] Optionally, the remote upgrade module can check for updates on the remote server regularly or on demand. Once a new version of the Lua script is found, the remote upgrade module will download and verify the new version, and then update the local script file. After updating the script, the remote upgrade module will notify the Lua virtual machine to reload and execute the updated script to achieve seamless system upgrade.

[0041] The log management module is used to record the running logs of the embedded system at different levels.

[0042] Optionally, the log management module will be initialized when the embedded system starts, and the log recording level and output method will be configured. During the operation of the embedded system, each module can record logs by calling the API of the log management module. The logs can be output to the console, file or remote server for subsequent analysis and storage.

[0043] In summary, through the modules included in the above application layer, the application layer realizes the high flexibility and maintainability of the embedded system through functions such as dynamic loading and unloading, configuration management, remote upgrade and log recording. Through the collaborative work of these modules, not only the complexity of development and deployment is reduced, but also it is ensured that the embedded system can be flexibly cross-platform transplanted in different operating environments.

[0044] Optionally, in the architecture system provided in the embodiment of the present application for embedded system development, the virtualization interface layer further includes:

[0045] A virtual machine for reading, parsing and executing Lua scripts.

[0046] Optionally, when the application layer requests to execute a Lua script, the virtual machine will first read the Lua source code file and use the Lua compiler to convert it into bytecode. Then, the interpreter of the virtual machine will interpret and execute these bytecode instructions one by one to implement the functions of the script. During the execution process, the virtual machine will call the data conversion interface to handle the data type differences between C language and Lua scripts to ensure the correct transfer and use of data.

[0047] The hardware control interface is used to encapsulate the interfaces of the hardware abstraction layer into Lua functions for the application layer to call.

[0048] Optionally, the hardware control interface is responsible for encapsulating the C language APIs in the hardware abstraction layer into Lua functions, so that the application layer can indirectly access and control hardware resources through Lua scripts. This not only hides the complexity of the hardware, but also simplifies the development of the application layer, making it more focused on the implementation of business logic.

[0049] The system service interface is used to provide system services such as timers and message queues.

[0050] Optionally, the above-mentioned timer refers to a hardware or software function used to trigger an event or interrupt after a specific time interval. A message queue refers to a data structure for inter-process communication that stores messages waiting to be processed, enabling asynchronous communication and decoupling between tasks.

[0051] A data conversion interface for converting data types between C language and Lua scripts.

[0052] Optionally, when a C language function needs to pass data to a Lua script or a Lua script needs to call a C language function, the data conversion interface automatically converts the data from one type to another. For example, converting an integer type in C to a numeric type in Lua, or converting a string in Lua to a character array in C.

[0053] A debugging interface for providing breakpoint and single-step debugging functions.

[0054] Optionally, the debugging interface provides a series of debugging functions through the virtual machine, allowing developers to set breakpoints in the Lua script. When the Lua script executes to a breakpoint, the virtual machine pauses the execution of the script, allowing developers to check variable states, memory usage, and the execution path. The single-step execution function enables developers to execute the script step by step and observe the changes at each step.

[0055] In summary, through components such as the virtual machine, hardware control interface, system service interface, data conversion interface, and debugging interface in the above virtualization interface layer, the application layer can efficiently and flexibly access hardware resources and system services through Lua scripts, while ensuring the correctness and debuggability of the code.

[0056] Optionally, in the architecture system applied to embedded system development provided in the embodiments of the present application, the hardware abstraction layer further includes:

[0057] A basic driver module for driving the underlying microcontroller unit peripherals in the embedded system and providing a driver interface.

[0058] Optionally, the above microcontroller unit is a microcomputer system that integrates a processor, memory, and peripherals on a single chip and is widely used in embedded systems. The basic driver module is responsible for interacting with the peripherals of the microcontroller unit in the embedded system and providing necessary driver functions. The peripherals of the microcontroller unit can include GPIO (General-Purpose Input / Output), UART (Universal Asynchronous Receiver / Transmitter), I2C (Inter-Integrated Circuit), SPI (Serial Peripheral Interface), etc. The basic driver module provides a set of unified APIs for the underlying operations of the peripherals, enabling upper-layer software to access and control these hardware resources in a unified manner.

[0059] The interrupt handling module is responsible for registering interrupts, distributing interrupts, and handling interrupts in the embedded system, and managing interrupt priorities.

[0060] Optionally, the interrupt handling module is used to manage hardware interrupts in the embedded system, including registering interrupts, distributing interrupts, and handling interrupts. An interrupt is an emergency signal sent by a hardware device to the processor to request the processor to immediately respond to certain events, such as the completion of peripheral data reception, timer timeout, etc. The interrupt handling module can also be responsible for managing interrupt priorities to ensure that high-priority interrupts can be responded to by the processor first.

[0061] The task scheduling module is used to perform task scheduling based on priorities.

[0062] Optionally, the task scheduling module is used to manage the multi-task environment in the embedded system. The task scheduling module decides which task should be allocated processor resources based on the priorities and states of the tasks. Multi-task scheduling is a key technology for handling concurrent events and tasks in embedded systems, which can optimize resource utilization and improve the overall efficiency and response speed of the embedded system.

[0063] Optionally, the task scheduling module maintains a task list. Each task has its priority, state (such as ready, running, waiting, etc.), and a time slice. When the processor is idle, the task scheduling module will select the highest-priority ready task according to the priority and allocate processor resources for this task to execute.

[0064] The memory management module is used to allocate memory, recycle memory, and defragment memory in the embedded system.

[0065] Optionally, the memory management module is responsible for the allocation, recycling, and fragmentation management of memory resources in the embedded system, ensuring that the embedded system can efficiently use memory resources and avoiding performance degradation caused by memory leaks and fragmentation. The memory management module can use an algorithm called "heap management" to maintain a memory pool for allocation and recycling. When a task requests memory, the memory management module allocates an appropriate memory area from the memory pool. When the task no longer needs this memory, it returns it to the memory pool, and the memory management module is responsible for recycling this memory and performing fragmentation management to maintain the continuity of memory. To improve efficiency, the memory management module can also adopt strategies such as fast allocation and deferred recycling to avoid frequent memory allocation and recycling operations.

[0066] In summary, the above hardware abstraction layer provides a powerful and flexible set of hardware control and resource management capabilities for the embedded system through modules such as the basic driver, interrupt handling, task scheduling, and memory management. This not only simplifies the development of the upper-layer software but also ensures the efficient operation and real-time performance of the embedded system, making it an indispensable part of embedded system development.

[0067] Optionally, in the architecture system provided in the embodiments of the present application for embedded system development, the virtual machine further includes:

[0068] A garbage collection module for performing garbage collection using the generational garbage collection algorithm.

[0069] Optionally, the above garbage collection module is a key component in the virtual machine for automatically managing memory allocation and memory release. During the execution of Lua scripts, the garbage collection module is responsible for identifying objects that are no longer referenced and releasing the memory they occupy to avoid memory leaks and memory fragmentation problems.

[0070] Optionally, the above generational garbage collection algorithm is an algorithm that determines the recycling strategy based on the lifespan of objects. The generational garbage collection algorithm assumes that objects can be divided into a "young generation" and an "old generation" according to their lifespan. Objects in the "young" generation usually have a short lifespan and will be recycled frequently; while objects in the "old generation" have a long lifespan and longer recycling intervals. During garbage collection, the virtual machine pauses all running Lua scripts, checks the reference relationships of all active objects, and then releases the memory occupied by those objects that are no longer referenced according to the generational algorithm.

[0071] A memory management module for recycling and allocating memory.

[0072] Optionally, the above memory management module is responsible for allocating and recycling memory in the Lua virtual machine, ensuring that all running Lua scripts and data structures have sufficient memory available, while minimizing memory fragmentation and improving memory usage efficiency.

[0073] Optionally, the memory management module can adopt the memory pool technology, that is, allocate a large block of memory in advance when the virtual machine starts, and then divide this block of memory into multiple small blocks for Lua scripts to use. When a Lua script requests memory, the memory management module will allocate a suitable block of memory from the pool. When the script no longer needs this block of memory, the garbage collection module will mark it as recyclable, and the memory management module will recycle this block of memory and put it back into the memory pool at an appropriate time. To improve efficiency, the memory management module can also adopt technologies such as fast allocation, deferred recycling, and memory compression.

[0074] An exception handling module, which is used to catch and handle exceptions when a Lua script is running.

[0075] Optionally, the exception handling module can be used to catch and handle various exception situations when a Lua script is running, such as runtime errors, type mismatches, division-by-zero errors, etc. The exception handling module monitors the execution of the Lua script. Once an exception is detected, it can immediately pause the execution of the script and collect information about the exception, such as the line number where the exception occurred, the exception type, and the error message. Then, the exception handling module can handle the exception according to predefined exception handling policies, which can include stopping the execution of the script, restoring to the previous safe state, logging the error, or notifying the application layer for error handling. The exception handling module can also support user-defined exception handling functions, allowing developers to customize the exception handling behavior.

[0076] In summary, through the garbage collection module, memory management module, and exception handling module in the above virtual machine, they jointly constitute the cornerstone for the safe and efficient execution of Lua scripts. The garbage collection module automatically manages memory through the generational garbage collection algorithm to prevent memory leaks and fragmentation; the memory management module adopts the memory pool technology to optimize the memory allocation and recycling process; the exception handling module ensures the security during script execution, can catch and handle exceptions in a timely manner, and avoids the risk of system-level crashes. The design and implementation of these modules significantly improve the reliability and performance of developing with Lua scripts in embedded systems.

[0077] Optionally, in the architecture system provided in the embodiments of the present application for embedded system development, the development environment of the embedded system includes:

[0078] An integrated development management module, which is used to provide functions for code editing, compilation, and debugging.

[0079] Optionally, the above integrated development management module is the cornerstone of embedded system development, providing a centralized environment for code editing, compilation, and debugging. The integrated development management module enables developers to complete the entire development process from writing code to testing code under a unified interface, greatly improving the development efficiency and code quality.

[0080] Optionally, the integrated development management module may include a code editor for writing C code and Lua scripts; a compiler or build tool for compiling the C code into an executable binary file and packaging the Lua scripts into the final firmware; and a debugger for discovering and fixing code errors during development. The development management module may also include functions such as a version control system, a project management tool, and a code analysis tool to help developers better manage the code and projects.

[0081] An emulation and debugging tool for online emulation of the hardware in the embedded system.

[0082] Optionally, the above emulation and debugging tool is used to simulate the hardware behavior of the embedded system during development, enabling developers to test and debug the code without actual hardware. This is very useful in the early development stage when the hardware is not yet ready or for debugging complex hardware operations.

[0083] Optionally, the emulation and debugging tool can simulate the hardware environment of the embedded system through software, including the processor, memory, peripherals, and communication protocols. During the testing and debugging process, developers can use the interfaces provided by the emulation tool to check whether the logic and functions of the code are correct. The emulation tool also provides real-time monitoring and debugging functions to help developers understand the execution flow and status of the code.

[0084] A performance analysis tool for analyzing metrics such as the processor occupancy rate and memory usage in the embedded system.

[0085] Optionally, the performance analysis tool can collect various performance data during development or when the embedded system is running, including the processor occupancy rate, memory usage, task scheduling, interrupt response time, etc. These data can be displayed in the form of graphs or reports. The performance analysis tool can also provide performance optimization suggestions, such as reducing the number of calls to specific functions, optimizing the use of data structures, and reducing memory allocation.

[0086] A remote maintenance tool for remote debugging of devices applying the embedded system and program updates in the embedded system.

[0087] Optionally, the remote maintenance tool can communicate with the embedded device through network protocols such as TCP / IP, UDP, HTTP, etc. The remote maintenance tool can provide a graphical interface or a command-line interface, allowing users to remotely execute debugging commands, view the system status, update configuration files or firmware. When performing firmware updates, the remote maintenance tool will download the new firmware package to the non-volatile memory of the device and then restart the device to load and run the new firmware.

[0088] In summary, the integrated development management module, simulation debugging tool, performance analysis tool, and remote maintenance tool together constitute the development environment for embedded system development, providing a complete solution from code writing, testing, optimization to remote management. The application of these tools greatly simplifies the complexity of embedded system development, improves development efficiency and code quality, and also reduces the later maintenance cost. They are an indispensable part of embedded system development.

[0089] Embodiment 2

[0090] According to the embodiments of the present application, an architecture system embodiment for embedded system development is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0091] The present application provides a Figure 2 running method for the embedded system as shown. Figure 2 is a flowchart of the running method of the embedded system according to Embodiment 2 of the present application.

[0092] Step S201, initialize the virtual machine in the virtualization interface layer.

[0093] Optionally, when the embedded system starts, the virtual machine in the virtualization interface layer needs to be initialized, which may include setting the running environment of the virtual machine, allocating necessary memory space, loading the Lua interpreter and predefined library functions, and setting the garbage collection mechanism and exception handling mechanism.

[0094] Step S202, initialize the basic driver module, interrupt handling module, real-time task scheduling module, and memory management module of the hardware abstraction layer. Among them, the basic driver module is used to drive the underlying layer of the microcontroller unit peripherals in the embedded system and provide a driver interface. The interrupt handling module is responsible for registering interrupts, distributing interrupts, and handling interrupts in the embedded system, and managing interrupt priorities. The task scheduling module is used to perform task scheduling based on priorities, and the memory management module is used to allocate, recycle, and fragment the memory in the embedded system.

[0095] Optionally, the initialization of the hardware abstraction layer provides a unified hardware access interface for the embedded system, enabling the upper application layer or virtual machine to interact with the hardware in a consistent manner without caring about the specific implementation details of the underlying hardware. This not only reduces the cross-platform complexity of the embedded system, improves the code reuse rate, but also makes the development of the embedded system more modular, facilitating maintenance and upgrade.

[0096] Step S203: Start the virtual machine and run the Lua script at the application layer.

[0097] Optionally, after the virtual machine is started, it can read and parse the Lua script at the application layer, translate it into bytecode, and then execute it in the interpreter of the virtual machine. The Lua script can contain various business logics and algorithms, as well as calls to the hardware abstraction layer modules for controlling the hardware and executing system tasks. During the execution process, the virtual machine is responsible for handling data type conversion, memory management, and exception handling to ensure the correctness and stability of the script.

[0098] Step S204: Through the virtual machine, the application layer calls the basic driver module, interrupt handling module, real-time task scheduling module, and memory management module in the hardware abstraction layer.

[0099] Optionally, during the execution of the Lua script at the application layer, it can call each module in the hardware abstraction layer through the virtual machine. For example, when the script needs to read and write general-purpose input / output ports, it can call the corresponding interface in the virtual machine, and then the virtual machine calls the basic driver module in the hardware abstraction layer to actually operate the general-purpose input / output registers. When the script needs to handle interrupt events, it can register a Lua function for interrupt handling, and the virtual machine maps this function to the interrupt handling module in the hardware abstraction layer. When the hardware generates an interrupt, the interrupt handling module will call this function. For real-time task scheduling and memory management, the Lua script also interacts with the corresponding modules in the hardware abstraction layer through the virtual machine.

[0100] The running method of the embedded system provided by the embodiment of the present application initializes the virtual machine in the virtualization interface layer; initializes the basic driver module, interrupt handling module, real-time task scheduling module, and memory management module in the hardware abstraction layer. Among them, the basic driver module is used to drive the bottom layer of the microcontroller unit peripherals in the embedded system and provide a driver interface. The interrupt handling module is responsible for registering, distributing, and handling interrupts in the embedded system and managing the interrupt priority. The task scheduling module is used to perform task scheduling based on priorities. The memory management module is used to allocate, recycle, and defragment the memory in the embedded system. It starts the virtual machine and runs the Lua script at the application layer. Through the virtual machine, the application layer calls the basic driver module, interrupt handling module, real-time task scheduling module, and memory management module in the hardware abstraction layer, solving the problem that the direct programming method using C language in the related embedded system makes cross-platform transplantation difficult. Thus, the effect of improving the portability of the code in the embedded system is achieved.

[0101] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0102] Embodiment 3

[0103] An embodiment of the present application can provide a computer terminal, and the computer terminal can be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the above computer terminal can also be replaced with a mobile terminal or an electronic device and other terminal devices.

[0104] Optionally, in this embodiment, the above computer terminal can be located in at least one of a plurality of network devices in a computer network.

[0105] In this embodiment, the above computer terminal can execute the program code of the following steps in the running method of the embedded system: initialize the virtual machine in the virtualization interface layer; initialize the basic driver module, interrupt processing module, real-time task scheduling module, and memory management module of the hardware abstraction layer, where the basic driver module is used to drive the bottom layer of the microcontroller unit peripherals in the embedded system and provide a driver interface, the interrupt processing module is used to be responsible for the registration, distribution, and processing of interrupts in the embedded system, manage the interrupt priority, the task scheduling module is used to perform task scheduling based on the priority, and the memory management module is used to allocate, recycle, and defragment the memory in the embedded system; start the virtual machine and run the Lua script in the application layer; through the virtual machine, the application layer calls the basic driver module, interrupt processing module, real-time task scheduling module, and memory management module in the hardware abstraction layer.

[0106] Optionally, Figure 3 is a structural block diagram of an electronic device according to an embodiment of the present application. As Figure 3 shown, the electronic device can include: one or more ( Figure 3 only one is shown in the figure) processors 302, a memory 304, a storage controller, and a peripheral interface, where the peripheral interface is connected to a radio frequency module, an audio module, and a display.

[0107] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the running method and device of the embedded system in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implements the running method of the above-mentioned embedded system. The memory can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory can further include a memory remotely set relative to the processor, and these remote memories can be connected to the terminal through a network. Examples of the above network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.

[0108] The processor can call the information and application programs stored in the memory through the transmission device to execute the above steps in the running method of the above-mentioned embedded system.

[0109] Adopting the embodiments of the present application provides a solution for running an embedded system. By initializing the virtual machine in the virtualization interface layer; initializing the basic driver module, interrupt processing module, real-time task scheduling module, and memory management module of the hardware abstraction layer, where the basic driver module is used to drive the bottom layer of the microcontroller unit peripherals in the embedded system and provide a driver interface, the interrupt processing module is used to be responsible for the registration, distribution, and processing of interrupts in the embedded system, manage the interrupt priority, the task scheduling module is used to perform task scheduling based on priorities, and the memory management module is used to allocate, recycle, and defragment the memory in the embedded system; starting the virtual machine and running the Lua script in the application layer; through the virtual machine, the application layer calls the basic driver module, interrupt processing module, real-time task scheduling module, and memory management module in the hardware abstraction layer, which solves the problem that the cross-platform transplantation is difficult in the related art due to the direct programming method using the C language in the embedded system. Furthermore, the effect of improving the portability of the code in the embedded system is achieved.

[0110] Those of ordinary skill in the art can understand that Figure 3 The structure shown is only schematic, and the electronic device can also be a terminal device such as a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, and a Mobile Internet Device (MID), a PAD, etc. Figure 3 It does not limit the structure of the above-mentioned electronic device. For example, the electronic device may further include more or fewer components (such as a network interface, a display device, etc.) than those shown Figure 3 in the figure, or have a different configuration from that shown Figure 3 in the figure.

[0111] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, and the storage medium can include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, an optical disk, etc.

[0112] Embodiment 4

[0113] An embodiment of the present application also provides a computer-readable storage medium. Optionally, in this embodiment, the above storage medium can be used to store the program code executed by the running method of the embedded system provided in the first embodiment above.

[0114] Optionally, in this embodiment, the above storage medium can be located in any one of the computer terminals in the computer terminal group in the computer network, or in any one of the mobile terminals in the mobile terminal group.

[0115] Optionally, in this embodiment, the storage medium is set to store the program code for performing the following steps: initializing the virtual machine in the virtualization interface layer; initializing the basic driver module, the interrupt processing module, the real-time task scheduling module, and the memory management module of the hardware abstraction layer, where the basic driver module is used to drive the bottom layer of the microcontroller unit peripherals in the embedded system and provide a driver interface, the interrupt processing module is used to be responsible for the registration of interrupts, the distribution of interrupts, and the processing of interrupts in the embedded system, manage the interrupt priority, the task scheduling module is used to perform task scheduling based on the priority, and the memory management module is used to allocate, recycle, and defragment the memory in the embedded system; starting the virtual machine and running the Lua script in the application layer; through the virtual machine, the application layer calls the basic driver module, the interrupt processing module, the real-time task scheduling module, and the memory management module in the hardware abstraction layer.

[0116] The present application also provides a computer program product, which is suitable for executing the program of the steps of the running method of the embedded system when executed on a data processing device.

[0117] The serial numbers of the above embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.

[0118] In the above embodiments of the present application, the descriptions of the various embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0119] In several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of units or modules can be in electrical or other forms.

[0120] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0121] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

[0122] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs, and other media that can store program codes.

[0123] The above is only the preferred embodiment of the present application. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.

Claims

1. An architecture system applied to the development of embedded systems, characterized in that, including: An application layer, which is used to execute business logic in an embedded system and manage the configuration of the embedded system. The application layer is developed using Lua scripts. A hardware abstraction layer, which provides a unified hardware access interface. A virtualization interface layer, which is used to provide a unified interface to the application layer, enabling the application layer to access the hardware resources of the hardware abstraction layer and call the system services in the embedded system.

2. The system according to claim 1, characterized in that, The application layer further includes: A service management module, which is used to dynamically load and unload modules in the application layer. A configuration management module, which is used to parse configuration files in JSON format. A remote upgrade module, which is used to remotely update Lua scripts. A log management module, which is used to record the running logs of the embedded system at different levels.

3. The system according to claim 1, wherein The virtualization interface layer further includes: A virtual machine, which is used to read, parse, and execute Lua scripts. A hardware control interface, which is used to encapsulate the interfaces of the hardware abstraction layer into Lua functions for the application layer to call. A system service interface, which is used to provide system services such as timers and message queues. A data conversion interface, which is used to convert data types between C language and Lua scripts. A debugging interface, which is used to provide debugging functions such as breakpoints and single-stepping.

4. The system according to claim 3, wherein The hardware abstraction layer further includes: A basic driver module, which is used to drive the underlying microcontroller unit peripherals in the embedded system and provide driver interfaces. An interrupt handling module, which is responsible for registering, distributing, and handling interrupts in the embedded system and managing interrupt priorities. A task scheduling module, which is used to perform task scheduling based on priorities. A memory management module, which is used to allocate, recycle, and defragment the memory in the embedded system.

5. The system according to claim 4, wherein The virtual machine further includes: A garbage collection module, which is used to perform garbage collection using a generational garbage collection algorithm. A memory management module, which is used to recycle and allocate memory. An exception handling module, which is used to capture and handle exceptions when Lua scripts are running.

6. The system according to claim 1, wherein The development environment of the embedded system includes: An integrated development management module, which is used to provide functions such as code editing, compilation, and debugging. An emulation debugging tool, which is used to perform online emulation of the hardware in the embedded system. A performance analysis tool, which is used to analyze metrics such as processor occupancy and memory usage in the embedded system. A remote maintenance tool, which is used to remotely debug devices applying the embedded system and update programs in the embedded system.

7. A running method of an embedded system, which applies the architecture system for embedded system development described in any one of claims 1-6, characterized in that, including: Initializing the virtual machine in the virtualization interface layer. Initialize the basic driver module, interrupt handling module, real-time task scheduling module, and memory management module of the hardware abstraction layer. Among them, the basic driver module is used to drive the bottom layer of the microcontroller unit peripherals in the embedded system and provide a driver interface. The interrupt handling module is responsible for registering interrupts, distributing interrupts, and handling interrupts in the embedded system, and manages interrupt priorities. The task scheduling module is used to perform task scheduling based on priorities. The memory management module is used to allocate memory in the embedded system, recycle the memory, and defragment the memory; Start the virtual machine and run the Lua script in the application layer; Through the virtual machine, the application layer calls the basic driver module, the interrupt handling module, the real-time task scheduling module, and the memory management module in the hardware abstraction layer.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program. When the executable program runs, it controls the device where the computer-readable storage medium is located to execute the running method of the embedded system according to claim 7.

9. An electronic device, characterized in that, Comprising: A memory storing an executable program; A processor for running the program. When the program runs, it executes the running method of the embedded system according to claim 7.

10. A computer program product, comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, the steps of the running method of the embedded system according to claim 7 are implemented.

Citation Information

Patent Citations

  • Method for software development of an embedded single chip microcomputer and a storage medium

    CN109358839A

  • Embedded abstract virtual machine system for edge computing

    CN115495201A

  • Embeded system based on script programming language and operation method thereof

    KR1020110108143A

Cited By

  • Embedded development method, system and equipment based on artificial intelligence and storage medium

    CN120780288A

  • Artificial intelligence-based embedded development method, system, device and storage medium

    CN120780288B

  • RMU management platform and method compatible with multiple embedded platforms

    CN121728132A