Method, device, storage medium and burner for burning a chip
By merging factory configuration information and user configuration information into one sector in the chip and performing backup and verification in the main program area, the problem of large storage space occupied by the chip configuration area is solved, and hardware costs are reduced.
Patent Information
- Application Number
- CN202211189626.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-28
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2042-09-28
AI Technical Summary
The chip configuration area in existing chips occupies a lot of storage space, resulting in high hardware costs.
The chip configuration area is divided into a sector to store factory configuration information and user configuration information. After the chip is powered on, an integrity check is performed and backed up to the backup area of the main program area. After modifying the user configuration information, the check code is calculated and written back to the configuration area. The backup area is erased, and finally the main program code is burned into the main program area.
By merging factory configuration information and user configuration information into one sector, the chip's storage space usage is reduced, hardware costs are lowered, and the chip configuration and main program code burning process is not affected.
Smart Images

Figure CN115686544B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of chips, and more particularly to a method, apparatus, storage medium, and programmer for programming chips. Background Technology
[0002] A chip's storage area is generally divided into two parts: the main program area and the chip configuration area. The main program area stores the main program code, while the chip configuration area consists of two sectors: one sector stores factory configuration information, and the other sector stores user configuration information. Low-cost chips are more cost-sensitive; in existing chips, the chip configuration area occupies a significant amount of storage space, increasing the chip's hardware cost. Summary of the Invention
[0003] This application provides a method, apparatus, storage medium, and programmer for programming chips, which can solve the problem in the prior art where the chip configuration area occupies a large amount of storage space, resulting in a low hardware success rate. The technical solution is as follows:
[0004] In a first aspect, embodiments of this application provide a method for programming a chip, applied to a chip, wherein the chip's storage space is divided into a chip configuration area and a main program area, the chip configuration area is used to store factory configuration information and user configuration information, and the chip configuration area is a sector;
[0005] The method includes:
[0006] After the detection chip is powered on, the integrity of the data in the chip's configuration area is verified.
[0007] If the verification passes, the data in the chip configuration area is written to the backup area in the main program area, and the data in the chip configuration area is loaded into the random access memory of the programmer.
[0008] Perform an erase operation on the chip configuration area;
[0009] After successful erasure, the user configuration information in the random access memory is modified based on the user's configuration instructions;
[0010] Calculate the checksum based on the modified user configuration information and the factory configuration information;
[0011] The verification code, the modified user configuration information, and the factory configuration information are burned into the chip configuration area;
[0012] After successful burning, erase the backup area;
[0013] After successful erasure, the main program code is burned into the main program area.
[0014] Secondly, embodiments of this application provide a programmer, the apparatus comprising:
[0015] The verification unit is used to perform integrity verification on the data in the chip configuration area after the chip is powered on;
[0016] The backup unit is used to write the data in the chip configuration area to the backup area in the main program area if the verification passes, and to load the data in the chip configuration area into the random access memory of the programmer.
[0017] An erasing unit is used to perform an erasing operation on the chip configuration area;
[0018] The modification unit is used to modify the user configuration information in the random access memory based on the user's configuration instructions after successful erasure.
[0019] The calculation unit is used to calculate the check code based on the modified user configuration information and the factory configuration information;
[0020] The programming unit is used to program the verification code, the modified user configuration information, and the factory configuration information into the chip configuration area;
[0021] The erasure unit is also used to erase the backup area after successful burning;
[0022] The programming unit is also used to program the main program code in the main program area after successful erasure.
[0023] Thirdly, embodiments of this application provide a computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the above-described method steps.
[0024] Fourthly, embodiments of this application provide a programmer, which may include: a processor and a memory; wherein the memory stores a computer program, the computer program being adapted to be loaded by the processor and to execute the above-described method steps.
[0025] The beneficial effects of the technical solutions provided in some embodiments of this application include at least the following:
[0026] Factory configuration information and user configuration information are combined and stored in one sector. When the main program code needs to be programmed into the chip, the data in the chip configuration area is checked for integrity. After the check passes, the data in the chip configuration area is backed up to the backup area in the main program area and loaded into the programmer's random access memory (RAM). The user configuration information in the RAM is modified, and then the modified data and checksum are written back to the chip configuration area. After successful writing, the backup area is erased and the main program code is programmed into the main program area. This embodiment of the application reduces the number of sectors occupied by the chip by storing factory configuration information and user configuration information in one sector, thereby reducing the chip's storage space and lowering the chip's hardware cost. Furthermore, by backing up the data in the chip configuration area in the main program area, the user's chip configuration process and the main program code programming process are not affected. Attached Figure Description
[0027] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 This is a schematic diagram of the network architecture provided in the embodiments of this application;
[0029] Figure 2 This is a schematic flowchart of the chip programming method provided in the embodiments of this application;
[0030] Figure 3 This is a schematic diagram of the storage space distribution of the chip provided in the embodiments of this application;
[0031] Figure 4 This is a schematic diagram of the structure of a programmer provided in this application;
[0032] Figure 5 This is a schematic diagram of the structure of a programmer provided in this application. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0034] It should be noted that the chip programming method provided in this application is generally executed by a programmer, and correspondingly, the programmer is generally located in the chip.
[0035] Figure 1 An exemplary system architecture for a method or programmer that can be applied to the chip programming of this application is shown.
[0036] like Figure 1 As shown, the system architecture may include: programmer 101, computer device 102, chip ( Figure 1 (Not shown in the diagram). The programmer 101 and the computer device 102 can communicate via a network, which serves as the medium for providing communication links between the aforementioned units. The network can include various types of wired or wireless communication links, such as: wired communication links including optical fiber, twisted pair, or coaxial cable, and wireless communication links including Bluetooth, Wi-Fi, or microwave communication links.
[0037] The programmer 101 is equipped with one or more sockets for inserting chips, enabling communication between the chips and the programmer. The computer device 102 provides a graphical interface, allowing the user to interact with the programmer 101 and instruct it to perform chip programming operations.
[0038] The chip in this application may be a microcontroller, processor, or other integrated circuit that performs a control function.
[0039] It should be noted that the computer device 102 can be either hardware or software. When the computer device 102 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the computer device 102 is software, it can be implemented as multiple software programs or software modules (for example, used to provide distributed services), or as a single software program or software module; no specific limitations are made here.
[0040] The computer device 102 of this application can be equipped with various communication client applications, such as video recording applications, video playback applications, voice interaction applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0041] Computer device 102 can be various terminal devices with a display screen, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0042] The display device of computer device 102 can be any device capable of displaying information, with the camera used to capture video streams. For example, the display device can be a cathode ray tube display (CR), a light-emitting diode display (LED), an e-ink screen, a liquid crystal display (LCD), a plasma display panel (PDP), etc. Users can use the display device on the programmer to view displayed text, images, videos, and other information.
[0043] It should be understood that Figure 1 The number of chips, programmers, networks, and computer devices shown is for illustrative purposes only. Depending on the implementation requirements, there can be any number of computer devices, networks, chips, and programmers.
[0044] The following will be combined with the appendix Figure 2 This application provides a detailed description of the chip programming method provided in its embodiments. The programmer in these embodiments can be... Figure 1 The programmer shown.
[0045] Please see Figure 2 This is a flowchart illustrating a method for programming a chip, as provided in an embodiment of this application. Figure 2 As shown, the method described in this application embodiment may include the following steps:
[0046] S201. After the chip is powered on, the integrity of the data in the chip configuration area is checked.
[0047] In this embodiment, the chip's storage space is divided into a chip configuration area and a main program area. The chip configuration area stores factory configuration information and user configuration information. The chip configuration area is a sector, and the size of the sector is determined by the organization of the chip's internal storage space; for example, the sector size is typically 4KB. The factory configuration information is burned into the chip after packaging and testing and cannot be modified by the user. Factory configuration information includes hardware attribute information, chip calibration information, power-on configuration information, etc. User configuration information consists of user-defined configurations for the main program code within the chip, which can be customized by the user according to actual needs. User configuration information includes code encryption information, watchdog information, code protection information, etc. Before programming, the chip is inserted into the programmer's socket. When the programmer is powered on, it sends a power-on command to the chip, instructing the chip to perform a power-on operation. After detecting that the chip is powered on, it performs an integrity check on the data in the chip configuration area to verify whether the data within the chip is correct, i.e., whether it has been tampered with. This application embodiment can use the CRC algorithm to perform integrity verification on the data in the chip configuration area. The data in the chip configuration area includes factory configuration information, user configuration information, and a checksum generated based on the factory configuration information and user configuration information. The factory configuration information and user configuration information in the chip configuration area are read, and the checksum is calculated based on the read data. The calculated checksum is compared with the checksum in the chip configuration area. If they are the same, the integrity verification passes; otherwise, the integrity verification fails. Furthermore, the programmer can be equipped with multiple sockets to support simultaneous programming of multiple chips of the same model, thereby improving programming efficiency.
[0048] For example, see Figure 3 The diagram shows the distribution of the chip's storage space. In existing methods, the chip's storage space is divided into sector NVR0, sector NVR1, and the main program area. Sector NVR0 stores factory configuration information, sector NVR1 stores user configuration information, and the main program area stores the main program code. In the improved method of this embodiment, the chip's storage space is divided into sector NVR0 (chip configuration area) and the main program area. The size of the chip's storage space is reduced by one sector compared to the existing method. Sector NVR0 stores both factory configuration information and user configuration information, while the main program area remains unchanged and still stores the main program code. The size of a sector is generally thousands of bytes, while the size of the factory configuration information and user configuration information is generally tens of bytes; one sector is sufficient to store these two pieces of information.
[0049] Furthermore, the checksum in the chip configuration area can be formed by concatenating a first checksum and a second checksum. The order of the first and second checksums is not limited. The first checksum is calculated from the factory configuration information, and the second checksum is calculated from the user configuration information. The first checksum can be used to verify the integrity of the factory configuration information, and the second checksum can be used to verify the integrity of the user configuration information. Performing integrity verification through the two checksums makes it easier for users to distinguish the type of information that failed the verification, specifically which information in the chip configuration area failed the verification. When the verification fails, the type of information is indicated in the verification failure message displayed on the computer device.
[0050] S202. If the verification passes, write the data in the chip configuration area to the backup area in the main program area, and load the data in the chip configuration area into the random access memory of the programmer.
[0051] In this embodiment, after successful verification, indicating that the data in the chip configuration area is correct, the programmer writes the data (i.e., factory configuration information and user configuration information) from the chip configuration area to the backup area in the main program area. The backup area is a sector in the main program area, which may be the last sector in the main program area. The main program area generally has redundant space, meaning the last sector is less likely to be used. Backing up the data in the chip configuration area to the last sector will not affect the existing main program code of the chip. After writing the data in the chip configuration area to the backup area, the programmer reads the data in the chip configuration area and loads it into random access memory (RAM).
[0052] Furthermore, the programmer has multiple sockets, each with a memory partition in the random access memory (RAM). The RAM can perform programming operations on the chips on the sockets in parallel across different memory partitions. Data generated during the programming process is stored in the corresponding memory partition. In this embodiment, the programmer identifies the chip's socket ID, then reads data (i.e., factory configuration information and user configuration information) from the chip's configuration area. Based on the mapping relationship between the socket ID and memory partitions, the programmer determines the target memory partition corresponding to the chip and then writes the read data into the target memory partition.
[0053] S203, Perform an erase operation on the chip configuration area.
[0054] In this embodiment, the chip configuration area is a sector. The programmer instructs the chip to perform an operation. The chip only needs to perform an erase operation once to clear the data in the chip configuration area.
[0055] S204. After successful erasure, modify the user configuration information in the random access memory based on the user's configuration instructions.
[0056] In this embodiment, the programmer modifies user configuration information in the random access memory based on user configuration commands. The user can connect to the programmer via a computer device, which displays a configuration interface. The user interacts with the configuration interface using input devices such as a mouse, keyboard, or touchscreen to modify the user configuration information, and then sends the modified user configuration information to the programmer. Furthermore, the configuration interface has multiple configuration areas based on the number of sockets on the programmer. These configuration areas are used to configure the chips on the sockets, allowing the user to configure multiple chips simultaneously, thus improving chip configuration efficiency.
[0057] S205. Calculate the verification code based on the modified user configuration information and factory configuration information.
[0058] In this embodiment, the programmer calculates a checksum based on the modified user configuration information and factory configuration information. The calculation method can be: calculating a checksum for both the modified user configuration information and the factory configuration information, simplifying the calculation process; this checksum can be used to verify whether the data in the chip configuration area has been modified; or calculating a first checksum based on the modified user configuration information and a second checksum based on the factory configuration information, thus verifying which specific information type failed the check. Furthermore, the checksum can also be calculated by a computer device, which then writes the calculated checksum into the programmer's random access memory, reducing the programmer's processing overhead.
[0059] S206. Burn the verification code, modified user configuration information, and factory configuration information into the chip configuration area.
[0060] In this embodiment, the programmer reads the calculated checksum, the modified user configuration information, and the default travel configuration information from the random access memory and programs them into the chip configuration area.
[0061] S207. After successful burning, erase the backup area.
[0062] The programmer clears the data in the backup area.
[0063] S208. After successful erasure, the main program code is burned into the main program area.
[0064] Factory configuration information and user configuration information are combined and stored in one sector. When the main program code needs to be programmed into the chip, the data in the chip configuration area is checked for integrity. After the check passes, the data in the chip configuration area is backed up to the backup area in the main program area and loaded into the programmer's random access memory (RAM). The user configuration information in the RAM is modified, and then the modified data and checksum are written back to the chip configuration area. After successful writing, the backup area is erased and the main program code is programmed into the main program area. This embodiment of the application reduces the number of sectors occupied by the chip by storing factory configuration information and user configuration information in one sector, thereby reducing the chip's storage space and lowering the chip's hardware cost. Furthermore, by backing up the data in the chip configuration area in the main program area, the user's chip configuration process and the main program code programming process are not affected.
[0065] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0066] Please see Figure 4 This illustration shows a schematic diagram of a programmer provided in an exemplary embodiment of this application, hereinafter referred to as device 4. Device 4 can be implemented as all or part of the programmer through software, hardware, or a combination of both. Device 4 includes: a verification unit 401, a backup unit 402, an erasure unit 403, a modification unit 404, a calculation unit 105, and a programming unit 406.
[0067] The verification unit 401 is used to perform integrity verification on the data in the chip configuration area after the chip is powered on.
[0068] Backup unit 402 is used to write the data in the chip configuration area to the backup area in the main program area if the verification passes, and to load the data in the chip configuration area into the random access memory of the programmer.
[0069] Erasing unit 403 is used to perform an erasing operation on the chip configuration area;
[0070] Modification unit 404 is used to modify the user configuration information in the random access memory based on the user's configuration instructions after successful erasure.
[0071] Calculation unit 405 is used to calculate a check code based on the modified user configuration information and the factory configuration information;
[0072] The programming unit 406 is used to program the verification code, the modified user configuration information, and the factory configuration information into the chip configuration area;
[0073] The erasure unit 403 is also used to erase the backup area after successful burning;
[0074] The programming unit 406 is also used to program the main program code in the main program area after successful erasure.
[0075] In one or more possible embodiments, the backup area is a sector, and the backup area is the last sector in the main program area.
[0076] In one or more possible embodiments, the integrity of the data in the chip configuration area is verified based on the Cyclic Redundancy Check (CRC) algorithm.
[0077] In one or more possible embodiments, loading the data within the chip configuration area into the random access memory of the programmer includes:
[0078] Identify the socket ID of the chip;
[0079] Read data from the chip configuration area;
[0080] The read data is written to the memory partition in random access memory associated with the socket ID.
[0081] In one or more possible embodiments, the configuration instructions originate from a computer device and are generated by the user interacting with the configuration interface of the computer device.
[0082] In one or more possible embodiments, the calculation of the checksum based on the modified user configuration information and the factory configuration information includes:
[0083] The first verification code is calculated based on the modified user configuration information, and the second verification code is calculated based on the factory configuration information.
[0084] The first check code and the second check code are concatenated to obtain the final check code.
[0085] In one or more possible embodiments, the verification unit 401 is further configured to:
[0086] If the verification fails, a verification failure message will be displayed on the computer device. The verification failure message indicates the type of information that failed the verification in the chip configuration area.
[0087] It should be noted that the device 4 provided in the above embodiments is only illustrated by the division of the above functional modules when performing the chip programming method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the above functions. In addition, the programmer and the chip programming method embodiments provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.
[0088] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0089] This application also provides a computer storage medium that can store multiple instructions, which are adapted to be loaded and executed by a processor as described above. Figure 2 The method steps of the illustrated embodiment can be found in the following documentation for detailed execution. Figure 2 The specific details of the illustrated embodiments will not be elaborated here.
[0090] This application also provides a computer program product that stores at least one instruction, which is loaded and executed by the processor to implement the chip programming method described in the above embodiments.
[0091] Please see Figure 5 The diagram below provides a schematic representation of a programmer according to an embodiment of this application. Figure 5 As shown, the programmer 500 may include: at least one processor 501, at least one network interface 504, memory 503, at least one communication bus 502, and at least one socket.
[0092] The communication bus 502 is used to enable communication between these components.
[0093] The network interface 504 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface), and the network interface 504 is used to communicate with computer equipment.
[0094] The socket 505 is used to connect the chip.
[0095] The processor 501 may include one or more processing cores.
[0096] The processor 501 connects various parts within the programmer 500 using various interfaces and lines. It executes various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 503, and by calling data stored in the memory 503. Optionally, the processor 501 can be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 501 can integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem can also be implemented as a separate chip without being integrated into the processor 501.
[0097] The memory 503 may include random access memory (RAM) or read-only memory. Optionally, the memory 503 may include a non-transitory computer-readable storage medium. The memory 503 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 503 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 503 may also be at least one storage device located remotely from the aforementioned processor 501. Figure 5 As shown, the memory 503, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and application programs.
[0098] exist Figure 5 In the programmer 500 shown, the processor 501 can be used to call the application program stored in the memory 503 and specifically execute, such as... Figure 2 The method shown can be referred to for details. Figure 2As shown, it will not be elaborated further here.
[0099] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory, or random access memory, etc.
[0100] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.
Claims
1. A method for programming a chip, characterized in that, Applied to chips, the chip's storage space is divided into a chip configuration area and a main program area. The chip configuration area is used to store factory configuration information and user configuration information. The chip configuration area is one sector. The main program area is used to store the main program code. The user configuration information represents the configuration of the main program code. The user configuration information allows users to modify it according to actual needs. The factory configuration information does not allow users to modify it. The factory configuration information includes: hardware attribute information, chip calibration information, and power-on configuration information; the user configuration information includes: code encryption information, watchdog information, and code protection information. The method includes: After the detection chip is powered on, the integrity of the data in the chip's configuration area is verified. If the verification passes, the data in the chip configuration area is written to the backup area in the main program area, and the socket ID of the chip is identified; data is read from the chip configuration area; the read data is written to the memory partition in the random access memory associated with the socket ID; Perform an erase operation on the chip configuration area; After successful erasure, the user configuration information in the random access memory is modified based on the user's configuration instructions; Calculate the first verification code based on the modified user configuration information, and calculate the second verification code based on the factory configuration information; concatenate the first verification code and the second verification code to obtain the final verification code; The verification code, the modified user configuration information, and the factory configuration information are burned into the chip configuration area; After successful burning, the backup area is erased; the backup area is a sector, and the backup area is the last sector in the main program area; After successful erasure, the main program code is burned into the main program area.
2. The method according to claim 1, characterized in that, The integrity of the data in the chip configuration area is verified using the Cyclic Redundancy Check (CRC) algorithm.
3. The method according to claim 1, characterized in that, The configuration instructions originate from the computer device and are generated by the user interacting with the configuration interface of the computer device.
4. The method according to claim 1, characterized in that, Also includes: If the verification fails, a verification failure message will be displayed on the computer device. The verification failure message indicates the type of information that failed the verification in the chip configuration area.
5. A device for programming chips, characterized in that, Applied to chips, the chip's storage space is divided into a chip configuration area and a main program area. The chip configuration area is used to store factory configuration information and user configuration information. The chip configuration area is one sector. The main program area is used to store the main program code. The user configuration information represents the configuration of the main program code. The user configuration information allows users to modify it according to actual needs. The factory configuration information does not allow users to modify it. The factory configuration information includes: hardware attribute information, chip calibration information, and power-on configuration information; the user configuration information includes: code encryption information, watchdog information, and code protection information. The device includes: The verification unit is used to perform integrity verification on the data in the chip configuration area after the chip is powered on; The backup unit is used to write the data in the chip configuration area to the backup area in the main program area if the verification passes, and to identify the socket ID of the chip; read data in the chip configuration area; and write the read data to the memory partition in the random access memory associated with the socket ID. An erasing unit is used to perform an erasing operation on the chip configuration area; The modification unit is used to modify the user configuration information in the random access memory based on the user's configuration instructions after successful erasure. The calculation unit is used to calculate a first verification code based on the modified user configuration information, and to calculate a second verification code based on the factory configuration information; the first verification code and the second verification code are concatenated to obtain the final verification code; The programming unit is used to program the verification code, the modified user configuration information, and the factory configuration information into the chip configuration area; The erasure unit is also used to erase the backup area after successful burning; the backup area is a sector, and the backup area is the last sector in the main program area; The programming unit is also used to program the main program code in the main program area after successful erasure.
6. A computer storage medium, characterized in that, The computer storage medium stores a plurality of instructions, which are adapted to be loaded by a processor and executed as method steps as claimed in any one of claims 1 to 4.
7. A programmer, characterized in that, include: A processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed the method steps as claimed in any one of claims 1 to 4.
Citation Information
Patent Citations
Gateway product FLASH configuration loss processing method
CN103514013A
Chip firmware burning method, device and system and storage medium
CN114594973A