A microcontroller operation method and terminal

By using the kernel program to manage independent storage space in the microcontroller, the problems of complex microcontroller operating system program structure and large resource consumption are solved, achieving stable operation of the program and efficient utilization of resources, and improving the applicability rate.

CN113407250BActive Publication Date: 2024-08-30SHENZHEN INHEMETER
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110491229.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-06
Publication Date
2024-08-30
Estimated Expiration
2041-05-06

AI Technical Summary

Technical Problem

The operating system program structure of existing microcontrollers is complex and lacks independent storage space, resulting in unstable program operation. In addition, large-scale operating systems consume excessive resources and are not suitable for microcontrollers.

Method used

A microcontroller operating method is adopted to receive space allocation requests through the kernel program, allocate independent storage space, and initialize the kernel program to create and manage applications and device drivers, avoiding file system management and achieving independent operation of the program.

Benefits of technology

Managing applications and device drivers through the kernel program avoids program running conflicts, reduces file size, and improves the applicability and resource utilization of the microcontroller.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113407250B
    Figure CN113407250B
Patent Text Reader

Abstract

The invention discloses an operation method and a terminal of a microcontroller. Corresponding independent storage spaces are allocated to a kernel program, an application program and a device driver of the microcontroller according to a space allocation request, thereby avoiding the situation where each program runs on the same or overlapping space due to the absence of a memory management unit. The kernel program is used to obtain the creation information of the application program and the device driver, and the application program and the device driver are created and started, thereby directly calling the data of the application program and the device driver in the storage space through the kernel program, without the need to introduce a file system to manage the memory, thereby greatly reducing the file size of the microcontroller, and enabling the storage spaces of the kernel program, the application program and the device driver to be independent of each other, thereby improving the applicability of the microcontroller.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of controllers, and in particular to an operating method and a terminal of a microcontroller. Background Art

[0002] As living standards continue to improve, people have more and more demands for the functions of electronic products, making program design more and more complicated. If the program structure is not designed well, the program will be complicated, which is not conducive to the development, maintenance, and transplantation of product programs. Therefore, large-scale operating systems for high-end controllers, such as Windows, Linux, Android, and iOS, have emerged. They can all achieve the independence of operating system programs, device drivers, and application programs, making the program structure clear.

[0003] However, running a large operating system requires a lot of ROM (Read-Only Memory) and RAM (Random Access Memory) space, and the controller itself needs to have an MMU (Memory Management Unit) function to achieve the conversion between virtual addresses and physical addresses to prevent various applications from running in the same or overlapping space. Due to the limitations of the above conditions, the program structure of large operating systems is not suitable for microcontrollers.

[0004] Therefore, small real-time operating systems tailored for microcontrollers have emerged, such as free-rtos, rt-thread, ucos, uclinux, etc. However, in the current application field of microcontrollers, except for uclinux, which can realize the independence of operating system programs, device drivers, and applications, others do not support this method. Moreover, although uclinux can implement this method, it requires the support of the file system, so the minimum ROM space consumed is several hundred KB, which cannot meet the requirements of many microcontrollers. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide an operating method and a terminal of a microcontroller, which can improve the applicability of the microcontroller.

[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0007] A method for operating a microcontroller comprises the steps of:

[0008] Receive a space allocation request, and allocate corresponding independent storage space for a kernel program, an application program, and a device driver of the microcontroller according to the space allocation request;

[0009] Starting and initializing the kernel program, obtaining creation information of the application program and the device driver through the kernel program, and creating and starting the application program and the device driver according to the obtained creation information;

[0010] All of the application programs and device drivers are managed by the kernel program.

[0011] In order to solve the above technical problems, another technical solution adopted by the present invention is:

[0012] A microcontroller operation terminal comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0013] Receive a space allocation request, and allocate corresponding independent storage space for a kernel program, an application program, and a device driver of the microcontroller according to the space allocation request;

[0014] Starting and initializing the kernel program, obtaining creation information of the application program and the device driver through the kernel program, and creating and starting the application program and the device driver according to the obtained creation information;

[0015] All of the application programs and device drivers are managed by the kernel program.

[0016] The beneficial effects of the present invention are as follows: corresponding independent storage spaces are allocated to the kernel program, application program and device driver program of the microcontroller according to the space allocation request, thereby avoiding the situation that the various programs run in the same or overlapping spaces due to the absence of a memory management unit; the kernel program is used to obtain the creation information of the application program and the device driver program, and the application program and the device driver program are created and started, so that the data of the application program and the device driver program in the storage space are directly called through the kernel program, and there is no need to introduce a file system to manage the memory, thereby greatly reducing the file size of the microcontroller, and enabling the storage spaces of the kernel program, application program and device driver program to be independent of each other, thereby improving the applicability of the microcontroller. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A flowchart of a method for operating a microcontroller according to an embodiment of the present invention;

