Method and system for improving MCU hardware compatibility
By designing a single firmware in the MCU that is compatible with multiple hardware components and using a host computer to configure the hardware ports, the problem of MCU firmware adapting to a single hardware component is solved, achieving efficient hardware compatibility and flexible custom development.
Patent Information
- Application Number
- CN202410695625.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2025-12-09
AI Technical Summary
In current MCU development, firmware can only be adapted to one hardware board, resulting in poor compatibility and requiring the development of multiple firmware versions, which increases the development workload.
Design a single firmware for an MCU that is compatible with multiple hardware components. Through interaction with a host computer, hardware ports can be flexibly configured from the outside. The MCU can update hardware configuration information by parsing configuration commands through the firmware, thus achieving compatibility with multiple hardware components.
It reduces the configuration, compilation, and generation operations of MCU program engineering, reduces development workload, improves hardware compatibility and development efficiency, and reduces program bugs.
Smart Images

Figure CN121092218A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of micro control unit, in particular to a method and system for improving the hardware compatibility of MCU. BACKGROUND
[0002] Generally, MCU (Microcontroller Unit, also known as single chip microcomputer) stores firmware, which can help MCU compatible with different hardware, and when the hardware changes, the firmware needs to be updated or upgraded (equivalent to developing a new firmware), for example, the patent number CN113094071B discloses a micro control unit, its control method and its firmware upgrade method, only after upgrading the firmware can the MCU compatible with multiple different hardware. At present, MCU development is different from Linux system development based on SOC (System on a Chip, System on a Chip). In order to adapt to different hardware, the Linux system development can simply adjust and configure the "device tree" according to different hardware interfaces, that is, the device tree burning file suitable for different hardware can be quickly configured, and then burned. However, for MCU development, there is no similar device tree configuration at present, and each different hardware board needs to be configured according to different IO ports, that is, different firmware needs to be developed to adapt. In other words, a MCU firmware can only adapt to one hardware board, and multiple firmware need to be developed to adapt to multiple hardware boards, which has poor compatibility and leads to large development workload. SUMMARY
[0003] The present application provides a method and system for improving the hardware compatibility of MCU, and the specific technical solutions are as follows: A method for improving the hardware compatibility of MCU, the method for improving the hardware compatibility of MCU comprising: after the MCU is powered on, detecting whether a configuration command of a host computer is received while running, if the running time of the MCU does not exceed a preset time and the configuration command is received, the MCU updates hardware configuration information according to the configuration command, and then restarts to complete the hardware configuration; wherein, when the MCU is connected with a hardware, the host computer sends a configuration command related to the hardware to the MCU, so that the MCU is compatible with the hardware; wherein, the MCU is pre-burned with a firmware, and the MCU analyzes the configuration command related to the hardware and updates the hardware configuration information through the firmware, so that the MCU is compatible with multiple different hardware by updating the hardware configuration information.
[0004] Further, after the MCU is powered on, the system clock and the serial port used for communication with the host computer are initialized, and then the program for communication between the serial port and the host computer is run.
[0005] Further, the MCU detects whether the hardware configuration information is stored in the FLASH inside the MCU after the initialization is completed, and if not, the MCU runs with the default configuration information, and if yes, the MCU runs with the stored hardware configuration information.
[0006] Further, the MCU detects whether the running time exceeds the preset time during the running with the default configuration information or during the running with the stored hardware configuration information, and if yes, the MCU no longer supports the interaction with the host computer, and if not, the MCU detects whether the configuration command from the host computer is received, and if not, the MCU continues to run, and if yes, the MCU updates the hardware configuration information according to the configuration command.
[0007] Further, the method for updating the hardware configuration information by the MCU according to the configuration command comprises that the MCU parses the configuration command by the firmware to obtain the hardware configuration information, and then saves the hardware configuration information into the FLASH inside the MCU, so as to update the hardware configuration information.
[0008] Further, when the MCU is connected with the hardware, the host computer generates the configuration command related to the hardware according to the received external instruction and sends the configuration command to the MCU through the serial port, so that the MCU is compatible with the hardware.
[0009] A MCU is used to implement the method for improving the hardware compatibility of the MCU, the MCU is pre-burned with a firmware, the MCU parses the configuration command related to the hardware connected with the MCU by the firmware and updates the hardware configuration information, so that the MCU is compatible with multiple different hardware by updating the hardware configuration information.
[0010] Further, the MCU comprises a FLASH, the FLASH is used to store the hardware configuration information, so that the MCU updates the hardware configuration information.
[0011] A host computer is used to implement the method for improving the hardware compatibility of the MCU, when the MCU is connected with the hardware, the host computer sends the configuration command related to the hardware to the MCU, so that the MCU is compatible with the hardware.
[0012] The system for improving MCU hardware compatibility is used for implementing the method for improving MCU hardware compatibility, and comprises an MCU and a host computer, wherein the MCU and the host computer are connected, the host computer sends a configuration command related to the hardware to the MCU when the MCU is connected with the hardware, so that the MCU is compatible with the hardware, the MCU is pre-burned with a firmware, and the MCU analyzes the configuration command related to the hardware and updates hardware configuration information through the firmware, so that the MCU is compatible with multiple different hardware through updating the hardware configuration information.
[0013] The method for improving MCU hardware compatibility disclosed in the application designs an MCU single firmware compatible with multiple hardware, and hardware ports are flexibly configured from the outside through host computer interaction, so that one firmware corresponds to one version of hardware is changed to one firmware compatible with multiple hardware, a series of operations such as configuration, compilation and generation of the MCU program engineering are reduced, the purposes of reducing development workload and reducing program BUG are achieved, and more flexible and efficient customized development of software and hardware is also achieved. BRIEF DESCRIPTION OF DRAWINGS
[0014] Figure 1 A flowchart of the method for improving MCU hardware compatibility according to an embodiment of the application is shown. DETAILED DESCRIPTION
[0015] In the following description, specific details are set forth such as particular system configurations, techniques, etc., in order to provide a thorough understanding of the embodiments of the application. However, persons skilled in the art will understand that the application can be practiced without such specific details. In other instances, well-known structures, devices, circuits, and methods have not been described in detail in order to avoid obscuring the application.
[0016] It should be understood that, when used in the present application, the term "comprising" indicates the presence of described features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or sets thereof. It should also be understood that the term "and / or" used in the present application refers to any combination of one or more of the associated listed items and all possible combinations thereof, and includes these combinations.
[0017] As used in this application, the term “if’ can be construed to mean “when” or “once” or “in response to a determination” or “in response to a detection” that a described condition precedent has been accomplished, unless context clearly requires otherwise. Similarly, the phrases “if it is determined” or “if [a described condition or event] is detected” can be construed to mean “once it has been determined” or “once [the described condition or event] has been detected,” or “in response to a determination” or “in response to the detection,” that the described condition precedent has been accomplished, unless context clearly requires otherwise.
[0018] In addition, the description in this application of references “one embodiment” or “some embodiments” and the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the application. The appearances of the phrases “in one embodiment,” “in some embodiments,” “in other embodiments,” “in still other embodiments,” and the like in the specification do not necessarily all refer to the same embodiment, unless otherwise noted particularly specifies that context. The terms “comprising,” “including,” “having” and the like are meant to be interpreted as “including but not limited to,” unless otherwise noted.
[0019] Generally, the MCU (Microcontroller Unit, also known as single-chip microcomputer) stores firmware, which can help the MCU compatible with different hardware, and when the hardware changes, the firmware needs to be updated or upgraded (equivalent to developing a new firmware), for example, the patent number CN113094071B discloses a microcontroller unit, its control method and its firmware upgrading method, only by upgrading the firmware can make the MCU compatible with a variety of different hardware. At present, MCU development is different from Linux system development based on SOC (System on a Chip, System on a Chip), in order to adapt to different hardware, the Linux system development can simply adjust and configure the “device tree” according to different hardware interfaces, that is, the device tree burning file suitable for different hardware can be quickly configured, and then burned. However, for MCU development, there is no similar device tree configuration at present, and each different hardware board needs to be configured according to different IO ports, that is, different firmware needs to be developed to adapt. In other words, a MCU firmware can only adapt to one hardware board, and multiple firmware needs to be developed to adapt to multiple hardware boards, which has poor compatibility and leads to large development workload.
[0020] To solve the above technical problems, the embodiment of the application provides a method for improving MCU hardware compatibility, designs an MCU single firmware compatible with multiple hardware, and flexibly configures a hardware port from the outside through upper computer interaction, so that one piece of engineering output one piece of firmware corresponds to one version of hardware, to one piece of engineering output one piece of firmware compatible with multiple hardware, reduces a series of operations such as configuration, compilation and generation of the MCU program engineering, achieves the purposes of reducing development workload and reducing program BUG, and also realizes more flexible and efficient customized development of software and hardware.
[0021] As shown in the figure, Figure 1 The method for improving MCU hardware compatibility comprises the following steps. After the MCU is powered on, whether a configuration command of the upper computer is received is detected while the MCU is running, if the running time of the MCU does not exceed a preset time and the configuration command is received, the MCU updates hardware configuration information according to the configuration command, and then restarts to complete hardware configuration; wherein, when the MCU is connected with hardware, the upper computer sends a configuration command related to the hardware to the MCU, so that the MCU is compatible with the hardware; wherein, the MCU is pre-burned with a firmware, the MCU analyzes the configuration command related to the hardware and updates the hardware configuration information through the firmware, so that the MCU is compatible with multiple different hardware by updating the hardware configuration information.
[0022] The firmware refers to a program written in an EPROM (erasable programmable read-only memory) or an EEPROM (electrically erasable programmable read-only memory), is a device "driver" saved in a device, and through the firmware, an operating system can realize running actions of a specific machine according to a standard device driver, for example, an optical drive, a CD recorder and the like all have internal firmware. The firmware is software performing the most basic and lowest level work of a system. In a hardware device, the firmware is the soul of the hardware device, because the hardware device is composed of no other software except the firmware, and thus the firmware determines the function and performance of the hardware device. Obviously, the firmware exists in the MCU, and the initialization and hardware configuration and the like of the MCU are realized by the firmware. In the embodiment of the application, the configuration command sent by the upper computer to the MCU is also analyzed by the firmware in the MCU, and after the analysis is completed, the result is stored in a FLASH in the MCU, so that the update of the hardware configuration information is realized.
[0023] It should be noted that, due to the limitation of MCU pins, generally, MCU pins can be configured to different functions to meet the needs of different application scenarios. For example, pin 1 of a certain MCU can be configured as a USB function or a normal GPIO function. If the user scenario requires pin 1 to control an LED lamp, at this time, only the hardware configuration information of the MCU needs to be updated, and pin 1 is configured as a GPIO output. In the prior art, if pin 1 is to be fully utilized, at least two firmware need to be prepared, one is the firmware in which pin 1 is configured as a GPIO function, and the other is the firmware in which pin 1 is configured as a USB function. The method for improving the hardware compatibility of the MCU described in the embodiments of the present application only needs to develop one firmware, which can parse the configuration command of the upper computer, so that the MCU configures the pin to the function currently required according to the configuration command, that is, the hardware port is flexibly configured from the outside through the upper computer interaction, so that the MCU is compatible with multiple hardware, greatly reducing the development workload.
[0024] As one of the implementation manners, after the MCU is powered on, the system clock and the serial port for communicating with the upper computer are initialized, and then a program for the serial port to communicate with the upper computer is run. It should be noted that, since communication is carried out through the upper computer, different boards need a certain serial port to communicate with the upper computer. In order to be compatible with the same version of software, the boards must also have a fixed port, otherwise communication cannot be carried out.
[0025] As one of the implementation manners, after the MCU is initialized, it is detected whether the hardware configuration information is stored in the FLASH inside the MCU. If not, the default configuration information is used for running, and if yes, the stored hardware configuration information is used for running. After initialization, the stored hardware configuration information is used for running, which improves the configuration efficiency without replacing the hardware.
[0026] As one of the implementation manners, during the process of using the default configuration information for running or during the process of using the stored hardware configuration information for running, it is detected whether the running time exceeds the preset time. If the preset time is exceeded, the interaction with the upper computer is no longer supported, and if the preset time is not exceeded, it is detected whether the configuration command of the upper computer is received. If the configuration command is not received, the running is continued, and if the configuration command is received, the MCU updates the hardware configuration information according to the configuration command. In order not to affect the normal use of the MCU, when the running time exceeds the preset time, such as more than 1 minute, the upper computer does not send the configuration command by default, and the hardware port does not need to be configured.
[0027] As one of the embodiments, when the MCU is connected with the hardware, the host computer generates the configuration command related to the hardware according to the received external instruction and sends the configuration command to the MCU through the serial port, so that the MCU is compatible with the hardware. The external instruction is input to the host computer by the production personnel through the PC, and then the host computer automatically generates the configuration command related to the hardware according to the external instruction. The process of generating the configuration command by the host computer is as follows: 1. Since it is different hardware configuration, the production personnel should first start from different hardware schematics, and confirm different boards and different devices corresponding to different GPIO ports according to the circuit schematic diagram; 2. According to the different GPIO ports, the production personnel selects or inputs the corresponding port on the host computer; 3. Check the port required for the configuration of the current function, and save it as a configuration command on the host computer; 4. The first three steps only need to be operated once, and then the production personnel imports the configuration command during actual operation, and then sends it to the MCU.
[0028] The embodiment of the present application provides a MCU, which is used for implementing the method for improving the hardware compatibility of the MCU. The MCU is pre-burned with a firmware. The MCU analyzes the configuration command related to the hardware connected with the MCU through the firmware and updates the hardware configuration information, so that the MCU is compatible with multiple different hardware through updating the hardware configuration information.
[0029] As one of the embodiments, the MCU comprises a FLASH, which is used for storing the hardware configuration information, so that the MCU realizes the updating of the hardware configuration information.
[0030] The embodiment of the present application provides a host computer, which is used for implementing the method for improving the hardware compatibility of the MCU. When the MCU is connected with the hardware, the host computer sends the configuration command related to the hardware to the MCU, so that the MCU is compatible with the hardware.
[0031] The embodiment of the present application provides a system for improving the hardware compatibility of the MCU, which is used for implementing the method for improving the hardware compatibility of the MCU. The system for improving the hardware compatibility of the MCU comprises a MCU and a host computer. The MCU and the host computer are connected. When the MCU is connected with the hardware, the host computer sends the configuration command related to the hardware to the MCU, so that the MCU is compatible with the hardware. The MCU is pre-burned with a firmware. The MCU analyzes the configuration command related to the hardware through the firmware and updates the hardware configuration information, so that the MCU is compatible with multiple different hardware through updating the hardware configuration information.
[0032] The system for improving MCU hardware compatibility described in the application designs an MCU single firmware compatible with multiple hardware, and the hardware port is flexibly configured from the outside through the host computer interaction, so that one engineering output one firmware corresponds to one hardware is changed to one engineering output one firmware compatible with multiple hardware, which reduces a series of operations such as configuration, compilation, and generation of the MCU program engineering, achieves the purpose of reducing the development workload and reducing the program BUG, and also realizes more flexible and efficient customized development of software and hardware.
[0033] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiment methods. In the embodiments provided in the present application, the references to the memory, storage, database or other medium can include non-volatile and / or volatile memory. The non-volatile memory can include read-only memory (ROM), programmable memory (PROM), electrically programmable memory (DPROM), electrically erasable programmable memory (DDPROM) or flash memory. The volatile memory can include random access memory (RAM) or external cache memory.
[0034] The technical features of the above embodiments can be combined in any way. In order to make the description simple, not all possible combinations of the above embodiments are described, but as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.
[0035] The above embodiments only express several embodiments of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the patent application range. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of the present application.
Claims
1. A method for improving MCU hardware compatibility, characterized in that, The method for improving the hardware compatibility of the MCU comprises: After the MCU is powered on, whether a configuration command of the upper computer is received is detected while the MCU is running, if the running time of the MCU does not exceed a preset time and the configuration command is received, the MCU updates the hardware configuration information according to the configuration command, and then restarts to complete the hardware configuration; When the MCU is connected with hardware, the upper computer sends a configuration command related to the hardware to the MCU, so that the MCU is compatible with the hardware. The MCU is pre-burned with a firmware, the MCU analyzes the configuration command related to the hardware and updates the hardware configuration information through the firmware, so that the MCU is compatible with multiple different hardware by updating the hardware configuration information.
2. The method for improving MCU hardware compatibility according to claim 1, characterized in that, After the MCU is powered on, the system clock and the serial port used for communication with the upper computer are initialized, and then a program for communication between the serial port and the upper computer is run.
3. The method of claim 2, wherein, After the MCU completes the initialization, whether the hardware configuration information is stored in the FLASH inside the MCU is detected, if not, the default configuration information is used for running, and if yes, the stored hardware configuration information is used for running.
4. The method of claim 3, wherein, During the process of using the default configuration information for running or during the process of using the stored hardware configuration information for running, whether the running time exceeds a preset time is detected, if yes, the interaction with the upper computer is no longer supported, and if no, whether the configuration command of the upper computer is received is detected, if not, the running is continued, and if yes, the MCU updates the hardware configuration information according to the configuration command.
5. The method of claim 4, wherein, The method that the MCU updates the hardware configuration information according to the configuration command comprises that the MCU analyzes the configuration command through the firmware to obtain the hardware configuration information, and then saves the hardware configuration information into the FLASH inside the MCU, so as to realize the update of the hardware configuration information.
6. The method of claim 2, wherein, When the MCU is connected with hardware, the upper computer generates a configuration command related to the hardware according to the received external instruction and sends the configuration command to the MCU through the serial port, so that the MCU is compatible with the hardware.
7. An MCU, characterized in that, The MCU is used to realize the method for improving the hardware compatibility of the MCU according to any one of claims 1 to 6, the MCU is pre-burned with a firmware, the MCU analyzes the configuration command related to the hardware connected with the MCU through the firmware and updates the hardware configuration information, so that the MCU is compatible with multiple different hardware by updating the hardware configuration information.
8. The MCU of claim 7, wherein, The MCU comprises a FLASH, the FLASH is used to store the hardware configuration information, so that the MCU realizes the update of the hardware configuration information.
9. A host computer, characterized by The upper computer is used to realize the method for improving the hardware compatibility of the MCU according to any one of claims 1 to 6, when the MCU is connected with hardware, the upper computer sends a configuration command related to the hardware to the MCU, so that the MCU is compatible with the hardware.
10. A system for improving MCU hardware compatibility, the system comprising: The system for improving MCU hardware compatibility is used to implement the method for improving MCU hardware compatibility according to any one of claims 1 to 6, and comprises the MCU according to any one of claims 7 to 8 and the host computer according to claim 9, wherein the MCU and the host computer are connected, and when the MCU is connected with hardware, the host computer sends a configuration command related to the hardware to the MCU, so that the MCU is compatible with the hardware, the MCU is pre-burned with a firmware, and the MCU analyzes the configuration command related to the hardware and updates hardware configuration information through the firmware, so that the MCU is compatible with a plurality of different hardware by updating the hardware configuration information.
Citation Information
Patent Citations
A microcontroller unit, its control method, and its firmware upgrade method
CN113094071B