Running method of microcontroller and terminal

文档序号:7252 发布日期:2021-09-17 浏览:22次 中文

1. A method of operating a microcontroller, comprising the steps of:

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

starting and initializing the kernel program, acquiring the creation information of an application program and a device driver through the kernel program, and creating and starting the application program and the device driver according to the acquired creation information;

and managing all the application programs and the device drivers by the kernel program.

2. The method according to claim 1, wherein the step of obtaining creation information of an application program and a device driver by the kernel program, and creating the application program and the device driver according to the obtained creation information comprises:

searching the creation information of the application program and the device driver through the kernel program;

judging whether the creating information meets the condition of creating the application program and the equipment driving program, if so, creating the corresponding application program and the equipment driving program according to the creating information, and returning to the step of searching the creating information of the application program and the equipment driving program through the kernel program until all the creating information or the created application program and the created equipment driving program reach the preset program quantity;

if not, returning to the step of searching the creation information of the application program and the device driver through the kernel program.

3. The method according to claim 1, wherein after creating and starting the application and the device driver according to the acquired creation information, the method comprises:

sending a data access interface of the kernel program to the application program and the device driver;

and enabling the application program and the device driver to access data in the kernel program through the data access interface.

4. The method of claim 1, wherein managing all of the applications by the kernel program comprises:

scheduling all application programs by a scheduler of the kernel program;

and upgrading all the application programs by executing upgrading programs in the kernel program.

5. The method according to any one of claims 1 to 4, wherein the obtaining, by the kernel program, creation information of an application program and a device driver further comprises:

acquiring creation information of an application program and a device driver through a 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 by the kernel program further comprises:

and synchronizing and sharing the data of the application program and the device driver according to a thread synchronization mechanism in the kernel program.

6. An operation terminal of a microcontroller, comprising a memory, a processor and a computer program stored on the memory and operable on the processor, characterized in that the processor implements the following steps when executing the computer program:

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

starting and initializing the kernel program, acquiring the creation information of an application program and a device driver through the kernel program, and creating and starting the application program and the device driver according to the acquired creation information;

and managing all the application programs and the device drivers by the kernel program.

7. The operating terminal of claim 6, wherein the acquiring creation information of an application program and a device driver by the kernel program, and creating the application program and the device driver according to the acquired creation information comprises:

searching the creation information of the application program and the device driver through the kernel program;

judging whether the creating information meets the condition of creating the application program and the equipment driving program, if so, creating the corresponding application program and the equipment driving program according to the creating information, and returning to the step of searching the creating information of the application program and the equipment driving program through the kernel program until all the creating information or the created application program and the created equipment driving program reach the preset program quantity;

if not, returning to the step of searching the creation information of the application program and the device driver through the kernel program.

8. The operation terminal of a microcontroller according to claim 6, wherein after creating and starting the application and the device driver according to the acquired creation information, the operation terminal comprises:

sending a data access interface of the kernel program to the application program and the device driver;

and enabling the application program and the device driver to access data in the kernel program through the data access interface.

9. The operation terminal of claim 6, wherein the management of all the application programs by the kernel program comprises:

scheduling all application programs by a scheduler of the kernel program;

and upgrading all the application programs by executing upgrading programs in the kernel program.

10. The operation terminal of a microcontroller according to any one of claims 6 to 9, wherein the acquiring creation information of an application program and a device driver by the kernel program further comprises:

acquiring creation information of an application program and a device driver through a 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 by the kernel program further comprises:

and synchronizing and sharing the data of the application program and the device driver according to a thread synchronization mechanism in the kernel program.

Background

With the increasing living standard, people have more and more requirements on functions of electronic products, so that the design of programs is more and more complex, and if the program structure is not well designed, the programs are intricate and complex, and the development, maintenance and transplantation of the product programs are not facilitated, so that the independence of operating system programs, device drivers and application programs can be realized for large operating systems of high-end controllers, such as windows, linux, android, ios and the like, and the program structure is clear.

However, the ROM (Read-Only Memory) and RAM (Random Access Memory) spaces consumed for running the large-scale operating system are large, and the controller itself needs to have an MMU (Memory Management Unit) function to implement the conversion between the virtual address and the physical address, so as to prevent the application programs from running in the same or overlapping spaces.

Therefore, small real-time operating systems, such as free-rtos, rt-thread, ucos, uclinux, etc., are available for the microcontroller, but currently in the application field of the microcontroller, the operating system program, the device driver program and the application program are not supported by uclinux. Furthermore, while uclinux can implement this approach, it requires file system support such that the minimum consumed ROM space also requires several hundred KB, which also fails to meet many microcontroller requirements.

Disclosure of Invention

The technical problem to be solved by the invention is as follows: the running method and the terminal of the microcontroller can improve the utilization rate of the microcontroller.

