Changing storage content of main memory of microcontroller without separate storage management unit
By introducing basic firmware and component blocks into the main memory of the microcontroller and updating the code part of the component block using storage management information, the problem of difficult changes in the main memory content of the microcontroller is solved without a storage management unit, and the flexibility and update capabilities of the system are realized.
Patent Information
- Application Number
- CN202380063833.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-10-14
- Filing Date
- 2023-09-18
- Publication Date
- 2025-04-11
AI Technical Summary
In the absence of a separate storage management unit, the storage content of the microcontroller's main memory is difficult to change, limiting software updates and system flexibility.
By introducing basic firmware and component blocks into main memory, the component block contains code parts and storage management information. The microcontroller's processor processes the storage management information to change the code parts of the component block and update the storage management information.
It realizes simple, reliable and flexible changes to the storage content of the microcontroller main memory without a storage management unit, enhancing the adaptability and update capabilities of the system.
Smart Images

Figure CN119816810A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method for changing the storage content of a main memory of a microcontroller without a separate memory management unit according to the type defined in more detail in the preamble of claim 1 and the use of such a method, as well as a microcontroller and a vehicle comprising such a microcontroller. Background Art
[0002] Microcontrollers, sometimes also called System-on-Chip (SoC), are used in a wide variety of devices and machines to solve a variety of tasks. For example, microcontrollers are used as control devices for household appliances or are integrated in vehicles to provide vehicle functions.
[0003] The control commands to be executed by the microcontroller are pre-stored in the form of source code on a storage medium. As is usually required for information technology systems, software updates may be required, for example to patch security holes, fix errors or provide new functions. The microcontroller may have a memory management unit, also called a memory management unit (MMU), for converting the virtual addresses of each individual process handled by the microcontroller into physical addresses of the storage medium used. If a software update is installed, the corresponding program code pre-stored in the storage medium must be changed. This is entirely possible when using a memory management unit.
[0004] The tasks to be performed by a microcontroller are usually relatively simple. Furthermore, microcontrollers should be manufactured at low cost. For these reasons, the complexity of microcontrollers should be designed to be as low as possible. Therefore, the integration of a memory management unit into the microcontroller is usually abandoned. In this case, it is no longer so easy to install software updates. Therefore, it is necessary to provide a method that allows software updates to be installed on microcontrollers without a memory management unit.
[0005] One possible method is known from DE 10 2011 106 078 A1, which discloses a vehicle unit and a method for operating the vehicle unit. The vehicle unit is a computing unit that has the capability to independently perform software repairs. The vehicle unit has a microkernel structure for this purpose. The operating system is divided into a main operating system unit, an encryption unit and a monitoring unit for this purpose. In addition, a policy unit can also be optionally provided. A basic version of the operating system is pre-stored on a flash memory as a backup image, wherein the encryption unit and the monitoring unit monitor the operation of the main operating system unit and cause the operating system to be reinstalled from the backup image in the event of a fault. By providing the encryption unit and the monitoring unit, it is possible to dispense with the provision of a separate storage controller. However, the disadvantage here is that the vehicle unit disclosed here is based on a microkernel structure and therefore has the attendant disadvantages, such as reduced execution speed, high synchronization overhead for user processes and limited hardware access to the executed processes. The functions of controlling the memory are performed by the monitoring unit and the encryption unit, which are implemented as read-only units. This greatly limits the flexibility of adjusting the vehicle unit to changing boundary conditions, because the storage management logic cannot be adjusted. Summary of the invention
[0006] The object of the present invention is to provide an improved method for modifying the memory content of a main memory of a microcontroller without a separate memory management unit, by means of which method a particularly simple, reliable and flexible modification of the memory content is possible.
[0007] The technical solution of the present invention for achieving this object is a method for changing the storage content of a main memory of a microcontroller without a separate memory management unit, having the features of claim 1. Advantageous embodiments and developments as well as the use of such a method, a microcontroller and a vehicle having such a microcontroller result from the dependent claims.
[0008] A general method for changing the memory content of the main memory of a microcontroller without a separate memory management unit, wherein a part of the main memory is occupied by basic firmware, is developed according to the invention by:
[0009] - when the base firmware is introduced into the main memory, at least one component block is written together into the main memory, wherein the component block comprises a code portion / code component for providing at least one firmware component and / or at least one application component and storage management information; and
[0010] - In order to change at least a part of the code portion of at least one component block, the processor of the microcontroller processes the storage management information and writes the information to be written in the main memory at the location defined by the storage management information, and updates the storage management information of the changed component block.
[0011] The main memory of the microcontroller is not a working memory, also called a random access memory (RAM), but a main data carrier on which the source code of the basic firmware is contained. For example, the main memory can be a flash memory element. In order to simplify the structure of the microcontroller, the integration of a memory management unit (i.e., MMU) is abandoned. Nevertheless, it is possible with the method of the present invention to change the content of the main memory after the initial loading of data. In this case, the instructions for controlling the main memory are themselves contained in the changeable part of the data structure, which makes it possible to adjust the control of the main memory particularly flexibly. This makes it possible to use the microcontroller particularly flexibly even in the case of changing boundary conditions.
[0012] Here, the basic firmware refers to an unchangeable basic framework at the software level for providing basic functions. Further functions can be attached to this basic firmware later in the form of one or more component blocks. In addition to supplementary firmware components, application components can also be written to the component blocks, which allows the provision of applications with the aid of the microcontroller. There are fixed rules defined by the storage management information, i.e., at which locations in the component blocks information can be found, which prompts the processor of the microcontroller to manipulate the respectively relevant locations of the main memory in order to change the storage content.
[0013] Each time information needs to be written, i.e., for example, a software update, the microcontroller can be informed from the outside. For this purpose, the microcontroller has a suitable interface. For example, a storage medium such as a USB stick or an SD card can be inserted into a suitable reading slot and the information to be written can be read from it. The microcontroller can also be embedded in an information technology network of multiple computing units and obtain the information to be written via the network. In this case, the computing units of the network can be implemented as communication modules, so that the information can also be obtained via the Internet (for example, via mobile communication).
[0014] "Write" in this context means deleting, supplementing or overwriting information already existing in the main memory. Here, new component blocks can also be written to the main memory and attached to existing component blocks when appropriate. Correspondingly, not only the storage management information of the initial last component block in the component block chain is changed, but also new storage management information is defined for the newly created and attached component blocks.
[0015] Unlike attaching a new component block to an existing chain consisting of a basic firmware and a component block, instead, the complete content of the main memory can have been divided into the basic firmware and at least one component block. When changing the storage content, the component block can be gradually divided into multiple component blocks afterwards. If the main memory has a size of 256MB, for example, and the basic firmware occupies 20MB therein, the first component block (including the supplementary firmware component) occupies 60MB, then the size of the second (placeholder) component block is 176MB. Afterwards, this 176MB large second component block can be divided into a new second component block and a third component block when changing the storage content of the main memory, or it is decomposed into these component blocks afterwards. For example, if 56MB of other information is to be written to the main memory, then this 176MB is divided into a new second component block of 56MB in size and a third component block of 120MB in size. In this way, the storage space available on the main memory can be gradually divided into component blocks.
[0016] An advantageous development of the method provides for implementing the following structure for the corresponding component blocks:
[0017] - a length part, which defines the length of the area occupied by the corresponding component block on the main memory;
[0018] - a text portion comprising a code portion for providing at least one firmware component and / or at least one application component;
[0019] - an input interface part, which defines which input interfaces are read by the corresponding component blocks to read in input data;
[0020] - an output interface part, which defines which output interfaces are written by the corresponding component blocks to output the output data; and
[0021] - A parameter part, which defines the execution frequency of the firmware components and / or application components that can be provided by the corresponding component blocks, and defines application storage requirement information, which defines how much storage size is occupied on the RAM of the microcontroller when executing each firmware component and / or application component.
[0022] The text part here refers to the relevant part of the corresponding component block for providing the firmware component or application component. The text part therefore contains the actual "payload". The remaining part correspondingly represents the storage management information.
[0023] The length part describes the size of the content of the main memory written by the corresponding component block. In this case, a representation is selected that can be processed for the embodiment of the corresponding main memory, such as file size, number of flash pages, address range, etc. The information is stored step by step in the main memory, so that a series of written parts or a chain of written parts is formed. The microcontroller can then determine exactly where the corresponding component block starts and ends on the main memory by reading the corresponding written length of the part written by the component block.
[0024] The programs or program parts provided by each component block need to read input data when appropriate, and provide output data after the processor has processed it. Here, the input interface part contains information that defines which input data must be read from which input interfaces. The component block can contain a single firmware component and / or a single application component, or it can contain multiple firmware components and / or multiple application components. For each individual firmware component or each individual application component, there is its own interface definition, that is, which input interfaces and which output interfaces are used. That is, via the output interface part, each of these program components defines which output data is provided and the corresponding identifier of the output interface.
[0025] The microcontroller is informed via the parameter part at which execution frequency the individual program components contained in the component block should be executed. In addition, the parameter part contains information about how much storage space each program component needs to reserve on the RAM. This makes it possible to reliably provide sufficient storage space on the RAM.
[0026] The corresponding component blocks, i.e., the individual program components contained in the component blocks, can each call and use the functions of the basic firmware. However, the program components cannot directly call other program components in other component blocks. The communication between the component blocks is carried out via corresponding input data and output data.
[0027] The code sections contained in component blocks should be compiled in a position-independent manner, because the order and position of component blocks in the main memory are unknown. Therefore, the use of global or static variables is not allowed. All information related to component blocks is passed as function calls (also called Funktion Calls).
[0028] According to another advantageous embodiment of the method, variables representing output data that can be output by the corresponding component blocks are written to the RAM of the microcontroller when the microcontroller is started. "When the microcontroller is started" in this context means that the basic firmware is executed by the processor of the microcontroller when the microcontroller is started. This makes it possible for part of the RAM to be initially filled with these variables. These variables represent output data that can be generated by the program components of the component blocks. This makes it possible for each program component to write output data to the RAM even after being processed by the processor. These variables can be collected as one or more exchange files.
[0029] Another advantageous embodiment of the method provides that, when the microcontroller is started, the following information is written to the RAM of the microcontroller for each component block, taking into account the respective memory management information:
[0030] - a mapping structure, which defines the locations in the RAM where the output data that can be generated by the corresponding component block are written, and defines the allocation relationship, that is, the allocation relationship in which storage areas of the RAM the input data required by the corresponding component block are stored;
[0031] - a functional sequence structure defining a corresponding sequence of functions to be performed by a processor in order to provide the firmware components and / or application components that can be provided by the corresponding component blocks; and
[0032] - for each firmware component and / or application component of the corresponding component block: output structure,
[0033] It defines the output data that needs to be written by each firmware component and / or application component.
[0034] In this context, "when the microcontroller is started" also means that the basic firmware is executed by the processor when the microcontroller is started. The mapping structure describes where in the RAM the aforementioned variables are written and which program component generates which output data and reads which input data accordingly. This makes it possible for each program component, i.e. for the respective firmware component or application component, to reliably read and output the information to be processed.
[0035] The function sequence structure communicates to the microcontroller in what order the program components contained in the component blocks must be executed in order to provide a specific function.
[0036] In other words, the output structure describes which variables are output by the individual program components.
[0037] An input or output interface can be defined by a unique name, a unique version identifier and a unique (file) size. In this way, variables are transferred via the corresponding interface. The individual variables can have different sizes.
[0038] A pointer to the corresponding mapping structure is passed to each executing program component at each execution.
[0039] In this case, a null pointer, also called a Null Point, can also be passed, so that the respective program component can optionally also be regarded as not existing.
[0040] The sequence defined via the function sequence structure represents a function pointer, which is initially formed by the beginning of the corresponding text section, which contains the basic components of the corresponding program component.
[0041] When initializing the microcontroller, the base firmware processes / traverses each component block one by one, retains the previously executed area of RAM, and writes the previously mentioned pointers to RAM according to the mapping structure.
[0042] According to another advantageous embodiment of the method of the present invention, each component block is granted direct hardware access rights to the hardware components of the microcontroller. In this way, it is possible to allow or prohibit direct access of individual program components of the component block to the hardware of the microcontroller. The more program components are granted access rights to the hardware, the smaller the basic firmware can be designed.
[0043] Preferably, before executing at least one firmware component and / or at least one application component of the corresponding component block, write access to the RAM is restricted so that for the corresponding component block, only output data that can be output by the corresponding component block can be written to the RAM. In other words, before executing a component, the memory protection unit (MPU) can be configured so that only the following corresponding part of the RAM can be written: in which the output data of the corresponding program component will be written. In this way, the "freedom of interference" required by ISO 26262 can be ensured.
[0044] The use of the above-described method according to the invention proposes the use for software updating of programs stored in the main memory of a microcontroller, in particular for updating the firmware of a microcontroller. With the method of the invention, even microcontrollers without a separate memory management unit can change the storage content of the respective main memory. In this way, the program to be executed can be updated by the microcontroller or even a new program can be loaded. Particularly advantageously, the firmware of the microcontroller can also be changed here. For this purpose, the firmware is divided into basic firmware and firmware components provided in the component blocks. The basic firmware provides basic instructions for controlling the hardware used in order to read the relevant interfaces and communicate with the hardware components. Supplementary functions are contained in the firmware components of the component blocks.
[0045] Furthermore, a microcontroller according to the invention is adapted to carry out the method described above.
[0046] According to the invention, a vehicle comprises at least one such microcontroller. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Further advantageous embodiments of the method according to the invention for changing the memory content of the main memory of a microcontroller without a separate memory management unit also emerge from the exemplary embodiments, which will be described in more detail below with reference to the drawings.
[0048] in:
[0049] Figure 1 A schematic diagram showing the contents of the main memory and the working memory of the microcontroller of the present invention; and
[0050] Figure 2 A schematic diagram shows the content of a component block which is written to the main memory as a supplement to the basic firmware, divided into the content of the main memory and the content of the working memory. DETAILED DESCRIPTION
[0051] Figure 1 The main memory 1 and the working memory, also called random access memory (RAM) 4, of the microcontroller of the present invention are shown. The main memory 1 is in particular a flash memory element. Information is stored step by step in the main memory 1. This information represents the source code for providing various programs. This information is connected in series to form a chain.
[0052] The figure shows a basic firmware 2, followed by at least one component block 3. Figure 1 In the exemplary embodiment shown, the main memory has a plurality of component blocks 3, which are designated K1 to KN. In this case, the main memory 1 can have free storage space, wherein further component blocks 3 are introduced into the main memory 1 when the storage content of the main memory 1 is changed according to the method according to the invention. It is also possible that the main memory 1 is already completely divided into component blocks 3. In this case, there can also be particularly large component blocks 3, which are divided into more component blocks 3 when the content of the main memory 1 is changed. Such a component block 3 can be understood as a placeholder.
[0053] Figure 1 The contents of the RAM 4 are also shown. A basic firmware part 2.1 and at least one stack 5, also called a swap file, can be seen. In the stack 5, the compiled code of the corresponding program to be executed by the processor of the microcontroller and the data required for the respective program during processing are stored in advance. If the processor or microcontroller is adapted for parallel processing, also called multithreading, each task can also have its own stack 5, as shown in the figure.
[0054] Furthermore, interface information 6 can be found in RAM 4 , which describes for each program component (ie firmware component and / or application component) contained in component block 3 which input interfaces and output interfaces are connected to one another and how.
[0055] Figure 2 The contents written to the main memory 1 and RAM 4 for the corresponding component blocks 3 are shown in detail again. That is, each component block 3 (here exemplarily K1) includes information of the types of length part 3.1, text part 3.2, input interface part 3.3, output interface part 3.4 and parameter part 3.5 to be written to the main memory 1.
[0056] The length part 3.1 defines the area occupied by the corresponding component block 3 on the main memory 1. Since the component blocks 3 are attached to each other as chain-type information, the microprocessor is able to recognize the respective start and end positions of all component blocks 3, so that it can jump directly to the corresponding component block 3 on the main memory 1 when performing read and write access.
[0057] The text part 3-2 represents the actual payload of the component block 3 and contains the code part for providing the corresponding firmware component or application component. This is position-independent code, i.e., the code is compiled position-independently because the order and position of the program components are unknown from the component block 3 itself.
[0058] The input interface part 3.3 describes which input data the corresponding program component requests. Correspondingly, the output interface part 3.4 describes which output data is generated by the corresponding program component. The input interface part 3.3 and the output interface part 3.4 can be described by an interface specification 7, which explicitly describes the identifier of the corresponding interface, such as the name, version description and / or size.
[0059] Parameter part 3 . 5 ultimately describes at what frequency the respective program component of the respective component block 3 is executed by the microprocessor and how much storage space the respective program component requires on RAM 4 in the form of the respective stack 5 or in the form of a section of the respective stack 5 .
[0060] Furthermore, the RAM contents of the corresponding component block 3 are shown. For each program component, a mapping structure 4.1, a function sequence structure 4.2 and an output structure 4.3 can be seen.
[0061] The mapping structure 4.1 describes the structure of pointers to the corresponding input interfaces and output interfaces used by the component block 3. The function sequence structure 4.2 describes in which order the microprocessor has to process the various program components contained in the component block 3. Finally, after the processing of the corresponding program component, the output data is written to the corresponding output structure 4.3.
Claims
1. A method for changing the storage content of a main memory (1) of a microcontroller without a separate memory management unit, a part of which is occupied by basic firmware (2), It is characterized in that - when the basic firmware (2) is introduced into the main memory (1), at least one component block (3) is written into the main memory (1) together, the component block (3) comprising a code portion for providing at least one firmware component and / or at least one application component and comprising storage management information; and - In order to change at least a part of the code portion of at least one component block (3), the processor of the microcontroller processes the storage management information and writes the information to be written to the location defined by the storage management information in the main memory (1), and updates the storage management information of the changed component block (3).
2. The method according to claim 1, It is characterized in that The following structure is implemented for the corresponding component block (3): - a length part (3.1) which defines the length of the area occupied by the corresponding component block (3) on the main memory (1); - a text portion (3.2), said text portion comprising said code portion for providing at least one firmware component and / or at least one application component; - an input interface section (3.3), which defines which input interfaces are read by the corresponding component block (3) to read in input data; - an output interface section (3.4) which defines which output interfaces are written by the corresponding component block (3) to output the output data; and - A parameter part (3.5), which defines the execution frequency of the firmware components and / or application components that can be provided by the corresponding component block (3), and defines application storage requirement information, which defines how much storage size is occupied on the RAM (4) of the microcontroller when executing each firmware component and / or application component.
3. The method according to claim 1 or 2, It is characterized in that When the microcontroller is started, variables representing output data that can be output by the corresponding component block (3) are written into the RAM (4) of the microcontroller.
4. The method according to any one of claims 1 to 3, It is characterized in that When the microcontroller is started, for each component block (3), the following information is written into the RAM (4) of the microcontroller, taking into account the respective storage management information of the component block: - a mapping structure (4.1), which defines the locations of the RAM (4) into which output data that can be generated by the corresponding component block (3) are written, and defines the allocation relationship of the storage areas of the RAM (4) in which input data required by the corresponding component block are stored; - a functional sequence structure (4.2) defining a corresponding sequence of functions to be performed by the processor in order to provide firmware components and / or application components that can be provided by corresponding component blocks (3); and For each firmware component and / or application component of the corresponding component block (3): an output structure (4.3) which defines the output data to be written by the respective firmware component and / or application component.
5. The method according to any one of claims 1 to 4, It is characterized in that A direct hardware access right to the hardware components of the microcontroller is granted to the corresponding component block (3).
6. The method according to any one of claims 1 to 5, It is characterized in that Before executing the at least one firmware component and / or at least one application component of the corresponding component block (3), write access to the RAM (4) is restricted so that the corresponding component block (3) can only write output data that can be output by the corresponding component block (3) into the RAM (4).
7. Use of the method according to any one of claims 1 to 6, Features Use for performing a software update of a program stored in a main memory (1) of a microcontroller, in particular for updating the firmware of the microcontroller.
8. A microcontroller, It is characterized in that It comprises means for carrying out the method according to any one of claims 1 to 6.
9. A vehicle, It is characterized in that It comprises at least one microcontroller according to claim 8 .
Citation Information
Patent Citations
Vehicle unit and method for operating the vehicle unit
DE102011106078A1