[0018] Figure 2 A schematic diagram of an operating terminal of a microcontroller according to an embodiment of the present invention;

[0019] Figure 3 The present invention is a flowchart of the specific steps of a method for operating a microcontroller according to an embodiment of the present invention. DETAILED DESCRIPTION

[0020] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.

[0021] Please refer to Figure 1 , an embodiment of the present invention provides a method for operating a microcontroller, comprising the steps of:

[0022] Receive a space allocation request, and allocate corresponding independent storage space for a kernel program, an application program, and a device driver of the microcontroller according to the space allocation request;

[0023] Starting and initializing the kernel program, obtaining creation information of the application program and the device driver through the kernel program, and creating and starting the application program and the device driver according to the obtained creation information;

[0024] All of the application programs and device drivers are managed by the kernel program.

[0025] From the above description, it can be seen that the beneficial effects of the present invention are: corresponding independent storage space is allocated to the kernel program, application program and device driver program of the microcontroller according to the space allocation request, which can avoid the running of each program in the same or overlapping space due to the absence of a memory management unit; the kernel program is used to obtain the creation information of the application program and the device driver program, and the application program and the device driver program are created and started, so that the data of the application program and the device driver program in the storage space are directly called through the kernel program, and there is no need to introduce a file system to manage the memory, thereby greatly reducing the file size of the microcontroller, and can make the storage space of the kernel program, application program and device driver program independent of each other, thereby improving the applicability of the microcontroller.

[0026] Further, obtaining creation information of the application program and the device driver through the kernel program, and creating the application program and the device driver according to the obtained creation information includes:

[0027] Searching for creation information of the application program and the device driver through the kernel program;

[0028] Determine whether the creation information satisfies the conditions for creating the application and the device driver. If so, create the corresponding application and the device driver according to the creation information, and return to the above step of searching for the creation information of the application and the device driver through the kernel program until all the creation information is found or the number of created application and device drivers reaches a preset number;

[0029] If not, return to the above step of searching the creation information of the application program and the device driver through the kernel program.

[0030] From the above description, it can be seen that by querying the creation information of applications and device drivers through the kernel program and creating corresponding applications and device drivers, the creation of applications and device drivers can be managed directly through the kernel program, thereby managing the storage space of applications and device drivers, without using a memory management unit to manage the memory of each program.

[0031] Further, after creating and starting the application and the device driver according to the acquired creation information, the following steps are included:

[0032] Sending the data access interface of the kernel program to the application program and the device driver;

[0033] The data access interface enables the application program and the device driver to access the data in the kernel program.

[0034] From the above description, it can be seen that the kernel program provides a data access interface to applications and device drivers, enabling device drivers and applications to access interface functions published by the kernel, as well as access to all published interface functions between applications, adaptively solving the data access problem when the storage spaces of device drivers, applications, and kernel programs are independent of each other.

[0035] Further, managing all the application programs through the kernel program includes:

[0036] Scheduling all application programs through the scheduler of the kernel program;

[0037] All the application programs are upgraded by executing the upgrade program in the kernel program.

[0038] From the above description, it can be seen that scheduling and upgrading applications through the kernel program can uniformly manage applications through the kernel program, and the kernel program can be adaptively used to schedule and upgrade applications without configuring the file system or memory management unit, thereby improving the applicability of the microcontroller.

[0039] Furthermore, the step of obtaining the creation information of the application program and the device driver through the kernel program further includes:

[0040] Acquiring creation information of the application program and the device driver through the kernel program, and creating a thread synchronization mechanism in the kernel program according to the creation information;

[0041] Managing all of the application programs and device drivers through the kernel program also includes:

[0042] The data of the application program and the device driver are synchronized and shared according to the thread synchronization mechanism in the kernel program.

[0043] From the above description, it can be seen that a thread synchronization mechanism is created in the kernel program according to the actual application needs to achieve data synchronization and sharing between applications, while also achieving device driver data synchronization, and memory management can be performed without setting up a memory management unit and a file system.

[0044] Please refer to Figure 2 Another embodiment of the present invention provides an operating terminal of a microcontroller, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0045] Receive a space allocation request, and allocate corresponding independent storage space for a kernel program, an application program, and a device driver of the microcontroller according to the space allocation request;

