A method, system, medium and electronic device for realizing OTP multiple programming
By adding an illegal instruction detection module and a programmable startup address module to the microcontroller, multiple programming of the OTP chip is realized, which solves the problem that the OTP chip can only be programmed once, and improves the utilization and performance of the chip.
Patent Information
- Application Number
- CN202211481430.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-24
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-11-24
AI Technical Summary
The OTP chip can only support one programming, resulting in the programmed chip being unable to be reused, resulting in a waste of resources. The existing technology increases the number of programming times by adding an external adder, but affects the operating frequency and performance.
An illegal instruction detection module and a programmable startup address module are added to the microcontroller. Multiple programming of OTP is realized through illegal instruction judgment and pointer calculation, and addresses are automatically accumulated to achieve multiple programming.
It realizes the reuse of OTP storage space, saves costs, improves chip utilization, and avoids the impact of increased physical delay on performance.
Smart Images

Figure CN115712414B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of chip programming technology, and more specifically, to a method, system, medium and electronic equipment for implementing OTP multiple programming. Background Art
[0002] OTP (One Time Programmable) is a type of memory in a microcontroller, which means one-time programmable: after the program is burned into the microcontroller, it cannot be changed or cleared again. As the code area of the microcontroller, OTP is widely used in various electronic products due to its high reliability and low cost. In most application scenarios, the user code uses a small part of the OTP code area. Because OTP can only support one-time programming, the second programming needs to be exposed to ultraviolet light before it can be used. This results in the programmed OTP chip being discarded, resulting in a large waste.
[0003] Prior to the technology of the present invention, the prior art greatly increased the area by adding an adder of at least 16 bits to the address line outside the MCU. At the same time, due to the increase in the physical delay of the addition calculation of the adder, the operating frequency of the single-chip device was greatly affected, thereby affecting the performance of the entire SoC. By increasing the number of space and area zone switching programming times, the previously programmed area cannot be programmed again, and only the area that has not been programmed can be reused, thereby achieving the purpose of multiple programming. Summary of the invention
[0004] In view of the above problems, the present invention proposes a method, system, medium and electronic device for realizing OTP multiple programming. By adding only one OR gate, the condition of illegal instructions is added to the condition for generating automatic accumulation of the microcontroller, thereby realizing simple and efficient OTP multiple programming.
[0005] According to a first aspect of an embodiment of the present invention, a method for implementing OTP multiple programming is provided.
[0006] In one or more embodiments, preferably, the method for implementing OTP multiple programming includes:
[0007] Add an illegal instruction detection module to the instruction decoding module in the microcontroller;
[0008] Add a programmable start address module and address input to the pointer calculation module in the microcontroller;
[0009] Select one of the first method and the second method to start the microcontroller programming;
[0010] When the first mode is determined, the illegal instruction detection module is started to judge illegal instructions, and multiple programming is performed according to preset program partitions;
[0011] When the second method is determined, the pointer content in the program instruction area is read, and the content of the program pointer is matched according to the number of 1s in the pointer content;
[0012] The content of the program pointer is written into the register BOOT_ADDR inside the OTP controller, the microcontroller reset is released, and automatic program programming is performed.
[0013] In one or more embodiments, preferably, the instruction decoding module in the single-chip microcomputer adds an illegal instruction detection module, specifically including:
[0014] An illegal instruction detection module capable of sequentially judging whether an instruction is illegal is provided in the instruction decoding module of the single-chip microcomputer;
[0015] When a legal instruction is detected, the instruction decoding module starts the program.
[0016] In one or more embodiments, preferably, the adding of a programmable startup address module and an address input in a pointer calculation module in a single chip microcomputer specifically includes:
[0017] Adding the programmable startup address module for obtaining the program startup address in the single-chip microcomputer;
[0018] The startup address of the programmable startup address module is connected to the controller of the OTP.
[0019] In one or more embodiments, preferably, the selecting one of the first mode and the second mode to start the single chip microcomputer programming specifically includes:
[0020] Set the startup mode in the microcontroller based on experience;
[0021] Setting the startup mode to one of the first mode and the second mode;
[0022] In the first mode, programming is performed automatically, and in the second mode, programming is performed according to address selection.
[0023] In one or more embodiments, preferably, when the first mode is determined, the illegal instruction detection module is started to perform illegal instruction judgment, and multiple programming is performed according to preset program partitions, specifically including:
[0024] After starting the first method, the illegal instruction detection module is used in the single-chip microcomputer to determine that it is a programming code area;
[0025] Place the programs to be programmed in the OTP positions in the order preset by the program;
[0026] When reading the unprogrammed code area, the automatic control instruction fetch address is automatically accumulated;
[0027] When a legal and valid instruction is read, multiple programming operations are started in sequence.
[0028] In one or more embodiments, preferably, when the second mode is determined, the pointer content in the program instruction area is read, and the content of the program pointer is matched according to the number of 1s in the pointer content, specifically including:
[0029] After starting the second mode, the starting address of each program is stored in the OTP as a program pointer of each program;
[0030] The program address selection pointer is used to directly read the program pointer of each program as the pointer content;
[0031] After the OTP is initialized, the number of 1s in the pointer content is automatically read to select the content of the program pointer.
[0032] In one or more embodiments, preferably, the step of writing the content of the program pointer into the register BOOT_ADDR inside the OTP controller, releasing the reset of the single-chip microcomputer, and performing automatic program programming specifically includes:
[0033] Write the content of the program pointer into the register BOOT_ADDR in the OTP controller;
[0034] The register BOOT_ADDR is connected to the programmable boot address module of the single-chip microcomputer core;
[0035] At the rising edge of the single-chip microcomputer core reset release, the number of 1s in the pointer content is increased by 1, and the pointer content is automatically updated to the register BOOT_ADDR.
[0036] According to a second aspect of an embodiment of the present invention, a system for implementing OTP multiple programming is provided.
[0037] In one or more embodiments, preferably, the system for implementing OTP multiple programming includes:
[0038] The first mode arranges the modules, and is used to add an illegal instruction detection module to the instruction decoding module in the single chip microcomputer;
[0039] The second mode arranges the modules for adding a programmable start address module and an address input to a pointer calculation module in a single chip microcomputer;
[0040] A mode judgment module is used to select one of the first mode and the second mode to start the single chip microcomputer programming;
[0041] A first mode execution module, used for starting the illegal instruction detection module to judge illegal instructions when the first mode is determined, and performing multiple programming according to preset program partitions;
[0042] A second mode pointer module, for reading the pointer content in the program instruction area when the second mode is determined, and matching the content of the program pointer according to the number of 1s in the pointer content;
[0043] The second mode execution module is used to write the content of the program pointer into the register BOOT_ADDR inside the OTP controller, release the reset of the single-chip microcomputer, and perform automatic program programming.
[0044] According to a third aspect of an embodiment of the present invention, there is provided a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method as described in any one of the first aspect of the embodiment of the present invention is implemented.
[0045] According to a fourth aspect of an embodiment of the present invention, there is provided an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement any one of the methods described in the first aspect of the embodiment of the present invention.
[0046] The technical solution provided by the embodiments of the present invention may have the following beneficial effects:
[0047] In the scheme of the present invention, an architecture and method for OTP multiple programming are designed, so that the spare OTP storage space can be reused, thereby realizing multiple programming, and the programmed chip can be utilized, thereby saving costs.
[0048] In the scheme of the present invention, multiple programming of OTP is realized by two ways. The first way is to realize automatic startup through illegal instruction detection, and the second way is to realize fast startup and multiple programming through a pointer calculation module.
[0049] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0050] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0052] Figure 1 The present invention is a flowchart of a method for implementing OTP multiple programming according to an embodiment of the present invention.
[0053] Figure 2 The present invention is a flow chart of adding an illegal instruction detection module to an instruction decoding module in a single-chip computer in a method for realizing OTP multiple programming according to an embodiment of the present invention.
[0054] Figure 3 The present invention is a flowchart of adding a programmable startup address module and an address input to a pointer calculation module in a single-chip computer in a method for realizing OTP multiple programming in one embodiment of the present invention.
[0055] Figure 4 This is a flow chart of selecting one of a first mode and a second mode in a method for implementing OTP multiple programming in one embodiment of the present invention, and starting single-chip computer programming.
[0056] Figure 5 It is a flowchart of a method for implementing OTP multiple programming in an embodiment of the present invention, in which when the first mode is judged, the illegal instruction detection module is started to perform illegal instruction judgment, and multiple programming is performed according to preset program partitions.
[0057] Figure 6 It is a flowchart of a method for implementing OTP multiple programming in an embodiment of the present invention, in which when the second method is determined, the pointer content in the program instruction area is read, and the content of the program pointer is matched according to the number of 1s in the pointer content.
[0058] Figure 7 The present invention is a flowchart of a method for realizing OTP multiple programming in one embodiment of the present invention, which includes writing the content of the program pointer into the register BOOT_ADDR inside the OTP controller, releasing the reset of the single-chip microcomputer, and performing automatic program programming.
[0059] Figure 8 It is a structural diagram of a system for implementing OTP multiple programming according to an embodiment of the present invention.
[0060] Fig. 9 It is a structural diagram of an electronic device in one embodiment of the present invention.
[0061] Fig.10This is the OTP program partition diagram of the first method in one embodiment of the present invention.
[0062] Fig.11 This is the working sequence in one embodiment of the present invention. DETAILED DESCRIPTION
[0063] In some of the processes described in the specification and claims of the present invention and the above-mentioned figures, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.
[0064] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0065] OTP (One Time Programmable) is a type of memory in a microcontroller, which means one-time programmable: after the program is burned into the microcontroller, it cannot be changed or cleared again. As the code area of the microcontroller, OTP is widely used in various electronic products due to its high reliability and low cost. In most application scenarios, the user code uses a small part of the OTP code area. Because OTP can only support one-time programming, the second programming needs to be exposed to ultraviolet light before it can be used. This results in the programmed OTP chip being discarded, resulting in a large waste.
[0066] Prior to the technology of the present invention, the prior art greatly increased the area by adding an adder of at least 16 bits to the address line outside the MCU. At the same time, due to the increase in the physical delay of the addition calculation of the adder, the operating frequency of the single-chip device was greatly affected, thereby affecting the performance of the entire SoC. By increasing the number of space and area zone switching programming times, the previously programmed area cannot be programmed again, and only the area that has not been programmed can be reused, thereby achieving the purpose of multiple programming.
[0067] In the embodiment of the present invention, a method, system, medium and electronic device for realizing OTP multiple programming are provided. The scheme adds only one OR gate to add the condition of illegal instruction to the condition of generating automatic accumulation of single chip microcomputer, thereby realizing simple structure and efficient OTP multiple programming.
[0068] According to a first aspect of an embodiment of the present invention, a method for implementing OTP multiple programming is provided.
[0069] Figure 1 The present invention is a flowchart of a method for implementing OTP multiple programming according to an embodiment of the present invention.
[0070] In one or more embodiments, preferably, the method for implementing OTP multiple programming includes:
[0071] S101, adding an illegal instruction detection module to the instruction decoding module in the single chip microcomputer;
[0072] S102, adding a programmable start address module and an address input to the pointer calculation module in the single chip microcomputer;
[0073] S103, selecting one of the first mode and the second mode to start single chip microcomputer programming;
[0074] S104, when it is determined to be the first mode, starting the illegal instruction detection module to perform illegal instruction judgment, and performing multiple programming according to the preset program partitions;
[0075] S105, when it is determined to be the second mode, reading the pointer content in the program instruction area, and matching the content of the program pointer according to the number of 1s in the pointer content;
[0076] S106, writing the content of the program pointer into the register BOOT_ADDR inside the OTP controller, releasing the reset of the single-chip microcomputer, and performing automatic program programming.
[0077] In an embodiment of the present invention, in order to solve the above problems, the present invention designs an architecture and method for OTP multiple programming, so that the free OTP storage space can be reused, thereby realizing multiple programming, and the programmed chip can be utilized, thereby saving costs. Two inventions are made to the architecture of the MCU core: First, an illegal instruction detection module is added to the instruction decoding module. When an illegal instruction is found, the PC instruction is automatically accumulated. Second, a programmable boot address module and a BOOT_ADDR input are added to the PC pointer calculation module. BOOT_ADDR is the boot address. At the rising edge of the MCU core reset release, the value of BOOT_ADDR is sampled into the PC pointer register, and then the PC pointer will automatically change based on the value of this BOOT_ADDR.
[0078] Figure 2 The present invention is a flow chart of adding an illegal instruction detection module to an instruction decoding module in a single-chip computer in a method for realizing OTP multiple programming according to an embodiment of the present invention.
[0079] like Figure 2 As shown, in one or more embodiments, preferably, the instruction decoding module in the single-chip microcomputer adds an illegal instruction detection module, specifically including:
[0080] S201, setting an illegal instruction detection module in the instruction decoding module of the single-chip microcomputer, which can judge whether the instruction is illegal in turn;
[0081] S202: When a legal instruction is detected, the instruction decoding module starts the program.
[0082] In an embodiment of the present invention, in order to achieve multiple programming, when the illegal instruction detection module reads an unprogrammed code area (usually a value of 0xFF or 0x00, which is hexadecimal data), it controls the PC instruction address to be automatically accumulated, and only starts executing the corresponding program when a legal and valid instruction is read.
[0083] Figure 3 The present invention is a flowchart of adding a programmable startup address module and an address input to a pointer calculation module in a single-chip computer in a method for realizing OTP multiple programming in one embodiment of the present invention.
[0084] like Figure 3 As shown, in one or more embodiments, preferably, the adding of a programmable startup address module and an address input in the pointer calculation module in the single-chip microcomputer specifically includes:
[0085] S301, adding the programmable startup address module for obtaining the program startup address in the single chip microcomputer;
[0086] S302, connecting the startup address of the programmable startup address module to the controller of the OTP.
[0087] In the embodiment of the present invention, it is assumed that multiple programming is performed through the programmable boot address module, and the starting address of program x (program x pointer) and the program x starting address selection pointer (program pointer area pointer) are stored in the OTP. After the OTP is initialized, the program x starting address selection pointer is automatically read, and then the corresponding program x starting address is selected and read, and this value is written to the register BOOT_ADDR in the OTP controller.
[0088] Figure 4 This is a flow chart of selecting one of a first mode and a second mode in a method for implementing OTP multiple programming in one embodiment of the present invention, and starting single-chip computer programming.
[0089] like Figure 4 As shown, in one or more embodiments, preferably, the selecting one of the first mode and the second mode to start the single chip microcomputer programming specifically includes:
[0090] S401, setting the startup mode in the single chip microcomputer according to experience;
[0091] S402, setting the startup mode to one of the first mode and the second mode;
[0092] S403: In the first mode, programming is performed automatically; in the second mode, programming is performed according to address selection.
[0093] In the embodiment of the present invention, specific OTP multiple programming is implemented through two methods. The selection of the two methods adopts experience judgment, so that the free OTP storage space can be reused, thereby realizing multiple programming, and the programmed chip can be utilized, thereby saving costs. The specific experience judgment process is as follows.
[0094] Figure 5 It is a flowchart of a method for implementing OTP multiple programming in an embodiment of the present invention, in which when the first mode is judged, the illegal instruction detection module is started to perform illegal instruction judgment, and multiple programming is performed according to preset program partitions.
[0095] like Figure 5 As shown, in one or more embodiments, preferably, when the first mode is determined, the illegal instruction detection module is started to perform illegal instruction judgment, and multiple programming is performed according to the preset program partition, specifically including:
[0096] S501, after starting the first method, using the illegal instruction detection module in the single chip microcomputer to determine that it is a programming code area;
[0097] S502, placing the program to be programmed in the position of the OTP in sequence according to the sequence preset by the program;
[0098] S503, when reading the unprogrammed code area, automatically controlling the instruction fetch address to be automatically accumulated;
[0099] S504: When a legal and valid instruction is read, multiple programming operations are started in sequence.
[0100] In an embodiment of the present invention, when an unprogrammed code area is read (usually a value of 0xFF or 0x00), it is only necessary to place the first programmed program at the highest position of the OTP, and the second programmed program at the second highest position, and so on, to achieve multiple programming of the OTP. The accumulated PC here refers to the address of the MCU's read instruction. Through the accumulation of addresses, the MCU automatically searches for instruction codes from the non-programmed area to the programmed area until the first legal instruction is found, that is, the required execution target area code is searched, and then the program code is executed. Before the technology of the present invention, it is necessary to preset the location or address of the execution target area code.
[0101] Figure 6 It is a flowchart of a method for implementing OTP multiple programming in an embodiment of the present invention, in which when the second method is determined, the pointer content in the program instruction area is read, and the content of the program pointer is matched according to the number of 1s in the pointer content.
[0102] like Figure 6 As shown, in one or more embodiments, preferably, when the second mode is determined, the pointer content in the program instruction area is read, and the content of the program pointer is matched according to the number of 1s in the pointer content, specifically including:
[0103] S601, after starting the second mode, storing the starting address of each program in the OTP as the program pointer of each program;
[0104] S602, the program address selection pointer is used to directly read the program pointer of each program as the pointer content;
[0105] S603, after the OTP is initialized, the number of 1s in the pointer content is automatically read to select the content of the program pointer.
[0106] In the embodiment of the present invention, there is no limitation of the first method. Programs 0-n can be placed in the OTP corresponding area in the OTP program partition without any limitation. To save OTP space, it is recommended to store programs from the lowest address. The highest address of OTP reserves more than ten bytes to store the program pointer area. The program pointer area stores the starting address of each program 0-n and the pointer to the program pointer area (used to select the program starting address).
[0107] Figure 7 The present invention is a flowchart of a method for realizing OTP multiple programming in one embodiment of the present invention, which includes writing the content of the program pointer into the register BOOT_ADDR inside the OTP controller, releasing the reset of the single-chip microcomputer, and performing automatic program programming.
[0108] like Figure 7As shown, in one or more embodiments, preferably, the writing of the content of the program pointer into the register BOOT_ADDR inside the OTP controller, releasing the reset of the single-chip microcomputer, and performing automatic program programming specifically includes:
[0109] S701, write the content of the program pointer into the register BOOT_ADDR in the OTP controller;
[0110] S702, the register BOOT_ADDR is connected to the programmable boot address module of the single-chip microcomputer core;
[0111] S703 . At the rising edge of the single-chip microcomputer core reset release, increase the number of 1s in the pointer content by 1, and automatically update the pointer content to the register BOOT_ADDR.
[0112] In the embodiment of the present invention, each bit of the OTP that has been erased by ultraviolet rays or not programmed is usually 0. When programming the corresponding bit to 1, the corresponding bit 0 can only be changed to 1. The core of this method is to increase or change the number of "1" in the program pointer area pointer (selection pointer) in sequence each time programming to select the starting address of the program x to be used (such as 0x00, 0x01, 0x03, 0x7). The 0th programming, program 0 and program 0 pointer, and then program the program pointer area pointer to 0x00; the first programming, program 1 and program 1 pointer, and then program the pointer in the program pointer area to 0x01; the second programming, program 2 and program 2 pointer, and then program the pointer in the program pointer area to 0x03.
[0113] According to a second aspect of an embodiment of the present invention, a system for implementing OTP multiple programming is provided.
[0114] Figure 8 It is a structural diagram of a system for implementing OTP multiple programming according to an embodiment of the present invention.
[0115] In one or more embodiments, preferably, the system for implementing OTP multiple programming includes:
[0116] The first mode arranges the module 801, which is used to add an illegal instruction detection module to the instruction decoding module in the single chip microcomputer;
[0117] The second arrangement module 802 is used to add a programmable start address module and an address input to the pointer calculation module in the single chip microcomputer;
[0118] A mode determination module 803 is used to select one of the first mode and the second mode to start the single chip microcomputer programming;
[0119] The first mode execution module 804 is used to start the illegal instruction detection module to judge illegal instructions when the first mode is determined, and perform multiple programming according to the preset program partitions;
[0120] The second mode pointer module 805 is used to read the pointer content in the program instruction area when the second mode is determined, and correspond the program pointer content according to the number of 1s in the pointer content;
[0121] The second mode execution module 806 is used to write the content of the program pointer into the register BOOT_ADDR inside the OTP controller, release the reset of the single-chip microcomputer, and perform automatic program programming.
[0122] In the embodiment of the present invention, a system suitable for different structures is realized through a series of modular designs. The system can achieve closed-loop, reliable and efficient execution through collection, analysis and control.
[0123] According to a third aspect of an embodiment of the present invention, there is provided a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method as described in any one of the first aspect of the embodiment of the present invention is implemented.
[0124] According to a fourth aspect of an embodiment of the present invention, an electronic device is provided. Fig. 9 It is a structural diagram of an electronic device in one embodiment of the present invention. Fig. 9 The electronic device shown is a general-purpose OTP multiple programming device, which includes a general-purpose computer hardware structure, which at least includes a processor 901 and a memory 902. The processor 901 and the memory 902 are connected via a bus 903. The memory 902 is suitable for storing instructions or programs executable by the processor 901. The processor 901 can be an independent microprocessor or a collection of one or more microprocessors. Thus, the processor 901 executes the instructions stored in the memory 902, thereby executing the method flow of the embodiment of the present invention as described above to realize the processing of data and the control of other devices. The bus 903 connects the above-mentioned multiple components together, and at the same time connects the above-mentioned components to the display controller 904 and the display device and the input / output (I / O) device 905. The input / output (I / O) device 905 can be a mouse, a keyboard, a modem, a network interface, a touch input device, a somatosensory input device, a printer, and other devices known in the art. Typically, the input / output device 905 is connected to the system through an input / output (I / O) controller 906.
[0125] Fig.10The OTP program partition diagram for the first method, after the MCU is reset and released, the instruction code is usually read from address 0. The default value of the unprogrammed OTP code area is 0xFF or 0x00. The MCU obtains 0x00 or 0xFF and considers it as an illegal instruction or part of an instruction. The instruction decoding module or illegal instruction detection module will control the PC to automatically accumulate. Only when the PC accumulates to the OTP code area of legal and valid instructions, the program can be started. Arrange the OTP code area as shown in the following figure. The program programmed for the first time is placed in program area 0, the program programmed for the second time is placed in program area 1, and the others are analogous. For the first programming, the program is programmed to program area 0. The OTP areas lower than program area 0 are all unprogrammed areas. After the MCU is reset and released, the PC automatically accumulates from address 0 to program area 0 and starts to execute the program in program area 0. For the second programming, the program is programmed to program area 1 lower than program area 0. The OTP areas lower than program area 1 are all unprogrammed areas. After the MCU is reset and released, the PC automatically accumulates from address 0 to program area 1 and starts to execute the program in program area 1. More programming times, and so on, thus achieving multiple programming, making full use of the entire OTP programmable area and saving costs.
[0126] The specific working sequence is as follows Fig.11 After OTP is reset and initialized (MCU core reset is not released), the OTP controller automatically reads the program instruction area in the highest address area of OTP. First, the content of the pointer of the program instruction area is read. According to the number of "1" in the content, the content of the read program x pointer (the value is 0x00, the content of the program 0 pointer is read; the value is 0x01, the content of the program 1 pointer is read; the value is 0x03, the content of the program 2 pointer is read, and the same applies to the others) is determined, and this content is written into the register BOOT_ADDR inside the OTP controller. Then the MCU reset is released, and the programmable boot address module of the MCU automatically reads the corresponding program x with BOOT_ADDR as the starting address of the PC pointer. In this way, multiple programming can be realized, and the entire OTP programmable area can be fully utilized to save costs. The advantage of this method is that it does not have the limitation of not supporting interrupts in the first method, and its implementation logic circuit is also relatively simple. It only requires the MCU core reset rising edge detection and loading BOOT_ADDR to the PC pointer starting address register logic. The delay of the additional logic circuit is also very small, and the operating frequency of the MCU IC back-end physical implementation is also very small.
[0127] The technical solution provided by the embodiments of the present invention may have the following beneficial effects:
[0128] In the scheme of the present invention, an architecture and method for OTP multiple programming are designed, so that the spare OTP storage space can be reused, thereby realizing multiple programming, and the programmed chip can be utilized, thereby saving costs.
[0129] In the scheme of the present invention, multiple programming of OTP is realized by two ways. The first way is to realize automatic startup through illegal instruction detection, and the second way is to realize fast startup and multiple programming through a pointer calculation module.
[0130] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0131] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0132] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0133] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0134] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for implementing OTP multiple programming, characterized in that: The method includes: Add an illegal instruction detection module to the instruction decoding module in the microcontroller; Add a programmable start address module and address input to the pointer calculation module in the microcontroller; Select one of the first method and the second method to start the microcontroller programming; When the first mode is determined, the illegal instruction detection module is started to judge illegal instructions, and multiple programming is performed according to preset program partitions; When the second method is determined, the pointer content in the program instruction area is read, and the content of the program pointer is matched according to the number of 1s in the pointer content; Write the content of the program pointer into the register BOOT_ADDR inside the OTP controller, release the reset of the microcontroller, and perform automatic program programming; The instruction decoding module in the single-chip microcomputer adds an illegal instruction detection module, which specifically includes: An illegal instruction detection module capable of sequentially judging whether an instruction is illegal is provided in the instruction decoding module of the single-chip microcomputer; When a legal instruction is detected, the instruction decoding module starts the program; The step of adding a programmable startup address module and an address input to a pointer calculation module in a single chip microcomputer specifically includes: Adding the programmable startup address module for obtaining the program startup address in the single-chip microcomputer; Connecting the startup address of the programmable startup address module to the controller of OTP; The process of writing the content of the program pointer into the register BOOT_ADDR inside the OTP controller, releasing the reset of the microcontroller, and performing automatic program programming specifically includes: Write the content of the program pointer into the register BOOT_ADDR in the OTP controller; The register BOOT_ADDR is connected to the programmable boot address module of the single-chip microcomputer core; At the rising edge of the single-chip microcomputer core reset release, the number of 1s in the pointer content is increased by 1, and the pointer content is automatically updated to the register BOOT_ADDR.
2. A method for implementing OTP multiple programming as claimed in claim 1, characterized in that: The selecting one of the first mode and the second mode to start the single chip microcomputer programming specifically includes: Set the startup mode in the microcontroller based on experience; Setting the startup mode to one of the first mode and the second mode; In the first mode, programming is performed automatically, and in the second mode, programming is performed according to address selection.
3. A method for implementing OTP multiple programming as claimed in claim 1, characterized in that: When the first mode is determined, the illegal instruction detection module is started to perform illegal instruction judgment, and multiple programming is performed according to the preset program partitions, specifically including: After starting the first method, the illegal instruction detection module is used in the single-chip microcomputer to determine that it is a programming code area; Place the programs to be programmed in the OTP positions in the order preset by the program; When reading the unprogrammed code area, the automatic control instruction fetch address is automatically accumulated; When a legal and valid instruction is read, multiple programming operations are started in sequence.
4. A method for implementing OTP multiple programming as claimed in claim 1, characterized in that: When the second mode is determined, the pointer content in the program instruction area is read, and the content of the program pointer is matched according to the number of 1s in the pointer content, specifically including: After starting the second mode, the starting address of each program is stored in the OTP as a program pointer of each program; The program address selection pointer is used to directly read the program pointer of each program as the pointer content; After the OTP is initialized, the number of 1s in the pointer content is automatically read to select the content of the program pointer.
5. A system for implementing OTP multiple programming, characterized in that: The system is used to implement the method according to any one of claims 1 to 4, and the system comprises: The first mode arranges the modules, and is used to add an illegal instruction detection module to the instruction decoding module in the single chip microcomputer; The second mode arranges the modules for adding a programmable start address module and an address input to a pointer calculation module in a single chip microcomputer; A mode judgment module is used to select one of the first mode and the second mode to start the single chip microcomputer programming; A first mode execution module, used for starting the illegal instruction detection module to judge illegal instructions when the first mode is determined, and performing multiple programming according to preset program partitions; A second mode pointer module, for reading the pointer content in the program instruction area when the second mode is determined, and matching the content of the program pointer according to the number of 1s in the pointer content; The second mode execution module is used to write the content of the program pointer into the register BOOT_ADDR inside the OTP controller, release the reset of the single-chip microcomputer, and perform automatic program programming.
6. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: The computer program instructions implement the method according to any one of claims 1 to 4 when executed by a processor.
7. An electronic device comprising a memory and a processor, characterized in that: The memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1-4.