In order to solve the technical problems, the invention adopts the technical scheme that:

a method of operating a microcontroller, comprising the steps of:

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

starting and initializing the kernel program, acquiring the creation information of an application program and a device driver through the kernel program, and creating and starting the application program and the device driver according to the acquired creation information;

and managing all the application programs and the device drivers by the kernel program.

In order to solve the technical problem, the invention adopts another technical scheme as follows:

an operation terminal of a microcontroller, comprising a memory, a processor and a computer program stored on the memory and operable on the processor, the processor implementing the following steps when executing the computer program:

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

starting and initializing the kernel program, acquiring the creation information of an application program and a device driver through the kernel program, and creating and starting the application program and the device driver according to the acquired creation information;

and managing all the application programs and the device drivers by the kernel program.

The invention has the beneficial effects that: corresponding independent storage spaces are allocated to a kernel program, an application program and a device driver of the microcontroller according to the space allocation request, so that the situation that all programs run in the same or overlapped space due to the fact that no memory management unit exists can be avoided; the kernel program is used for acquiring the creation information of the application program and the device driver, and the application program and the device driver are created and started, so that the data of the application program and the device driver in the storage space are called directly through the kernel program, a file system is not required to be introduced for managing a memory, the file size of the microcontroller is greatly reduced, the storage spaces of the kernel program, the application program and the device driver are mutually independent, and the applicability of the microcontroller is improved.

Drawings

FIG. 1 is a flow chart of a method of operating a microcontroller according to an embodiment of the present invention;

fig. 2 is a schematic diagram of an operation terminal of a microcontroller according to an embodiment of the present invention;

fig. 3 is a flowchart illustrating specific steps of a method for operating a microcontroller according to an embodiment of the present invention.

Detailed Description

In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.

Referring to fig. 1, an embodiment of the present invention provides an operating method of a microcontroller, including:

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

starting and initializing the kernel program, acquiring the creation information of an application program and a device driver through the kernel program, and creating and starting the application program and the device driver according to the acquired creation information;

and managing all the application programs and the device drivers by the kernel program.

From the above description, the beneficial effects of the present invention are: corresponding independent storage spaces are allocated to a kernel program, an application program and a device driver of the microcontroller according to the space allocation request, so that the situation that all programs run in the same or overlapped space due to the fact that no memory management unit exists can be avoided; the kernel program is used for acquiring the creation information of the application program and the device driver, and the application program and the device driver are created and started, so that the data of the application program and the device driver in the storage space are called directly through the kernel program, a file system is not required to be introduced for managing a memory, the file size of the microcontroller is greatly reduced, the storage spaces of the kernel program, the application program and the device driver are mutually independent, and the applicability of the microcontroller is improved.

Further, acquiring creation information of an application program and a device driver through the kernel program, and creating the application program and the device driver according to the acquired creation information includes:

searching the creation information of the application program and the device driver through the kernel program;

judging whether the creating information meets the condition of creating the application program and the equipment driving program, if so, creating the corresponding application program and the equipment driving program according to the creating information, and returning to the step of searching the creating information of the application program and the equipment driving program through the kernel program until all the creating information or the created application program and the created equipment driving program reach the preset program quantity;

if not, returning to the step of searching the creation information of the application program and the device driver through the kernel program.

As can be seen from the above description, the kernel program queries the creation information of the application program and the device driver and creates the corresponding application program and device driver, and the creation of the application program and device driver can be directly managed by the kernel program, so that the storage spaces of the application program and device driver are managed, and the memory management unit does not need to be used to manage the memories of the respective programs.

Further, after the application program and the device driver are created and started according to the acquired creation information, the method includes:

sending a data access interface of the kernel program to the application program and the device driver;

and enabling the application program and the device driver to access data in the kernel program through the data access interface.

It can be known from the above description that the kernel program provides a data access interface for the application program and the device driver program, which enables the device driver program and the application program to access the interface functions published by the kernel and to realize the access of all the published interface functions among the application programs, and adaptively solves the data access when the storage spaces of the device driver program, the application program and the kernel program are independent from each other.

Further, managing all of the applications by the kernel program includes:

scheduling all application programs by a scheduler of the kernel program;

and upgrading all the application programs by executing upgrading programs in the kernel program.

As can be seen from the above description, the kernel program is used to schedule and upgrade the application program, so that the kernel program can be used to manage the application program uniformly, and the kernel program can be used to schedule and upgrade the application program adaptively without configuring a file system or a memory management unit, thereby improving the utilization rate of the microcontroller.

Further, the acquiring the creation information of the application program and the device driver by the kernel program further includes:

acquiring creation information of an application program and a device driver through a 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 by the kernel program further comprises:

and synchronizing and sharing the data of the application program and the device driver according to a thread synchronization mechanism in the kernel program.

