Segmented starting method and device of system, storage medium and electronic equipment
By dividing the firmware into the system startup part and the system application part, and using header information for segmented loading, the problem of too long startup time of the embedded system is solved, and rapid startup and efficient resource utilization are achieved.
Patent Information
- Application Number
- CN202411717948.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-04-11
AI Technical Summary
The startup time of an embedded system is too long, resulting in inefficient user interaction and affects other devices or functions that rely on fast startup.
By dividing the firmware into header information, system startup part and system application part, using the address and security verification information in the header information, the system is loaded in segments, first loading the system startup part, and then loading the system application part when specific conditions are met.
It realizes rapid system startup, reduces resource usage, enhances system security and stability, and solves the problem of too long startup time for embedded systems.
Smart Images

Figure CN119806655A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of embedded systems, and in particular to a segmented startup method, device, storage medium and electronic device of a system. Background Art
[0002] During the boot process of an embedded system, it is usually necessary to read multiple firmware from multiple partitions in NAND flash to RAM to ensure the integrity and reliability of the firmware. This process is critical to the normal boot of the system, because this interaction between the NAND flash of the embedded device that can retain data after power failure and the RAM where data will be lost after power failure ensures that the firmware can be successfully loaded and run. With the increasing number and complexity of embedded applications, the size of embedded firmware is also increasing. For example, in automotive network access devices, the firmware often contains multiple parts, such as modem firmware, Linux kernel firmware, and Linux root file system firmware. These large firmware will directly lead to longer boot time of embedded systems under the same hardware environment. The larger the firmware, the longer it takes to read data from NAND flash and load it to RAM during the boot process. Users and applications need to wait a long time before they can start using the device, resulting in inefficient interaction. At the same time, other devices or functions that rely on fast startup may be affected and unable to respond in time. Summary of the invention
[0003] The present application provides a system segmented startup method, device, storage medium and electronic device to solve the technical problem that the startup time of the embedded system is too long.
[0004] In a first aspect, the present application provides a method for segmented startup of a system, comprising: when the system starts to power on, according to the header information of the firmware, loading the system startup part of the above-mentioned firmware to start the above-mentioned system, wherein the above-mentioned firmware includes the above-mentioned header information, the above-mentioned system startup part and the system application part; after the above-mentioned system is started, and when it is determined that the above-mentioned system meets any loading condition of the above-mentioned system application part, according to the above-mentioned header information, loading the above-mentioned system application part of the above-mentioned firmware to start the system application of the above-mentioned system.
[0005] In the second aspect, the present application provides a segmented startup device for a system, comprising: a first loading module, used to load the system startup part of the above-mentioned firmware according to the header information of the firmware when the system starts to power on, so as to start the above-mentioned system, wherein the above-mentioned firmware includes the above-mentioned header information, the above-mentioned system startup part and the system application part; a second loading module, used to load the above-mentioned system application part of the above-mentioned firmware according to the above-mentioned header information after the above-mentioned system is started and it is determined that the above-mentioned system meets any loading condition of the above-mentioned system application part, so as to start the system application of the above-mentioned system.
[0006] As an optional example, the above-mentioned device also includes: a division module, used to divide the above-mentioned firmware into the above-mentioned header information, the above-mentioned system startup part and the above-mentioned system application part before the above-mentioned system starts to power on, wherein the above-mentioned system startup part includes the system startup code and the system startup security verification information, and the above-mentioned system application part includes the system application code and the system application security verification information; a processing module, used to write the first storage address of the above-mentioned system startup code, the second storage address of the above-mentioned system startup security verification information, the third storage address of the above-mentioned system application code and the fourth storage address of the above-mentioned system application security verification information to the above-mentioned header information, wherein the above-mentioned first storage address is the storage address of the above-mentioned system startup code in the first memory of the above-mentioned system, the above-mentioned second storage address is the storage position of the above-mentioned system startup security verification information in the above-mentioned first memory, the above-mentioned third storage address is the storage address of the above-mentioned system application code in the above-mentioned first memory, and the above-mentioned fourth storage address is the storage address of the above-mentioned system application security verification information in the above-mentioned first memory.
[0007] As an optional example, the first loading module includes: a first acquisition unit, used to acquire the first storage address of the system startup code and the second storage address of the system startup security verification information from the header information; a first copy unit, used to copy the system startup code and the system startup security verification information in the first memory to the second memory of the system according to the first storage address and the second storage address, wherein the first memory is used for long-term storage of data, and the second memory is used for temporary storage of running data; a first verification unit, used to verify the system startup code in the second memory based on the system startup security verification information; a first execution unit, used to execute the system startup code to start the system if the system startup code is verified to be successful.
[0008] As an optional example, the first loading module further includes: a first downloading unit, for downloading the backup firmware from the external storage device to the first memory after obtaining the first storage address and the second storage address from the header information, in the event that the system startup code fails to be copied and / or the system startup security verification information fails to be copied, so as to update the firmware in the first memory and restart the system; a second downloading unit, for downloading the backup firmware from the external storage device to the first memory, in the event that the system startup code fails to be verified, so as to update the firmware in the first memory and restart the system.
[0009] As an optional example, the above-mentioned device also includes: a first determination module, which is used to determine that the above-mentioned system meets the above-mentioned loading conditions when a preset time after the above-mentioned system is started after the above-mentioned system is started; a second determination module, which is used to determine that the above-mentioned system meets the above-mentioned loading conditions when a loading instruction of the application part of the above-mentioned system is received; a third determination module, which is used to determine that the above-mentioned system meets the above-mentioned loading conditions when the processor usage rate of the above-mentioned system is lower than a preset usage rate; and a fourth determination module, which is used to determine that the above-mentioned system meets the above-mentioned loading conditions when a call instruction of any application of the above-mentioned system application is received.
[0010] As an optional example, the second loading module includes: a second acquisition unit, used to acquire the third storage address of the system application code and the fourth storage address of the system application security verification information from the header information; a second copy unit, used to copy the system application code and the system application security verification information in the first memory to the second memory of the system according to the third storage address and the fourth storage address; a second verification unit, used to verify the system application code in the second memory based on the system application security verification information; and a second execution unit, used to execute the system application code to start the system application if the system application code passes the verification.
[0011] As an optional example, the second loading module further includes: a third downloading unit, which is used to download the backup firmware from the external storage device to the first memory after obtaining the third storage address and the fourth storage address from the header information, in case the system application code copy fails and / or the system application security verification information copy fails, so as to update the firmware in the first memory and restart the system; a fourth downloading unit, which is used to download the backup firmware from the external storage device to the first memory, in case the system application code fails to be verified, so as to update the firmware in the first memory and restart the system.
[0012] In a third aspect, the present application provides a storage medium storing a computer program, wherein the computer program executes the segmented startup method of the above-mentioned system when executed by a processor.
[0013] In a fourth aspect, the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the segmented startup method of the system through the computer program.
[0014] In an embodiment of the present application, a method is adopted in which, when the system starts to power on, the system startup part of the above-mentioned firmware is loaded according to the header information of the firmware to start the above-mentioned system, wherein the above-mentioned firmware includes the above-mentioned header information, the above-mentioned system startup part and the system application part; after the above-mentioned system is started, and when it is determined that the above-mentioned system meets any loading condition of the above-mentioned system application part, the above-mentioned system application part of the above-mentioned firmware is loaded according to the above-mentioned header information to start the system application of the above-mentioned system. Since in the above-mentioned method, the firmware of the system is divided into header information, system startup part and system application part, and the header information records the address of each part and the address of the security verification information of each part, after the system is powered on, the system startup part is first loaded to complete the startup of the system. After the system is started, and when any loading condition of the system application part is met, the system application part is loaded to complete the startup of the system application, thereby realizing the purpose of starting the system in stages, improving the system startup speed, reducing resource occupation, and enhancing the security and stability of the system, thereby solving the technical problem of too long startup time of the embedded system. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0017] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0018] Figure 1is a flowchart of an optional segmented startup method of a system according to an embodiment of the present application;
[0019] Figure 2 It is a specific startup flow chart of a system according to an optional segmented startup method of a system in an embodiment of the present application;
[0020] Figure 3 is a structural schematic diagram of a segmented starting device of an optional system according to an embodiment of the present application;
[0021] Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0023] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0024] According to a first aspect of an embodiment of the present application, a segmented startup method of a system is provided, optionally, as follows: Figure 1 As shown, the above method includes:
[0025] S102, when the system starts to power on, loading the system startup part of the firmware according to the header information of the firmware to start the system, wherein the firmware includes the header information, the system startup part and the system application part;
[0026] S104, after the system is started, and when it is determined that the system meets any loading condition of the system application part, the system application part of the firmware is loaded according to the header information to start the system application of the system.
[0027] Optionally, in this embodiment, during the system firmware compilation phase, the system firmware is divided into two main parts: a system startup part and a system application part. The system startup part includes the basic components required for system startup. Specifically, it includes: hardware driver (a driver responsible for interacting with hardware devices (such as modem, CPU, memory, etc.)), configuration (basic configuration files and parameters required for system operation), and necessary system applications (applications or services that are essential during the startup process. For example, system initialization services or basic monitoring applications). The system application part includes applications and services that do not need to be run immediately during the system startup phase. Specifically, it may include: user applications (such as graphical user interface applications or user-defined services), background services (some services that can be loaded later when the system is started, such as network services or data processing tasks). The header information of the firmware contains multiple important addresses and verification information, which are crucial for the loading and verification of the firmware: Firmware system startup part address: points to the storage address of the system startup part in NAND Flash, and the Bootloader needs to start loading the system startup part from this address. Firmware startup part verification code, certificate, signature, etc. address: The verification code is used to verify the integrity of the loaded system startup part data to ensure that it is not damaged during transmission or storage. The certificate is used to confirm the legitimacy of the source of the firmware, ensuring that the firmware is generated by a trusted source to prevent the injection of malicious code. The signature is a digital signature generated by the developer to ensure that the firmware has not been tampered with. The Bootloader verifies the signature when loading the firmware. The address of the firmware system application part points to the address of the system application part in the storage medium, which is used to load this part after meeting specific conditions. The address of the firmware application part verification code, certificate, signature, etc.: Similar to the system startup part, this contains the verification and security verification information of the application part to ensure that the loaded application is also complete and trustworthy.
[0028] Optionally, in this embodiment, when the system is powered on, the system first reads the header information of the firmware. The header information contains multiple important addresses and verification information, including the starting address of the system startup part, the address of the security verification information (such as verification code, certificate and digital signature) of the system startup part, which is used to ensure the integrity and legitimacy of the system startup part, the starting address of the system application part, the security verification information (also including verification code, certificate and signature) of the system application part, to ensure the security of the application part. The header information guides the system on how to load, verify and manage the various parts of the firmware, and provides key configuration information for the entire loading process. According to the address in the header information, the system finds the location of the system startup part, and verifies its integrity and legitimacy by reading the verification code, certificate and signature of the system startup part. After the verification is passed, the system loads the content of the system startup part. This part contains the components required for the basic startup of the system, such as hardware initialization code, bottom-level driver, operating system kernel loader, etc. The system startup part ensures that the system reaches the basic working state and makes the hardware and software resources ready. After the system startup part is loaded and initialized, the system enters the basic running state, can perform basic operations and monitor various system environments. The system will continue to determine whether the loading conditions of the system application part are met, such as detecting network connections, external hardware devices, user input or system status. If any loading conditions are met, the system will continue to load the application part according to the header information. Once it is determined that the loading conditions are met, the system finds the address of the system application part based on the header information, and reads its security verification information (checksum, certificate and signature), and verifies the application part to ensure that its data has not been tampered with and the source is trustworthy. After the verification is passed, the system loads the application part, which contains specific application and service codes, so that the system's functions are extended to all application layer operations required by the end user. After the application part is loaded, the system can fully enter the working state, provide the functions of all applications and services, and provide interactive services for users or other devices.
[0029] Optionally, in this embodiment, by dividing the firmware into the startup and application parts, the application functions can be flexibly updated or upgraded without affecting the startup part. When the system starts, only the basic components are loaded without loading the application part, which greatly shortens the startup time. The application part is loaded after the system enters the working state and meets the loading conditions, making the system resource utilization more efficient.
[0030] As an optional example, before the system starts to power on, the method further includes:
[0031] The firmware is divided into header information, a system startup part and a system application part, wherein the system startup part includes a system startup code and system startup security verification information, and the system application part includes a system application code and system application security verification information;
[0032] The first storage address of the system startup code, the second storage address of the system startup security verification information, the third storage address of the system application code and the fourth storage address of the system application security verification information are written to the header information, wherein the first storage address is the storage address of the system startup code in the first memory of the system, the second storage address is the storage position of the system startup security verification information in the first memory, the third storage address is the storage address of the system application code in the first memory, and the fourth storage address is the storage address of the system application security verification information in the first memory.
[0033] Optionally, in this embodiment, before the system is powered on, the firmware partitioning and the address configuration of the header information are completed in advance, which can ensure that the system startup and application parts have independent security verification information and access addresses, respectively, making the loading process more efficient and more secure. In the firmware compilation stage, the system firmware is divided into three main parts: header information, system startup part, and system application part. The header information stores the location of each firmware part in the NAND Flash memory, as well as the information required for security verification. The system startup part includes system startup code and system startup security verification information. The system startup code is responsible for the basic boot operation of the system, and the system security verification information (such as verification code, certificate, signature) is used to confirm the legitimacy of the system startup code. The system application part includes system application code and system application security verification information. The system application code serves various functions of the user and the system, and the system application security verification information is used to verify its integrity and security when loading the system application part. In order to facilitate loading and verification, the storage address of each firmware part is written into the header information so that the system can directly access the corresponding content when loading the startup and application parts. The first storage address is the location of the system startup code in the first memory (NAND Flash), the second storage address is the location of the system startup security verification information in the first memory, usually adjacent to the system startup code, the third storage address is the storage location of the system application code in the first memory, and the fourth storage address is the location of the system application security verification information in the first memory. This clear address configuration method enables the system to quickly locate and load the corresponding code and verification information, improving the startup efficiency and system security. After power-on, the system reads and parses these storage addresses from the header information. Based on the address positioning, the system first verifies and loads the system startup part, and then verifies and loads the system application part when the application conditions are met. The address data provided by the header information enables the system to ensure that the firmware is loaded as expected without scanning the entire memory, which improves the loading speed. The clear firmware division and address configuration allow the startup and application parts of the system to be updated and maintained independently. For example, the application part can be updated without affecting the startup part. This partitioning method improves the maintainability and upgrade flexibility of the system and facilitates subsequent functional expansion.
[0034] As an optional example, according to the header information of the firmware, the system startup part of the firmware is loaded to start the system, including:
[0035] Acquire a first storage address of the system startup code and a second storage address of the system startup security verification information from the header information;
[0036] According to the first storage address and the second storage address, the system startup code and the system startup security verification information in the first storage are copied to the second storage of the system, wherein the first storage is used for long-term storage of data, and the second storage is used for temporary storage of running data;
[0037] In the second memory, the system startup code is verified based on the system startup security verification information;
[0038] When the system startup code is verified to be successful, the system startup code is executed to start the system.
[0039] Optionally, in this embodiment, when the system is powered on, the system first reads the header information of the firmware, and extracts two key addresses from the header information, the first storage address: the position of the system startup code in the first memory; the second storage address: the position of the system startup security verification information in the first memory. The system locates the specific position of the system startup code and the system security verification information in the first memory through the first storage address and the second storage address, and copies the system startup code and the corresponding system security verification information from the first memory to the second memory. The first memory is used for long-term storage of firmware content, such as flash memory or EEPROM, and the data persistence is high. The second memory is used for temporary storage and processing of currently running data, such as RAM. It has a fast read and write speed and is suitable for runtime access. This copy operation not only speeds up the subsequent startup process, but also avoids frequent access to the first memory, thereby improving the system operation efficiency. After the system startup code and the system security verification information are copied to the second memory, the system will verify the system startup code to ensure the integrity and security of the code. The verification method usually includes: checksum check: to ensure that the data has not been tampered with; certificate or digital signature verification: to ensure that the code comes from a trusted source. If the verification is successful, the system can continue to boot, otherwise the boot process will be terminated to prevent the loading of unsafe code. After the verification is successful, the system officially executes the system boot code. The tasks performed by the system boot code include initializing the hardware, loading the operating system kernel, and other necessary basic functional components to prepare for system operation. By saving the security verification information in the first memory and copying it to the second memory for verification at startup, it is ensured that the boot code has not been tampered with and the source is credible. The verification step can prevent malicious code or illegal firmware from booting the system and ensure the security of the system.
[0040] As an optional example, after obtaining the first storage address and the second storage address from the header information, the method further includes:
[0041] In case that the system startup code copy fails and / or the system startup security verification information copy fails, downloading the backup firmware from the external storage device to the first memory to update the firmware in the first memory, and restarting the system;
[0042] When the system startup code fails to pass the verification, the backup firmware is downloaded from the external storage device to the first memory to update the firmware in the first memory, and the system is restarted.
[0043] Optionally, in this embodiment, an exception handling mechanism is set when the system loads the firmware to ensure that it can automatically recover when the boot code or security verification information fails to copy, and take further measures in the event of verification failure. This mechanism can enhance the self-repair capability of the system and ensure system reliability. Specifically, the system first obtains the first storage address of the system boot code and the second storage address of the system security verification information from the firmware header information. The system copies the system boot code and the system security verification information from the first memory to the second memory through the first and second storage addresses. If the copy process is successfully completed, the system can enter the next verification step. If the copying process of the system startup code or the system security verification information fails, the system will automatically trigger an exception handling mechanism. The exception handling mechanism may include restarting the system (trying to load and verify the firmware again to prevent occasional errors), switching the system (switching to the backup system image and continuing basic operations to avoid affecting key functions), entering the download mode (directly entering the firmware re-download mode to ensure that a complete firmware is available at the next startup), and other methods. The attempts can be made once or multiple times in a certain order. Taking the download mode as an example, the complete backup firmware is re-downloaded to the first memory through an external storage device (such as a network server or a USB device), the firmware in the first memory is updated, and the newly downloaded firmware is divided into header information, a system startup part, and a system application part. The storage address of the system startup code, the storage address of the system startup security verification information, the storage address of the system application code, and the storage address of the system application security verification information are written into the header information. The updated header information will contain metadata such as the address of the re-downloaded system startup code and the system security verification information to ensure that the system can correctly locate the latest firmware information. After the update is completed, the system will automatically restart and re-execute the startup process. After the copy is successful, the system verifies the system startup code in the second memory based on the system security verification information to ensure its integrity and security. If the verification is successful, the system startup code can be executed smoothly and the system starts normally. If the verification fails, the system triggers the exception handling mechanism again. If the download fails or the verification fails multiple times, the system can switch to other exception handling mechanisms in sequence to ensure that the system will not restart infinitely due to firmware errors. The system can automatically resume normal operation after a startup failure to avoid long downtime.
[0044] As an optional example, after the system is started, the method further includes:
[0045] When a preset time after the system is started is reached, determining that the system meets the loading condition;
[0046] Upon receiving a loading instruction from the application part of the system, determining that the system meets the loading condition;
[0047] When the processor usage rate of the system is lower than a preset usage rate, determining that the system meets the loading condition;
[0048] When a call instruction of any application of the system application is received, it is determined that the system meets the loading condition.
[0049] Optionally, in this embodiment, after the system is started, the firmware loading process includes an additional conditional judgment mechanism to determine when to load the code of the system application part. A delay time (for example, a few seconds or minutes) can be set after the system is started. When the preset time is reached, it is determined whether the system is running stably. At this time, if the system resources are ready and stable, it is considered that the loading conditions are met and the system application part is loaded. The preset time delay can ensure that the system does not disperse resources due to parallel loading of applications during the startup process, thereby improving the stability and startup speed of the system startup.
[0050] Optionally, in this embodiment, when the system receives a clear loading instruction (such as an instruction from an external device or user interaction), it can immediately determine that the system meets the loading conditions. The instruction can come from the network, device interface or user control panel to load the application part according to actual needs, providing a flexible loading method so that the system application part can be called immediately when needed to adapt to dynamic needs.
[0051] Optionally, in this embodiment, the system determines whether it is appropriate to load the application part by monitoring the utilization rate of the processor. For example, when the utilization rate of the processor is lower than a preset value (e.g., 20%), the system confirms that the loading condition is met, which can avoid the system from loading a large number of applications under high load, prevent the loading from affecting the system performance, dynamically load the application part based on the resource utilization, optimize resource allocation, and improve the overall system performance and response speed.
[0052] Optionally, in this embodiment, when the system receives a specific call instruction from an application in the system application part (for example, a user or other system process requests the start of an application), the system confirms that the loading conditions are met, so that the relevant code can be dynamically loaded when the application demand arises, without having to load all of it when the system starts, thereby reducing the initial load amount and accelerating system startup. At the same time, the required modules are loaded immediately when the application calls, thereby improving the response speed.
[0053] As an optional example, according to the header information, loading the system application part of the firmware to start the system application of the system includes:
[0054] Acquire a third storage address of the system application code and a fourth storage address of the system application security verification information from the header information;
[0055] According to the third storage address and the fourth storage address, the system application code and the system application security verification information in the first memory are copied to the second memory of the system;
[0056] In the second memory, verifying the system application code based on the system application security verification information;
[0057] When the system application code passes the verification, the system application code is executed to start the system application.
[0058] Optionally, in this embodiment, the system reads the firmware header information, extracts the storage location of the system application code and its security verification information in the first memory, specifically, the third storage address specifies the location of the system application code, and the fourth storage address indicates the location of the application security verification information. The system copies the system application code and security verification information from the first memory to the second memory for further processing. The system uses the system application security verification information (such as hash value, signature or certificate) in the second memory to perform security verification on the system application code. If the verification is successful, it means that the system application code has not been tampered with or damaged, and the verification is passed; if the verification fails, it indicates that the code may be tampered with or damaged. After the verification is passed, the system starts to execute the system application code and loads the required application or service. Verifying the integrity of the code by verifying the information before loading the application code can effectively prevent abnormal system behavior caused by code damage and improve the stability of the system. The system can load system applications under specific conditions, adapt to various scenario requirements, ensure that applications are loaded only when necessary, optimize system resources, and the condition-based on-demand loading mechanism can support dynamically expanded application requirements and adapt to different business scenarios and resource usage.
[0059] As an optional example, after obtaining the third storage address and the fourth storage address from the header information, the method further includes:
[0060] In case that the system application code copy fails and / or the system application security verification information copy fails, downloading the backup firmware from the external storage device to the first memory to update the firmware in the first memory, and restarting the system;
[0061] In the case that the system application code fails to pass the verification, the backup firmware is downloaded from the external storage device to the first memory to update the firmware in the first memory, and the system is restarted.
[0062] Optionally, in this embodiment, when the system attempts to copy the application code or its verification information from the first memory to the second memory, if the copy fails, it may indicate that the code or verification information is damaged or incomplete in the first memory, and the system will automatically trigger the exception handling mechanism. Taking the download mode as an example, the system will re-download the complete firmware from the external storage device (such as an external flash memory or a network server) to the first memory to ensure that the latest firmware version is replaced. By re-downloading the firmware, the integrity of the storage is restored to prevent the wrong or damaged code from being loaded into the system, ensuring the security and availability of subsequent applications. After downloading the complete firmware, the system updates the header information so that the system can identify the new storage address or firmware version to avoid repeated loading of the old or wrong firmware version. After the update is completed, the system automatically restarts to ensure that the updated firmware is loaded and the startup process is re-executed. If the system finds that the application code verification fails during the verification process after the copy (that is, it does not match the system application security verification information), it indicates that the code may be damaged or tampered with. The system automatically triggers the exception handling mechanism again. Taking the download mode as an example, the system will re-download the firmware from the external storage, update the header information, and restart the system to ensure that the untampered and complete firmware is loaded during the subsequent startup process. If the system application code still cannot be loaded or verified after multiple attempts, the system can switch to other exception handling mechanisms in order. Through the exception handling mechanism, the system can be restored to a normal state as much as possible when loading or verification problems occur, avoiding long-term downtime or unavailability.
[0063] With reference to an example for illustration, the present application relates to a segmented startup method for a system. In order to improve the system startup speed, the system firmware is divided into two main parts: a system startup part and a system application part. The system startup part includes the basic components required for system startup. The system application part includes application programs and services that do not need to be run immediately during the system startup phase. The header information of the firmware contains multiple important addresses and verification information: Firmware system startup part address: points to the storage address of the system startup part in NAND Flash. Addresses of verification codes, certificates, signatures, etc. of the firmware startup part. Address of the firmware system application part, pointing to the address of the system application part in the storage medium. Addresses of verification codes, certificates, signatures, etc. of the firmware application part.
[0064] During the system startup phase, the system first copies the system startup part and its security verification information (check code, certificate, signature, etc.) from the NAND flash partition to the memory space according to the address of the system startup part and the address of the system startup security verification information, and verifies its integrity based on its security verification information. If the verification passes, the system immediately executes the code of the system startup part to provide the core functions of the system. When the system startup part is loaded and meets any loading condition of the system application part (for example, the processor load is low, the preset time is reached, or a loading instruction is received), the system application part will be loaded and run. This ensures the rapid startup of the system, improves resource utilization, and ensures the flexibility and performance of the system. The specific startup process of the system is as follows: Figure 2 As shown:
[0065] Step 1: Check the status of the system startup part: Check whether all system partitions of the system startup part have been started. If not, go to the next step.
[0066] Step 2: Copy the system startup part: copy the system startup code and security verification information of the firmware from the NAND partition to the RAM space. If the copy fails, the exception handling mechanism is triggered (such as restarting, switching the system or entering the download mode); if the copy is successful, proceed to the next step.
[0067] Step 3: Verify and run the code of the system startup part: Verify the integrity and reliability of the system startup part in RAM. If the verification fails, trigger the exception handling mechanism; if the verification succeeds, return to step 1 to check the system partition.
[0068] Step 4: System startup part is completed: If the system startup part of all system partitions has been started, it means that the system startup part has been successfully completed.
[0069] Step 5: Match the predefined loading conditions of the system application part: Check whether any of the loading conditions of the firmware system application part is met (such as delayed arrival, CPU usage rate is lower than the threshold, application call, etc.). If the match is successful, proceed to the next step.
[0070] Step 6: Check the status of the system application part: Check whether the system application part of all system partitions has been started. If not, proceed to the next step.
[0071] Step 7: Copy the system application part: copy the code and security verification information of the system application part of the firmware from the NAND partition to the RAM space. If the copy fails, the exception handling mechanism is triggered; if the copy succeeds, proceed to the next step.
[0072] Step 8: Verify and run the system application part: Verify the integrity and reliability of the system application part in RAM. If it fails, trigger the exception handling mechanism; if it succeeds, return to step 6 until all system application parts are loaded.
[0073] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0074] According to another aspect of the embodiment of the present application, a segmented starting device of a system is also provided, such as Figure 3 As shown, including:
[0075] A first loading module 302 is used to load the system startup part of the firmware according to the header information of the firmware when the system starts to power on, so as to start the system, wherein the firmware includes the header information, the system startup part and the system application part;
[0076] The second loading module 304 is used to load the system application part of the firmware according to the header information after the system is started and it is determined that the system meets any loading condition of the system application part to start the system application of the system.
[0077] It should be noted that the first loading module 302 in this embodiment can be used to execute step S102 in the embodiment of the present application, and the second loading module 304 in this embodiment can be used to execute step S104 in the embodiment of the present application.
[0078] As an optional example, the above device further includes:
[0079] A partitioning module, used for partitioning the firmware into header information, a system startup part and a system application part before the system starts to power on, wherein the system startup part includes a system startup code and system startup security verification information, and the system application part includes a system application code and system application security verification information;
[0080] A processing module is used to write a first storage address of a system startup code, a second storage address of system startup security verification information, a third storage address of a system application code, and a fourth storage address of the system application security verification information into header information, wherein the first storage address is a storage address of the system startup code in a first memory of the system, the second storage address is a storage location of the system startup security verification information in the first memory, the third storage address is a storage address of the system application code in the first memory, and the fourth storage address is a storage address of the system application security verification information in the first memory.
[0081] As an optional example, the first loading module includes:
[0082] A first acquiring unit, used for acquiring a first storage address of a system startup code and a second storage address of system startup security verification information from the header information;
[0083] A first copy unit, used for copying the system startup code and the system startup security verification information in the first memory to the second memory of the system according to the first storage address and the second storage address, wherein the first memory is used for long-term storage of data, and the second memory is used for temporary storage of running data;
[0084] A first verification unit, configured to verify the system startup code in the second memory based on the system startup security verification information;
[0085] The first execution unit is used to execute the system startup code to start the system when the system startup code verification passes.
[0086] As an optional example, the first loading module further includes:
[0087] a first downloading unit, configured to, after acquiring the first storage address and the second storage address from the header information, download the backup firmware from the external storage device to the first memory in case that the system startup code copy fails and / or the system startup security verification information copy fails, so as to update the firmware in the first memory and restart the system;
[0088] The second downloading unit is used to download the backup firmware from the external storage device to the first memory to update the firmware in the first memory and restart the system when the system startup code fails to pass the verification.
[0089] As an optional example, the above device further includes:
[0090] A first determination module is used to determine that the system meets the loading condition when a preset time after the system startup is reached after the system startup;
[0091] A second determination module is used to determine that the system meets the loading condition when receiving the loading instruction of the system application part;
[0092] A third determination module, configured to determine that the system meets the loading condition when the processor usage rate of the system is lower than a preset usage rate;
[0093] The fourth determination module is used to determine whether the system meets the loading condition when receiving a call instruction from any application of the system application.
[0094] As an optional example, the second loading module includes:
[0095] A second acquiring unit, configured to acquire a third storage address of the system application code and a fourth storage address of the system application security verification information from the header information;
[0096] A second copy unit, used for copying the system application code and the system application security verification information in the first memory to the second memory of the system according to the third storage address and the fourth storage address;
[0097] The second verification unit is used to verify the system application code in the second memory based on the system application security verification information; the second execution unit is used to execute the system application code to start the system application when the system application code verification passes.
[0098] As an optional example, the second loading module further includes:
[0099] a third downloading unit, configured to, after acquiring the third storage address and the fourth storage address from the header information, download the backup firmware from the external storage device to the first memory in case that the system application code copy fails and / or the system application security verification information copy fails, so as to update the firmware in the first memory and restart the system;
[0100] The fourth downloading unit is used to download the backup firmware from the external storage device to the first memory to update the firmware in the first memory and restart the system when the system application code fails to pass the verification.
[0101] For other examples of this embodiment, please refer to the examples and will not be repeated here.
[0102] Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the present application, such as Figure 4 As shown, it includes a processor 402, a communication interface 404, a memory 406 and a communication bus 408, wherein the processor 402, the communication interface 404 and the memory 406 communicate with each other through the communication bus 408, wherein,
[0103] Memory 406, used to store computer programs;
[0104] The processor 402 is used to implement the following steps when executing the computer program stored in the memory 406:
[0105] When the system starts to power on, the system startup part of the firmware is loaded according to the header information of the firmware to start the system, wherein the firmware includes the header information, the system startup part and the system application part;
[0106] After the system is started, and when it is determined that the system meets any loading condition of the system application part, the system application part of the firmware is loaded according to the header information to start the system application of the system.
[0107] Optionally, in this embodiment, the communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 The communication interface is used for communication between the above electronic device and other devices.
[0108] The memory may include RAM, or may include non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0109] As an example, the memory 406 may include but is not limited to the first loading module 302 and the second loading module 304 in the segmented startup device of the system. In addition, it may also include but is not limited to other module units in the segmented startup device of the system, which will not be repeated in this example.
[0110] The above-mentioned processor can be a general-purpose processor, which can include but not be limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0111] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0112] It can be understood by those skilled in the art that Figure 4 The structure shown is for illustration only. The electronic device implementing the segmented startup method of the above system may be a module capable of realizing communication functions or a terminal device including the module, etc. The terminal device may be a mobile terminal or a smart terminal. The mobile terminal may be at least one of a mobile phone, a tablet computer, a laptop computer, etc.; the smart terminal may be a terminal including a wireless communication module such as a smart car, a smart watch, a shared bicycle, a smart cabinet, etc.; the module may be a wireless communication module, such as any one of a 2G communication module, a 3G communication module, a 4G communication module, a 5G communication module, and a NB-IOT communication module. Figure 4 The structure of the electronic device is not limited. For example, the electronic device may also include Figure 4 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 4 Different configurations shown.
[0113] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which can include: a flash drive, ROM, RAM, a magnetic disk or an optical disk, etc.
[0114] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program executes the steps in the segmented startup method of the above system when executed by a processor.
[0115] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0116] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0117] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
[0118] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0119] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0120] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0121] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0122] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for starting a system in stages, characterized in that: include: When the system starts to power on, according to the header information of the firmware, the system startup part of the firmware is loaded to start the system, wherein the firmware includes the header information, the system startup part and the system application part; After the system is started, and when it is determined that the system meets any one of the loading conditions of the system application part, the system application part of the firmware is loaded according to the header information to start the system application of the system.
2. The method according to claim 1, characterized in that Before the system starts to power on, the method further includes: Dividing the firmware into the header information, the system startup part and the system application part, wherein the system startup part includes a system startup code and system startup security verification information, and the system application part includes a system application code and system application security verification information; The first storage address of the system startup code, the second storage address of the system startup security verification information, the third storage address of the system application code and the fourth storage address of the system application security verification information are written to the header information, wherein the first storage address is the storage address of the system startup code in the first memory of the system, the second storage address is the storage position of the system startup security verification information in the first memory, the third storage address is the storage address of the system application code in the first memory, and the fourth storage address is the storage address of the system application security verification information in the first memory.
3. The method according to claim 2, characterized in that The step of loading the system startup part of the firmware according to the header information of the firmware to start the system includes: Acquire a first storage address of the system startup code and a second storage address of the system startup security verification information from the header information; According to the first storage address and the second storage address, copy the system startup code and the system startup security verification information in the first storage to the second storage of the system, wherein the first storage is used for long-term storage of data, and the second storage is used for temporary storage of running data; In the second memory, verifying the system startup code based on the system startup security verification information; When the system startup code passes the verification, the system startup code is executed to start the system.
4. The method according to claim 3, characterized in that After acquiring the first storage address and the second storage address from the header information, the method further includes: In case the system startup code copy fails and / or the system startup security verification information copy fails, downloading the backup firmware from the external storage device to the first memory to update the firmware in the first memory, and restarting the system; In the case that the system startup code fails to pass the verification, the backup firmware is downloaded from the external storage device to the first memory to update the firmware in the first memory, and the system is restarted.
5. The method according to claim 1, characterized in that After the system is started, the method further includes: When a preset time after the system is started is reached, determining that the system meets the loading condition; Upon receiving a loading instruction of the application part of the system, determining that the system satisfies the loading condition; When the processor usage rate of the system is lower than a preset usage rate, determining that the system meets the loading condition; When a call instruction of any one of the system applications is received, it is determined that the system meets the loading condition.
6. The method according to claim 2, characterized in that The step of loading the system application part of the firmware according to the header information to start the system application of the system includes: Acquire a third storage address of the system application code and a fourth storage address of the system application security verification information from the header information; According to the third storage address and the fourth storage address, copy the system application code and the system application security verification information in the first memory to the second memory of the system; In the second memory, verifying the system application code based on the system application security verification information; When the system application code passes the verification, the system application code is executed to start the system application.
7. The method according to claim 6, characterized in that After acquiring the third storage address and the fourth storage address from the header information, the method further includes: In case the system application code copying fails and / or the system application security verification information copying fails, downloading the backup firmware from the external storage device to the first memory to update the firmware in the first memory, and restarting the system; In the case that the system application code fails to pass the verification, the backup firmware is downloaded from the external storage device to the first memory to update the firmware in the first memory, and the system is restarted.
8. A segmented starting device for a system, characterized in that: include: A first loading module, used for loading a system startup part of the firmware according to the header information of the firmware when the system starts to be powered on, so as to start the system, wherein the firmware includes the header information, the system startup part and the system application part; The second loading module is used to load the system application part of the firmware according to the header information after the system is started and it is determined that the system meets any loading condition of the system application part to start the system application of the system.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.
Citation Information
Cited By
Firmware loading method and device of processor, storage medium and program product
CN121349563A
A processor firmware loading method, device, storage medium and program product
CN121349563B