Permission management execution method and system of microcontroller
By introducing a permission management interface in the microcontroller and setting the manager mode and user mode, the problem of the lack of flexibility of the existing TEE mechanism is solved, and flexible permission management of functions and peripheral devices is realized, which is suitable for a variety of scenarios and Provides a high level of protection.
Patent Information
- Application Number
- CN202310326395.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-03-20
- Filing Date
- 2023-03-30
- Publication Date
- 2024-09-20
AI Technical Summary
The Trusted Execution Environment (TEE) mechanism of current microcontrollers is inflexible and difficult to apply to various scenarios. In particular, program developers will encounter complex call and return problems when protecting design resources.
Propose a microcontroller permission management execution method and system. By providing a permission management interface, the development software suite is used to set the manager mode and user mode in the memory resources. In the manager mode, peripheral devices and functions can be configured and pointed to Collections are used by consumer mode, and these resources cannot be changed in consumer mode.
It realizes flexible permission settings for microcontroller functions and peripheral devices, is suitable for various scenarios, enhances operational flexibility, and has a high level of data protection capabilities.
Smart Images

Figure CN118673510A
Abstract
Description
Technical Field
[0001] The present invention relates to a microcontroller authority management execution method and a microcontroller authority management execution system, and in particular to a microcontroller authority management execution method and a microcontroller authority management execution system with an administrator mode and a user mode. Background Art
[0002] With the rapid development of technology, various microcontrollers are gradually being used in daily life. Microcontrollers can integrate processors, memory, timers / counters, and various input / output interfaces on an integrated circuit chip, so they are also called microcomputers. Current microcontrollers support 32-bit and 64-bit Trusted Execution Environment (TEE). The Trusted Execution Environment is an environment dedicated to running security-critical tasks, which can ensure that the programs and data in it are protected in terms of confidentiality and integrity.
[0003] The Trusted Execution Environment provides resources for users at different levels according to the hardware manufacturer's factory settings. However, the current TEE mechanism of microcontrollers lacks flexibility to be applied to various scenarios. For example, if a programmer wants to protect his or her design resources, calling and returning to various security areas will be very complicated. Summary of the invention
[0004] An embodiment of the present invention provides a method for executing permission management of a microcontroller. The method for executing permission management of a microcontroller includes providing a microcontroller; generating a permission management interface; setting the administrator mode and user mode corresponding to the memory resources of the microcontroller by using a development software package through the permission management interface; and in the administrator mode, pointing the set peripheral device set and function set to the user mode through the memory resources. When the peripheral device set and function set are used in the user mode, the peripheral device set and function set cannot be changed.
[0005] Another embodiment of the present invention provides a permission management execution system for a microcontroller. The permission management execution system for a microcontroller includes a microcontroller and a computer device. The microcontroller includes a user mode area and a manager mode area. The user mode area includes a user mode application module, a user mode memory module, a user mode interrupt request module and a user mode input / output module. The user mode memory module is coupled to the user mode application module. The user mode interrupt request module is coupled to the user mode memory module. The user mode input / output module is coupled to the user mode interrupt request module. The manager mode area includes a manager mode application module, a manager mode memory module, a manager mode interrupt request module and a manager mode input / output module. The manager mode memory module is coupled to the manager mode application module. The manager mode interrupt request module is coupled to the manager mode memory module. The manager mode input / output module is coupled to the manager mode interrupt request module. The computer device is coupled to the microcontroller to set the microcontroller. The computer device uses the development software package to set the microcontroller's memory resources to correspond to the administrator mode in the administrator mode area and the user mode in the user mode area through the permission management interface. When the computer device is set in administrator mode, the peripheral device set and function set in the set administrator mode application module are pointed to by memory resources for use in user mode. When using peripheral device sets and function sets in user mode, the peripheral device sets and function sets cannot be changed. BRIEF DESCRIPTION OF THE DRAWINGS
[0006] Figure 1 FIG. 4 is a block diagram of an embodiment of a rights management execution system for a microcontroller according to the present invention.
[0007] Figure 2 Is for Figure 1 A schematic diagram of configuration of an administrator mode and a user mode in memory resources in a permission management execution system of a microcontroller.
[0008] Figure 3 Is for Figure 1 Schematic diagram of the permission management interface in the permission management execution system of the microcontroller.
[0009] Figure 4 Is for Figure 1 Flowchart of executing the boot procedure in the permission management execution system of the microcontroller.
[0010] Figure 5 Is for Figure 1 A schematic diagram of a boot ROM and a summary viewer during matching in a permission management execution system of a microcontroller.
[0011] Figure 6 Is for Figure 1 A microcontroller permission management execution system is provided to execute a flowchart of a microcontroller permission management method.
[0012] The reference numerals are described as follows:
[0013] 100 Microcontroller Rights Management Execution System
[0014] 10. Microcontroller
[0015] 11 Boot ROM
[0016] 12 Summary Viewer
[0017] PC computer equipment
[0018] 10U User Mode Area
[0019] 10A Administrator Mode Area
[0020] 10U1 User Mode Application Module
[0021] 10U2 User Mode Memory Module
[0022] 10U3 User Mode Interrupt Request Module
[0023] 10U4 User Mode I / O Module
[0024] 10A1 Administrator Mode Application Module
[0025] 10A2 Supervisor Mode Memory Module
[0026] 10A3 Supervisor Mode Interrupt Request Module
[0027] 10A4 Administrator Mode Input / Output Module
[0028] 10B Specific file register
[0029] UI Permission Management Interface
[0030] SRAM_N General memory area
[0031] SRAM_SEC Secure Memory Area
[0032] SRAM_NA1 General memory area for managers
[0033] SRAM_NU1 User's general memory area
[0034] SRAM_SECA1 Manager's secure memory area
[0035] SRAM_SECU1 User's secure memory area
[0036] W1 to W5 Windows
[0037] Steps S401 to S411
[0038] Steps S601 to S604 DETAILED DESCRIPTION
[0039] Figure 1 1 is a block diagram of an embodiment of a microcontroller rights management execution system 100 of the present invention. The microcontroller rights management execution system 100 includes a microcontroller 10 and a computer device PC. Various software, hardware and even peripheral devices of the microcontroller 100 can be divided into two areas. For example, in Figure 1In the embodiment, the microcontroller 10 can be divided into a user mode area 10U and an administrator mode area 10A. The user mode area 10U corresponds to the user mode described below and has lower management authority. The administrator mode area 10A corresponds to the administrator mode described below and has higher management authority. The user mode area 10U includes a user mode application module 10U1, a user mode memory module 10U2, a user mode interrupt request (IRQ) module 10U3 and a user mode input / output module 10U4. The user mode application module 10U1 includes objects, application functions or attributes that can be operated by the user. The user mode memory module 10U2 can be a static random access memory (SRAM) configured exclusively for the user. The user mode memory module 10U2 is coupled to the user mode application module 10U1. The user mode interrupt request module 10U3 is coupled to the user mode memory module 10U2. Here, an interrupt request can temporarily stop a running program and allow a special program (such as an interrupt handler) to run. In practice, an interrupt request can be identified by an index with an IRQ format. The user mode input / output module 10U4 is coupled to the user mode interrupt request module 10U3. The user mode input / output module 10U4 can be used to control user-available functions such as a Universal Asynchronous Receiver / Transmitter (UART), a general-purpose input / output (GPIO), or a peripheral device. The manager mode area 10A includes a manager mode application module 10A1, a manager mode memory module 10A2, a manager mode interrupt request module 10A3, and a manager mode input / output module 10A4. The manager mode application module 10A1 includes objects, application functions, or properties that can be operated by the manager. The manager mode memory module 10A2 can be a static random access memory configured exclusively for the user. The supervisor mode memory module 10A2 is coupled to the supervisor mode application module 10A1. The supervisor mode interrupt request module 10A3 is coupled to the supervisor mode memory module 10A2. The supervisor mode input / output module 10A4 is coupled to the supervisor mode interrupt request module 10A3. The supervisor mode input / output module 10A4 can be used to control the supervisor, such as an asynchronous transceiver, a general-purpose input / output, or a peripheral device. The computer device PC is coupled to the microcontroller 10 to set the microcontroller 10.In the microcontroller's permission management execution system 100, the computer device PC can use the permission management interface and the development software package to set the memory resources of the microcontroller 10 to correspond to the administrator mode under the administrator mode area 10A and the user mode under the user mode area 10U. The computer device 10 can be set in the administrator mode, and the memory resources point to the peripheral device set and function set in the set administrator mode application module for use in the user mode. Since the authority in the administrator mode is greater than that in the user mode, some resources such as peripheral devices and function libraries can be "configured" in the administrator mode for use in the user mode. However, since the user's authority is lower, when the peripheral device set and function set configured by the administrator are used in the user mode, the peripheral device set and the function set cannot be changed, and their source code content cannot be browsed. The microcontroller 10 can also include a specific file register 10B. The specific file register 10B is used to store specific files or special files, which can be specified for use in the user mode and / or the administrator mode.
[0040] Figure 21 is a schematic diagram of the configuration of the administrator mode and the user mode in the memory resource in the permission management execution system 100 of the microcontroller. As mentioned above, the microcontroller 10 includes an administrator mode memory module 10A2 and a user mode memory module 10U2. The memory addresses corresponding to the administrator mode memory module 10A2 and the user mode memory module 10U2 are separate, and the details are as follows. The general data of the administrator mode can be configured in the first memory interval SRAM_NA1 of the memory resource. Therefore, the first memory interval SRAM_NA1 can also be called the administrator's general memory interval SRAM_NA1. The general data of the user mode can be configured in the second memory interval SRAM_NU1 of the memory resource. Therefore, the second memory interval SRAM_NU1 can also be called the user's general memory interval SRAM_NU1. The security data of the administrator mode can be configured in the third memory interval SRAM_SECA1 of the memory resource. Therefore, the third memory interval SRAM_SECA1 can also be called the administrator's secure memory interval SRAM_SECA1. The security data of the user mode can be configured in the fourth memory interval SRAM_SECU1 of the memory resource. Therefore, the fourth memory interval SRAM_SECU1 can also be called the user's secure memory interval SRAM_SECU1. Therefore, the administrator's general memory interval SRAM_NA1 and the user's general memory interval SRAM_NU1 belong to the general memory interval SRAM_N. The general memory interval SRAM_N can access data of the general security level. The administrator's secure memory interval SRAM_SECA1 and the user's secure memory interval SRAM_SECU1 belong to the secure memory interval SRAM_SEC. In practice, the secure memory interval SRAM_SEC can be stored in a physical random access memory in a data scrambled manner (such as Scramble) by hardware, so it has a higher security level and can access more confidential data. Alternatively, a mapping table can be generated, and according to the mapping table, the output address and the input address in the memory resource correspond to each other, so that security can be enhanced. The mapping table can be generated by a plurality of random numbers. For example, these random numbers can be generated by a random number source of a physical unclonable function (PUF). Furthermore, the general memory area SRAM_NA1 of the administrator, the general memory area SRAM_NU1 of the user, the secure memory area SRAM_SECA1 of the administrator, and the secure memory area SRAM_SECU1 of the user do not overlap.
[0041] Figure 31 is a schematic diagram of a permission management interface UI in a permission management execution system 100 for a microcontroller. The permission management interface UI may be Figure 3 The mode shown is not limited to this, and any reasonable interface change belongs to the scope disclosed by the present invention. The permission management interface UI can be generated by the development software package to set the microcontroller 10 on the PC side of the computer device. The permission management interface UI can include multiple windows, such as windows W1 to W5. The administrator can open the permission management interface UI to set various parameters. For example, the administrator can allocate the static random access memory size available to the administrator through window W1, which includes the general memory interval (such as 6KB) and the secure memory interval (such as 2KB) mentioned above. The remaining general memory interval and secure memory interval will be allocated to the user. The administrator can allocate the flash memory (Flash) and electronically erasable programmable read-only memory (EEPROM) size available to the administrator through window W2, such as setting the flash memory to 64KB and the EEPROM to 7.5KB. Administrators can use Window W3 to set the permissions for peripheral device privileges, such as using check boxes and drop-down menus to select the peripheral devices available in administrator mode. Administrators can use Window W4 to set the permissions for each GPIO pin, such as using check boxes and drop-down menus to select the general-purpose input and output pins available in administrator mode. Administrators can use Window W5 to set the permissions for system control parameter privileges, such as using check boxes and drop-down menus to select the parameters that can be controlled in administrator mode. However, Figure 3 The window positions, interface adjustment modes, interface parameter setting methods and templates shown are not limited to the present invention.
[0042] Figure 4 It is a flowchart of executing the boot program in the permission management execution system 100 of the microcontroller. Figure 5 A schematic diagram of the boot ROM 11 and the summary viewer 12 in the microcontroller rights management execution system 100 when matching. The process of the microcontroller rights management execution system 100 executing the boot program includes steps S401 to S411. Any reasonable step changes or technical replacements fall within the scope of the present invention. Steps S401 to S411 are described as follows:
[0043] Step S401: initializing the microcontroller 10;
[0044] Step S402: The microcontroller 10 is synchronized with the computer device PC through the development software package;
[0045] Step S403: Entering write mode;
[0046] Step S404: Determine whether to leave the write mode, if yes, go to step S405; if no, return to step S403;
[0047] Step S405: Execute the safe boot procedure;
[0048] Step S406: Checking the manager summary information;
[0049] Step S407: Check whether the manager summary information has passed the check. If so, proceed to step S408; if not,
[0050] Go to step S411;
[0051] Step S408: Check user summary information;
[0052] Step S409: Check whether the user summary data passes the check. If yes, proceed to step S410; if no,
[0053] Go to step S411;
[0054] Step S410: Entering standby state.
[0055] Step S411: Generate boot failure information.
[0056] After the computer device PC is connected to the microcontroller 10 through the development software kit, in step S401, the microcontroller 10 can be initialized. Then, the microcontroller 10 is synchronized with the computer device PC through the development software kit. In step S403, the microcontroller 10 enters the write mode. In step S404, the computer device PC determines whether the microcontroller 10 leaves the write mode. If it leaves the write mode, it enters step S405 and executes the safe boot procedure. If it has not left the write mode, it returns to step S403. The safe boot procedure can be referred to Figure 5 In practice, the first hardware and the second hardware can be used to detect whether they match. If the first hardware and the second hardware match, the security boot verification is passed. For example, the first hardware can be a boot read-only memory (Boot Read-Only Memory), and the second hardware can be a digest checker. The contents of the boot read-only memory 11 and the digest checker 12 can be checked for a match using a string of a predetermined bit length. For example, the contents of the boot read-only memory 11 and the digest checker 12 can be compared using a 256-bit hash code to determine whether they match. The subsequent steps are based on Figure 5 The secure boot matching method is completed. In step S406, the administrator summary data is checked. Next, the administrator summary data in the summary viewer 12 is compared with the boot ROM 11. In step S407, if the administrator summary data passes the check, the process proceeds to step S408. If the administrator summary data does not pass the check, it indicates that the match fails, and the process proceeds to step S411 to generate a boot failure message. In step S408, the user summary data in the summary viewer 12 is compared with the boot ROM 11. In step S409, if the user summary data passes the check, the process proceeds to step S410. If the user summary data does not pass the check, it indicates that the match fails, and the process proceeds to step S411 to generate a boot failure message. In other words, since the microcontroller's permission management execution system 100 can check the strings between different hardware to determine whether to boot, it has a high degree of security.
[0057] Any reasonable permission setting or function call of the microcontroller's permission management execution system 100 belongs to the scope disclosed by the present invention. For example, the microcontroller 10 can be a 16-bit microcontroller. The permission management execution system 100 of the microcontroller can obtain a set of interrupt vector resources and use the development software kit to point the set of interrupt vector resources to the administrator mode and the user mode. As mentioned above, the administrator mode has higher permissions, so in the administrator mode, all the interrupt vector resources of the microcontroller can be used. In addition, in the administrator mode, the interrupt vector resources that can be called in the user mode in the set of interrupt vector resources can also be planned. In another embodiment, the permission management execution system 100 of the microcontroller can obtain a special interrupt vector. The administrator mode uses a special interrupt vector to enter the user mode after executing the function. Then, the user mode enters the administrator mode again and writes a special memory location using a special string. Here, if the subroutine call of the user mode is reserved in advance in the administrator mode, the user mode can return to the user mode after entering the administrator mode and executing the subroutine call. The permission management execution system 100 of the microcontroller can also introduce a password mechanism to increase security. For example, the microcontroller's permission management execution system 100 can set an administrator mode password. Therefore, when entering the administrator mode, the development software package can authenticate the administrator mode password to protect the parameters and function sets of the peripheral device set set in the administrator mode.
[0058] Figure 6 1 is a flowchart of a microcontroller permission management execution system 100 running a microcontroller permission management method. The microcontroller permission management method includes steps S601 to S604. Any reasonable technical changes fall within the scope of the present invention. Steps S601 to S604 are described below:
[0059] Step S601: providing a microcontroller 10;
[0060] Step S602: Generate a rights management interface UI;
[0061] Step S603: Using the permission management interface UI, using the development software package to set the administrator mode and user mode corresponding to the memory resources of the microcontroller 10;
[0062] Step S604: In the administrator mode, use memory resources to point to the set peripheral device set and function set for use in the user mode.
[0063] The details of step S601 to step S604 have been described in detail above, so they will not be repeated here. The microcontroller permission management execution system 100 can independently set the permissions of the functions, features and peripheral devices used by the microcontroller, so it is suitable for various scenarios and various applications. In addition to having high data protection capabilities, it also has high operational flexibility.
[0064] In summary, the present invention describes a permission management execution method for a microcontroller and a permission management execution system for a microcontroller. The permission management execution system for a microcontroller can independently set the permissions of the functions, functions, and peripheral devices used by the microcontroller through a permission management interface. For example, higher permissions will be set in administrator mode, and lower permissions will be set in user mode. Therefore, since the functions, functions, and peripheral devices used by the microcontroller can independently set their permissions, the permission management execution system of the present invention is suitable for various scenarios and various applications. In addition to having high data protection capabilities, it also has a high degree of operational flexibility.
[0065] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for executing permission management of a microcontroller, It is characterized in that include: Provide a microcontroller; Generate a permissions management interface; Setting the administrator mode and the user mode corresponding to the memory resources of the microcontroller by using the development software package through the permission management interface; and In the administrator mode, the memory resource is used to point to the set peripheral device set and function set for use in the user mode; When the peripheral device set and the function set are used in the user mode, the peripheral device set and the function set cannot be changed.
2. The method according to claim 1, It is characterized in that The microcontroller is a 16-bit microcontroller, and the method further comprises: Obtain a set of interrupt vector resources; and Using the development software suite, directing the set of interrupt vector resources to the manager mode and the user mode; In the supervisor mode, all interrupt vector resources of the microcontroller are authorized to be used, and in the supervisor mode, the interrupt vector resources in the group of interrupt vector resources that are authorized to be called in the user mode are planned.
3. The method according to claim 1, It is characterized in that Also includes: Get the special interrupt vector; The supervisor mode uses the special interrupt vector to enter the user mode after executing the function; Entering the administrator mode from the user mode and writing a special string into a special memory location; and If the subroutine call of the user mode is reserved in advance in the administrator mode, the user mode returns to the user mode after entering the administrator mode and executing the subroutine call. model.
4. The method according to claim 1, It is characterized in that Also includes: Generate a mapping table; and According to the mapping table, generating an output address and an input address corresponding to the memory resource; The mapping table is generated from a plurality of random numbers.
5. The method of claim 4, wherein the random numbers are generated by a random number source of a Physical Unclonable Function (PUF).
6. The method according to claim 1, It is characterized in that Also includes: Set the administrator mode password; and When entering the administrator mode, the development software suite authenticates the administrator mode password to protect the parameters of the peripheral device set and the function set set in the administrator mode.
7. The method according to claim 1, It is characterized in that Also includes: Allocating the general data of the administrator mode in the first memory interval of the memory resource; Allocate the general data of the user mode in the second memory interval of the memory resource; and allocate the security data of the administrator mode in the third memory interval of the memory resource; and The security data of the user mode is arranged in a fourth memory interval of the memory resource; wherein the first memory interval, the second memory interval, the third memory interval and the fourth memory interval do not overlap.
8. The method according to claim 1, It is characterized in that Also includes: Enable safe boot; Check whether the first hardware and the second hardware match; and If the first hardware and the second hardware match, the security boot verification is passed; The first hardware includes a boot read-only memory (BOM), and the second hardware includes a digest checker (Digest Check).
9. The method according to claim 8, It is characterized in that The boot ROM and the digest detector use a string of predetermined bit length to check whether they match.
10. A microcontroller rights management execution system, include: Microcontroller, including: User mode area, including: User mode application module; A user mode memory module coupled to the user mode application module; A user mode interrupt request module coupled to the user mode memory module; and A user mode input / output module coupled to the user mode interrupt request module; and The manager mode area includes: Administrator mode application module; A manager mode memory module coupled to the manager mode application module; A supervisor mode interrupt request module coupled to the supervisor mode memory module; and A supervisor mode input / output module coupled to the supervisor mode interrupt request module; and A computer device, coupled to the microcontroller, for setting the microcontroller; The computer device uses a development software kit through a permission management interface to set the memory resources of the microcontroller to correspond to the administrator mode in the administrator mode area and the user mode in the user mode area. The computer device is set in the administrator mode and uses the memory resources to point to the peripheral device set and function set in the set administrator mode application module for use in the user mode. When the peripheral device set and the function set are used in the user mode, the peripheral device set and the function set cannot be changed.
