Micro-containerization method of microcontroller and microcontroller with micro-container
By implementing the microcontainerization method on the microcontroller, including legality verification, authorization authentication and permission settings, the problem of being unable to run containers due to the lack of a storage manager on the microcontroller is solved, and independent deployment and deployment of containers on the microcontroller are realized. Isolated, with high security and cross-platform portability.
Patent Information
- Application Number
- CN202410839559.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-10-01
AI Technical Summary
In the existing technology, the microcontroller (MCU) cannot run real Linux systems and containers due to the lack of a memory manager (MMU).
By implementing the microcontainerization method on the microcontroller, including the legality verification and authorization authentication of the microcontainer to be started, setting the access rights of user space and kernel space, and using the RTOS kernel and microcontainer manager to realize the isolation and isolation of microcontainers. Initialization, even in scenarios where storage protection unit configuration parameters are not supported, the microcontainer can be run by modifying the scheduler code.
It realizes running containers on microcontrollers without storage managers. It has the characteristics of independent development and deployment, isolation between microcontainers, kernel isolation, high security, and cross-platform portability. It solves the problems of running containers on microcontrollers. Technical difficulties.
Smart Images

Figure CN118734285A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of container technology, and in particular to a micro-containerization method of a microcontroller and a microcontroller with a micro-container. Background Art
[0002] Container technology is an important technology that has rapidly emerged in the field of software development in recent years. Container technology is an efficient application deployment method that allows developers to package and run applications in an isolated environment. Containerization is a technology that packages application machine dependencies into an independent, portable container that contains all the components required for the application to run, such as code, runtime environment, libraries, and system tools.
[0003] Unlike traditional deployment methods, the key idea of containers is to achieve consistency in different environments. Whether deployed on a developer's local workstation or on a production server, there is no need to worry about differences in operating system configuration and underlying infrastructure. The container engine is the core software that provides the container runtime environment. It is responsible for creating, running, and managing the life cycle of containers. The container engine achieves isolation and independent operation of applications by loading container mappings into the host system and running container processes. The benefits of containerization: lightweight, low overhead, rapid scalability, unified environment, process isolation, high security, configurable resources, platform independence, etc.
[0004] In the process of implementing this application, the inventors found that there are at least the following problems in the prior art:
[0005] The Linux operating system generally runs on a CPU with a memory manager MMU, which can implement the mapping of virtual addresses to physical addresses and provide a memory protection mechanism. In addition, the Linux operating system can also set access rights to physical address resources through the memory manager MMU. However, on a microcontroller MCU, because the MCU does not have a memory manager (MMU), it is impossible to run a true Linux system and related containers. Summary of the invention
[0006] The purpose of the present application is to provide a micro-containerization method for a microcontroller and a microcontroller having a micro-container, so as to solve the technical problem in the prior art that an operating system requires a storage manager to run a true container.
[0007] The various technical effects that can be produced by the optional technical solutions among the many technical solutions provided in this application are described in detail below.
[0008] To achieve the above objectives, this application provides the following technical solutions:
[0009] In a first aspect, the present application provides a micro-containerization method for a microcontroller, the method comprising:
[0010] Perform legitimacy verification and authorization authentication on the microcontainer to be started;
[0011] If the legitimacy and authorization authentication of the microcontainer to be started are passed, setting permissions for access of the microcontainer to be started in the user space and the kernel space to determine the access boundaries of the microcontainer to be started in the user space and the kernel space;
[0012] According to the authorization file of the micro-container to be started and the access boundary, completing parameter configuration of the micro-container to be started;
[0013] The configured parameters are passed to the microcontainer to be started, the calling function of the microcontainer to be started is initialized, and the driving function and the callback function of the authorized access resource are initialized, so that the microcontainer has access rights to the initialized resources.
[0014] In some embodiments, the legitimacy verification and authorization authentication of the micro-container to be started includes:
[0015] Reading the header file and authorization file of the microcontainer to be started;
[0016] The information of the header file is verified for legitimacy, and the authorization file is authenticated for authorization.
[0017] In some embodiments, the verifying the legitimacy of the information in the header file and the authenticating the authorization file include:
[0018] The legitimacy of the information in the header file is verified through format comparison and verification, and the signature of the authorization file is authenticated through a public key algorithm.
[0019] In some embodiments, the setting of permissions for access to the microcontainer to be started in the user space and the kernel space includes:
[0020] According to the header file, applying for memory space on the operating system heap that meets the requirements of the microcontainer to be started;
[0021] If the scheduler of the kernel space supports loading of storage protection unit configuration parameters, then, according to the authorization file, the storage protection unit MPU parameters corresponding to the microcontainer to be started are configured to limit the access boundaries of the microcontainer to be started in the user space and the kernel space;
[0022] The offset value of the storage space address of the micro-container to be started in the user space and the size of the storage space are consistent with the area offset value and area size limit of the storage protection unit.
[0023] In some embodiments, the method further comprises:
[0024] If the scheduler of the kernel space does not support the loading of the storage protection unit configuration parameters, it is necessary to modify the scheduler code to add the loading of the storage protection unit configuration parameters when the task is switched.
[0025] In some embodiments, the method further comprises:
[0026] The startup function of the microcontainer is called to start the microcontainer, so that the microcontainer calls the system function according to the startup function to schedule and run the microcontainer.
[0027] In some embodiments, the method further comprises:
[0028] If the microcontainer needs to be uninstalled, the stop function of the microcontainer is called to delete and stop the threads and resources created by the microcontainer, and release the memory space applied for by the microcontainer on the system heap.
[0029] In a second aspect, the present application further provides a microcontroller with a microcontainer, wherein the microcontroller with a microcontainer comprises: a kernel space, an intermediate space, and a user space;
[0030] The kernel space is used to collect and manage all system resources;
[0031] The intermediate space is used to run the microcontainer manager;
[0032] The user space includes a plurality of microcontainers;
[0033] The microcontainer manager is used to verify the legitimacy of the microcontainer and set access rights to the microcontainer when starting the microcontainer, so as to control address isolation between the microcontainers, communication between the microcontainers, unify the access interface functions of the microcontainers, and address isolation between the user space and the kernel space.
[0034] In some embodiments, the microcontainer includes a header file, an authorization file, and a microcontainer program;
[0035] The header file is used to define the microcontainer, including the header file length, ID code, version number, ROM space size, RAM space, operating environment configuration function entry, start function entry, stop function entry, microcontainer priority attribute, microcontainer initial task stack size, callback thread entry, callback thread stack size, code space size, compiler type, whether shared memory is supported, whether MPU is supported, and whether privileged level operation is supported;
[0036] The authorization file includes a list of resources that provide access rights to the microcontainer;
[0037] The micro-container program is placed behind the header file and the authorization file, and is used to provide the user with the running program of the micro-container.
[0038] In some embodiments, the micro-containers communicate with each other via inter-process communication.
[0039] Implementing one of the above technical solutions of this application has the following advantages or beneficial effects:
[0040] The present application discloses a microcontainerization method for a microcontroller and a microcontroller with a microcontainer. When the microcontainer needs to be loaded and started, the legitimacy verification and authorization authentication of the microcontainer to be started are performed. If the legitimacy verification and authorization authentication are passed, the permission of the microcontainer to be started can be set to achieve isolation between the microcontainer and other microcontainers, and isolation between the user space where the microcontainer is located and the kernel space. When the microcontainer has access rights to the initialized resources, the independent compilation deployment and portability of the microcontainer are achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. It is obvious that the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0042] Figure 1 It is a flowchart of a micro-containerization method of a microcontroller according to an embodiment of the present application;
[0043] Figure 2 is a system architecture diagram of a microcontroller with a microcontainer according to an embodiment of the present application;
[0044] Figure 3 This is a diagram of the micro-container storage space structure of an embodiment of the present application;
[0045] Figure 4 It is a schematic diagram of communication between micro-containers in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of the present application clearer, the various exemplary embodiments to be described below will refer to the corresponding drawings, which constitute a part of the exemplary embodiments, wherein various exemplary embodiments that may be used to implement the present application are described. Unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation methods described in the following exemplary embodiments do not represent all implementation methods consistent with the present disclosure. It should be understood that they are only examples of processes, methods, and devices that are consistent with some aspects disclosed in the present application as detailed in the attached claims, and other embodiments may also be used, or the embodiments listed herein may be modified in structure and function without departing from the scope and essence of the present application.
[0047] In the description of the present application, it should be understood that the terms "center", "longitudinal", "lateral", etc. indicate the orientation or positional relationship based on the drawings, which is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the elements referred to must have a specific orientation, be constructed and operated in a specific orientation. The terms "first", "second", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. The term "multiple" means two or more. The terms "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, an integral connection, a mechanical connection, an electrical connection, a communication connection, a direct connection, an indirect connection through an intermediate medium, and can be the internal connection of two elements or the interaction relationship between two elements. The term "and / or" includes any and all combinations of one or more related listed items. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances.
[0048] In order to illustrate the technical solution described in the present application, a specific embodiment is provided below, and only the parts related to the embodiment of the present application are shown.
[0049] Embodiment 1:
[0050] The present application provides a micro-containerization method for a microcontroller, which is applied to a microcontroller MCU, and the microcontroller MCU does not have a storage manager MMU, and the microcontroller MCU uses an RTOS operating system. The container running in the microcontroller MCU is a "microcontainer". In order to implement the microcontainer in the microcontroller MCU, the microcontroller of the present application includes a kernel space, an intermediate space, and a user space. Among them, the intermediate space runs a microcontainer manager for executing the microcontainerization method of the microcontroller.
[0051] Through the architecture of the microcontroller of the present application, the operation of the container can be realized without the need for a storage manager MMU, and it has the characteristics of independent development and deployment, dynamic loading, isolation between microcontainers, isolation between microcontainers and the kernel, signature-controlled access rights to microcontainers, lightweight, low overhead, high security, and cross-platform portability.
[0052] like Figure 1 As shown, the micro-containerization method of the microcontroller includes steps S10 to S40.
[0053] S10: Perform legitimacy verification and authorization authentication on the microcontainer to be started.
[0054] The microcontainer to be started is set in the microcontroller, such as Figure 2 As shown, the microcontroller includes kernel space, middle space and user space.
[0055] The kernel space is used to collect and manage all system resources. The kernel space can be any general RTOS kernel, which is an isolated privileged space. The RTOS (Real-Time Operating System) kernel is a core software designed specifically for real-time applications. It provides the basic functions of the operating system, such as task scheduling, interrupt management, memory management, time management, and providing interfaces for interaction with hardware. These kernels are designed to respond quickly to external events and complete the processing of tasks within the specified time limit.
[0056] The intermediate space is used to run the micro-container manager. The micro-container manager is a task / thread (Task / Thread) resident in the privileged space.
[0057] The user space includes several micro-containers. The user space is used to run the micro-containers, which are restricted permission spaces for working in the micro-containers and can be compiled and dynamically loaded separately.
[0058] The microcontainer manager is used to verify the legitimacy of the microcontainer and set access rights to the microcontainer when starting the microcontainer, so as to control address isolation between the microcontainers, communication between the microcontainers, unify the access interface functions of the microcontainers, and address isolation between the user space and the kernel space.
[0059] Therefore, when the microcontainer to be started refers to any microcontainer in the user space that needs to be started, the microcontainer manager performs legitimacy verification and authorization authentication on the microcontainer to be started.
[0060] In some embodiments, step S10 may include:
[0061] Reading the header file and authorization file of the microcontainer to be started;
[0062] The information of the header file is verified for legitimacy, and the authorization file is authenticated for authorization.
[0063] Specifically, Figure 3 As shown, the storage space of the microcontainer in the microcontroller includes a header file, an authorization file, and a microcontainer program. Among them, the header file is used to define the microcontainer, and includes information such as: header file length, ID code, version number, ROM space size, RAM space, operating environment configuration function entry, start function entry, stop function entry, microcontainer priority attribute, microcontainer initial task stack size, callback thread entry, callback thread stack size, code space size, compiler type, whether shared memory is supported, whether MPU is supported, and whether privileged level operation is supported.
[0064] The authorization file includes a list of resources that provide access permissions to the container space.
[0065] When performing legitimacy verification and authorization authentication on the microcontainer to be started, first read the header file and authorization file of the microcontainer to be started, and then verify the legitimacy of the header file information, including the header file length, ID code, version number, ROM space size, RAM space, operating environment configuration function entry, start function entry, and stop function entry.
[0066] In some implementations, the information of the header file may be verified for legitimacy by format comparison and verification. Specifically, according to different application scenarios, corresponding templates are provided to users, so there are different standard formats of header files. When the user's microcontainer to be started is verified for legitimacy, the microcontainer manager performs format comparison and verification according to the standard format of the header file under the application scenario to implement the verification of the legitimacy of the header file information.
[0067] In some implementations, the authorization file may be signed and authenticated using a public key algorithm, which may include an RSA algorithm or an elliptic curve-based public key algorithm ECCSA, but is not limited thereto.
[0068] The authorization file is signed and authenticated through the public key algorithm to achieve identity authentication of the microcontainer to be started, thereby ensuring the security of the microcontainer during operation.
[0069] If the legitimacy verification of the header file of the microcontainer to be started passes, and the authorization authentication of the authorization file succeeds, the microcontainer manager executes step S20. If the legitimacy verification of the header file of the microcontainer to be started fails, or the authorization authentication of the authorization file fails, the startup of the microcontainer to be started fails, and the startup process ends.
[0070] S20: If the legitimacy and authorization authentication of the microcontainer to be started are passed, setting permissions for access of the microcontainer to be started in the user space and the kernel space to determine the access boundary of the microcontainer to be started in the user space and the kernel space.
[0071] When the legitimacy and authorization authentication of the microcontainer to be started are passed, the access rights of the microcontainer to be started are set to achieve isolation between microcontainers and isolation between user space and kernel space.
[0072] Access permissions include read-only, read-write, etc.
[0073] In some implementations, step S20 may include:
[0074] According to the header file, applying for memory space on the operating system heap that meets the requirements of the microcontainer to be started;
[0075] If the scheduler of the kernel space supports loading of storage protection unit configuration parameters, then according to the authorization file, configure the storage protection unit MPU parameters to limit the access boundaries of the microcontainer to be started in the user space and the kernel space;
[0076] The offset value of the storage space address of the micro-container to be started in the user space and the size of the storage space are consistent with the area offset value and area size limit of the storage protection unit.
[0077] Specifically, the heap in the operating system is part of the address space and is a memory area dynamically allocated and released by the program at runtime. The management of the heap memory is the responsibility of the program's memory management functions, such as malloc and free functions. These functions request the operating system to return the memory space to the program as blocks of available memory. Therefore, the memory space required by the microcontainer to be started can be requested in the heap. The memory space required by the microcontainer to be started is determined based on the RAM space in the header file.
[0078] Through the heap, the flexibility of dynamic memory allocation can be provided to the microcontainer to be started.
[0079] In an operating system, a memory protection unit (MPU) is a hardware component that provides memory protection to prevent program code from misusing memory or accessing memory areas that do not belong to it.
[0080] If the kernel space scheduler supports the loading of the storage protection unit MPU parameters, the storage protection unit MPU parameters can be configured according to the authorization file of the microcontainer to be started, and the offset value of the storage space address of the microcontainer to be started in the user space and the size of the storage space are consistent with the region offset value and region size limit of the storage protection unit. That is, the MPU parameters include the region offset value and the region size.
[0081] By configuring the memory protection unit MPU parameters to limit the access boundaries of the microcontainer to be started in the user space and the kernel space, the microcontainer to be started has accessible memory areas in the user space and the kernel space after startup, which are the access boundaries, thereby ensuring that the microcontainer will not unauthorizedly access the memory areas of other programs or systems, and realizing the isolation between the microcontainer and other microcontainers, as well as the isolation between the microcontainer and the kernel space, thereby enhancing the security and stability of the system.
[0082] In some embodiments, the method may further include:
[0083] If the scheduler of the kernel space does not support the loading of the storage protection unit configuration parameters, it is necessary to modify the scheduler code to add the loading of the storage protection unit configuration parameters when the task is switched.
[0084] Specifically, if the kernel space scheduler does not support the loading of storage protection unit configuration parameters, then it is necessary to improve the system scheduling related functions. The scheduler code can be modified to add the loading of storage protection unit MPU configuration parameters when task switching, so as to achieve thread isolation.
[0085] Since the microcontainer manager thread works in privileged mode and manages all system resources through the general RTOS, the microcontainer manager unifies the interfaces of all system functions and the access interfaces of all resources, thereby realizing the cross-platform portability of the microcontainer.
[0086] S30: Complete parameter configuration of the micro-container to be started according to the authorization file of the micro-container to be started and the access boundary.
[0087] After determining the access boundaries of the microcontainer to be started in the user space and the kernel space, the parameter configuration of the microcontainer to be started is completed according to the resource list with access rights and the access boundaries in the authorization file.
[0088] S40, passing the configured parameters to the microcontainer to be started, completing the initialization of the calling function of the microcontainer to be started, and initializing the driving function and the callback function of the authorized access resource, so that the microcontainer has access rights to the initialized resources.
[0089] After the initialization of the related functions of the micro-container to be started is completed, the loading and starting of the micro-container to be started is completed.
[0090] Obviously, the microcontainer can only access initialized resources, and the permission management of the microcontainer to access resources is realized by starting and loading the microcontainer. At the same time, the microcontainer manager will also judge and limit the access rights of the microcontainer.
[0091] In some implementations, after the loading and startup of the microcontainer is successful, the microcontainer manager thread calls the startup function to start the microcontainer. Therefore, after step S40, the method may further include:
[0092] The startup function of the microcontainer is called to start the microcontainer, so that the microcontainer calls the system function according to the startup function to schedule and run the microcontainer.
[0093] After the microcontainer's operating environment is initialized, the microcontainer is ready to run. By calling the system function through the startup function, the microcontainer thread and other resources can be created. Through the system scheduling, the microcontainer thread can be scheduled and run.
[0094] In some embodiments, after step S40, the method may further include:
[0095] If the microcontainer needs to be uninstalled, the stop function of the microcontainer is called to delete and stop the threads and resources created by the microcontainer, and release the memory space applied for by the microcontainer on the system heap.
[0096] Specifically, the microcontainer is a microcontainer that has been loaded and started. If the running microcontainer needs to be stopped, the microcontainer manager thread calls the stop function of the microcontainer, deletes and stops the threads and resources created by the microcontainer according to the stop function, and releases the memory space applied for by the microcontainer on the system heap, thereby realizing the recycling of the memory space of the microcontainer.
[0097] The microcontainerization method of the microcontroller of the present application performs legitimacy verification and authorization authentication on the microcontainer to be started when the microcontainer needs to be loaded and started. If the legitimacy verification and authorization authentication pass, the permission of the microcontainer to be started can be set to achieve isolation between the microcontainer and other microcontainers, and isolation between the user space and kernel space where the microcontainer is located. When the microcontainer has access rights to the initialized resources, the independent compilation deployment and portability of the microcontainer are achieved.
[0098] In addition, the microcontainer of the present application can run on a microcontroller without a memory manager (MMU), and has the advantages of independent development and deployment, dynamic loading, isolation between microcontainers, isolation between microcontainers and the kernel, signature-controlled access rights to microcontainers, lightweight, low overhead, high security, and cross-platform portability.
[0099] The embodiment is only a special case and does not indicate that the present application is implemented in such a way.
[0100] Embodiment 2:
[0101] The second embodiment of the present application also provides a microcontroller having a microcontainer, such as Figure 2 As shown, it includes: kernel space, middle space, and user space; the kernel space is used to collect and manage all system resources; the middle space is used to run the microcontainer manager; the user space includes a plurality of microcontainers; the microcontainer manager is used to verify the legitimacy of the microcontainer when starting the microcontainer, set the access rights of the microcontainer, so as to control the address isolation between each of the microcontainers, the communication between the microcontainers, unify the access interface functions of the microcontainers, and the address isolation between the user space and the kernel space.
[0102] As an optional implementation, the microcontainer includes a header file, an authorization file, and a microcontainer program;
[0103] The header file is used to define the microcontainer, including header file length, ID code, version number, ROM space size, RAM space, operating environment configuration function entry, start function entry, stop function entry, microcontainer priority attribute, microcontainer initial task stack size, callback thread entry, callback thread stack size, code space size, compiler type, whether shared memory is supported, whether MPU is supported, and whether privileged level operation is supported.
[0104] The authorization file includes a resource list that provides access rights to the micro-container.
[0105] Each microcontainer must contain an authorization file. By default, the microcontainer cannot access any resources. Since the authorization file contains a list of resources that the microcontainer can access, it provides the microcontainer with authorization for the resources that it can access. Therefore, the authorization file needs to be signed using an asymmetric algorithm.
[0106] The microcontainer program is placed behind the header file and the authorization file to provide users with the running program of the microcontainer. The microcontainer program is compiled and linked using an address-independent mode to achieve the deployment and operation of the microcontainer at any location in the user space.
[0107] It is understandable that the relevant details of the microcontroller with microcontainers are all introduced in detail in the first embodiment and will not be repeated here.
[0108] As an optional implementation, the micro-containers communicate with each other through inter-process communication.
[0109] like Figure 4 As shown, micro-containers communicate with each other using inter-process communication (IPC). IPC communication can be implemented using operating system semaphores, message mailboxes, message queues, or shared memory.
[0110] In the IoT industry, there are many wireless access protocols, such as W-MBUS, LoRaWAN, Sigfox, MIOTY, Wi-SUN, ZigBee, Thread, BlueTooth, WiFi, Matter, G3 dual-mode, NBIOT, and various enterprise standards and private protocols. These wireless protocols can be applied in a wide range of fields. The traditional development model of IoT application terminal products often separates application development from wireless communication protocol development. Business development uses a single MCU for data collection and business logic implementation, and then uses a wireless communication module to complete the transmission of communication data. Although this development model achieves decoupling to a certain extent, the addition of an MCU makes the hardware cost high and the product power consumption high. Connecting different wireless modules often requires different hardware interfaces and different interaction protocols. Once the product is finalized, it is difficult to have scalability and portability.
[0111] The microcontainerization method of the microcontroller and the microcontroller with a microcontainer of the present application can be applied to many fields, such as the platform development of IoT terminal products and gateway products. The dynamic loading of the microcontainer in the microcontroller, the unified API interface and cross-platform transplantation can effectively solve the problem of IoT market fragmentation.
[0112] The micro-container technology of the present application can also be applied to devices in the Internet of Things platform, which can change the development model of Internet of Things products.
[0113] This application fully integrates the characteristics of various general-purpose MCUs, the development characteristics of embedded C language, virtualization technology, knowledge of cryptography, etc., to build a technology for running microcontainers and realize the running of containers on microcontrollers MCU without a storage manager MMU.
[0114] The microcontroller of the present application also includes one or more processors; a memory for storing one or more computer programs, and one or more of the processors are used to execute one or more computer programs stored in the memory, so that one or more of the processors execute the microcontainerization method of the microcontroller as described in any one of Embodiment 1.
[0115] Microcontrollers can be used in various electronic devices, such as computers, smartphones, tablets, wearable electronic equipment, smart home electronics, industrial and other equipment.
[0116] The present application also provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by a microcontroller, the microcontroller executes the method described in any one of the first embodiments.
[0117] Those skilled in the art can understand that all or part of the features / steps of the above-mentioned method embodiments can be implemented by methods, data processing systems or computer programs, and these features can be implemented without hardware, entirely by software, or by a combination of hardware and software. The aforementioned computer program can be stored in one or more computer-readable storage media, and the storage medium stores a computer program, and when the computer program is executed (such as a processor), the steps of the microcontainerization method embodiment of the above-mentioned microcontroller are executed.
[0118] The aforementioned storage media that can store program codes include: static hard disks, solid-state hard disks, random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), optical storage devices, magnetic storage devices, flash memory, magnetic disks or optical disks and / or combinations of the above devices, that is, it can be implemented by any type of volatile or non-volatile storage device or a combination thereof.
[0119] The above is only the preferred embodiment of the present application. Those skilled in the art will appreciate that various changes or equivalent substitutions may be made to these features and embodiments without departing from the spirit and scope of the present application. In addition, under the guidance of the present application, these features and embodiments may be modified to adapt to specific circumstances and materials without departing from the spirit and scope of the present application. Therefore, the present application is not limited to the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of the present application belong to the protection scope of the present application.
Claims
1. A micro-containerization method for a microcontroller, characterized in that: The method comprises: Perform legitimacy verification and authorization authentication on the microcontainer to be started; If the legitimacy and authorization authentication of the microcontainer to be started are passed, setting permissions for access of the microcontainer to be started in the user space and the kernel space to determine the access boundaries of the microcontainer to be started in the user space and the kernel space; According to the authorization file of the micro-container to be started and the access boundary, completing parameter configuration of the micro-container to be started; The configured parameters are passed to the microcontainer to be started, the calling function of the microcontainer to be started is initialized, and the driving function and the callback function of the authorized access resource are initialized, so that the microcontainer has access rights to the initialized resources.
2. The micro-containerization method of a microcontroller according to claim 1, characterized in that: The legitimacy verification and authorization authentication of the micro-container to be started includes: Reading the header file and authorization file of the microcontainer to be started; The information of the header file is verified for legitimacy, and the authorization file is authenticated for authorization.
3. The micro-containerization method of a microcontroller according to claim 2, characterized in that: The legitimacy verification of the information of the header file and the authorization authentication of the authorization file include: The legitimacy of the information in the header file is verified through format comparison and verification, and the signature of the authorization file is authenticated through a public key algorithm.
4. The micro-containerization method of a microcontroller according to claim 2, characterized in that: The step of setting permissions for accessing the microcontainer to be started in the user space and the kernel space includes: According to the header file, applying for memory space on the operating system heap that meets the requirements of the microcontainer to be started; If the scheduler of the kernel space supports loading of storage protection unit configuration parameters, then, according to the authorization file, the storage protection unit MPU parameters corresponding to the microcontainer to be started are configured to limit the access boundaries of the microcontainer to be started in the user space and the kernel space; The offset value of the storage space address of the micro-container to be started in the user space and the size of the storage space are consistent with the area offset value and area size limit of the storage protection unit.
5. The micro-containerization method of a microcontroller according to claim 1, characterized in that: The method further comprises: If the scheduler of the kernel space does not support the loading of the storage protection unit configuration parameters, it is necessary to modify the scheduler code to add the loading of the storage protection unit configuration parameters when the task is switched.
6. The micro-containerization method of a microcontroller according to claim 1, characterized in that: The method further comprises: The startup function of the microcontainer is called to start the microcontainer, so that the microcontainer calls the system function according to the startup function to schedule and run the microcontainer.
7. The micro-containerization method of a microcontroller according to claim 1, characterized in that: The method further comprises: If the microcontainer needs to be uninstalled, the stop function of the microcontainer is called to delete and stop the threads and resources created by the microcontainer, and release the memory space applied for by the microcontainer on the system heap.
8. A microcontroller having a microcontainer, characterized in that: The microcontroller with a microcontainer includes: a kernel space, an intermediate space, and a user space; The kernel space is used to collect and manage all system resources; The intermediate space is used to run the microcontainer manager; The user space includes a plurality of microcontainers; The microcontainer manager is used to verify the legitimacy of the microcontainer and set access rights to the microcontainer when starting the microcontainer, so as to control address isolation between the microcontainers, communication between the microcontainers, unify the access interface functions of the microcontainers, and address isolation between the user space and the kernel space.
9. The microcontroller with a microcontainer according to claim 8, characterized in that: The microcontainer includes a header file, an authorization file and a microcontainer program; The header file is used to define the microcontainer, including the header file length, ID code, version number, ROM space size, RAM space, operating environment configuration function entry, start function entry, stop function entry, microcontainer priority attribute, microcontainer initial task stack size, callback thread entry, callback thread stack size, code space size, compiler type, whether shared memory is supported, whether MPU is supported, and whether privileged level operation is supported; The authorization file includes a list of resources that provide access rights to the microcontainer; The micro-container program is placed behind the header file and the authorization file, and is used to provide the user with the running program of the micro-container.
10. The microcontroller with a microcontainer according to claim 8, characterized in that: The micro-containers communicate with each other through inter-process communication.
