Firmware online upgrading method for anti-radiation single chip microcomputer based on RISC-V core
By using RISC-V cores and multiple storage media in radiation-resistant microcontrollers, the bootloader program and multiple storage media fusion methods are designed to solve the problem that traditional microcontrollers are difficult to achieve online firmware upgrades in harsh environments, firmware backup and online upgrades are realized, and firmware reliability is improved.
Patent Information
- Application Number
- CN202411891183.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-04
AI Technical Summary
Traditional microcontrollers are difficult to achieve online firmware upgrades in harsh environments, and the data power-down storage and anti-irradiation design has defects, which cannot meet the online upgrade function.
Using a RISC-V core-based radiation-resistant microcontroller, three storage media are used: two irradiation-resistant QSPI interface FLASH and one MRAM, the bootloader program and multiple storage media fusion methods are designed to realize firmware backup and online copy functions.
It realizes the backup and online upgrade of firmware in a single-particle environment, reducing the data damage to the microcontroller's logical code operation in the irradiation environment, thereby improving the reliability of the firmware.
Smart Images

Figure CN119759376A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of single-chip microcomputers, and in particular to an online firmware upgrade method for a radiation-resistant single-chip microcomputer based on a RISC-V core. Background Art
[0002] With the widespread application of electronic equipment in aerospace, nuclear power and other fields, higher requirements are placed on the radiation resistance of equipment. As an open, royalty-free instruction set architecture, RISC-V architecture has good scalability and customizability, and is gaining more and more attention in the design of radiation-resistant microcontrollers.
[0003] The reliability of MCU firmware is mainly reflected in two aspects: first, the integrity of the running firmware is guaranteed, so firmware backup is required; second, the maintainability of the firmware, so the firmware needs to be upgraded online. Online upgrade is an important means to improve the reliability and adaptability of equipment.
[0004] The traditional firmware upgrade method usually requires the device to be offline and the firmware to be burned through the physical interface. This method is not only inefficient, but also difficult to implement in harsh environments. Therefore, it is urgent to develop a firmware online upgrade method for radiation-resistant microcontrollers based on RISC-V cores while being able to maintain firmware backup; at the same time, the traditional microcontroller has certain defects in the radiation-resistant design of data power-off storage, and cannot meet the online upgrade function. Summary of the invention
[0005] The purpose of the present invention is to provide a firmware online upgrade method for a radiation-resistant single-chip microcomputer based on a RISC-V core to solve the problems in the background technology.
[0006] In order to solve the above technical problems, the present invention provides a method for online firmware upgrade of a radiation-resistant single-chip microcomputer based on a RISC-V core. The method adopts three storage media, including two radiation-resistant QSPI interface FLASH and one MRAM; one FLASH is used to store bootloader program code, called K_FLASH_BOOT; the other FLASH is used to store backup program code, called K_FLASH_BACKUP; and K_FLASH_BACKUP is divided into two storage parts, K_FLASH_BACKUP_A for backup firmware storage area and K_FLASH_BACKUP_B for firmware backup and online upgrade flag recording area;
[0007] The method comprises the following steps:
[0008] Step 1: The bootloader program code starts running. First, read the K_FLASH_BACKUP_B area to determine whether it is in the firmware backup state. If so, read the K_FLASH_BACKUP_A area. If the firmware code does not exist or fails the verification, continue to read the firmware code on the MRAM. If the code does not exist or fails the verification, the MCU continues to run in the bootloader state of K_FLASH_BOOT and waits for the firmware update.
[0009] Step 2: The bootloader program code starts running, first reads the K_FLASH_BACKUP_B area to determine whether it is in the firmware backup state; if so, reads the K_FLASH_BACKUP_A area; if the firmware code exists and passes the verification, continue to read the firmware code on the MRAM; if the firmware code on the MRAM exists and passes the verification, the program verification passes, and the program startup address jumps to the MRAM startup address;
[0010] Step 3: The bootloader program code starts running, first reads the K_FLASH_BACKUP_B area to determine whether it is in the firmware backup state. If so, reads the K_FLASH_BACKUP_A area; if the firmware code exists and passes the verification, continue to read the firmware code on the MRAM; if the firmware code on the MRAM does not exist or fails the verification, copy the firmware code stored in K_FLASH_BACKUP to the MRAM; after the copy is completed, if the verification program fails, repeat step 2; if the program verification passes, jump to the program startup address and jump to the MRAM startup address;
[0011] Step 4: To achieve the remote online upgrade function, the negotiation upgrade instruction code is embedded in the firmware; when the firmware runs on the MRAM, after the MCU receives the remote online upgrade instruction and passes the verification, it writes the online upgrade instruction flag data in the K_FLASH_BACKUP_B area, and then jumps to the program startup address to K_FLASH_BOOT;
[0012] Step 5. After the program determines the upgrade instruction, it writes the remote upgrade firmware code into K_FLASH_BACKUP_A. After the firmware code is written, the data is verified to be correct, and the K_FLASH_BACKUP_B area is changed to the firmware backup mark; perform a soft reset or jump to step 1.
[0013] In one embodiment, the method uses a built-in MRAM type single chip microcomputer, which is a non-volatile magnetic random access memory that uses the magnetoresistance effect to store data.
[0014] In one embodiment, the method is based on RISC-V open source, designs two program startup addresses, uses 32-bit addressing space, and is set to 0xA0000000 and 0x20000000 respectively; 0xA0000000 is designed to correspond to the MRAM storage medium program startup address, and 0x20000000 corresponds to the K_FLASH_BOOT storage program code startup address, and the startup address is enabled by external hardware, or the startup address is switched by program code logic.
[0015] In one implementation, in the method, K_FLASH_BOOT and K_FLASH_BACKUP are connected to the single-chip microcomputer by hardware through a QSP interface, and when the single-chip microcomputer system is powered on, the startup address is enabled by external hardware to be 0x20000000, that is, starting from K_FLASH_BOOT.
[0016] In one embodiment, the method designs the K_FLASH_BOOT storage area to be a read-only area after the bootloader code is burned. After one-time burning using SPI, serial port or other burning tools, K_FLASH_BOOT is set to a write-protected read-only state.
[0017] The present invention provides a method for online firmware upgrade of a radiation-resistant single-chip microcomputer based on a RISC-V core, which has the following beneficial effects:
[0018] (1) The use of MRAM (non-volatile magnetic random access memory) integrated inside the microcontroller can prevent data damage caused by radiation to a greater extent;
[0019] (2) Design the microcontroller with QSPI (six-wire serial peripheral interface) and use external radiation-resistant FLASH (flash memory) devices in conjunction with internal MRAM to implement the bootloader function;
[0020] (3) Design the MCU to have a program startup address jump function after the device is powered on, so that the MCU working state can jump from the startup program area to the application execution area;
[0021] (4) Design a method to integrate multiple storage media to realize the functions of firmware backup and online firmware copy. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flowchart of a firmware online upgrade method for a radiation-resistant single-chip microcomputer based on a RISC-V core provided by the present invention. DETAILED DESCRIPTION
[0023] The following is a further detailed description of the firmware online upgrade method of a radiation-resistant microcontroller based on a RISC-V core proposed by the present invention in combination with the accompanying drawings and specific embodiments. According to the following description, the advantages and features of the present invention will become clearer. It should be noted that the accompanying drawings are all in a very simplified form and are not in precise proportions, which are only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention.
[0024] It can be found that the single-particle experimental environment verifies that the single-chip microcomputer operation logic function is overturned by a single particle mostly when writing to the storage medium. The ECC function can be used to ensure the data read from the storage medium. In order to reduce the irreversible risk caused by writing to the storage medium, three storage media are used in the firmware online upgrade method of the present invention, including two radiation-resistant QSPI (six-wire serial peripheral interface) interface type FLASH (flash memory) and one MRAM (non-volatile magnetic random access memory).
[0025] In the present invention, two radiation-resistant QSPI interface FLASH are distinguished. One is used to store bootloader (boot loading) code, which is referred to as K_FLASH_BOOT for the convenience of later description. The other is used as a backup program code storage, which is referred to as K_FLASH_BACKUP for the convenience of later description. The present invention adopts a built-in MRAM type single-chip microcomputer. MRAM is a non-volatile magnetic random access memory that uses magnetoresistance effect to store data. It is mainly made of metal materials and has much stronger radiation resistance than semiconductor materials. Therefore, running normal firmware logic code on MRAM is the most suitable choice. Thanks to RISC-V open source, two program startup addresses are designed in the method, using 32-bit addressing space, which are set to 0xA0000000 and 0x20000000 respectively. 0xA0000000 is designed to correspond to the MRAM storage medium program startup address, and 0x20000000 corresponds to the K_FLASH_BOOT storage program code startup address. The startup address can be enabled by external hardware, or the startup address can be switched by program code logic.
[0026] To ensure the reliability of the firmware, the K_FLASH_BOOT storage area is designed in the method to be a read-only area after the bootloader code is burned. After a one-time burning using SPI, serial port or other burning tools, K_FLASH_BOOT is set to a write-protected read-only state. K_FLASH_BACKUP is divided into two storage parts, one part is the backup firmware storage area, called K_FLASH_BACKUP_A; the other part is the firmware backup and online upgrade flag recording area, called K_FLASH_BACKUP_B. In the method, K_FLASH_BOOT and K_FLASH_BACKUP are connected to the microcontroller through the QSP interface. When the microcontroller system is powered on, the startup address is enabled by external hardware to 0x20000000, that is, starting from K_FLASH_BOOT. Figure 1 There are three storage areas, and the firmware reliability assurance flow chart is as follows:
[0027] 1. The Bootloader program starts running. It reads the K_FLASH_BACKUP_B area through the QSPI interface to determine whether it is in the firmware backup state. If so, it reads the K_FLASH_BACKUP_A area. If the firmware code does not exist or fails the verification, it continues to read the firmware code on the MRAM. If the code does not exist or fails the verification, the MCU continues to run in the Bootloader state of K_FLASH_BOOT, waiting for the firmware update;
[0028] 2. The Bootloader program starts running. It reads the K_FLASH_BACKUP_B area through the QSPI interface to determine whether it is in the firmware backup state. If so, it reads the K_FLASH_BACKUP_A area. If the firmware code exists and passes the verification, it continues to read the firmware code on the MRAM. If the firmware code on the MRAM exists and passes the verification, the program startup address jumps to the MRAM startup address if the program verification passes. The jump code is as follows:
[0029] Typedefvoid(*pFunction)(void);
[0030] Void CallMainPrg(void)
[0031] {
[0032] pFunction Jump_ToApplication;
[0033] unsigned long JumpAddress;
[0034] disable_all_interrupt();
[0035] JumpAddress=*(unsigned long*)(0xa0000000);
[0036] Jump_ToApplication=(pFunction)JumpAddress;
[0037] Jump_ToApplication();
[0038] }
[0039] 3. The Bootloader program starts running, and reads the K_FLASH_BACKUP_B area through the QSPI interface to determine whether it is in the firmware backup state. If so, read the K_FLASH_BACKUP_A area. If the firmware code exists and passes the verification, continue to read the firmware code on the MRAM. If the firmware code on the MRAM does not exist or fails the verification, copy the firmware code stored in K_FLASH_BACKUP to the MRAM. After the copy is completed, if the verification program fails, repeat process 2. If the program verification passes, jump to the program startup address and jump to the MRAM startup address;
[0040] 4. In order to achieve the remote online upgrade function, the method is designed to embed the negotiation upgrade instruction code in the firmware. When the firmware runs on MRAM, after the MCU receives the remote online upgrade instruction, after verification, it writes the online upgrade instruction flag data in the K_FLASH_BACKUP_B area, and then jumps to the program startup address to K_FLASH_BOOT.
[0041] 5. After the program determines the upgrade instruction, it writes the remote upgrade firmware code to K_FLASH_BACKUP_A. After the firmware code is written, the data is verified to be correct, and the K_FLASH_BACKUP_B area is changed to the firmware backup mark. Perform a soft reset or jump to process 1.
[0042] Through the above method and process, the firmware backup and online upgrade functions in a single-particle environment can be effectively realized, reducing the data damage caused by the radiation environment to the operation of the microcontroller logic code, thereby improving the firmware reliability.
[0043] The above description is only a description of the preferred embodiments of the present invention, and is not intended to limit the scope of the present invention. Any changes or modifications made by a person skilled in the art in the field of the present invention based on the above disclosure shall fall within the scope of protection of the claims.
Claims
1. A method for online firmware upgrade of a radiation-resistant single-chip microcomputer based on a RISC-V core, characterized in that: The method adopts three storage media, including two radiation-resistant QSPI interface FLASH and one MRAM; one FLASH is used to store bootloader program code, called K_FLASH_BOOT; the other FLASH is used to store backup program code, called K_FLASH_BACKUP; and K_FLASH_BACKUP is divided into two storage parts, K_FLASH_BACKUP_A for backup firmware storage area and K_FLASH_BACKUP_B for firmware backup and online upgrade mark recording area; The method comprises the following steps: Step 1: The bootloader program code starts running. First, read the K_FLASH_BACKUP_B area to determine whether it is in the firmware backup state. If so, read the K_FLASH_BACKUP_A area. If the firmware code does not exist or fails the verification, continue to read the firmware code on the MRAM. If the code does not exist or fails the verification, the MCU continues to run in the bootloader state of K_FLASH_BOOT and waits for the firmware update. Step 2: The bootloader program code starts running, first reads the K_FLASH_BACKUP_B area to determine whether it is in the firmware backup state; if so, reads the K_FLASH_BACKUP_A area; if the firmware code exists and passes the verification, continue to read the firmware code on the MRAM; If the firmware code on the MRAM exists and passes the verification, the program verification passes, and the program startup address jumps to the MRAM startup address; Step 3: The bootloader program code starts running, first reads the K_FLASH_BACKUP_B area to determine whether it is in the firmware backup state. If so, reads the K_FLASH_BACKUP_A area; if the firmware code exists and passes the verification, continue to read the firmware code on the MRAM; if the firmware code on the MRAM does not exist or fails the verification, copy the firmware code stored in K_FLASH_BACKUP to the MRAM; After the copy is completed, if the program verification fails, repeat step 2; if the program verification passes, jump to the program startup address and jump to the MRAM startup address; Step 4: To achieve the remote online upgrade function, embed the negotiation upgrade instruction code in the firmware; When the firmware runs on MRAM, after the MCU receives the remote online upgrade command and passes the verification, it writes the online upgrade command flag data in the K_FLASH_BACKUP_B area, and then jumps to the program startup address to K_FLASH_BOOT; Step 5: After the program determines the upgrade instruction, it writes the remote upgrade firmware code into K_FLASH_BACKUP_A. After the firmware code is written, the data is verified to be correct, and the K_FLASH_BACKUP_B area is changed to the firmware backup mark; Perform a soft reset or skip to step 1.
2. The method for online firmware upgrade of a radiation-resistant single-chip microcomputer based on a RISC-V core as claimed in claim 1, characterized in that: The method adopts a built-in MRAM type single chip computer, which is a non-volatile magnetic random access memory and uses the magnetoresistance effect to store data.
3. The firmware online upgrade method of the radiation-resistant single-chip microcomputer based on the RISC-V core as claimed in claim 1, characterized in that: The method is based on RISC-V open source, designs two program startup addresses, uses 32-bit addressing space, and is set to 0xA0000000 and 0x20000000 respectively; 0xA0000000 is designed to correspond to the MRAM storage medium program startup address, and 0x20000000 corresponds to the K_FLASH_BOOT storage program code startup address, and the startup address is enabled by external hardware, or the startup address is switched by program code logic.
4. The firmware online upgrade method of the radiation-resistant single-chip microcomputer based on the RISC-V core as claimed in claim 3 is characterized in that: In the method, K_FLASH_BOOT and K_FLASH_BACKUP are connected to the single-chip microcomputer by hardware through the QSP interface. When the single-chip microcomputer system is powered on, the startup address is enabled by external hardware to be 0x20000000, that is, starting from K_FLASH_BOOT.
5. The firmware online upgrade method of the radiation-resistant single-chip microcomputer based on the RISC-V core as claimed in claim 1, characterized in that: In the method, the K_FLASH_BOOT storage area is designed to be a read-only area after the bootloader code is burned. After one-time burning using SPI, serial port or other burning tools, K_FLASH_BOOT is set to a write-protected read-only state.
Citation Information
Patent Citations
Method and system for mounting file and running mirror firmware in external QSPI Flash
CN117251408A
Memory firmware online upgrading method and device
CN118349265A
Remote upgrading method and system of Internet of Things terminal
CN118540220A
Program backup and upgrade method of multi-level embedded industrial control system
CN119149292A