As can be seen from the above description, a thread synchronization mechanism is created in the kernel program according to the requirements of the actual application, so as to implement synchronization and sharing of data between application programs, and implement synchronization of device driver data, so that memory management can be performed without setting a memory management unit and a file system.

Referring to fig. 2, another embodiment of the present invention provides an operation terminal of a microcontroller, including a memory, a processor, and a computer program stored in the memory and operable on the processor, where the processor executes the computer program to implement the following steps:

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

starting and initializing the kernel program, acquiring the creation information of an application program and a device driver through the kernel program, and creating and starting the application program and the device driver according to the acquired creation information;

and managing all the application programs and the device drivers by the kernel program.

As can be seen from the above description, allocating corresponding independent storage spaces for the kernel program, the application program, and the device driver of the microcontroller according to the space allocation request can avoid that the programs run on the same or overlapping spaces because there is no memory management unit; the kernel program is used for acquiring the creation information of the application program and the device driver, and the application program and the device driver are created and started, so that the data of the application program and the device driver in the storage space are called directly through the kernel program, a file system is not required to be introduced for managing a memory, the file size of the microcontroller is greatly reduced, the storage spaces of the kernel program, the application program and the device driver are mutually independent, and the applicability of the microcontroller is improved.

Further, acquiring creation information of an application program and a device driver through the kernel program, and creating the application program and the device driver according to the acquired creation information includes:

searching the creation information of the application program and the device driver through the kernel program;

judging whether the creating information meets the condition of creating the application program and the equipment driving program, if so, creating the corresponding application program and the equipment driving program according to the creating information, and returning to the step of searching the creating information of the application program and the equipment driving program through the kernel program until all the creating information or the created application program and the created equipment driving program reach the preset program quantity;

if not, returning to the step of searching the creation information of the application program and the device driver through the kernel program.

As can be seen from the above description, the kernel program queries the creation information of the application program and the device driver and creates the corresponding application program and device driver, and the creation of the application program and device driver can be directly managed by the kernel program, so that the storage spaces of the application program and device driver are managed, and the memory management unit does not need to be used to manage the memories of the respective programs.

Further, after the application program and the device driver are created and started according to the acquired creation information, the method includes:

sending a data access interface of the kernel program to the application program and the device driver;

and enabling the application program and the device driver to access data in the kernel program through the data access interface.

It can be known from the above description that the kernel program provides a data access interface for the application program and the device driver program, which enables the device driver program and the application program to access the interface functions published by the kernel and to realize the access of all the published interface functions among the application programs, and adaptively solves the data access when the storage spaces of the device driver program, the application program and the kernel program are independent from each other.

Further, managing all of the applications by the kernel program includes:

scheduling all application programs by a scheduler of the kernel program;

and upgrading all the application programs by executing upgrading programs in the kernel program.

As can be seen from the above description, the kernel program is used to schedule and upgrade the application program, so that the kernel program can be used to manage the application program uniformly, and the kernel program can be used to schedule and upgrade the application program adaptively without configuring a file system or a memory management unit, thereby improving the utilization rate of the microcontroller.

Further, the acquiring the creation information of the application program and the device driver by the kernel program further includes:

acquiring creation information of an application program and a device driver through a 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 by the kernel program further comprises:

and synchronizing and sharing the data of the application program and the device driver according to a thread synchronization mechanism in the kernel program.

As can be seen from the above description, a thread synchronization mechanism is created in the kernel program according to the requirements of the actual application, so as to implement synchronization and sharing of data between application programs, and implement synchronization of device driver data, so that memory management can be performed without setting a memory management unit and a file system.

The operation method and the terminal of the microcontroller are suitable for realizing independence of a kernel program, a device driver and an application program in various microcontrollers, do not need support of a file system or a memory management system, and are described in the following through specific implementation modes:

example one

Referring to fig. 1, an operating method of a microcontroller includes the steps of:

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

specifically, in this embodiment, the program structure of the microcontroller includes a kernel program, an application program, and a device driver, where the kernel program is developed based on a real-time operating system kernel, and implements operations such as creating, starting, scheduling, and upgrading the application program, and provides a communication interface for each application program; the application program is an indispensable part in software design, is one or more programs for realizing functional requirements, and internally comprises one or more tasks; the device driver is an external device of the microcontroller, such as a memory, a display, a communication, an LED, a key and the like, can provide uniform operation interfaces of reading, writing, setting, resetting and the like, and is a bridge for the application program to access the external device;

according to the space allocation request, allocating storage spaces of corresponding ROM and RAM in the projects of kernel programs, application programs and device driving programs according to respective space requirements, wherein each program is mutually independent and non-overlapped in space;

s2, starting and initializing the kernel program, acquiring the creation information of an application program and a device driver through the kernel program, and creating and starting the application program and the device driver according to the acquired creation information;

