CN107894899B - ROM program upgrading system and upgrading method - Google Patents
ROM program upgrading system and upgrading method Download PDFInfo
- Publication number
- CN107894899B CN107894899B CN201711277903.4A CN201711277903A CN107894899B CN 107894899 B CN107894899 B CN 107894899B CN 201711277903 A CN201711277903 A CN 201711277903A CN 107894899 B CN107894899 B CN 107894899B
- Authority
- CN
- China
- Prior art keywords
- rom
- function
- main control
- control chip
- flash
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
- G06F8/66—Updates of program code stored in read-only memory [ROM]
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a ROM program upgrading system and method, comprising: the device comprises an upper computer, a communication conversion module, a main control chip and an external Flash; an RS232 interface of the upper computer is connected with a communication conversion module, the communication conversion module is connected with a UART interface of a main control chip, an SPI interface of the main control chip is connected with an external Flash, and the external Flash is used for writing in a packaged upgrade file; the main control chip comprises an RAM, an internal Flash and an ROM, the ROM comprises function pointer arrays, each function pointer array corresponds to different ROM function execution addresses, and the ROM function execution addresses are loaded into the RAM when the system runs; the invention simultaneously supports the jump from the ROM space to the internal Flash code space and the return to the ROM space after the operation of any legal address is finished, and can solve the problems of the existing Flash bad block and program integrity.
Description
Technical Field
The invention relates to the technical field of ROM program upgrading, in particular to a ROM program upgrading system and method.
Background
The conventional ROM program is solidified in the chip ROM memory during the chip production manufacturing process, and its main function is to download the application program into the internal Flash code space through an available serial peripheral (UART, CAN, USB, I2C, etc.).
Chinese patent publication No. CN102243587A discloses a method for upgrading a ROM program in an embedded system, where the system needs to create an independent program upgrading area in Flash to store an upgrading program package, and when software needs to be upgraded, the system creates the upgrading program package and writes the upgrading program package into the program upgrading area in Flash. And the upgrading calling program module detects whether an upgrading program package exists in the Flash, and if the upgrading program package is not found, the original program in the ROM software is executed. The scheme utilizes a fixed Flash upgrading area to upgrade the ROM program, and because Flash erasing and writing have service life, frequent erasing and writing of the same Flash area can cause bad blocks, and the reliability of ROM upgrading is reduced; at the same time, this solution does not verify the integrity of the replacement program, i.e. the correctness of the data.
Disclosure of Invention
Aiming at the defects existing in the problems, the invention provides a ROM program upgrading system and a ROM program upgrading method.
To achieve the above object, the present invention provides a ROM program upgrading system, comprising: the device comprises an upper computer, a communication conversion module for converting RS232 to UART, a main control chip and external Flash;
an RS232 interface of the upper computer is connected with a communication conversion module, the communication conversion module is connected with a UART interface of a main control chip, an SPI interface of the main control chip is connected with an external Flash, and the external Flash is used for writing in a packaged upgrade file;
the main control chip comprises an RAM, an internal Flash and an ROM, the ROM comprises function pointer arrays, each function pointer array corresponds to different ROM function execution addresses, and the ROM function execution addresses are loaded into the RAM when the system runs.
As a further improvement of the invention, the main control chip is an MCU.
As a further improvement of the invention, the external Flash is SPI Flash.
The invention also provides an upgrading method of the ROM program upgrading system, which comprises the following steps:
step 1, writing the packaged upgrade file into an external Flash;
step 2, the upper computer sends an instruction for updating the ROM program to the main control chip, the main control chip reads a data head of an external Flash specified address to the RAM after receiving the instruction, and the correctness of the data head is verified according to the verification information contained in the data head;
step 3, after the data head passes the verification, analyzing the data in the data head, reading and writing the codes in the external Flash into the internal Flash address space appointed by the data head, and verifying the correctness of the code data according to the code checksum contained in the data head;
step 4, after the code verification is passed, judging whether the instruction issued by the upper computer in the step 2 is a function replacement instruction or a new function instruction;
step 5, if the command is a function replacement command, analyzing function replacement related data provided in the external Flash, and replacing a corresponding execution address of a function pointer array in the RAM; when executing the corresponding function, jumping to an internal Flash space for execution, and returning to a ROM space after the execution is finished;
if the new function instruction is added, analyzing the execution entry address of the newly added function according to the information in the data header, and calling the new function.
As a further improvement of the invention, the method also comprises the following steps between the step 1 and the step 2:
after the system is powered on, the main control chip initializes a UART interface of the communication conversion module, communicates with an upper computer through the communication conversion module, and initializes an SPI interface of external Flash; the upper computer completes data communication with the UART interface of the main control chip through the communication conversion module.
As a further improvement of the present invention, in step 5, the function replacement related data includes the total number of replacement functions, the index of the function pointer array corresponding to the new function, and the new function execution address.
Compared with the prior art, the invention has the beneficial effects that:
the invention enhances the flexibility of the ROM software, firstly, the predefined ROM function is directly operated, secondly, if the existing function in the ROM is found to be incapable of meeting the requirement, the function replacement can be realized, thirdly, the ROM upgrade can be carried out only aiming at partial functions needing to be modified, the replacement of the whole ROM function table is not needed, fourthly, the data verification and the integrity verification are carried out when the ROM program function is replaced, and the ROM upgrade can be carried out only when the verification is passed.
Drawings
Fig. 1 is a block diagram of a ROM program upgrade system according to an embodiment of the present invention.
In the figure:
10. an upper computer; 20. a communication conversion module; 30. a main control chip; 31. a RAM; 32. internal Flash; 33. a ROM; 40. and (4) external Flash.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the present invention, it should also be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
The invention is described in further detail below with reference to the attached drawing figures:
in order to solve the problems of bad blocks and program integrity of the existing Flash, the invention provides a ROM program upgrading system and method with strong reliability, and simultaneously supports the jump from a ROM space to an internal Flash code space and the return to the ROM space after the operation of any legal address is finished.
As shown in fig. 1, the present invention provides a ROM program upgrade system, comprising: the device comprises an upper computer 10, a communication conversion module 20 for converting RS232 to UART, a main control chip 30 and an external Flash 40; wherein: the main control chip 30 is MCU, and the external Flash40 is SPI Flash.
The RS232 interface of the host computer 10 is connected with the communication conversion module 20, the communication conversion module 20 is connected with the UART interface of the main control chip 30, the SPI interface of the main control chip 30 is connected with the external Flash40, and the external Flash40 is used for writing in the packaged upgrade files.
The main control chip 30 includes a RAM 31, an internal Flash 32 and a ROM 33, the ROM 33 program includes a function pointer array, each function pointer array corresponds to different ROM function execution addresses, the ROM function execution addresses are loaded into the RAM when the system runs, and only the function execution addresses of corresponding items in the RAM need to be replaced when the function replacement is performed.
The invention provides an upgrading method based on a ROM program upgrading system, which comprises the following steps:
step 1, when the ROM program needs to be upgraded, writing the packaged upgrade file into an external Flash; after the system is powered on, the main control chip initializes a UART interface of the communication conversion module, communicates with an upper computer through the communication conversion module, and initializes an SPI interface of external Flash; the upper computer completes data communication with the UART interface of the main control chip through the communication conversion module.
Step 2, the upper computer sends an instruction for updating the ROM program to the main control chip, and the instruction is a function replacing instruction or a new function instruction; the main control chip reads a data head of an external Flash specified address into the RAM after receiving the instruction, and verifies the correctness of the data head according to the verification information contained in the data head;
step 3, after the data head passes the verification, analyzing the data in the data head, reading and writing the codes in the external Flash into the internal Flash address space appointed by the data head; after the data is written into the internal Flash from the external Flash, verifying the correctness of the code data according to the code checksum contained in the data head;
step 4, after the code verification is passed, judging whether the instruction issued by the upper computer in the step 2 is a function replacement instruction or a new function instruction;
step 5, if the command is a function replacement command, analyzing function replacement related data provided in the external Flash, wherein the function replacement related data comprises the total number of replacement functions, indexes of function pointer arrays corresponding to the new functions and new function execution addresses; replacing the corresponding execution address of the function pointer array in the RAM; therefore, when the corresponding function is executed, the internal Flash space is jumped to execute, and the ROM space is returned after the execution is finished.
If the new function is added, the execution entry address of the newly added function is analyzed according to the information in the data header, and the new function is called.
The invention calls and replaces the function pointer array stored in the ROM program, the storage address of the replacement function can be appointed by the data head information, and the internal Flash space of the fixed address can not be erased and written, thereby achieving load balance.
The invention enhances the flexibility of the ROM software, firstly, the predefined ROM function is directly operated, secondly, if the existing function in the ROM is found to be incapable of meeting the requirement, the function replacement can be realized, thirdly, the ROM upgrade can be carried out only aiming at partial functions needing to be modified, the replacement of the whole ROM function table is not needed, fourthly, the data verification and the integrity verification are carried out when the ROM program function is replaced, and the ROM upgrade can be carried out only when the verification is passed.
The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes will occur to those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (5)
1. An upgrading method of a ROM program upgrading system, the ROM program upgrading system comprising: the device comprises an upper computer, a communication conversion module for converting RS232 to UART, a main control chip and external Flash; an RS232 interface of the upper computer is connected with a communication conversion module, the communication conversion module is connected with a UART interface of a main control chip, an SPI interface of the main control chip is connected with an external Flash, and the external Flash is used for writing in a packaged upgrade file; the main control chip comprises an RAM, an internal Flash and an ROM, the ROM comprises function pointer arrays, each function pointer array corresponds to different ROM function execution addresses, and the ROM function execution addresses are loaded into the RAM when the system runs;
the upgrading method comprises the following steps:
step 1, writing the packaged upgrade file into an external Flash;
step 2, the upper computer sends an instruction for updating the ROM program to the main control chip, the main control chip reads a data head of an external Flash specified address to the RAM after receiving the instruction, and the correctness of the data head is verified according to the verification information contained in the data head;
step 3, after the data head passes the verification, analyzing the data in the data head, reading and writing the codes in the external Flash into the internal Flash address space appointed by the data head, and verifying the correctness of the code data according to the code checksum contained in the data head;
step 4, after the code verification is passed, judging whether the instruction issued by the upper computer in the step 2 is a function replacement instruction or a new function instruction;
step 5, if the command is a function replacement command, analyzing function replacement related data provided in the external Flash, and replacing a corresponding execution address of a function pointer array in the RAM; when executing the corresponding function, jumping to an internal Flash space for execution, and returning to a ROM space after the execution is finished;
if the new function instruction is added, analyzing the execution entry address of the newly added function according to the information in the data header, and calling the new function.
2. The upgrade method according to claim 1, wherein the main control chip is an MCU.
3. The upgrade method according to claim 1, wherein the external Flash is an SPI Flash.
4. The upgrading method according to claim 1, further comprising, between step 1 and step 2:
after the system is powered on, the main control chip initializes a UART interface of the communication conversion module, communicates with an upper computer through the communication conversion module, and initializes an SPI interface of external Flash; the upper computer completes data communication with the UART interface of the main control chip through the communication conversion module.
5. The upgrading method according to claim 1, wherein in step 5, the function replacement related data includes a total number of replacement functions, an index of a function pointer array corresponding to the new function, and a new function execution address.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711277903.4A CN107894899B (en) | 2017-12-06 | 2017-12-06 | ROM program upgrading system and upgrading method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711277903.4A CN107894899B (en) | 2017-12-06 | 2017-12-06 | ROM program upgrading system and upgrading method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107894899A CN107894899A (en) | 2018-04-10 |
CN107894899B true CN107894899B (en) | 2021-04-06 |
Family
ID=61806140
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711277903.4A Active CN107894899B (en) | 2017-12-06 | 2017-12-06 | ROM program upgrading system and upgrading method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107894899B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109933358B (en) * | 2019-01-28 | 2022-06-24 | 金卡智能集团股份有限公司 | Control method for reducing program upgrading amount of metering equipment |
CN110308953A (en) * | 2019-04-01 | 2019-10-08 | 深圳市德名利电子有限公司 | ROM code function amending method based on 32 MCU master controls |
CN112463230B (en) * | 2020-11-23 | 2023-08-25 | 浙江地芯引力科技有限公司 | Program running method and device, electronic equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102243587A (en) * | 2010-05-14 | 2011-11-16 | 康佳集团股份有限公司 | Method for upgrading read only memory (ROM) program in embedded system |
CN102945174A (en) * | 2012-11-08 | 2013-02-27 | 大连捷成实业发展有限公司 | Method for upgrading singlechip program by means of connected off-chip Flash |
EP2778910A1 (en) * | 2013-03-15 | 2014-09-17 | Maxim Integrated Products, Inc. | Systems and methods to extend rom functionality |
CN104090796A (en) * | 2014-07-08 | 2014-10-08 | 成都万维图新信息技术有限公司 | Embedded device program updating method and system |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW200719142A (en) * | 2005-11-08 | 2007-05-16 | Mstar Semiconductor Inc | Content correction method of an ROM build-in program code |
EP2881858B1 (en) * | 2013-12-09 | 2016-04-06 | dSPACE digital signal processing and control engineering GmbH | Method for modifying the software in the memory of an electronic control device |
-
2017
- 2017-12-06 CN CN201711277903.4A patent/CN107894899B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102243587A (en) * | 2010-05-14 | 2011-11-16 | 康佳集团股份有限公司 | Method for upgrading read only memory (ROM) program in embedded system |
CN102945174A (en) * | 2012-11-08 | 2013-02-27 | 大连捷成实业发展有限公司 | Method for upgrading singlechip program by means of connected off-chip Flash |
EP2778910A1 (en) * | 2013-03-15 | 2014-09-17 | Maxim Integrated Products, Inc. | Systems and methods to extend rom functionality |
CN104090796A (en) * | 2014-07-08 | 2014-10-08 | 成都万维图新信息技术有限公司 | Embedded device program updating method and system |
Also Published As
Publication number | Publication date |
---|---|
CN107894899A (en) | 2018-04-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107894899B (en) | ROM program upgrading system and upgrading method | |
US8086919B2 (en) | Controller having flash memory testing functions, and storage system and testing method thereof | |
CN109189405B (en) | Method and system for verifying Flash data consistency of program | |
CN101853692B (en) | Controller with flash memory test function, and storage system and test method thereof | |
CN111240720A (en) | Boot program upgrading method and device and storage medium | |
CN102163155A (en) | Upgrade controlling device and method for upgrading memory device | |
KR20150096782A (en) | Virtual boundary codes in a data image of a read-write memory device | |
CN103605540A (en) | Flash mirror fast writing method based on Android system | |
US20130067455A1 (en) | Memory online update system and method | |
CN110851163B (en) | Software updating method compatible with multi-equipment platform based on CAN communication | |
CN102736932B (en) | The method for making of image file, image file and the starting factor method of multisystem | |
CN108182078B (en) | Optimized missile-borne device non-dismantling software online upgrading method | |
CN102279763A (en) | Method for optimizing boot read-only memory (BOOTROM) | |
CN109445691A (en) | A kind of method and device improving FTL algorithm development and verification efficiency | |
CN100549971C (en) | A kind of method and device that reads the CPU code | |
CN109725941A (en) | A kind of programmable initial method and system for display driver chip | |
CN115220758A (en) | Method for upgrading firmware of single chip microcomputer on line | |
CN103019969A (en) | Flash memory storage device and determination method of bad storage area thereof | |
CN107704338A (en) | A kind of data reconstruction method and device of data storage type flash | |
CN111857785B (en) | MCU starting method and device and terminal equipment | |
US9817573B2 (en) | Smart card management method, memory storage device and memory control circuit unit | |
JP6194714B2 (en) | Universal IC card and security attribute verification method | |
CN107885523B (en) | Rapid and stable serial port software upgrading method | |
CN101221519A (en) | Read-write debugging method for flash memory device in processor system | |
CN114356365A (en) | Remote updating method based on PSoC chip |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |