Main and standby mirror image starting system and method based on eMMC (Embedded Multi Media Card) memory
By setting the main and backup boot images and the boot count memory in the eMMC memory, the checksum switching of the boot image is realized, which solves the reliability problem of boot image startup in the existing technology and ensures that the system can correctly start the backup image when it fails.
Patent Information
- Application Number
- CN202410738494.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-10-01
AI Technical Summary
The existing boot image startup method based on eMMC memory cannot verify the correctness and integrity of the image, and there is no backup image switching mechanism after the boot image fails to start, resulting in low reliability.
Use the primary and secondary images of eMMC memory to start the system, store the primary and secondary boot images in the first boot partition and the second boot partition respectively, and use the boot count memory to determine the boot mode, and perform switching after the checksum of the boot image fails. Combined with The reset circuit ensures that the system restarts if boot fails.
It realizes the verification of the correctness and integrity of the boot image, ensures the reliable startup of the boot image, and switches to the backup image when it fails, improving the reliability of the system.
Smart Images

Figure CN118733353A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of embedded technology, and in particular to a master-slave mirror startup system and method based on an eMMC memory. Background Art
[0002] eMMC is the abbreviation of Embedded MultiMediaCard, which is an embedded multimedia card. It is a standard for flash memory cards, which defines the physical architecture, access interface and protocol of storage systems based on embedded multimedia cards. eMMC has the advantages of small size, low power consumption and large capacity, and is suitable for use as a storage medium for embedded devices and consumer electronic devices. The eMMC memory includes three hardware partitions, namely the first boot partition (boot0), the second boot partition (boot1) and the user partition. Among them, the user partition has a larger capacity and is usually used for the storage of user and system files, while the boot0 and boot1 partitions have smaller capacities and are usually used for the storage of boot images.
[0003] Currently, combined with Figure 1 and Figure 2 As shown, based on the eMMC memory, the prior art usually uses the following method to start the boot image: after selecting to start from the eMMC memory, the SoC chip initializes the eMMC memory, and further reads the boot image from the boot0 partition for startup. However, this startup method has the following disadvantages: it is impossible to verify the boot image to determine whether it is correct and complete. At the same time, after the boot image in the boot0 partition fails to start, there is no backup boot image to use for restarting, and the reliability is low.
[0004] The information disclosed in this background technology section is only intended to enhance the understanding of the overall background of the invention and should not be regarded as an acknowledgment or any form of suggestion that the information constitutes the prior art already known to a person skilled in the art. Summary of the invention
[0005] The object of the present invention is to provide a primary and backup image startup system based on eMMC memory, which can at least verify the boot image to verify its correctness and integrity, ensure the correct startup of the boot image, and can switch between the primary and backup boot images after the boot image startup fails, so as to ensure the reliability of the boot image startup.
[0006] The present invention also aims to provide a primary and backup image startup method based on eMMC memory, which can at least verify the boot image to verify its correctness and integrity, ensure the correct startup of the boot image, and can switch between the primary and backup boot images after the boot image startup fails to ensure the reliability of the boot image startup.
[0007] To achieve the above object, an embodiment of the present invention provides a primary-backup mirror boot system based on an eMMC memory, comprising:
[0008] The eMMC memory includes a first boot partition and a second boot partition, wherein the first boot partition is configured to store a primary boot image, and the second boot partition is configured to store a backup boot image;
[0009] A startup count memory configured to store a value for identifying a startup mode;
[0010] A processor is connected to the eMMC memory and the boot count memory, and is configured to perform the following steps:
[0011] Step 1: Initialize the eMMC memory and determine whether to boot from the boot partition based on the value of the boot count memory;
[0012] Step 2, in response to starting from the boot partition, reading the boot image of the corresponding partition;
[0013] Step 3, verify the boot image, and if the verification fails, add 1 to the value in the boot count memory and execute step 1, and if the verification succeeds, execute step 4;
[0014] Step 4: start the timer and execute the boot image, and when the boot fails, at least reset the processor and add one to the value in the boot count memory and execute step 1.
[0015] In one or more embodiments of the present invention, the numerical value is selected from a first preset value and a second preset value, wherein the first preset value is used to identify booting from the first boot partition; the second preset value is used to identify booting from the second boot partition.
[0016] In one or more embodiments of the present invention, the determining whether to boot from the boot partition based on the value of the boot count memory includes:
[0017] Determine whether the value is one of a first preset value and a second preset value;
[0018] In response to one of the first preset value and the second preset value, it is determined to start from the boot partition.
[0019] In one or more embodiments of the present invention, the boot count memory is a register integrated into a processor.
[0020] In one or more embodiments of the present invention, the processor initializes the eMMC memory by sending a command configured based on the eMMC protocol.
[0021] In one or more embodiments of the present invention, the checking of the startup image includes:
[0022] Match the information carried by the boot image and determine that the boot image is the correct image when matching;
[0023] A CRC check is performed on the boot image, and if the check passes, the boot image is determined to be a complete image.
[0024] In one or more embodiments of the present invention, startup failure is determined by the following steps:
[0025] When the timer reaches the set value, the startup is determined to have failed.
[0026] In one or more embodiments of the present invention, the eMMC memory, the boot count memory and the processor are integrated into a circuit board.
[0027] In one or more embodiments of the present invention, the system further includes
[0028] The reset circuit is configured to receive a reset signal sent by the processor and reset the entire system when the startup fails.
[0029] An embodiment of the present invention provides a primary and backup mirroring startup method based on an eMMC memory, comprising the following steps:
[0030] Step 1: Initialize the eMMC memory and determine whether to boot from the boot partition based on the value of the boot count memory;
[0031] Step 2, in response to starting from the boot partition, reading the boot image of the corresponding partition;
[0032] Step 3: Verify the boot image, and if the verification fails, add one to the value in the boot count memory and re-execute step 1, and if the verification succeeds, execute step 4;
[0033] Step 4: start the timer and execute the boot image, and when the boot fails, at least reset the processor and add one to the value in the boot count memory and execute step 1.
[0034] Compared with the prior art, (1) the present invention adopts eMMC memory as the storage medium, utilizes its hardware partition to flexibly store the primary and backup boot images, and flexibly selects the boot image through the startup count memory, so that the startup of the boot image has better flexibility.
[0035] (2) The present invention also verifies the correctness and integrity of the boot image to ensure that the boot image is started correctly.
[0036] (3) The present invention also sets a boot counter memory to select a corresponding boot mode, and increases the value of the boot count register by one when the boot image fails to start. At the same time, the hardware design (i.e., the reset circuit) is used to reset the processor and the entire system, and restart execution to ensure that there is a chance to start another boot image when the boot image fails to start, thereby ensuring the reliability of boot image startup. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a structure diagram of a mirror boot system based on eMMC memory in the prior art;
[0038] Figure 2 It is a mirror startup flow chart based on eMMC memory in the prior art;
[0039] Figure 3 It is a structural diagram of a main-backup mirror boot system based on an eMMC memory according to an embodiment of the present invention;
[0040] Figure 4 The present invention is a flowchart of a primary and backup image startup based on an eMMC memory according to an embodiment of the present invention. DETAILED DESCRIPTION
[0041] The specific implementation modes of the present invention are described in detail below in conjunction with the accompanying drawings, but it should be understood that the protection scope of the present invention is not limited by the specific implementation modes.
[0042] Unless explicitly stated otherwise, throughout the specification and claims, the term “comprise” or variations such as “include” or “comprising”, etc., will be understood to include the stated elements or components but not to exclude other elements or components.
[0043] Combination Figure 3 and Figure 4As shown, a system for performing primary and backup image startup based on eMMC memory according to a preferred embodiment of the present invention can make full use of the hardware partitions of the eMMC memory to store the primary and backup boot images respectively, and can verify the boot image when loading it to ensure its correctness and completeness, and can ensure that the boot image can switch between the primary and backup boot images after a startup failure through corresponding processing logic when executing the boot image, so as to ensure the reliability of boot image startup.
[0044] Specifically, he Figure 3 As shown, the system includes an eMMC memory, a boot count memory and a processor. In a specific implementation, the processor, the eMMC memory and the boot count memory are integrated on a circuit board, and the processor is a SoC (System on chip) chip.
[0045] Among them, the eMMC (Embedded MultiMedia Card) memory includes a first boot partition (such as Figure 3 Boot0 as shown) and the second boot partition (as Figure 3 As shown in boot1), the first boot partition is configured to store the main boot image file, and the second boot partition is configured to store the backup boot image file.
[0046] The boot count memory is used to store a numerical value, and the numerical value is used to identify the corresponding boot mode. Therefore, the corresponding boot mode can be selected through the numerical value. For example, when the numerical value stored in the boot count memory is a first preset value (such as Ox0), it indicates that the first boot partition is selected for booting; when the numerical value stored in the boot count memory is a second preset value (such as Ox1), it indicates that the second boot partition is selected for booting; when the numerical value stored in the boot count memory is a third preset value (such as Ox2), it indicates that the serial port is selected for booting. In a specific implementation, the boot count memory stores the first preset value by default, that is, the first boot partition is booted by default. The boot count memory here is preferably a register inside the processor. Of course, in other embodiments, it can also be a storage medium outside the processor, which can be selected according to actual needs.
[0047] The processor is connected to both the eMMC memory and the boot count memory, and the processor is configured to perform the following steps to achieve flexible, accurate and reliable booting of the boot image.
[0048] Combination Figure 4 As shown, in step 1, the processor initializes the eMMC memory and determines whether to start from the boot partition based on the value of the boot count memory;
[0049] Step 2, in response to starting from the boot partition, reading the boot image of the corresponding partition;
[0050] Specifically, the processor chooses to boot from the eMMC memory. When implemented, the corresponding boot pin can be used in the hardware design to choose to boot from the eMMC memory. After choosing to boot from the eMMC memory, the eMMC memory is further initialized. When implemented, the processor can send a corresponding command to the eMMC memory to initialize the eMMC memory. The command is generated based on the eMMC protocol.
[0051] After the processor completes the initialization of the eMMC memory, it further obtains the value stored in the boot count memory to determine the corresponding boot mode, that is, it determines whether to boot from the boot partition or from the serial port by the value stored in the boot count memory. In specific implementation, it can be determined whether to boot from the boot partition or from the serial port by the value. The value and the corresponding boot mode are detailed above and will not be repeated here, such as determining whether the value is one of the first preset value and the second preset value. When it is one of the first preset value and the second preset value, it is determined to boot from the boot partition.
[0052] After determining to start from the boot partition, the boot image in the corresponding partition can be further read. In specific implementation, the processor obtains the value stored in the boot count memory, and the corresponding partition can be determined. If the value obtained by the processor is the first preset value, it is determined to start from the first boot partition. After determining the corresponding partition, the boot image in the corresponding partition can be read. If it is determined to start from the first boot partition, the boot image can be read from the first boot partition.
[0053] Step 3: Verify the boot image, and if the verification fails, add one to the value in the boot count memory and re-execute step 1, and if the verification succeeds, execute step 4;
[0054] Specifically, after reading the boot image stored in the corresponding partition, the boot image is verified to ensure that it is correct and complete. In specific implementation, the corresponding data information carried by the boot image can be matched to determine whether the boot image is a correct image, such as matching the corresponding information carried by the boot image header with the preset information, and determining that the boot image is correct when matching, and determining that the boot image is incorrect when it does not match. At the same time, the CRC verification method can be used to determine whether the boot image is complete, such as the tail data of the boot image is usually fixed, that is, the tail carries a CRC check code, and the CRC check code calculated based on the information carried by the boot image is compared with the CRC check code to determine whether the boot image is complete.
[0055] When the boot image verification succeeds, that is, the boot image is determined to be correct and complete, then the next step is executed. When the boot image verification fails, that is, the boot image is determined to be incorrect and / or incomplete, the value in the boot count memory is incremented by one and stored in the boot count memory, and step 1 is further executed. By incrementing the value in the boot count memory by one and re-executing step 1, it is convenient to select to boot from another partition or to select to boot from the serial port, so as to realize the switching of the boot mode and ensure the reliability of the boot.
[0056] Step 4: start the timer and execute the boot image, and when the boot fails, at least reset the processor and add one to the value in the boot count memory and execute step 1.
[0057] Specifically, when the boot image verification succeeds, the boot image is executed to start the boot image. During the boot image startup process, it is determined whether the boot image is successfully started. When the boot image is successfully started, it indicates that the boot image is started based on the eMMC memory. When the boot image fails to start, another boot image is started through corresponding processing to achieve the switching between the main and standby boot images. In the specific implementation, a watchdog timer is set to perform timing statistics. When the watchdog timer reaches the preset value, it is determined that the boot image fails to start. At this time, the watchdog timeout mechanism will be triggered. The processor will at least be reset by the watchdog timeout mechanism. At the same time, the value in the startup count memory will be added by one, and step one will be re-executed to facilitate the selection of starting from another partition, or to choose to start from the serial port. For example, the default value of the startup count register is 0x0, and the default is to start from the first boot partition. If the watchdog timeout mechanism is triggered once, it will be executed again from step one, and the value in the startup count memory becomes 0x1, so it starts from the second boot partition, realizing the switching between the main and standby boot images.
[0058] In this embodiment, in addition to resetting the processor, the entire circuit board needs to be reset. In a specific implementation, the entire circuit board can be reset through a corresponding reset circuit. In a specific implementation, the reset circuit receives a reset signal sent by the processor when the startup fails and resets the entire circuit board (system).
[0059] The present invention adopts an eMMC memory as a storage medium, utilizes its hardware partition to flexibly store the main and standby boot images, and flexibly selects the boot image through the startup count memory, so that the startup of the boot image has better flexibility.
[0060] Furthermore, the present invention also verifies the correctness and integrity of the boot image to ensure that the boot image is correctly started.
[0061] Furthermore, the present invention also sets a startup counter memory to select a corresponding startup mode, and adds 1 to the value of the startup count register when the boot image fails to start. At the same time, in conjunction with the hardware design, the SoC chip and the entire board are reset, and the software logic is restarted, ensuring that if the boot image fails to start, there is still a chance to start another boot image.
[0062] The present invention also discloses a method for starting a primary and backup image based on an eMMC memory. Based on the primary and backup image starting system described above, the method is executed by a processor and specifically includes the following steps:
[0063] Step 1: Initialize the eMMC memory and determine whether to boot from the boot partition based on the value of the boot count memory;
[0064] Step 2, in response to starting from the boot partition, reading the boot image of the corresponding partition;
[0065] Step 3: Verify the boot image, and if the verification fails, add one to the value in the boot count memory and re-execute step 1, and if the verification succeeds, execute step 4;
[0066] Step 4: start the timer and execute the boot image, and when the boot fails, at least reset the processor and add one to the value in the boot count memory and execute step 1.
[0067] The details of how the processor executes each step are as described above and will not be repeated here.
[0068] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0069] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program commands. These computer program commands can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the commands executed by the processor of the computer or other programmable data processing device generate commands for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0070] These computer program commands may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the commands stored in the computer readable memory produce an article of manufacture comprising a command device, the command device implementing the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0071] These computer program commands can also be loaded onto a computer or other programmable data processing device so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the commands executed on the computer or other programmable device provide the instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0072] The foregoing description of specific exemplary embodiments of the present invention is for the purpose of illustration and demonstration. These descriptions are not intended to limit the present invention to the precise form disclosed, and it is clear that many changes and variations can be made based on the above teachings. The purpose of selecting and describing the exemplary embodiments is to explain the specific principles of the present invention and its practical application, so that those skilled in the art can realize and utilize various different exemplary embodiments of the present invention and various different selections and changes. The scope of the present invention is intended to be limited by the claims and their equivalents.
Claims
1. A main-backup mirror boot system based on eMMC memory, characterized in that: include: The eMMC memory includes a first boot partition and a second boot partition, wherein the first boot partition is configured to store a primary boot image, and the second boot partition is configured to store a backup boot image; A startup count memory configured to store a value for identifying a startup mode; A processor is connected to the eMMC memory and the boot count memory, and is configured to perform the following steps: Step 1: Initialize the eMMC memory and determine whether to boot from the boot partition based on the value of the boot count memory; Step 2, in response to starting from the boot partition, reading the boot image of the corresponding partition; Step 3, verify the boot image, and if the verification fails, add 1 to the value in the boot count memory and execute step 1, and if the verification succeeds, execute step 4; Step 4: start the timer and execute the boot image, and when the boot fails, at least reset the processor and add one to the value in the boot count memory and execute step 1.
2. The system according to claim 1, characterized in that The numerical value is selected from one of a first preset value and a second preset value, wherein the first preset value is used to identify booting from a first boot partition; and the second preset value is used to identify booting from a second boot partition.
3. The system according to claim 2, characterized in that The determining whether to start from the boot partition based on the value of the boot count memory includes: Determine whether the value is one of a first preset value and a second preset value; In response to one of the first preset value and the second preset value, it is determined to start from the boot partition.
4. The system according to claim 1, characterized in that The boot count memory is a register integrated into the processor.
5. The system according to claim 1, wherein: The processor initializes the eMMC memory by sending a command configured based on the eMMC protocol.
6. The system according to claim 1, wherein: The verification of the startup image includes: Match the information carried by the boot image and determine that the boot image is the correct image when matching; A CRC check is performed on the boot image, and if the check passes, the boot image is determined to be a complete image.
7. The system according to claim 1, characterized in that Determine the startup failure by following the steps below: When the timer reaches the set value, the startup is determined to have failed.
8. The system of claim 1, wherein: The eMMC memory, the boot count memory and the processor are integrated in a circuit board.
9. The system of claim 1, wherein: The system also includes The reset circuit is configured to receive a reset signal sent by the processor and reset the entire system when the startup fails.
10. A method for starting a primary and backup mirror image based on the primary and backup mirror image starting system according to claim 1, characterized in that: The steps include: Step 1: Initialize the eMMC memory and determine whether to boot from the boot partition based on the value of the boot count memory; Step 2, in response to starting from the boot partition, reading the boot image of the corresponding partition; Step 3: Verify the boot image, and if the verification fails, add one to the value in the boot count memory and re-execute step 1, and if the verification succeeds, execute step 4; Step 4: start the timer and execute the boot image, and when the boot fails, at least reset the processor and add one to the value in the boot count memory and execute step 1.
Citation Information
Cited By
Baseboard management controller starting method, computer equipment, medium and product
CN120255970A
Memory testing method and device, equipment and medium
CN120510904A
Three-level fault-tolerant degradation mechanism domain controller starting method and system
CN121144111A
