Application program updating method and electronic device
By solidifying the first-level boot program in OTP space and updating the MCU's application with the second-level boot program, the storage efficiency problem caused by BootLoader footprint in traditional MCU application upgrades is solved, and 100% of the space utilization of the application is achieved and savings in storage resources.
Patent Information
- Application Number
- CN202010490198.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-02
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2040-06-02
AI Technical Summary
When the Flash storage space of traditional MCUs is upgraded, the user's application space utilization rate is low, and it is only 75% efficient.
By pre-hardening the first-level boot program in the OTP space, we can determine whether the Flash space needs to be updated, and use the second-level boot program to download and update the application from the upper computer or terminal device to achieve the complete occupation of the Flash space of the application.
Improves the space utilization of applications, saves MCU storage resources, and ensures 100% utilization of Flash storage space.
Smart Images

Figure CN111752588B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of embedded technology, and in particular to an application program updating method and electronic equipment. Background Art
[0002] In the application of electronic devices, user applications often change. In order to facilitate the update of applications in electronic devices, the user application is separated from another program in design. The user application is loaded and upgraded through another program, which is generally called BootLoader program.
[0003] Traditional MCU program storage areas are mostly divided into two areas: Bootloader area and APP area. The APP area is the area where the application is located and executes the user program; while the Bootloader area is the program boot area, which is used to load and update the application. The BootLoader program and the user application will be in different areas of the MCU Memory.
[0004] The traditional application upgrade method is to divide the MCU's Flash into two parts: the boot area Bootloader and the application area APP. The BootLoader program and the application are allocated in the ROM (Flash) area. The BootLoader area is generally fixed, that is, the program area where the BootLoader is located will not be erased when the program is upgraded. However, the Flash erase of the TI C2000 MCU is erased in sectors as the minimum unit. Taking TMS320F28023 as an example, the total Flash space is 32K, which is divided into 4 sectors, and the capacity of each sector is 8K. The minimum unit of erase is a sector, that is, 8K. Even if the BootLoader program segment only occupies 1K of space, the remaining 7K space cannot be allocated to the user application. In this way, the BootLoader program will occupy an 8K sector space alone, and the space left for the user application is actually only 24K, with a utilization rate of only 75%, resulting in a waste of storage space. Summary of the invention
[0005] Based on this, it is necessary to provide an application updating method and electronic device to improve the space utilization of the application in response to the above technical problems.
[0006] In a first aspect, an embodiment of the present invention provides a method for updating an application program, the method comprising:
[0007] Determine whether the application in the Flash space needs to be updated through the first-level boot program pre-solidified in the OTP space;
[0008] If the application needs to be updated, the application is updated through the second-level boot program.
[0009] In some embodiments, the method further comprises:
[0010] Dividing the boot program into a first-level boot program and a second-level boot program in advance;
[0011] Pre-fix the first-level boot program into the OTP space;
[0012] The second-level boot program is stored in a host computer or a terminal device.
[0013] In some embodiments, if the application needs to be updated, updating the application through the second-level boot program includes:
[0014] Receiving the second-level boot program sent by the host computer or the terminal device through the first-level boot program;
[0015] The second-level boot program is stored in the RAM, and the second-level boot program is run to update the application program.
[0016] In some embodiments, storing the second-level boot program in RAM and running the second-level boot program to update the application program includes:
[0017] Receiving the application program sent by the host computer or the terminal device through the second-level boot program;
[0018] Burn the application program into the application program area.
[0019] In some embodiments, burning the application into the application area includes:
[0020] The Flash API function is called to burn the application program into the application program area.
[0021] In some embodiments, after calling the Flash API function to burn the application into the application area, the method further includes:
[0022] Jump to the application.
[0023] In some embodiments, before determining whether the application in the Flash space needs to be updated by the first-level boot program solidified in the OTP space, the method further includes:
[0024] After the MCU is powered on and reset, the MCU is booted into the OTP space through the pre-set boot configuration options;
[0025] Run the first-level boot program solidified in the OTP space.
[0026] In some embodiments, the method further comprises:
[0027] If the application does not need to be updated, jump to the application.
[0028] In a second aspect, an embodiment of the present invention further provides an electronic device, including:
[0029] at least one processor; and,
[0030] a memory communicatively connected to the at least one processor; wherein,
[0031] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned application updating method.
[0032] In a third aspect, an embodiment of the present invention further 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 processor, the processor executes the update method of the above-mentioned application.
[0033] Compared with the prior art, the beneficial effects of the present invention are: different from the prior art, the application update method and electronic device in the embodiments of the present invention, by pre-solidifying the first-level boot program in the OTP space, the application can completely occupy the Flash space, and then use the first-level boot program to determine whether the application in the Flash space has an update requirement. If the application needs to be updated, the second-level boot program is obtained, and the application in the Flash space is updated through the second-level boot program, thereby improving the space utilization of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0035] Figure 1 is a schematic diagram of an application environment of a method for updating an application program in one embodiment of the present invention;
[0036] Figure 2 is a flow chart of a method for updating an application program in one embodiment of the present invention;
[0037] Figure 3is a flowchart of dividing a 2-level boot program in one embodiment of the present invention;
[0038] Figure 4 is a schematic diagram of a process of updating an application program through a second-level boot program in one embodiment of the present invention;
[0039] Figure 5 is a schematic diagram of presetting MCU boot configuration options in one embodiment of the present invention;
[0040] Figure 6 is a detailed flow chart of a method for updating an application in one embodiment of the present invention;
[0041] Figure 7 is a schematic diagram of the structure of an application updating device in one embodiment of the present invention;
[0042] Figure 8 It is a schematic diagram of the hardware structure of an electronic device in one embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0044] It should be noted that, if there is no conflict, the various features in the embodiments of the present invention can be combined with each other, all within the scope of protection of the present invention. In addition, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a different order from the module division in the device or the flow chart. Furthermore, the words "first", "second", "third", etc. used in the present invention do not limit the data and execution order, but only distinguish the same items or similar items with basically the same functions and effects.
[0045] The application program update method provided in the embodiment of the present invention is applicable to all MCUs with OTP space, such as Figure 1 In the application environment shown, the application environment includes an MCU and a host computer or a terminal device. Figure 1 The MCU 10 and the host computer 20 are shown as examples. The MCU 10 and the host computer 20 are in communication connection, and the MCU 10 is used to receive a program sent by the host computer.
[0046] The MCU 10 may be a TI C2000 series MCU, which has a 1K OTP (One Time Programmable) storage space in addition to the conventional Flash storage space. The host computer 20 may be any computer capable of directly sending control commands, such as an industrial computer, a workstation, and a touch screen.
[0047] It should be noted that the method provided in the embodiment of the present invention can be further extended to other suitable application environments, and is not limited to Figure 1 In the actual application process, the application environment may also include more or fewer MCUs and host computers or terminal devices.
[0048] like Figure 2 As shown, an embodiment of the present invention provides a method for updating an application program, the method comprising:
[0049] Step 202: determine whether the application program in the Flash space needs to be updated through the first-level boot program pre-cured in the OTP space.
[0050] In the embodiment of the present invention, the TI C2000 series MCU is taken as an example for explanation. In addition to the conventional Flash storage space, the TI C2000 series MCU also has a 1K OTP storage space. Since the boot program needs to realize communication, application data verification, call functions to unlock, erase, program and verify the Flash, and other complex functions, the 1K OTP space is not enough to complete so many functions. Therefore, in the embodiment of the present invention, by pre-fixing the first-level boot program in the OTP space, the functions implemented by the first-level boot program are relatively simple, so the 1K OTP space is sufficient to support the first-level boot program to complete the functions required to be implemented. The first-level boot program is pre-fixed in the OTP space and does not occupy the Flash storage space, so the application can completely occupy the Flash storage space.
[0051] Among them, OTP space is OTP (One Time Programmable) storage space, which is used to store the first-level boot program. The first-level boot program is the first code executed after the MCU is powered on, which is used to determine whether the application software needs to be updated and receive the second-level boot program. Flash space is used to store application programs. Application programs can occupy 100% of Flash space, which is conducive to saving MCU storage resources.
[0052] Specifically, the following methods can be used to determine whether the application in the Flash storage space needs to be updated: When the MCU sends a handshake signal to the host computer, the host computer replies with a handshake signal; or the Flash application area fails the check and is in a waiting state for update; or when the application area receives an update instruction, it determines whether the RAM address meets the preset requirements according to the update instruction, and then determines whether it needs to be updated.
[0053] Step 204: If the application needs to be updated, the application is updated through the second-level boot program.
[0054] The second level boot program is used to receive the application program sent by the host computer or the terminal device and update the application program. Specifically, after determining that the application program needs to be updated through step 202, the second level boot program is used to update the application program.
[0055] In an embodiment of the present invention, by pre-solidifying the first-level boot program in the OTP space, the application can completely occupy the Flash space. Then, the first-level boot program is used to determine whether the application in the Flash space needs to be updated. If the application needs to be updated, the second-level boot program is obtained, and the application in the Flash space is updated through the second-level boot program. This not only improves the space utilization of the application, but also saves the storage resources of the MCU.
[0056] In some embodiments, Figure 3 As shown, the method also includes:
[0057] Step 302: pre-dividing the boot program into a first-level boot program and a second-level boot program.
[0058] The boot program is the first code executed by the embedded system after power-on. After it completes the initialization of the CPU and related hardware, it loads the operating system image or the solidified embedded application into the memory and then jumps to the space where the operating system is located to start the operating system. For example, when the system is powered on or reset, it usually starts execution from address 0x00000000, and the system boot program is usually arranged at this address, and traditional boot programs occupy Flash storage space.
[0059] In order to improve the utilization of Flash storage space, the boot program is pre-divided into a first-level boot program and a second-level boot program, wherein the first-level boot program and the second-level boot program have different functions. The first-level boot program is only used to receive the second-level boot program, and the second-level boot program is used to receive the application program and implement the update of the application program.
[0060] Step 304: pre-fix the first-level boot program into the OTP space.
[0061] Step 306: store the second-level boot program in a host computer or a terminal device.
[0062] Specifically, since the traditional boot program will occupy the Flash storage space, the application program cannot completely occupy the Flash storage space, thereby reducing the utilization rate of the Flash storage space. Therefore, in the embodiment of the present invention, a 1K OTP space that is almost never used is used to solidify or store the first-level boot program. At the same time, the second-level boot program is stored in the host computer or the terminal device, thereby enabling the application program to completely occupy the Flash storage space, thereby improving the utilization rate of the Flash storage space.
[0063] In some embodiments, Figure 4 As shown, if the application needs to be updated, updating the application through the second-level boot program includes:
[0064] Step 402: receiving the second-level boot program sent by the host computer or the terminal device through the first-level boot program.
[0065] Specifically, since the second-level boot program is pre-stored on the host computer or terminal device, after determining that the application needs to be updated, the second-level boot program sent by the host computer or terminal device is received through the first-level boot program solidified in the OTP storage space, that is, the second-level boot program is downloaded from the host computer.
[0066] Step 404: store the second-level boot program in RAM, and run the second-level boot program to update the application.
[0067] When the first-level boot program completes downloading the second-level boot program from the host computer, the second-level boot program is stored in the MCU's RAM (Random Access Memory), which can be read and written at any time and at a fast speed. Then jump to the RAM to run the second-level boot program so that the second-level boot program updates the application. Specifically, the application sent by the host computer or the terminal device is received through the second-level boot program, that is, the application is downloaded from the host computer or the terminal device through the second-level boot program, and the Flash API function is called to burn the application into the application area, that is, the Flash storage space, to complete the update of the application.
[0068] In some other embodiments, after calling the Flash API function to burn the application into the application area, ie, the Flash storage space, and completing the update of the application, the program jumps to the application.
[0069] In some embodiments, the boot configuration options of the MCU are pre-set before the first-level boot program solidified in the OTP space determines whether the application in the Flash space needs to be updated. Figure 5 As shown, by setting two positions in OTP, one is to boot to Flash and the other is to boot to OTP. Because the first-level boot program is solidified in OTP, it must be run from OTP first. Therefore, in the embodiment of the present invention, boot to OTP is selected. Specifically, when the MCU is powered on and reset, the MCU is booted to the OTP space through the pre-set boot configuration options, and the first-level boot program solidified in the OTP space is run.
[0070] In some other embodiments, if the first-level boot program determines that the application does not need to be updated, it automatically jumps to the application.
[0071] To facilitate understanding of the present invention, the following will be specifically described:
[0072] like Figure 6 As shown, first, the boot program is divided into two levels of boot programs. Since traditional boot programs occupy the Flash storage space, the application program cannot completely occupy the Flash storage space, thereby reducing the utilization rate of the Flash storage space. In order to improve the utilization rate of the Flash storage space, the boot program is pre-divided into a first-level boot program and a second-level boot program, and a 1K OTP space that is almost never used is used to solidify or store the first-level boot program, and the second-level boot program is stored in the host computer or terminal device.
[0073] Next, set the boot configuration options of the MCU. By setting two locations in OTP, one for booting to Flash and the other for booting to OTP. Since the first-level boot program is fixed in OTP, it must be run from OTP first, so select booting to OTP in the boot configuration options of the MCU in advance.
[0074] When the MCU is powered on and reset, the MCU is booted to OTP through the pre-set boot configuration options and runs the first-level boot program solidified in the OTP space.
[0075] Furthermore, the first-level boot program pre-solidified in the OTP space is used to determine whether the application in the Flash space needs to be updated. Specifically, when the MCU sends a handshake signal to the host computer, the host computer replies with a handshake signal; or when the Flash application area fails to pass the check and is in a waiting state for update; or when the application area receives an update instruction, it determines whether the RAM address meets the preset requirements according to the update instruction, and then determines whether it needs to be updated.
[0076] After the first-level boot program determines that the application needs to be updated, it receives the second-level boot program sent by the host computer or terminal device and stores the second-level boot program in RAM. Then it jumps to RAM to run the second-level boot program, receives the application sent by the host computer or terminal device through the second-level boot program, and then calls the Flash API function to burn the application into the application area, that is, the Flash storage space, completes the application update, and finally jumps to the application.
[0077] Furthermore, if the first-level boot program determines that the application does not need to be updated, it automatically jumps to the application.
[0078] Accordingly, the embodiment of the present invention further provides an application program updating device 700, such as Figure 7 As shown, including:
[0079] The judging module 702 is used to judge whether the application program in the Flash space needs to be updated through the first-level boot program pre-cured in the OTP space;
[0080] The updating module 704 is configured to update the application program through the second-level boot program if the application program needs to be updated.
[0081] The application updating device provided in the embodiment of the present invention solidifies the first-level boot program in the OTP space in advance, so that the application can completely occupy the Flash space, and then determines whether the application in the Flash storage space needs to be updated through the judgment module in the first-level boot program. If the application needs to be updated, the application is updated through the update module in the second-level boot program, thereby improving the space utilization of the application.
[0082] Optionally, in other embodiments of the device, please refer to Figure 7 , the device 700 further includes:
[0083] A division module 706, used for pre-dividing the boot program into a first-level boot program and a second-level boot program;
[0084] A curing module 708, used for pre-curing the first-level boot program into the OTP space;
[0085] The storage module 710 is used to store the second-level boot program in a host computer or a terminal device.
[0086] Optionally, in other embodiments of the device, please refer to Figure 7 , the device 700 further includes:
[0087] The jump module 712 is used to jump to the application program.
[0088] If the application does not need to be updated, jump to the application.
[0089] Optionally, in other embodiments of the device, the updating module 704 is specifically used for:
[0090] Receiving the second-level boot program sent by the host computer or the terminal device through the first-level boot program;
[0091] The second-level boot program is stored in the RAM, and the second-level boot program is run to update the application program.
[0092] Receiving the application program sent by the host computer or the terminal device through the second-level boot program;
[0093] Burn the application program into the application program area.
[0094] The Flash API function is called to burn the application program into the application program area.
[0095] It should be noted that the above-mentioned application updating device can execute the application updating method provided in the embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not fully described in the embodiment of the application updating device, please refer to the application updating method provided in the embodiment of the present invention.
[0096] Figure 8 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention, such as Figure 8 As shown, the electronic device 800 includes:
[0097] One or more processors 802 and memory 804, Figure 8 A processor 802 is taken as an example.
[0098] The processor 802 and the memory 804 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0099] The memory 804 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the update method of the application program in the embodiment of the present invention (for example, the attached Figure 7 The processor 802 executes various functional applications and data processing of the electronic device by running the non-volatile software programs, instructions and modules stored in the memory 804, that is, the updating method of the application program of the above method embodiment is implemented.
[0100] The memory 804 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created by using an update device according to the application, etc. In addition, the memory 804 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 804 may optionally include a memory remotely arranged relative to the processor 802, and these remote memories may be connected to the update device of the application via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0101] The one or more modules are stored in the memory 804, and when executed by the one or more electronic devices, the updating method of the application in any of the above method embodiments is executed, for example, the updating method described above is executed. Figure 2 Steps 202 to 204 of the method, Figure 3 Steps 302 to 306 of the method, Figure 4 Steps 402 to 404 of the method; implementing Figure 7 The functions of modules 702 to 712 in FIG.
[0102] An embodiment of the present invention further provides a computer program product, including a computer program stored on a non-volatile computer-readable storage medium, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer is caused to execute: Figure 2 Steps 202 to 204 of the method, Figure 3 Steps 302 to 306 of the method, Figure 4 Method steps 402 to 404 in.
[0103] The above product can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in the embodiment of the present invention, please refer to the method provided by the embodiment of the present invention.
[0104] The electronic device of the embodiment of the present invention exists in various forms, including but not limited to:
[0105] (1) Mobile communication devices: These devices are characterized by their mobile communication functions and their main purpose is to provide voice and data communications. These terminals include: smart phones (such as iPhone), multimedia phones, functional phones, and low-end phones.
[0106] (2) Ultra-mobile personal computer devices: These devices fall into the category of personal computers, have computing and processing capabilities, and generally also have mobile Internet access features. These terminals include: PDA, MID and UMPC devices, such as iPad.
[0107] (3) Portable entertainment devices: These devices can display and play multimedia content. They include audio and video players (such as iPods), handheld game consoles, e-books, as well as smart toys and portable car navigation devices.
[0108] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0109] Through the description of the above implementation methods, ordinary technicians in this field can clearly understand that each implementation method can be implemented by means of a program plus a general hardware platform, and of course, it can also be implemented by hardware. Ordinary technicians in this field can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0110] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Under the concept of the present invention, the technical features in the above embodiments or different embodiments may also be combined, the steps may be implemented in any order, and there are many other changes in different aspects of the present invention as described above, which are not provided in detail for the sake of simplicity. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for updating an application, characterized in that: The method comprises: Dividing the boot program into a first-level boot program and a second-level boot program in advance; Determine whether the application in the Flash space needs to be updated through the first-level boot program pre-solidified in the OTP space; If the application needs to be updated, the second-level boot program sent by the host computer or the terminal device is received through the first-level boot program; storing the second-level boot program in RAM, and running the second-level boot program; Receiving the application program sent by the host computer or the terminal device through the second-level boot program; The Flash API function is called to burn the application program into the application program area.
2. The method according to claim 1, characterized in that: The method further comprises: Pre-fix the first-level boot program into the OTP space; The second-level boot program is stored in a host computer or a terminal device.
3. The method according to claim 1, characterized in that: After calling the Flash API function to burn the application into the application area, the method further includes: Jump to the application.
4. The method according to claim 3, characterized in that Before determining whether the application program in the Flash space needs to be updated by the first-level boot program pre-cured in the OTP space, the method further includes: After the MCU is powered on and reset, the MCU is booted into the OTP space through the pre-set boot configuration options; Run the first-level boot program solidified in the OTP space.
5. The method according to claim 1, characterized in that The method further comprises: If the application does not need to be updated, jump to the application.
6. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
7. A non-volatile computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 5.
