Multi-system starting guiding method based on multi-core processor
By adopting a multi-system startup and boot method on multi-core processors, the problems of high cost and performance loss caused by virtualization technology are solved, the effect of running multiple operating systems on multi-core processors at the same time is achieved, and the system is prevented from being interference between.
Patent Information
- Application Number
- CN202410872325.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-10-01
AI Technical Summary
The existing technology has problems of high cost and performance loss when running multiple operating systems, especially when virtualization technology is used, and the performance loss is even greater on processors that do not support hardware virtualization.
A multi-system startup and boot method based on multi-core processors is proposed. System startup is achieved through steps S1-S6, including each processor core starting execution from the on-chip firmware after power-on, determining the first core, and sleeping except for the first core. External core, complete memory and serial port initialization, determine and load the system of the master core and slave core, and prevent interference and influence between systems.
It achieves the effect of running multiple operating systems simultaneously on a multi-core processor hardware platform, avoids the performance loss caused by virtualization technology, and prevents mutual interference and influence between multiple systems.
Smart Images

Figure CN118733131A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of system startup, and specifically provides a multi-system startup booting method based on a multi-core processor. Background Art
[0002] With the development of hardware, processor performance is getting stronger and stronger. Each processor has multiple CPU cores, so the demand for running multiple operating systems on one processor is becoming more and more urgent. Most manufacturers use virtualization technology to implement a platform to run multiple operating systems at the same time through an operating system plus a virtual machine solution. However, this solution has the following two disadvantages: 1. Requires separate virtualization software Virtualization solutions require the installation of software that supports virtualization, such as qemu. However, most embedded virtualization software is expensive and requires targeted customization, so virtualization solutions are not universal.
[0003] 2. Performance loss After adopting virtualization technology, all system operations will be intercepted by the virtualization software, and each operation will have a certain performance loss, especially on processors that do not support hardware virtualization, the performance loss will be even greater. Summary of the invention
[0004] In order to overcome the above-mentioned defects, the present invention is proposed to solve the technical problems of high cost and performance loss in running multiple systems in the prior art.
[0005] The present invention proposes a multi-system booting method based on a multi-core processor, comprising the steps of: S1: After power-on, each processor core starts executing from the on-chip firmware and determines the first core from all processor cores; S2: Sleep all processor cores except the first core; S3: Initialize the memory and serial port through the first core; S4: Determine whether there is a system other than the first core as the main core to be loaded. If so, select a system other than the first core as the main core to execute step S5. If not, select the system of the first core as the main core to execute step S6. S5: The first core starts to load the current system, and after the loading is completed, it returns to step S4; S6: The first core starts to load the current system, and after loading is completed, the boot process ends.
[0006] Further, the on-chip firmware includes a uboot boot program, and the step S2 includes: The uboot boot program determines whether it is running on the first core. If not, it puts the current processor core into sleep mode. Furthermore, the step S1 also includes moving the uboot boot program to the computer memory, and all processor cores jump to the uboot boot program to start execution.
[0007] Further, the step S5 comprises the steps of: S51: Move the kernel and file system of the current system to the computer memory through the first core; S52: Setting the operating environment of the processor core serving as the main core of the current system; S53: wake up the processor core that is the main core of the current system, run the current system, and complete the loading of the current system; S54: Return to step S4.
[0008] Furthermore, the step S53 further includes: when there is a slave core in the current system, setting the startup address of the processor core as the slave core of the current system through the current system, and waking up the processor core as the slave core of the current system.
[0009] Further, the step S6 comprises the steps of: S61: Move the kernel and file system of the current system to the computer memory through the first core; S62: The first core runs the current system and completes loading the current system; S63: The boot process ends.
[0010] Furthermore, the step S62 further includes: when there is a slave core in the current system, setting the startup address of the processor core that serves as the slave core of the current system through the current system, and waking up the processor core that serves as the slave core of the current system.
[0011] Working principle and beneficial effects of the present invention: In the technical solution of the present invention, after the system is powered on, the uboot boot program is started. The uboot boot program first puts all processor cores other than the first core into sleep mode, and completes the initialization of the memory and serial port through the first core. Then, all systems other than the first core as the main core are loaded, and finally the system with the first core as the main core is loaded to complete the entire boot process. The effect of running multiple operating systems simultaneously on a hardware platform of a multi-core processor is achieved, and interference and influence between multiple systems can be prevented. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The disclosure of the present invention will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present invention. In addition, similar numbers in the figures are used to represent similar components, among which: Figure 1This is a schematic flow chart of the main steps of a multi-system booting method based on a multi-core processor of the present invention; Figure 2 It is a flowchart of the boot process in Embodiment 2 of the present invention. DETAILED DESCRIPTION
[0013] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention. Example 1
[0014] Figure 1 This is a schematic flow chart of the main steps of a multi-system boot method based on a multi-core processor of the present invention. Figure 1 As shown, a multi-system booting method based on a multi-core processor in this embodiment mainly includes the following steps S1 to S6.
[0015] Step S1: After power-on, each processor core starts to execute from the on-chip firmware, and at the same time determines the first core from all processor cores.
[0016] When the power is turned on, all the cores of the processor are in reset state. After reset, the processor core starts to execute the first instruction from a predefined address. This address usually points to the on-chip firmware (Boot ROM / Bootloader). Each processor core starts to execute from the same Boot ROM or Bootloader code. By obtaining the value in the numbered register in the processor, if this value is 0, it means that this is the first core of the processor, that is, CPU1.
[0017] Furthermore, when the power is turned on, the uboot boot program is moved to the computer memory, and all processor cores jump to the uboot boot program to start execution.
[0018] In this embodiment, the migration process is performed by the internal firmware of the processor, which has two functions: 1. The uboot boot program is placed in the flash with limited erase and write times. Running the uboot boot program directly on the flash may cause data corruption. Moving the uboot boot program to the memory and allowing the flash to only read but not write can avoid the erase and write times limit of the flash memory. 2. The execution speed of the memory is faster than that of the flash.
[0019] Step S2: hibernate the processor cores except the first core.
[0020] Specifically, all processor cores run the same uboot boot program, which is a type of on-chip firmware. The uboot boot program code determines the processor core currently executing the uboot boot program. If the processor core executing the uboot boot program is not the first core, the current processor core is put into hibernation, and the uboot boot program executed by the current processor core is also suspended. After step S2, only the first core is still running.
[0021] Step S3: Initialize the memory and serial port through the first core.
[0022] Step S4: Determine whether there is a system to be loaded that is not the first core as the main core. If so, select a system that is not the first core as the main core to execute step S5. If not, select a system that is the first core as the main core to execute step S6.
[0023] Step S5: The first core starts to load the current system, and returns to step S4 after the loading is completed.
[0024] Specifically, step S5 includes steps S51-S54.
[0025] S51: The kernel and Ramdisk file system of the current system are moved to the computer memory through the first core. At this time, the memory range and device resources need to be planned to prevent interference between multiple systems.
[0026] Memory planning mainly refers to the planning of memory layout. For example, if the hardware has 4G memory and runs two systems, the 0-2G memory can be allocated to the first system, and the 2-4G memory can be allocated to the second system, separated from the physical memory. The device resources are similar. For example, if the hardware device has two physical network cards and runs two systems, the hardware resources of the first network card can be allocated to the first system, and the hardware resources of the second network card can be allocated to the second system. All of this information will eventually be reflected in the device tree, which contains information about all hardware resources in each system.
[0027] S52: Set the operating environment of the processor core as the main core of the current system. The PC register is a register in the processor, which is used to store the address of the currently executed instruction. It is also a configuration parameter in the operating environment set in step S52. Here, the value of the PC register is set to the kernel address of the current system.
[0028] S53: wake up the processor core as the master core of the current system, run the current system, and when there is a slave core in the current system, set the startup address of the processor core as the slave core of the current system through the current system, wake up the processor core as the slave core of the current system, and complete the loading of the current system. Here, wake up means executing the wake-up instruction. Taking E2000Q as an example, the SEV instruction is executed here.
[0029] S54: Return to step S4.
[0030] Step S6: The first core starts to load the current system, and after the loading is completed, the boot is completed.
[0031] Specifically, step S6 includes steps S61-S63.
[0032] S61: Move the kernel and file system of the current system to the computer memory through the first core; at this time, it is necessary to plan the memory range and device resources to prevent interference between multiple systems.
[0033] S62: The first core runs the current system. When a slave core exists in the current system, the startup address of the processor core that serves as the slave core of the current system is set through the current system, and the processor core that serves as the slave core of the current system is awakened to complete the loading of the current system.
[0034] S63: The boot process ends.
[0035] Based on the above steps S1 to S6, the uboot boot program is started after the system is powered on. The uboot boot program first puts all processor cores other than the first core into sleep mode, and completes the initialization of the memory and serial port through the first core. Then, all systems other than the first core as the main core are loaded, and finally the system with the first core as the main core is loaded to complete the entire boot process. This achieves the effect of running multiple operating systems simultaneously on a hardware platform of a multi-core processor, and can prevent interference and influence between multiple systems.
[0036] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effects of the present invention, different steps do not have to be performed in such an order, and they can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention. Example 2
[0037] Based on the above multi-system boot method based on a multi-core processor, this embodiment takes a single E2000Q processor as an example to implement running multiple operating systems on a single board hardware at the same time. Figure 2 Schematic diagram of the process of starting the boot process in Embodiment 2 of the present invention. Figure 2As shown, E2000Q has four cores, which are hereinafter represented as CPU1, CPU2, CPU3, and CPU4, so a maximum of four systems can be run, corresponding to one system running on each processor core. However, one system can also occupy multiple cores. In this embodiment, a solution of running two systems on E2000Q is implemented. The first system configures CPU3 as the master core and CPU4 as the slave core, and the second system configures CPU1 as the master core and CPU2 as the slave core.
[0038] A. Power on and start After power-on, all four processor cores start to execute from the on-chip firmware. At this time, the four processor cores CPU1, CPU2, CPU3, and CPU4 are determined, the uboot boot program is moved to the memory, and jumps to uboot execution.
[0039] B. Sleep non-CPU1 CPU1, CPU2, CPU3, and CPU4 will all run the uboot boot program once. During this process, CPU2, CPU3, and CPU4 will go into sleep mode through the uboot boot program.
[0040] C. First load the system with non-CPU1 as the main core First load the first system (CPU3 as the master core, CPU4 as the slave core), execute steps DF, then load the second system (CPU1 as the master core, CPU2 as the slave core), and execute step G.
[0041] D. Load the kernel, ramdisk, and device tree of the first system CPU1 moves the kernel and ramdisk of the first system from storage to memory. At this time, you need to plan the memory range and device resources to prevent interference between systems.
[0042] E. Setting up the environment Set up the relevant environment for waking up the first CPU3 to prepare for system operation, including the pointer value of the PC, etc.
[0043] F. Wake up CPU3, run the first system, set the startup address of CPU4 through the first system, wake up CPU4, and the first system is loaded.
[0044] G. Load the kernel, ramdisk, and device tree of the second system CPU1 moves the kernel and ramdisk of the second system from storage to memory. At this time, you need to plan the memory range to prevent interference between the first and second systems.
[0045] H.CPU1 starts the second system, which sets the startup address of CPU2 and wakes up CPU2. The loading of the second system is then completed.
[0046] In this embodiment, by modifying the process of the uboot boot program, the uboot two-boot system is implemented on the E2000 platform, thereby achieving the effect of running two operating systems on one hardware platform at the same time. To prevent the memory between the two systems from interfering and affecting each other, the physical memory and peripheral controller are well cut during the design. The first system is booted with CPU3 as the main core and CPU4 as the slave core. The second system is booted with CPU1 as the main core and CPU2 as the slave core.
[0047] Here are some terms involved in the present invention.
[0048] Uboot: is a boot loader, mainly used in the startup process of embedded systems.
[0049] Qemu: It is a pure software virtualization emulator that can simulate almost any hardware device. What we are most familiar with is the ability to simulate a virtual machine that can run an operating system independently.
[0050] Kernel: The kernel of the Linux system.
[0051] Ramdisk: Linux memory file system.
[0052] Device tree: describes the hardware resources used by the system.
[0053] CPU: Central Processing Unit.
[0054] CPU1: the first core of a multi-core processor. The CPU1 mentioned in the present invention refers to the first core of the E2000Q processor.
[0055] CPU2: the second core of a multi-core processor. The CPU2 mentioned in the present invention refers to the second core of the E2000Q processor.
[0056] CPU3: the third core of a multi-core processor. The CPU3 mentioned in the present invention refers to the third core of the E2000Q processor.
[0057] CPU4: the fourth core of a multi-core processor. The CPU4 mentioned in the present invention refers to the fourth core of the E2000Q processor.
[0058] E2000Q: Feiteng's embedded processor model, this processor has four cores.
[0059] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
Claims
1. A multi-system boot method based on a multi-core processor, It is characterized in that Includes steps: S1: After power-on, each processor core starts executing from the on-chip firmware and determines the first core from all processor cores; S2: Sleep all processor cores except the first core; S3: Initialize the memory and serial port through the first core; S4: Determine whether there is a system other than the first core as the main core to be loaded. If so, select a system other than the first core as the main core to execute step S5. If not, select the system of the first core as the main core to execute step S6. S5: The first core starts to load the current system, and after the loading is completed, it returns to step S4; S6: The first core starts to load the current system, and after loading is completed, the boot process ends.
2. A multi-system booting method based on a multi-core processor according to claim 1, It is characterized in that The on-chip firmware includes a uboot boot program, and step S2 includes: The uboot boot program determines whether it is running on the first core. If not, it puts the current processor core into hibernation.
3. A multi-system booting method based on a multi-core processor according to claim 2, It is characterized in that The step S1 also includes moving the uboot boot program to the computer memory, and all processor cores jump to the uboot boot program to start execution.
4. The multi-system booting method based on a multi-core processor according to claim 1, It is characterized in that The step S5 comprises the steps of: S51: Move the kernel and file system of the current system to the computer memory through the first core; S52: Setting the operating environment of the processor core serving as the main core of the current system; S53: wake up the processor core that is the main core of the current system, run the current system, and complete the loading of the current system; S54: Return to step S4.
5. A multi-system booting method based on a multi-core processor according to claim 4, It is characterized in that The step S53 further includes: when there is a slave core in the current system, setting the startup address of the processor core serving as the slave core of the current system through the current system, and waking up the processor core serving as the slave core of the current system.
6. A multi-system booting method based on a multi-core processor according to claim 1, It is characterized in that The step S6 comprises the steps of: S61: Move the kernel and file system of the current system to the computer memory through the first core; S62: The first core runs the current system and completes loading the current system; S63: The boot process ends.
7. A multi-system booting method based on a multi-core processor according to claim 6, It is characterized in that The step S62 further includes: when there is a slave core in the current system, setting the startup address of the processor core serving as the slave core of the current system through the current system, and waking up the processor core serving as the slave core of the current system.
