CN111459572B - Program loading method, controller, chip and electronic equipment - Google Patents

Program loading method, controller, chip and electronic equipment Download PDF

Info

Publication number
CN111459572B
CN111459572B CN202010246590.1A CN202010246590A CN111459572B CN 111459572 B CN111459572 B CN 111459572B CN 202010246590 A CN202010246590 A CN 202010246590A CN 111459572 B CN111459572 B CN 111459572B
Authority
CN
China
Prior art keywords
code
code block
block
program
area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010246590.1A
Other languages
Chinese (zh)
Other versions
CN111459572A (en
Inventor
王伟峰
冯勋锂
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Goodix Technology Co Ltd
Original Assignee
Shenzhen Goodix Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Goodix Technology Co Ltd filed Critical Shenzhen Goodix Technology Co Ltd
Priority to CN202010246590.1A priority Critical patent/CN111459572B/en
Publication of CN111459572A publication Critical patent/CN111459572A/en
Application granted granted Critical
Publication of CN111459572B publication Critical patent/CN111459572B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Abstract

The application relates to the technical field of computers, and provides a program loading method, a controller, a chip and electronic equipment. The program loading method is applied to a controller, a program memory of the controller comprises at least one code area, program codes comprising a plurality of code blocks are stored in an external memory, each code block corresponds to one code area, the storage space of each code area is larger than or equal to the length of the corresponding code block, and mutual calling does not exist between any two code blocks corresponding to the same code area; the controller executes a preset bootstrap program, loads a preset code block from an external memory to a code area corresponding to the preset code block in a program memory, and executes the preset code block; and if the function requirement is detected, loading the code block corresponding to the function requirement acquired from the external memory into the corresponding code area, and executing the code block corresponding to the function requirement. With the embodiments of the present application, the controller is enabled to execute program code that is larger than the memory space of its program memory.

Description

Program loading method, controller, chip and electronic equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a program loading method, a controller, a chip, and an electronic device.
Background
A Micro Control Unit (MCU), also called a Single Chip Microcomputer (Single Chip Microcomputer), a Microcontroller or a Single Chip Microcomputer (Single Chip Microcomputer), properly reduces the frequency and specification of a Central Processing Unit (CPU), and integrates peripheral interfaces such as a memory (memory), a counter (Timer), a USB, an a/D converter, a UART, a PLC, a DMA, and the like, even an LCD driving circuit, on a Single Chip to form a Chip-level computer.
The Memory of the microcontroller may be divided into an internal Memory and an external Memory, the internal Memory includes a program Memory and a data Memory, the program Memory is a Read Only Memory (ROM) or a Random Access Memory (RAM), and the data Memory is a Random Access Memory.
The inventor finds that the prior art has at least the following problems: with the increase of system complexity, the MCU often has insufficient internal storage space, and although the external memory has a large designed storage space, the problem of insufficient internal storage space cannot be solved due to limitations in access speed and bus design; at this time, the problem can be solved by modifying the chip design, increasing the memory or replacing the MCU with a large memory model, but the cost is high.
Disclosure of Invention
An object of some embodiments of the present application is to provide a program loading method, a controller, a chip, and an electronic device, so that the code region can execute a plurality of code blocks larger than a storage space of the code region, and the size limit of a program memory is broken through to some extent, so that the code region can execute a program code larger than the storage space of the program memory.
The embodiment of the application provides a program loading method, which is applied to a controller, wherein a program memory of the controller comprises at least one code area, the controller is connected with an external memory, the external memory stores a program code comprising a plurality of code blocks, each code block corresponds to one code area, the storage space of each code area is greater than or equal to the length of the corresponding code block, and mutual calling does not exist between any two code blocks corresponding to the same code area; the method comprises the following steps: executing a preset bootstrap program, loading a preset code block from an external memory to a corresponding code area, and executing the preset code block; and if the function requirement is detected, loading the code block corresponding to the function requirement acquired from the external memory into the corresponding code area, and executing the code block corresponding to the function requirement.
An embodiment of the present application further provides a controller, including: at least one processor; and a program memory communicatively coupled to the at least one processor; the program memory comprises at least one code area, the processor is connected with the external memory, the external memory stores a program code comprising a plurality of code blocks, each code block corresponds to one code area, the storage space of each code area is larger than the length of the corresponding code block, and mutual calling does not exist between any two code blocks corresponding to the same code area; the processor is used for executing a preset bootstrap program, loading a preset code block from the external memory to a code area corresponding to the preset code block in the program memory, and executing the preset code block; and the processor is also used for loading the code block corresponding to the function requirement acquired from the external memory into the corresponding code area and executing the code block corresponding to the function requirement when the function requirement is detected.
An embodiment of the present application further provides a chip, including: the controller and an external memory connected to the controller.
The embodiment of the application also provides electronic equipment which comprises the chip.
For the prior art, in the embodiment of the present application, a program memory of a controller includes at least one code region, the controller is connected to an external memory, a program code including a plurality of code blocks is stored in the external memory, each code block corresponds to one code region, a storage space of each code region is greater than a length of the corresponding code block, and there is no mutual call between any two code blocks corresponding to the same code region; after the microcontroller is powered on, a preset bootstrap program is executed, a preset code block is loaded from an external memory to a corresponding code area, then the preset code block is executed, when a function requirement is detected, the code block corresponding to the function requirement acquired from the external memory is loaded to the corresponding code area, and the code block corresponding to the function requirement is executed. The program code is divided into a plurality of code blocks, the plurality of code blocks which are not called mutually can be loaded and executed by multiplexing the same code area, so that the code area can execute a plurality of code blocks which are larger than the storage space of the code area, the size limit of the program memory is broken through to a certain extent, the program memory can execute the program codes which are larger than the storage space of the program memory, and compared with the mode that the program codes in the external memory are loaded into the program memory at one time in the prior art, the requirement on the program memory of the microcontroller is reduced; and for the storage space which is not divided into code areas or the idle code areas in the program memory, the data can be cached, the data storage capacity of the microcontroller is improved, and the method is more suitable for the microcontroller with a small memory.
For example, the number of the code regions is multiple, and the multiple code regions include a first code region and a second code region; the plurality of code blocks comprise a static code block and a plurality of dynamic code blocks; the static code block corresponds to a first code region; the plurality of dynamic code blocks correspond to the second code region; loading a predetermined code block from an external memory into a corresponding code region and executing the predetermined code block, including: loading a static code block from an external memory to a first code region, and executing the static code block; in the process of executing the static code block, if the static code block is detected to call the dynamic code block, judging that the function requirement is detected; loading the code block corresponding to the function requirement acquired from the external memory into the corresponding code area, wherein the loading comprises the following steps: and loading the called dynamic code block into the second code area. In this embodiment, when the program memory is divided into the first code area and the second code area, a specific way of loading the static code blocks and the dynamic code blocks is provided.
For example, the second code region includes a plurality of sub-code regions; each dynamic code block corresponds to a sub-code region; loading the called dynamic code block into the second code area, including: and loading the called dynamic code block to the corresponding sub-code area.
For example, a particular way of loading static code blocks and dynamic code blocks is provided when the second code region is partitioned into multiple subcode regions.
For example, the dynamic code blocks correspond to the sub-code regions one to one.
For example, when loading the static code block from the external memory into the first code region, and before executing the static code block, the method further includes: and loading the preset dynamic code block into the second code area. In the embodiment, the preloading of the dynamic code block is realized, and the code loading speed is improved
For example, after executing a predetermined code block, if an external input command is received, it is determined that a function requirement is detected; loading the code block corresponding to the function requirement acquired from the external memory into the corresponding code area, wherein the loading comprises the following steps: and loading the code block corresponding to the external input command acquired from the external memory into the corresponding code area. The present embodiment may load the code block according to an external input command.
For example, the code blocks correspond one-to-one to the code regions.
Drawings
One or more embodiments are illustrated by way of example in the accompanying drawings, which correspond to the figures in which like reference numerals refer to similar elements and which are not to scale unless otherwise specified.
Fig. 1 is a detailed flowchart of a program loading method according to a first embodiment of the present application;
FIG. 2 is a specific manner of dividing a code area by a program memory according to a first embodiment of the present application;
FIG. 3 is another concrete way of dividing a code area according to a program memory in the first embodiment of the present application;
FIG. 4 is a specific manner of dividing a code area by a program memory according to a second embodiment of the present application;
FIG. 5 is a detailed flowchart of a program loading method according to a second embodiment of the present application;
FIG. 6 is a diagram illustrating a specific manner of dividing the second code region according to a third embodiment of the present application;
FIG. 7 is a diagram illustrating another specific manner of dividing the second code region according to a third embodiment of the present application;
FIG. 8 is a flowchart illustrating a program loading method according to a third embodiment of the present application;
fig. 9 is a block diagram of a controller according to a fourth embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clearly understood, some embodiments of the present application will be described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. The following embodiments are divided for convenience of description, and should not constitute any limitation to the specific implementation manner of the present invention, and the embodiments may be mutually incorporated and referred to without contradiction.
The first embodiment of the present application relates to a program loading method, which is applied to a controller, where the controller may be a microcontroller, a program memory of the microcontroller includes at least one code area, and exemplarily, a memory of the microcontroller further includes a data memory; wherein the program memory may be a RAM memory. The microcontroller is also connected to an external memory, in which a program code is stored, the program code includes a plurality of code blocks, the program memory is divided into one or more code areas, each code block corresponds to one code area in the program memory, the storage space of each code area is greater than or equal to the length of the corresponding code block, and there is no mutual call between any two code blocks corresponding to the same code area, that is, if a plurality of code blocks correspond to the same code area, the plurality of code blocks are independent of each other, there is no mutual call, that is, there are two code blocks that are called to each other must correspond to two different code areas. In this embodiment, the corresponding relationship between the code block and the code region may be set in the following manner: in the compiling stage, the link between the code blocks and the code areas is established through the link file, and the corresponding code areas are allocated to the code blocks as the running areas for loading and executing the code blocks.
Fig. 1 shows a specific flowchart of a program loading method according to a first embodiment of the present application.
In step 101, a preset boot program is executed, a predetermined code block is loaded from an external memory into a code area corresponding to the predetermined code block in a program memory, and the predetermined code block is executed.
Specifically, after the microcontroller is powered on and started, the microcontroller executes a Boot Loader (Boot Loader) solidified in a program memory, the Boot Loader sets code blocks which need to be loaded currently, the code blocks are code blocks which need to be loaded when the microcontroller is started (namely, preset code blocks), the preset code blocks are stored in an external memory, the microcontroller loads the preset code blocks from the external memory to code areas corresponding to the preset code blocks in the program memory, and the code blocks are executed after the loading is finished; the predetermined code block may be a static code block or a dynamic code block. Specifically, the static code block is a code block area marked by a static keyword, is defined in the class and is used for completing initialization of the class, and the static code block is executed along with loading of the class and is only executed once; the dynamic code blocks are parts of the same constructor that are executed once each time an object is created.
In one example, the boot program may further set a next code block to be loaded, and if the code block and a predetermined code block correspond to different code areas, the code block may be loaded simultaneously when the predetermined code block is loaded, so that the code loading efficiency is improved to a certain extent.
And step 102, if the function requirement is detected, loading the code block corresponding to the function requirement acquired from the external memory into the corresponding code area, and executing the code block corresponding to the function requirement.
Specifically, after executing a predetermined code block, if a function requirement is detected, acquiring a code block corresponding to the function requirement from an external memory, loading the code block into a corresponding code area, and after the loading is finished, executing the code block corresponding to the function requirement to realize a corresponding function; if other code blocks are loaded before the code area, the executed old code block is still stored in the code area, and the old code block in the code area is directly covered by the code block corresponding to the function requirement. It should be noted that, if the code block corresponding to the function requirement has been previously loaded into the corresponding code area and is not covered, the code block may be directly executed.
In an example, referring to fig. 2, if there is no mutual call between multiple code blocks (i.e. code block 1 to code block N in the figure, where N is a positive integer greater than 2) of the program code, only one code area may be set in the program memory of the microcontroller, and the storage space of the code area is greater than or equal to the maximum length among the respective lengths of the multiple code blocks; for example, the program code includes a plurality of code blocks, and if the storage space occupied by the code block with the largest length is 1M, the storage space of the code area is greater than or equal to 1M.
In one example, referring to fig. 3, if the storage space of the program memory of the microcontroller is greater than or equal to the total length of the program code, the code blocks may be set to correspond to the code areas one to one, and the storage space of each code area is greater than or equal to the length of the code block corresponding to the code area. For example, if the program code includes N code blocks, the program memory is divided into N code regions, each code block corresponds to each code region one to one, and the storage space of each code region is greater than or equal to the length of the code block corresponding to the code region, where N is an integer greater than 1.
In one example, after a predetermined code block is executed, if the code block does not call other code blocks, when an external input command is received, judging that a function requirement is detected, and loading a code block corresponding to the external input command acquired from an external memory into a corresponding code area; if the code block does not call other code blocks and does not receive the external input command, and the function requirement is not detected, the method stays in the preset code block until the preset code block is executed, the current program code enters an idle state, the next loading call is waited, and the microcontroller can execute other program codes. The external input command may be a command for opening a certain function, or may be an external interrupt signal, and when receiving the external interrupt signal, the microcontroller loads and executes the corresponding code block to implement the corresponding function.
Compared with the prior art, the program memory of the controller comprises at least one code area, the controller is connected to the external memory, the program code comprising a plurality of code blocks is stored in the external memory, each code block corresponds to one code area, the storage space of each code area is larger than the length of the corresponding code block, and no mutual call exists between any two code blocks corresponding to the same code area; after the microcontroller is powered on, a preset bootstrap program is executed, a preset code block is loaded from an external memory to a corresponding code area, then the preset code block is executed, when a function requirement is detected, the code block corresponding to the function requirement acquired from the external memory is loaded to the corresponding code area, and the code block corresponding to the function requirement is executed. The program code is divided into a plurality of code blocks, the plurality of code blocks which are not called mutually can be loaded and executed by multiplexing the same code area, so that the code area can execute a plurality of code blocks which are larger than the storage space of the code area, the size limit of the program memory is broken through to a certain extent, the program memory can execute the program codes which are larger than the storage space of the program memory, and compared with the mode that the program codes in the external memory are loaded into the program memory at one time in the prior art, the requirement on the program memory of the microcontroller is reduced; and for the storage space which is not divided into the code area or the idle code area in the program memory, the data can be cached, the data storage capacity of the microcontroller is improved, and the method is more suitable for the microcontroller with small memory.
The second embodiment of the present application relates to a program loading method, and compared with the first embodiment, the main difference of the present embodiment is that: a specific way of dividing the code area of the program memory is provided.
In this example, please refer to fig. 4, the number of the code regions is plural, and specifically, the plural code regions may include a first code region and a second code region; the program code includes a plurality of code blocks which are more than the number of code regions, for example, the plurality of code blocks of the program code in fig. 4 includes a static code block and a plurality of dynamic code blocks, the static code block corresponds to a first code region, and a storage space of the first code region is greater than or equal to a length of the static code block; the plurality of dynamic code blocks correspond to a second code region, i.e., there is no mutual call between any two dynamic code blocks, and the storage space of the second code region is greater than or equal to the maximum length among the lengths of the plurality of dynamic code blocks.
It should be noted that, in this embodiment, no limitation is imposed on the storage spaces of the first code region and the second code region, and it is only required to ensure that the storage space of the first code region is greater than or equal to the length of the static code block, and the storage space of the second code region is greater than or equal to the maximum length of the lengths of the multiple dynamic code blocks.
The specific flow of the program loading method in this embodiment is shown in fig. 5.
Step 201, executing a preset boot program, loading a static code block from an external memory to a first code area, and executing the static code block.
Specifically, after the microcontroller is powered on and powered on, it executes a Boot Loader (Boot Loader) solidified in a program memory, the Boot Loader sets a configuration in which a static code block is loaded from an external memory to a first code area and the static code block is executed, the static code block can call the function of a dynamic code block, and the static code block resides in the first code area after being loaded once at power on, and will not change until being cleared after being powered off and powered off.
In one example, when loading the static code block from the external memory into the first code region and before executing the static code block, the method further comprises: and loading the preset dynamic code block into the second code area. The preset dynamic code block can be the first dynamic code block called by the static code block, so that the preloading of the dynamic code block is realized, and the code loading speed is increased.
Step 202, in the process of executing the static code block, if it is detected that the static code block calls the dynamic code block, loading the called dynamic code block to the second code area.
Specifically, in the process of executing the static code block, if it is detected that the static code block needs to call the function of a certain dynamic code block, it is determined that a function requirement is detected, at this time, the dynamic code block is loaded from the external memory to the second code area, the dynamic code block is executed, after the dynamic code block is executed, the first code area is returned, the static code block is continuously executed, and when the static code block calls the dynamic code block again, the above-mentioned process is repeated.
Compared with the first embodiment, the embodiment provides a specific way to load the static code blocks and the dynamic code blocks when the program memory is divided into the first code area and the second code area.
A third embodiment of the present application relates to a program loading method, and compared with the second embodiment, the main difference of the present embodiment is that: a specific division of the second code region is provided.
In this example, referring to fig. 6, the number of the code areas is multiple, the multiple code areas may include a first code area and a second code area, and the program code includes multiple code blocks greater than the number of the code areas, for example, the multiple code blocks of the program code in fig. 6 include a static code block and multiple dynamic code blocks. The static code block corresponds to a first code area, and the storage space of the first code area is larger than or equal to the length of the static code block; the plurality of dynamic code blocks correspond to a second code region including a plurality of sub-code regions (two are exemplified in the figure); each dynamic code block corresponds to one sub-code region, mutual calling does not exist between any two dynamic code blocks corresponding to the same sub-code region, and the storage space of each sub-code region is larger than or equal to the maximum length of the corresponding dynamic code block.
In one example, referring to fig. 7, if the storage space of the second code region is greater than or equal to the total length of the plurality of dynamic code blocks, the dynamic code blocks are set to correspond to the sub-code regions one to one, and each sub-code region is greater than or equal to the length of the corresponding dynamic code block.
Fig. 8 shows a specific flowchart of the program loading method according to the present embodiment.
In step 301, a preset boot program is executed, a predetermined code block is loaded from an external memory into a code area corresponding to the predetermined code block in a program memory, and the predetermined code block is executed. This step is substantially the same as step 201 in the second embodiment, and will not be described herein again.
Step 302, in the process of executing the static code block, if it is detected that the static code block calls the dynamic code block, loading the called dynamic code block to the corresponding sub-code area.
Specifically, in the process of executing the static code block, if it is detected that the static code block needs to call a function of a certain dynamic code block, it is determined that a function requirement is detected, at this time, the called dynamic code block is loaded from the external memory to the corresponding sub-code region and executed, after the dynamic code block is executed, the first code region is returned, the static code block is continuously executed, and when the static code block calls the dynamic code block again, the above process is repeated.
Compared with the second embodiment, the present embodiment provides a specific way to load the static code block and the dynamic code block when the second code region is divided into a plurality of sub-code regions.
A fourth embodiment of the present application relates to a controller, which may be a microcontroller, please refer to fig. 9, in which the microcontroller 10 includes: at least one processor 1 (one is taken as an example in the figure); and a program memory 2 communicatively connected to the at least one processor, the program memory 2 may be a RAM memory.
In the present exemplary embodiment, the program memory 2 of the microcontroller 10 comprises at least one code field, and the memory of the microcontroller 10 also comprises, by way of example, a data memory 3. The processor 1 is further connected to an external memory 20, the external memory 20 stores a program code, the program code includes a plurality of code blocks, the program memory is divided into one or more code areas, each code block corresponds to one code area in the program memory, the storage space of each code area is larger than or equal to the length of the corresponding code block, and there is no mutual call between any two code blocks corresponding to the same code area, that is, if a plurality of code blocks correspond to the same code area, the plurality of code blocks are independent from each other, there is no mutual call, that is, there are two code blocks that are called to each other and must correspond to two different code areas. In this embodiment, the corresponding relationship between the code block and the code region may be set in the following manner: in the compiling stage, a link between the code block and the code area is established through a link file, and the corresponding code area is allocated to the code block as a running area for loading and executing the code block.
The processor 1 is configured to execute a preset boot program, load a predetermined code block from the external memory 20 into a code area in the program memory 2 corresponding to the predetermined code block, and execute the predetermined code block.
The processor 1 is further configured to, when a function requirement is detected, load a code block corresponding to the function requirement acquired from the external memory 20 into a corresponding code region, and execute the code block corresponding to the function requirement.
In one example, referring to fig. 2, if there is no mutual call between a plurality of code blocks of the program code, only one code region may be set in the program memory 2 of the microcontroller 10, and the storage space of the code region is greater than or equal to the maximum length of the respective lengths of the plurality of code blocks; for example, the program code includes a plurality of code blocks, and if the storage space occupied by the code block with the largest length is 1M, the storage space of the code area is greater than or equal to 1M.
In one example, referring to fig. 3, if the storage space of the program memory 2 of the microcontroller 10 is greater than or equal to the total length of the program codes, the code blocks may be set to correspond to the code areas one to one, and the storage space of each code area is greater than or equal to the length of the code block corresponding to the code area. For example, if the program code includes N code blocks, the program memory is divided into N code regions, each code block corresponds to each code region one to one, and the storage space of each code region is greater than or equal to the length of the code block corresponding to the code region, where N is an integer greater than 1.
In one example, after executing a predetermined code block, if the code block does not call another code block, the processor determines that a function requirement is detected when receiving an external input command, and at this time, loads a code block corresponding to the external input command acquired from the external memory 20 into a corresponding code area; if the code block does not call other code blocks and does not receive the external input command, and the function requirement is not detected, the method stays in the preset code block until the preset code block is executed, the current program code enters an idle state, the next loading call is waited, and the microcontroller can execute other program codes. The external input command may be a command to open a certain function, or an external interrupt signal.
Since the first embodiment corresponds to the present embodiment, the present embodiment can be implemented in cooperation with the first embodiment. The related technical details mentioned in the first embodiment are still valid in this embodiment, and the technical effects that can be achieved in the first embodiment can also be achieved in this embodiment, and are not described herein again in order to reduce repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the first embodiment.
Compared with the first embodiment, the program memory of the controller comprises at least one code area, the controller is connected with the external memory, the program code comprising a plurality of code blocks is stored in the external memory, each code block corresponds to one code area, the storage space of each code area is larger than the length of the corresponding code block, and no mutual call exists between any two code blocks corresponding to the same code area; after the microcontroller is powered on, a preset bootstrap program is executed, a preset code block is loaded from an external memory to a corresponding code area, then the preset code block is executed, when a function requirement is detected, the code block corresponding to the function requirement acquired from the external memory is loaded to the corresponding code area, and the code block corresponding to the function requirement is executed. The program code is divided into a plurality of code blocks, the plurality of code blocks which are not called by each other can be loaded and executed by multiplexing the same code area, so that the code area can execute a plurality of code blocks which are larger than the storage space of the code area, the size limit of the program memory is broken through to a certain extent, the program memory can execute the program codes which are larger than the storage space of the program memory, and compared with the mode of loading the program codes in an external memory device into the program memory at one time in the prior art, the requirement on the program memory of the microcontroller is reduced; and for the storage space which is not divided into the code area or the idle code area in the program memory, the data can be cached, the data storage capacity of the microcontroller is improved, and the method is more suitable for the microcontroller with small memory.
The fifth embodiment of the present application relates to a controller, and compared with the fourth embodiment, the present embodiment is mainly distinguished by: a specific way of dividing the code area of the program memory is provided.
In this example, please refer to fig. 4, the number of the code areas of the program memory 2 is plural, and specifically, the plural code areas may include a first code area and a second code area; the program code comprises a plurality of code blocks which are more than the number of the code areas, for example, the plurality of code blocks of the program code in fig. 4 comprise a static code block and a plurality of dynamic code blocks, the static code block corresponds to a first code area, and the storage space of the first code area is larger than or equal to the length of the static code block; the plurality of dynamic code blocks correspond to a second code region, i.e., there is no mutual call between any two dynamic code blocks, and the storage space of the second code region is greater than or equal to the maximum length among the lengths of the plurality of dynamic code blocks.
The processor 1 is configured to execute a preset boot program, load a static code block from the external memory 20 into the first code area, and execute the static code block.
In one example, the processor 1 is further configured to load a preset dynamic code block into the second code region when loading the static code block from the external memory into the first code region and before executing the static code block. The preset dynamic code block can be the first dynamic code block called by the static code block, so that the preloading of the dynamic code block is realized, and the code loading speed is increased.
The processor 1 is used for loading the called dynamic code block into the second code area when detecting that the static code block calls the dynamic code block.
Since the second embodiment corresponds to the present embodiment, the present embodiment can be implemented in cooperation with the second embodiment. The related technical details mentioned in the second embodiment are still valid in this embodiment, and the technical effects that can be achieved in the second embodiment can also be achieved in this embodiment, and are not described herein again in order to reduce repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the second embodiment.
Compared with the fourth embodiment, the present embodiment provides a specific way to load the static code blocks and the dynamic code blocks when the program memory is divided into the first code area and the second code area.
A sixth embodiment of the present application relates to a controller, and the present embodiment is mainly different from the fifth embodiment in that: referring to fig. 6, the second code region includes a plurality of sub-code regions.
In this example, each dynamic code block corresponds to one sub-code region, there is no mutual call between any two dynamic code blocks corresponding to the same sub-code region, and the storage space of each sub-code region is greater than or equal to the maximum length of its corresponding dynamic code block.
In one example, referring to fig. 7, if the storage space of the second code region is greater than or equal to the total length of the plurality of dynamic code blocks, the dynamic code blocks are set to correspond to the sub-code regions one to one, and each sub-code region is greater than or equal to the length of the corresponding dynamic code block.
The processor 1 is configured to, when detecting that the static code block calls the dynamic code block, load the called dynamic code block to the corresponding sub-code area.
Since the third embodiment corresponds to the present embodiment, the present embodiment can be implemented in cooperation with the third embodiment. The related technical details mentioned in the third embodiment are still valid in this embodiment, and the technical effects that can be achieved in the third embodiment can also be achieved in this embodiment, and are not described herein again in order to reduce repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the third embodiment.
Compared with the fifth embodiment, the present embodiment provides a specific way to load a static code block and a dynamic code block when the second code region is divided into a plurality of sub-code regions.
A seventh embodiment of the present application relates to a chip including the controller in any one of the third to sixth embodiments, and an external memory connected to the controller.
The eighth embodiment of the present application relates to an electronic device, which includes the chip in the seventh embodiment, and the electronic device may be a wearable device, an intelligent home device, a sensor, or the like.
It will be understood by those of ordinary skill in the art that the foregoing embodiments are specific examples for carrying out the present application, and that various changes in form and details may be made therein without departing from the spirit and scope of the present application in practice.

Claims (16)

1. A program loading method is applied to a controller which is a Micro Control Unit (MCU), a program memory of the controller comprises at least one code area, the controller is connected with an external memory, the external memory stores a program code comprising a plurality of code blocks, each code block corresponds to one code area, the storage space of each code area is larger than or equal to the length of the corresponding code block, and mutual calling does not exist between any two code blocks corresponding to the same code area; the method comprises the following steps:
executing a preset bootstrap program, loading a preset code block from the external memory to the code area corresponding to the preset code block in the program memory, and executing the preset code block, wherein the preset code block is a code block which needs to be loaded when the controller is started;
the bootstrap program is also provided with a next code block needing to be loaded, and if the next code block needing to be loaded and the predetermined code block correspond to different code areas, the next code block needing to be loaded is loaded while the predetermined code block is loaded;
and if the function requirement is detected, loading the code block corresponding to the function requirement acquired from the external memory into the corresponding code area, and executing the code block corresponding to the function requirement.
2. The program loading method according to claim 1, wherein the number of the code areas is plural, and the plural code areas include a first code area and a second code area; the plurality of code blocks comprise a static code block and a plurality of dynamic code blocks; the static code block corresponds to a first code region; a plurality of the dynamic code blocks correspond to the second code region;
the loading a predetermined code block from the external memory into the code area in the program memory corresponding to the predetermined code block and executing the predetermined code block includes:
loading the static code block from the external memory into the first code region and executing the static code block; in the process of executing the static code block, if the static code block is detected to call the dynamic code block, judging that a function requirement is detected;
the loading the code block corresponding to the function requirement acquired from the external memory into the corresponding code area includes:
loading the called dynamic code block to the second code region.
3. The program loading method according to claim 2, wherein the second code area includes a plurality of sub-code areas; each dynamic code block corresponds to one of the subcode regions;
the loading the called dynamic code block to the second code area includes:
and loading the called dynamic code block to the corresponding sub-code area.
4. A program loading method according to claim 3, wherein the dynamic code blocks correspond one-to-one to the sub-code regions.
5. The program loading method of claim 2, further comprising, when loading the static code block from the external memory into the first code region and before executing the static code block:
and loading the preset dynamic code block into the second code area.
6. The program loading method according to claim 1, wherein after said executing of the predetermined code block, if an external input command is received, it is determined that a functional requirement is detected;
the loading the code block corresponding to the function requirement acquired from the external memory into the corresponding code area includes:
and loading the code block corresponding to the external input command acquired from the external memory into the corresponding code area.
7. The program loading method according to claim 1, wherein the code blocks correspond one-to-one to the code areas.
8. A controller, comprising: at least one processor; the program memory is in communication connection with the at least one processor, and the controller is a Micro Control Unit (MCU);
the program memory comprises at least one code area, the processor is connected with an external memory, program codes comprising a plurality of code blocks are stored in the external memory, each code block corresponds to one code area, the storage space of each code area is larger than the length of the corresponding code block, and mutual calling does not exist between any two code blocks corresponding to the same code area;
the processor is configured to execute a preset boot program, load a predetermined code block from the external memory to the code region corresponding to the predetermined code block in the program memory, and execute the predetermined code block, where the predetermined code block is a code block that needs to be loaded when the controller is started up;
the bootstrap program is also provided with a next code block needing to be loaded, and if the next code block needing to be loaded and the predetermined code block correspond to different code areas, the next code block needing to be loaded is loaded while the predetermined code block is loaded;
the processor is further configured to, when a function requirement is detected, load the code block corresponding to the function requirement acquired from the external memory into the corresponding code region, and execute the code block corresponding to the function requirement.
9. The controller of claim 8, wherein the number of the code regions is plural, the plural code regions including a first code region and a second code region; the plurality of code blocks comprise a static code block and a plurality of dynamic code blocks; the static code block corresponds to a first code region; a plurality of the dynamic code blocks correspond to the second code region;
the processor is used for executing a preset bootstrap program, loading the static code block from the external memory to the first code area, and executing the static code block;
the processor is configured to load the called dynamic code block into the second code region when it is detected that the static code block calls the dynamic code block.
10. The controller of claim 9, wherein the second code region includes a plurality of sub-code regions; each dynamic code block corresponds to one of the sub-code regions;
the processor is configured to load the called dynamic code block to the corresponding sub-code region when it is detected that the static code block calls the dynamic code block.
11. The controller of claim 10, wherein the dynamic code blocks are in one-to-one correspondence with the sub-code regions.
12. The controller of claim 9, wherein the processor is further configured to load a preset dynamic code block into the second code region when the static code block is loaded into the first code region from the external memory and before the static code block is executed.
13. The controller of claim 8, wherein the processor is configured to load the code block corresponding to the external input command obtained from the external memory into the corresponding code region when the external input command is received.
14. The controller of claim 8, wherein the code blocks are in one-to-one correspondence with the code regions.
15. A chip, comprising: the controller of any one of claims 8 to 14, and an external memory connected to the controller.
16. An electronic device comprising the chip of claim 15.
CN202010246590.1A 2020-03-31 2020-03-31 Program loading method, controller, chip and electronic equipment Active CN111459572B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010246590.1A CN111459572B (en) 2020-03-31 2020-03-31 Program loading method, controller, chip and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010246590.1A CN111459572B (en) 2020-03-31 2020-03-31 Program loading method, controller, chip and electronic equipment

Publications (2)

Publication Number Publication Date
CN111459572A CN111459572A (en) 2020-07-28
CN111459572B true CN111459572B (en) 2023-01-31

Family

ID=71685169

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010246590.1A Active CN111459572B (en) 2020-03-31 2020-03-31 Program loading method, controller, chip and electronic equipment

Country Status (1)

Country Link
CN (1) CN111459572B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112306402A (en) * 2020-07-31 2021-02-02 神州融安科技(北京)有限公司 Program execution method, electronic device, and computer-readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101131649A (en) * 2006-08-23 2008-02-27 乐金电子(昆山)电脑有限公司 Updating speed improving method for read-only memory of device with flash memory
CN101546287A (en) * 2008-03-26 2009-09-30 国际商业机器公司 Code modification method and code modification equipment
CN101782859A (en) * 2010-03-18 2010-07-21 上海乐毅信息科技有限公司 Upgrading method of embedded system in application
CN101834608A (en) * 2009-03-10 2010-09-15 华为技术有限公司 Multichannel decoder-coder operation method and device
CN106843938A (en) * 2016-12-30 2017-06-13 西南技术物理研究所 FPGA and DSP programs are upgraded and on-line reorganization system and method
CN110147329A (en) * 2019-05-24 2019-08-20 武汉瓯越网视有限公司 A kind of method, apparatus and terminal of dynamic detection simulator

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6920543B1 (en) * 1999-12-14 2005-07-19 Genesis Microchip, Inc. Method and apparatus for performing distributed processing of program code
US7490177B2 (en) * 2006-01-23 2009-02-10 Infineon Technologies Ag System method for performing a direct memory access for automatically copying initialization boot code in a new memory architecture
JP5293062B2 (en) * 2008-10-03 2013-09-18 富士通株式会社 Computer apparatus, memory diagnosis method, and memory diagnosis control program
CN201359723Y (en) * 2008-12-31 2009-12-09 广州市鸿芯微电子有限公司 Self-starting serial bootstrap program loading and reading system
CN101552840B (en) * 2009-03-09 2012-04-11 北京天碁科技有限公司 A method to reduce the power consumption of mobile terminals and the mobile terminals
US20120102314A1 (en) * 2010-04-01 2012-04-26 Huizhou TCL Mobile Communications Co., Ltd. Smart phone system and booting method thereof
US8479176B2 (en) * 2010-06-14 2013-07-02 Intel Corporation Register mapping techniques for efficient dynamic binary translation
US9619417B2 (en) * 2011-06-17 2017-04-11 Alcatel Lucent Method and apparatus for remote delivery of managed USB services via a mobile computing device
CN102722467A (en) * 2012-05-31 2012-10-10 深圳市江波龙电子有限公司 Multiprocessor device and program running method thereof
GB2515364B (en) * 2013-12-20 2015-06-17 Nordic Semiconductor Asa Updatable integrated-circuit radio
US9760382B2 (en) * 2014-06-24 2017-09-12 Los Alamos National Security, Llc Modular space vehicle boards, control software, reprogramming, and failure recovery
CN104866345B (en) * 2015-05-21 2018-03-23 福建升腾资讯有限公司 The storage method of executable code under a kind of ARMv7m frameworks
EP3572934A1 (en) * 2018-05-24 2019-11-27 Visteon Global Technologies, Inc. Method for starting an operating system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101131649A (en) * 2006-08-23 2008-02-27 乐金电子(昆山)电脑有限公司 Updating speed improving method for read-only memory of device with flash memory
CN101546287A (en) * 2008-03-26 2009-09-30 国际商业机器公司 Code modification method and code modification equipment
CN101834608A (en) * 2009-03-10 2010-09-15 华为技术有限公司 Multichannel decoder-coder operation method and device
CN101782859A (en) * 2010-03-18 2010-07-21 上海乐毅信息科技有限公司 Upgrading method of embedded system in application
CN106843938A (en) * 2016-12-30 2017-06-13 西南技术物理研究所 FPGA and DSP programs are upgraded and on-line reorganization system and method
CN110147329A (en) * 2019-05-24 2019-08-20 武汉瓯越网视有限公司 A kind of method, apparatus and terminal of dynamic detection simulator

Also Published As

Publication number Publication date
CN111459572A (en) 2020-07-28

Similar Documents

Publication Publication Date Title
CN102200916B (en) Electronic equipment, configurable member and method for storing configuration information of configurable member
CN111459572B (en) Program loading method, controller, chip and electronic equipment
CN111581129B (en) Terminal mainboard circuit, terminal equipment and ADC interface multiplexing control method
CN1303545C (en) Aggregation of hardware events in multi-node systems
US20220414052A1 (en) Multi-Core Processor, Multi-Core Processor Processing Method, and Related Device
US20180011713A1 (en) Bios control method for pci-e lane
CA1217565A (en) Vector interrupt system and method
CN114253619A (en) SSD multi-level Boot method and device, computer equipment and storage medium
US6349388B1 (en) Timer processing engine for supporting multiple virtual minimum time timers
CN114579499B (en) Control method, device, equipment and storage medium of processor communication interface
CN105573940B (en) A kind of automatic detection method and device of SDIO interface peripherals
CN201111021Y (en) Equipment interconnection equipment based on USB interface
CN111708631B (en) Data processing method based on multipath server, intelligent terminal and storage medium
KR101118111B1 (en) Mobile communication terminal and booting method thereof
CN113037506A (en) Interface switching control method, device, equipment and computer readable storage medium
US20060155978A1 (en) Method for initialising programmable systems
US5577260A (en) Data processing system having a serial interface comprising an end-of-transmission flag
CN115586981B (en) Method, system, computer and storage medium for preventing SIO signal loss
CN111221701A (en) Chip and circuit logic reconfiguration system thereof
KR100386199B1 (en) Improvements and Methods Using Processors, and Portable Electronic Devices
CN103747335A (en) Smart television mode switching method and device
CN116594953B (en) Multi-core heterogeneous chip based on PCIE interconnection, starting method and system
CN114489716A (en) Substrate management controller, updating method thereof and connector
CN113568349A (en) Data processing method and device, terminal equipment and readable storage medium
CN116340208A (en) Flash access method and application based on QSPI

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant