Search

CN-121996293-A - Output method for memory anti-overflow protection based on 32-bit singlechip firmware upgrade

CN121996293ACN 121996293 ACN121996293 ACN 121996293ACN-121996293-A

Abstract

The invention discloses an output method for memory anti-overflow protection based on 32-bit singlechip firmware upgrade, which relates to the field of singlechip memory anti-overflow protection, and specifically comprises the following operation steps of S1, configuration and management of environment variables; S2, core execution of Python automation script, S3, memory anti-overflow protection, and S4, cleaning of redundant files and environment variables. According to the output method based on the 32-bit singlechip firmware upgrade memory anti-overflow protection, the file path is defined as the environment variable and is stored in the independent configuration file in a concentrated manner, so that the complete separation of the path and the script logic is realized, the problem of non-portability caused by a hard coding path is avoided, meanwhile, the adaptation cost under different environments is reduced, an operator does not need to modify script codes, and deployment can be completed only by adjusting the configuration file.

Inventors

  • XU LIANG
  • HU JISONG
  • WANG XIAODONG

Assignees

  • 江苏盖睿健康科技有限公司

Dates

Publication Date
20260508
Application Date
20260128

Claims (6)

  1. 1. The output method for the memory overflow protection based on the 32-bit singlechip firmware upgrade is characterized by comprising the following operation steps of: s1, configuring and managing environment variables, replacing a hard coding path in a traditional script through unified variable definition, avoiding script reconstruction caused by path modification, and simultaneously facilitating parameter adaptation in different environments; S2, core execution of Python automation script, namely, completing merging of HEX files and format conversion from HEX to BIN files by calling two special scripts of hexamerge. Py and hexa2bin. Py; s3, memory anti-overflow protection, namely constructing a full-link memory anti-overflow protection system through a triple mechanism of address range hard constraint, overflow active detection and non-upgrading space initialization, and ensuring that a firmware file meets the Flash storage requirement of a single chip microcomputer; and S4, cleaning the redundant files and the environment variables, and ensuring the clean environment of the upper computer through the designed cleaning flow of the redundant files and the environment variables, so as to avoid redundant data interference.
  2. 2. The method for outputting the memory anti-overflow protection based on the 32-bit singlechip firmware upgrade of claim 1, wherein the step S1 specifically comprises the following steps: S101, defining rules of environment variables, defining the environment variables through batch processing commands and script configuration files in the Windows operating system environment, wherein the variable values need to explicitly point to absolute paths of the files, and folder names and file names in the paths need to be completely consistent with actual storage conditions, so that the problem that the scripts cannot identify the files due to name differences is avoided; S102, an environment variable verification mechanism automatically executes a verification process through a script to ensure that files corresponding to all variables meet the subsequent processing requirements, wherein the verification process comprises three steps, namely, a first step of path validity verification, a second step of file format verification, a third step of file integrity verification, a third step of calculating a checksum of the HEX file, and comparing the checksum with a checksum stored at the tail of the file, wherein the first step of path validity verification is to check whether a path pointed by the environment variable exists through a file existence detection command, the second step of file format verification is to read header information pointed by the environment variable to judge whether the file is in a standard HEX format, and the third step of file integrity verification is to calculate the checksum of the HEX file, and if the checksum and the checksum are inconsistent, the file is indicated to have data loss and damage in the transmission and storage processes; and S103, maintaining and adapting the environment variables, which are used for intensively defining the environment variables in independent configuration files to realize the separation of the variables and script logic.
  3. 3. The method for outputting the memory anti-overflow protection based on the 32-bit singlechip firmware upgrade of claim 1, wherein the step S2 specifically comprises the following steps: S201, HEX file merging processing is used for merging BootLoaderHEX files and APPHEX files into a complete HEX file, namely MERGER_HEX, according to the address allocation rule of a 32-bit singlechip Flash of a urine analyzer, and simultaneously ensuring that the two files are not overlapped in a Flash address space, so that firmware upgrading failure caused by data collision is avoided; And S202, HEX file conversion processing is used for respectively converting the combined MERGER_HEX file and the independent APP_HEX file into BIN files, namely MERGER_BIN and APP_BIN, removing redundant format characters, reducing file volume and adapting to the programming requirement of a 32-bit singlechip of a urine analyzer.
  4. 4. The method of claim 3, wherein in S201, log records of the merging process are further included, the log records are used for monitoring the merging progress and troubleshooting the problem by an operator, the script records detailed logs in real time during the merging process, and the log contents include execution time, current operation, related files, address range and execution results.
  5. 5. The method for outputting the memory anti-overflow protection based on the 32-bit singlechip firmware upgrade of claim 1, wherein the step S3 specifically comprises the following steps: S301, address range hard constraint, namely in the whole process of merging and converting HEX files, always taking the writable address range of a 32-bit singlechip Flash of a urine analyzer as the hard constraint, and strictly limiting all file processing operations in the range so as to avoid address overflow risks from the source; In the HEX file merging link, the merged MERGER_HEX file is forced to only reserve the data in the address range through the parameter of "-r"08000000:0807FFFF "", and any redundant data exceeding the address range is automatically removed by a script; S302, overflow active detection, namely actively identifying whether the MDK output file has a problem that the address exceeds the writable range of Flash through an overflow detection function built in a script, and checking hidden danger in advance before the file enters a merging and converting process; S303, initializing a non-upgrading space, and initializing data of the non-upgrading space in the single chip microcomputer Flash through a script before generating a BIN file, so as to remove residual old data, redundant codes and error information and avoid collision with new firmware; The specific flow of the initialization process is that when the script generates the MERGER_BIN file, the address range of the non-upgrading space can be automatically identified, and 0xFF is uniformly written into all addresses in the range, namely the default value after Flash erasure of the singlechip is used for covering the original residual data.
  6. 6. The method for outputting the memory anti-overflow protection based on the 32-bit singlechip firmware upgrade of claim 1, wherein the step S4 specifically comprises the following steps: S401, cleaning logic of redundant files, wherein the cleaning of the redundant files follows the principle of checking and deleting firstly, and before deleting the files, the script confirms that the subsequent flow corresponding to the target files is finished, the files are not reserved and necessary, and the files still needed to be used are avoided being deleted by mistake; And S402, cleaning logic of environment variables, wherein the cleaning purpose of the environment variables is to avoid conflict between the variables defined by the method and environment variables of other programs in the system, and simultaneously release system resources, the cleaning process is executed after the cleaning of the redundant files is completed, and the script clears the values of the environment variables through a command of 'set variable name=', so that the values of the environment variables do not occupy the system environment variable resources.