[0046] Starting and initializing the kernel program, obtaining creation information of the application program and the device driver through the kernel program, and creating and starting the application program and the device driver according to the obtained creation information;

[0047] All of the application programs and device drivers are managed by the kernel program.

[0048] From the above description, it can be seen that corresponding independent storage space is allocated to the kernel program, application program and device driver of the microcontroller according to the space allocation request, which can avoid the running of various programs in the same or overlapping space due to the lack of a memory management unit; the kernel program is used to obtain the creation information of the application program and the device driver, and to create and start the application program and the device driver, so that the data of the application program and the device driver in the storage space can be directly called through the kernel program, and there is no need to introduce a file system to manage the memory. Therefore, the file size of the microcontroller is greatly reduced, and the storage space of the kernel program, application program and device driver can be made independent of each other, thereby improving the applicability of the microcontroller.

[0049] Further, obtaining creation information of the application program and the device driver through the kernel program, and creating the application program and the device driver according to the obtained creation information includes:

[0050] Searching for creation information of the application program and the device driver through the kernel program;

[0051] Determine whether the creation information satisfies the conditions for creating the application and the device driver. If so, create the corresponding application and the device driver according to the creation information, and return to the above step of searching for the creation information of the application and the device driver through the kernel program until all the creation information is found or the number of created application and device drivers reaches a preset number;

[0052] If not, return to the above step of searching the creation information of the application program and the device driver through the kernel program.

[0053] From the above description, it can be seen that by querying the creation information of applications and device drivers through the kernel program and creating corresponding applications and device drivers, the creation of applications and device drivers can be managed directly through the kernel program, thereby managing the storage space of applications and device drivers, without using a memory management unit to manage the memory of each program.

[0054] Further, after creating and starting the application and the device driver according to the acquired creation information, the following steps are included:

[0055] Sending the data access interface of the kernel program to the application program and the device driver;

[0056] The data access interface enables the application program and the device driver to access the data in the kernel program.

[0057] From the above description, it can be seen that the kernel program provides a data access interface to applications and device drivers, enabling device drivers and applications to access interface functions published by the kernel, as well as access to all published interface functions between applications, adaptively solving the data access problem when the storage spaces of device drivers, applications, and kernel programs are independent of each other.

[0058] Further, managing all the application programs through the kernel program includes:

[0059] Scheduling all application programs through the scheduler of the kernel program;

[0060] All the application programs are upgraded by executing the upgrade program in the kernel program.

[0061] From the above description, it can be seen that scheduling and upgrading applications through the kernel program can uniformly manage applications through the kernel program, and the kernel program can be adaptively used to schedule and upgrade applications without configuring the file system or memory management unit, thereby improving the applicability of the microcontroller.

[0062] Furthermore, the step of obtaining the creation information of the application program and the device driver through the kernel program further includes:

[0063] Acquiring creation information of the application program and the device driver through the kernel program, and creating a thread synchronization mechanism in the kernel program according to the creation information;

[0064] Managing all of the application programs and device drivers through the kernel program also includes:

[0065] The data of the application program and the device driver are synchronized and shared according to the thread synchronization mechanism in the kernel program.

[0066] From the above description, it can be seen that a thread synchronization mechanism is created in the kernel program according to the actual application needs to achieve data synchronization and sharing between applications, while also achieving device driver data synchronization, and memory management can be performed without setting up a memory management unit and a file system.

[0067] The above-mentioned microcontroller operation method and terminal of the present invention are suitable for realizing the independence of kernel programs, device drivers and application programs in various microcontrollers, and do not require support from a file system or a memory management system. The following is an explanation through specific implementation methods:

[0068] Embodiment 1

[0069] Please refer to Figure 1 , a method for operating a microcontroller, comprising the steps of:

[0070] S1, receiving a space allocation request, and allocating corresponding independent storage space for a kernel program, an application program, and a device driver of a microcontroller according to the space allocation request;

[0071] Specifically, in this embodiment, the program structure of the microcontroller includes a kernel program, an application program and a device driver program, wherein the kernel program is developed based on the real-time operating system kernel, and realizes operations such as creation, startup, scheduling, and upgrading of application programs, and provides a communication interface for each application program; the application program is an indispensable part of software design, and is one or more programs that realize functional requirements, and it contains one or more tasks; the device driver program is for the external devices of the microcontroller, such as memory, display, communication, LED, buttons, etc., and can provide a unified read, write, set, reset and other operation interface, and is a bridge for the application program to access the external device;

[0072] Based on the space allocation request, the corresponding ROM and RAM storage space is allocated in the kernel program, application program and device driver program according to their respective space requirements, where each program is independent of each other in space and does not overlap;

[0073] S2, starting and initializing the kernel program, obtaining creation information of the application program and the device driver through the kernel program, and creating and starting the application program and the device driver according to the obtained creation information;

[0074] Wherein, obtaining the creation information of the application program and the device driver through the kernel program, and creating and starting the application program and the device driver according to the obtained creation information includes:

[0075] Searching for creation information of the application program and the device driver through the kernel program;

[0076] Determine whether the creation information satisfies the conditions for creating the application and the device driver. If so, create the corresponding application and the device driver according to the creation information, and return to the above step of searching for the creation information of the application and the device driver through the kernel program until all the creation information is found or the number of created application and device drivers reaches a preset number;

[0077] If not, return to the above step of searching the creation information of the application program and the device driver through the kernel program;

[0078] Specifically, in this embodiment, the device driver and the application need to provide the necessary creation information to the kernel program, and the kernel program creates and starts the device driver and the application through the provided creation information, and the creation information includes the interface function and data structure information published by the device driver and the application;

[0079] Please refer to Figure 3 After the kernel program is started, it searches for the creation information provided by the device driver and the application. If the creation information meets the conditions for creating a program, the corresponding program is created until all the information is searched or the created program reaches the preset number of allowed programs to be created, then the search is exited;

[0080] After all applications and device drivers are created, start the device drivers, initialize all external devices, and start all created applications;

[0081] Wherein, the obtaining the creation information of the application program and the device driver through the kernel program further includes:

[0082] Acquiring creation information of the application program and the device driver through the kernel program, and creating a thread synchronization mechanism in the kernel program according to the creation information;

[0083] Specifically, in this embodiment, starting the kernel program includes initializing the kernel program and creating a thread synchronization mechanism, such as creating events, mailboxes, semaphores, mutexes, message queues, etc., so that the kernel program can create corresponding events, mailboxes, semaphores, mutexes, message queues according to actual applications to facilitate data management of the application;

[0084] The process of creating and starting the application and the device driver according to the acquired creation information includes:

[0085] Sending the data access interface of the kernel program to the application program and the device driver;

[0086] Allowing the application program and the device driver to access data in the kernel program through the data access interface;

[0087] Specifically, the kernel program needs to provide necessary information to the device driver and application program, so that the device driver and application program can access the interface functions published by the kernel program, and realize the access of all published interface functions between applications;

[0088] S3, managing all the application programs and device drivers through the kernel program;

[0089] wherein, data of the application program and the device driver are synchronized and shared according to a thread synchronization mechanism in the kernel program;

[0090] Specifically, in this embodiment, data synchronization and sharing between applications are achieved based on synchronization mechanisms such as events, mailboxes, semaphores, mutexes, message queues, etc. created in the kernel program according to actual applications;

[0091] Therefore, through the operation method of the above-mentioned microcontroller in this embodiment, it is possible to customize the division of independent ROM and RAM spaces for the kernel program, device driver and application, and create and start the device driver and application through the kernel program, thereby avoiding the running of various applications in the same or overlapping space due to the absence of MMU, and also eliminating the introduction of the file system, reducing the consumption of ROM and RAM space. The entire program file only requires a few KB at most, greatly increasing the applicability of the microcontroller.

[0092] Embodiment 2

[0093] The difference between this embodiment and the first embodiment is that how to manage all application programs through the kernel program is further defined:

[0094] Specifically, all application programs are scheduled by the scheduler of the kernel program;

[0095] Upgrading all the application programs by executing the upgrade program in the kernel program;

[0096] Please refer to Figure 3 In this embodiment, the scheduler of the kernel program schedules the execution of all applications, and includes an upgrade task in the main program of the kernel program. The upgrade task is used to determine whether there is an application that needs to be upgraded. If so, the access of other applications to all resources of the application to be upgraded is restricted, and the application to be upgraded is stopped. Then, the application to be upgraded is upgraded and started, thereby realizing the management of applications through the kernel program and improving the applicability of the microcontroller.

[0097] Embodiment 3

[0098] Please refer to Figure 2 , a microcontroller operating terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements each step of the microcontroller operating method of embodiment one or embodiment two when executing the computer program.

[0099] In summary, the present invention provides a microcontroller operation method and terminal, which allocates corresponding independent ROM and RAM storage spaces for the kernel program, application program and device driver of the microcontroller according to the space allocation request, and can avoid the running of various programs in the same or overlapping space due to the absence of a memory management unit; when starting the kernel program, it includes initializing the kernel program and building a synchronization mechanism to facilitate the subsequent management of the application; using the kernel program to obtain the creation information of the application program and the device driver, and creating and starting the application program and the device driver; starting the created program, scheduling and managing all applications through the kernel program, and adaptively synchronizing and sharing the data of the application program through the synchronization mechanism created in the kernel according to the needs of the actual application, so that the data of the application program and the device driver in the storage space are directly called through the kernel program, and there is no need to introduce a file system to manage the memory, which greatly reduces the file size of the microcontroller, and can make the storage space of the kernel program, application program and device driver independent of each other, thereby improving the applicability of the microcontroller.

[0100] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for operating a microcontroller, characterized in that: Includes steps: Receive a space allocation request, and allocate corresponding independent storage space for a kernel program, an application program, and a device driver of the microcontroller according to the space allocation request; Start and initialize the kernel program, obtain creation information of the application program and the device driver through the kernel program, and create and start the application program and the device driver according to the obtained creation information: Searching for the creation information of the application and the device driver through the kernel program; determining whether the creation information satisfies the conditions for creating the application and the device driver, and if so, creating the corresponding application and the device driver according to the creation information, and returning to the above step of searching for the creation information of the application and the device driver through the kernel program until all the creation information is found or the number of created application and device drivers reaches a preset number; If not, return to the above step of searching the creation information of the application program and the device driver through the kernel program; All of the application programs and device drivers are managed by the kernel program.

2. The operating method of a microcontroller according to claim 1, characterized in that: After creating and starting the application and the device driver according to the acquired creation information, the following steps are included: Sending the data access interface of the kernel program to the application program and the device driver; The data access interface enables the application program and the device driver to access the data in the kernel program.

3. The operating method of a microcontroller according to claim 1, characterized in that: Managing all the applications through the kernel program includes: Scheduling all application programs through the scheduler of the kernel program; All the application programs are upgraded by executing the upgrade program in the kernel program.

4. A method for operating a microcontroller according to any one of claims 1 to 3, characterized in that: The step of obtaining the creation information of the application program and the device driver through the kernel program further includes: Acquiring creation information of the application program and the device driver through the kernel program, and creating a thread synchronization mechanism in the kernel program according to the creation information; Managing all of the application programs and device drivers through the kernel program also includes: The data of the application program and the device driver are synchronized and shared according to the thread synchronization mechanism in the kernel program.

5. A microcontroller operation terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: Receive a space allocation request, and allocate corresponding independent storage space for a kernel program, an application program, and a device driver of the microcontroller according to the space allocation request; Start and initialize the kernel program, obtain creation information of the application program and the device driver through the kernel program, and create and start the application program and the device driver according to the obtained creation information: Searching for the creation information of the application and the device driver through the kernel program; determining whether the creation information satisfies the conditions for creating the application and the device driver, and if so, creating the corresponding application and the device driver according to the creation information, and returning to the above step of searching for the creation information of the application and the device driver through the kernel program until all the creation information is found or the number of created application and device drivers reaches a preset number; If not, return to the above step of searching the creation information of the application program and the device driver through the kernel program; All of the application programs and device drivers are managed by the kernel program.

6. A microcontroller operating terminal according to claim 5, characterized in that: After creating and starting the application and the device driver according to the acquired creation information, the following steps are included: Sending the data access interface of the kernel program to the application program and the device driver; The data access interface enables the application program and the device driver to access the data in the kernel program.

7. A microcontroller operating terminal according to claim 5, characterized in that: Managing all the applications through the kernel program includes: Scheduling all application programs through the scheduler of the kernel program; All the application programs are upgraded by executing the upgrade program in the kernel program.

8. A microcontroller operating terminal according to any one of claims 5 to 7, characterized in that: The step of obtaining the creation information of the application program and the device driver through the kernel program further includes: Acquiring creation information of the application program and the device driver through the kernel program, and creating a thread synchronization mechanism in the kernel program according to the creation information; Managing all of the application programs and device drivers through the kernel program also includes: The data of the application program and the device driver are synchronized and shared according to the thread synchronization mechanism in the kernel program.

Citation Information

Patent Citations

  • Drive loading method and device

    CN105912349A

  • Information processing method and device, equipment and storage medium

    CN112667405A