the method for acquiring 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 acquired creation information comprises the following steps:

searching the creation information of the application program and the device driver through the kernel program;

judging whether the creating information meets the condition of creating the application program and the equipment driving program, if so, creating the corresponding application program and the equipment driving program according to the creating information, and returning to the step of searching the creating information of the application program and the equipment driving program through the kernel program until all the creating information or the created application program and the created equipment driving program reach the preset program quantity;

if not, returning to the step of searching the creation information of the application program and the device driver through the kernel program;

specifically, in this embodiment, the device driver and the application program need to provide the created necessary information to the kernel program, the kernel program creates and starts the device driver and the application program according to the provided created information, and the created information includes interface functions and data structure information published by the device driver and the application program;

referring to fig. 3, after the kernel program is started, the creation information provided by the device driver and the application program is searched for, and if the creation information meets the condition of creating the program, the corresponding program is created, and the search is exited until the search of all information is completed or the number of created programs reaches the preset number of allowed creation programs;

after all the application programs and the device drivers are created, starting the device drivers, initializing all the external devices, and starting all the created application programs;

wherein the obtaining of the creation information of the application program and the device driver by the kernel program further comprises:

acquiring creation information of an application program and a device driver through a kernel program, and creating a thread synchronization mechanism in the kernel program according to the creation information;

specifically, in this embodiment, the kernel program includes initialization of the kernel program when being started, and a thread synchronization mechanism is created, such as creating an event, a mailbox, a semaphore, a mutex, a message queue, and the like, so that the kernel program can create a corresponding event, mailbox, semaphore, mutex, and message queue according to an actual application program, so as to facilitate data management of the application program;

wherein, after the application program and the device driver are created and started according to the acquired creation information, the method comprises the following steps:

sending a data access interface of the kernel program to the application program and the device driver;

enabling the application program and the device driver to access data in a kernel program through the data access interface;

specifically, the kernel program needs to provide necessary information to the device driver and the application program, so that the device driver and the application program can access the interface functions published by the kernel program and realize the access of all the published interface functions among the application programs;

s3, managing all the application programs and device drivers through the kernel program;

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

specifically, in this embodiment, data synchronization and sharing between applications are implemented according to synchronization mechanisms such as an event, a mailbox, a semaphore, a mutex, a message queue, and the like, which are created in the kernel program according to the actual application;

therefore, the running method of the microcontroller according to the embodiment can self-definitively divide the ROM and RAM spaces of the kernel program, the device driver and the application program, and create and start the device driver and the application program through the kernel program, thereby avoiding that the application programs run in the same or overlapped space due to no MMU, simultaneously omitting the introduction of a file system, reducing the consumption of the ROM and RAM spaces, requiring only a few KB of the whole program file at most, and greatly increasing the utilization rate of the microcontroller.

Example two

The difference between this embodiment and the first embodiment is that how to manage all the applications through the kernel program is further defined:

specifically, all application programs are scheduled by a scheduler of the kernel program;

upgrading all the application programs by executing upgrading programs in the kernel programs;

referring to fig. 3, in this embodiment, a scheduler of a kernel program schedules and executes all application programs, and a main program of the kernel program includes an upgrade task, and determines whether an application program needs to be upgraded or not through the upgrade task, if so, access to all resources of the application program to be upgraded by other application programs is limited, the application program to be upgraded is stopped, and then the application program to be upgraded is upgraded and started, so that management of the application program is realized through the kernel program, and the utilization rate of the microcontroller is improved.

EXAMPLE III

Referring to fig. 2, an operation terminal of a microcontroller includes a memory, a processor, and a computer program stored in the memory and operable on the processor, and the processor executes the computer program to implement the steps of the operation method of the microcontroller according to the first embodiment or the second embodiment.

In summary, according to the operating method and the terminal of the microcontroller provided by the present invention, the corresponding independent ROM and RAM storage spaces are allocated to the kernel program, the application program and the device driver of the microcontroller according to the space allocation request, so that it can be avoided that each program runs in the same or overlapping space due to no memory management unit; when the kernel program is started, initializing the kernel program and establishing a synchronization mechanism so as to facilitate the subsequent management of the application program; acquiring the creation information of an application program and a device driver by using a kernel program, and creating and starting the application program and the device driver; the built program is started, all application programs are scheduled and managed through the kernel program, and the data of the application programs are synchronized and shared through a synchronization mechanism built in the kernel adaptively according to the requirements of the actual application programs, so that the data of the application programs and the device driver in the storage space are directly called through the kernel program, a file system is not required to be introduced to manage a memory, the file size of the microcontroller is greatly reduced, the storage spaces of the kernel program, the application programs and the device driver are independent, and the adaptive rate of the microcontroller is improved.

The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种移动边缘网络业务卸载方法及装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!