Description

Output method for memory anti-overflow protection based on 32-bit singlechip firmware upgrade Technical Field The invention relates to the field of anti-overflow protection of a single-chip microcomputer memory, in particular to an output method for the anti-overflow protection of a memory based on a 32-bit single-chip microcomputer firmware upgrade. Background In the field of medical equipment, a 32-bit singlechip is a core control unit of precision equipment such as a urine analyzer and the like by virtue of high-efficiency computing capability and stable control performance. The urine analyzer needs to realize the control of key functions such as sample detection, data processing, result output and the like through firmware, and firmware upgrading is an important means for optimizing performance, repairing loopholes and expanding functions in the life cycle of equipment. Currently, firmware upgrading of a 32-bit singlechip on the market is generally finished by a bootstrap (BootLoader), and the mode has certain reliability and compatibility, but in practical application, particularly aiming at medical equipment with extremely high requirements on stability and automation degree such as a urine analyzer, a plurality of problems which are difficult to avoid are exposed, the efficiency and the safety of firmware upgrading are seriously influenced, and additional cost and risk are brought to the production and the maintenance of the equipment. First, the development and maintenance thresholds of BootLoader program are extremely high. The development of BootLoader requires engineers to be skilled in mastering the initialization logic of the bottom hardware of the singlechip, the data transmission protocol (such as SPI, I2C, USART and the like) and the Flash storage control mechanism, so that a great deal of research and development time is consumed, and strict requirements are put forward on the professional level of technicians. More importantly, if the BootLoader program itself has defects (such as initialization logic errors and data verification holes), the singlechip cannot be started normally, so that the urine analyzer falls into a dead state, sample detection work cannot be completed, and the normal diagnosis and treatment flow of a medical institution is affected. In the traditional firmware upgrading process, the operation of combining codes by relying on J-FLASH software is completely finished manually, and the degree of automation is extremely low. Operators need to manually select a BootLoader file and a main application program (APP) file, set merging parameters and output paths, and any step of manual misoperation (such as wrong file path selection and wrong address range setting) in the whole process can cause the problems of data deletion, address confusion and the like of the output firmware file. The problem files are used for upgrading the firmware of the urine analyzer, if the problem files are light, the upgrading is failed, if the problem files are heavy, the original control program of the equipment is destroyed, the function of the equipment is abnormal, and the after-sale maintenance cost is increased. Therefore, it is necessary to provide an output method for memory anti-overflow protection based on the firmware upgrade of the 32-bit singlechip to solve the above problems. Disclosure of Invention The invention mainly aims to provide an output method for memory overflow protection based on 32-bit singlechip firmware upgrade, which can effectively solve the problems in the background technology. In order to achieve the above purpose, the technical scheme adopted by the invention is as follows: The output method for the memory overflow protection based on the 32-bit singlechip firmware upgrade comprises the following operation steps: s1, configuring and managing environment variables, replacing a hard coding path in a traditional script through unified variable definition, avoiding script reconstruction caused by path modification, and simultaneously facilitating parameter adaptation in different environments; S2, core execution of Python automation script, namely, completing merging of HEX files and format conversion from HEX to BIN files by calling two special scripts of hexamerge. Py and hexa2bin. Py; s3, memory anti-overflow protection, namely constructing a full-link memory anti-overflow protection system through a triple mechanism of address range hard constraint, overflow active detection and non-upgrading space initialization, and ensuring that a firmware file meets the Flash storage requirement of a single chip microcomputer; and S4, cleaning the redundant files and the environment variables, and ensuring the clean environment of the upper computer through the designed cleaning flow of the redundant files and the environment variables, so as to avoid redundant data interference. Preferably, in S1, the method specifically includes the following steps: S101, defining rules of en