A U-Boot-based secondary boot system and method

By using a U-Boot-based two-level boot system and employing SPL and U-Boot images with various compilation configurations, the problem of customized designs being unable to adapt to multiple board-level environments is solved, improving loading success rate and boot reliability, and shortening system boot time.

CN119396478BActive Publication Date: 2025-12-1258TH RES INST OF CETC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411542349.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-12-12
Estimated Expiration
2044-10-31

AI Technical Summary

Technical Problem

The existing secondary boot program is a customized design that cannot be adapted to various board-level environments, and it reduces system boot reliability and prolongs boot time when a single media loading fails.

Method used

A two-level boot system based on U-Boot was designed. Through various compilation configurations of SPL and U-Boot images, it supports multiple board-level environments. In the event of media loading failure, a redundant process and dynamic configuration of the bootargs environment variable are adopted to realize the step-by-step transfer and loading of media.

Benefits of technology

It achieves the universality of the two-level boot program, improves the success rate of media loading and the reliability of system startup, and shortens the startup time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396478B_ABST
    Figure CN119396478B_ABST
Patent Text Reader

Abstract

The application relates to a U-Boot-based secondary starting system and method, wherein the secondary starting system comprises a master control chip, the master control chip is internally integrated with a ROM, an SRAM and special registers, the ROM is internally solidified with a ROMCODE, the secondary starting method is realized through a secondary starting program, the secondary starting program comprises two kinds of images, namely an SPL and a U-Boot, the U-Boot image is divided into two kinds through execution of different board-level compiling configurations, and the two kinds are respectively a u-boot.img without integrated firmware and a u-boot.itb with integrated firmware, and the secondary starting method comprises two stages, namely an SPL loading U-Boot stage and a U-Boot loading operating system stage.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of embedded system, in particular to a secondary starting system and method based on U-Boot. BACKGROUND

[0002] In the starting process of the master control chip, the secondary starting program is usually between the ROMCODE of the master control chip and the operating system; after the chip is powered on, the in-chip ROMCODE is started first, then the secondary starting program in the external starting medium is loaded, and finally the operating system is loaded by the secondary starting program to complete the starting process.

[0003] U-Boot is the abbreviation of "the Universal Boot Loader", which is an open source bootloader project; U-Boot, as a commonly used open source secondary starting program, is widely used in the field of embedded devices, has become a de facto standard in the field of embedded Linux devices, and is a mainstream bootloader.

[0004] At present, in actual application, for a specific board-level environment, the secondary starting program is usually designed in a customized manner and is only applicable to one board-level environment; the secondary starting program generally only supports one starting medium on board, loads the software image in the starting medium, and if the loading fails, the current starting fails; for the case of supporting multiple starting media, the starting order of these starting media is generally fixed, that is, after the previous starting medium fails to load, the subsequent starting medium is used for starting. Here, the loading failure generally includes an error in the external medium reading process or a data verification failure in loading the image.

[0005] In summary, the existing secondary starting program and starting method usually have the following shortcomings:

[0006] 1) The secondary starting program is designed in a customized manner and cannot adapt to multiple board-level environments;

[0007] 2) For the case of supporting only one starting medium, the failure of the medium to start will reduce the reliability of the normal starting of the system;

[0008] 3) For the case of supporting multiple starting media in a fixed order, since the previous starting medium fails to load, the subsequent starting medium can only be used for loading, which prolongs the overall starting time of the system. SUMMARY

[0009] To solve the above technical problems, the application provides a secondary starting system based on U-Boot, a hardware part of the secondary starting system comprises a master control chip, the master control chip is internally integrated with a ROM, a SRAM and a special register, wherein the ROM is internally solidified with a ROMCODE; meanwhile, the master control chip is externally connected with a starting medium, a DDR and a serial port through an output input interface, the starting medium comprises a starting medium I and a starting medium II, the starting medium I and the starting medium II both store an image file (including SPL, U-Boot, an operating system and a file system) required by system starting, the DDR provides a loading and running storage space for the image file, and the serial port is used for outputting system starting log.

[0010] A software part of the secondary starting system comprises a secondary starting program, the secondary starting program comprises two kinds of images of SPL and U-Boot; by executing different board-level compiling configurations, the U-boot image is divided into two kinds, u-boot.img without firmware and u-boot.itb with firmware.

[0011] In an embodiment of the application, the SPL first reads the starting medium code transmitted by the ROMCODE; then the SPL loads the U-Boot image according to a corresponding set of starting medium in sequence, and transmits the successfully loaded starting medium code to the U-Boot; the U-Boot loads the operating system image according to the starting medium code transmitted by the SPL in sequence, and prints the medium type information used through the serial port.

[0012] Different board-level compiling configurations are carried by compiling script files, which include different board-level compiling configurations corresponding to different compiling options, and the secondary starting program suitable for different boards is generated by executing the compiling script + option.

[0013] In an embodiment of the application, the U-Boot is compiled once, and two kinds of images of SPL and U-Boot are generated, wherein the ROMCODE starts the SPL, and the SPL starts the U-Boot; by executing different board-level compiling configurations, the U-boot image is divided into two kinds of u-boot.img without firmware and u-boot.itb with firmware, wherein u-boot.itb is the packaging format of the firmware and u-boot.bin file; for the RISCV architecture, the corresponding firmware is OpenSBI.

[0014] In the present application also provides a kind of secondary start method based on U-Boot, the secondary start method is based on secondary start system design, including two stages of SPL loading U-boot and U-boot loading operating system, SPL loading U-boot stage, including the following steps:

[0015] Step S11: after SPL starts running, first read the boot medium code passed from ROMCODE, and the boot medium code is stored in the special register in the internal master chip;

[0016] Step S12: then a set of boot medium sequence corresponding to boot medium code is loaded U-boot image;If the current boot medium loads U-boot image successfully, then no longer load the subsequent boot medium in this group, and maintain boot medium code, and the medium code of successful loading is written into special register;

[0017] Step S13: if the current boot medium loads U-boot image fails, then load U-boot image in the next boot medium according to the boot medium sequence in this group;If all boot media in this group all load U-boot image fail, then print the information of loading U-boot failure through serial port.

[0018] In an embodiment of the present application, U-boot loads operating system stage, including the following steps:

[0019] Step S21: after U-boot starts running, first read the boot medium code passed from SPL, and the boot medium code is stored in the special register in the internal master chip;

[0020] Step S22: then a set of boot medium sequence corresponding to boot medium code is loaded operating system image;If the current boot medium loads operating system image successfully, then no longer load the subsequent boot medium in this group;

[0021] Step S23: if the current boot medium loads operating system image fails, then load operating system image in the next boot medium according to the boot medium sequence in this group;If all boot media in this group all load operating system image fail, then print the information of loading operating system failure through serial port.

[0022] In one embodiment of the present application, the SPL first reads the boot medium code, the boot medium code is divided into '01' and '02', wherein the boot medium sequence corresponding to '01' is boot medium I, boot medium II, and the boot medium sequence corresponding to '02' is boot medium II, boot medium I; when the boot medium code is '01', the SPL first loads the U-boot image in the boot medium I, if the U-boot image in the boot medium I is loaded successfully, '01' is written into the special register; if the U-boot image in the boot medium I fails to be loaded, the U-boot image in the boot medium II is continuously loaded, if the U-boot image in the boot medium II is loaded successfully, '02' is written into the special register, otherwise, the U-boot loading failure information is printed through the serial port, and the present boot process is ended.

[0023] In one embodiment of the present application, when the boot medium code is '02', the SPL first loads the U-boot image in the boot medium II, if the U-boot image in the boot medium II is loaded successfully, '02' is written into the special register; if the U-boot image in the boot medium II fails to be loaded, the U-boot image in the boot medium I is continuously loaded, if the U-boot image in the boot medium I is loaded successfully, '01' is written into the special register, otherwise, the U-boot loading failure information is printed through the serial port, and the present boot process is ended.

[0024] In one embodiment of the present application, the U-boot first reads the boot medium code, the boot medium code is divided into '01' and '02', wherein the boot medium sequence corresponding to '01' is boot medium I, boot medium II, and the boot medium sequence corresponding to '02' is boot medium II, boot medium I. When the boot medium code is '01', the U-boot first loads the operating system image in the boot medium I, if the operating system image in the boot medium I is loaded successfully, '01' is written into the special register, and the bootargs environment variable is configured, the bootargs is configured to load the file system in the boot medium I, for the subsequent operating system startup file system; if the operating system image in the boot medium I fails to be loaded, the operating system image in the boot medium II is continuously loaded, if the operating system image in the boot medium II is loaded successfully, '02' is written into the special register, and the bootargs environment variable is configured, the bootargs is configured to load the file system in the boot medium II, for the subsequent operating system startup file system, otherwise, the operating system loading failure information is printed through the serial port, and the present boot process is ended.

[0025] In one embodiment of the present application, when the starting medium code is '02', U-boot first loads the operating system image in the starting medium II, if the operating system image in the starting medium II is loaded successfully, '02' is written into the special register, and the bootargs environment variable is configured, the bootargs is configured to load the file system in the starting medium II for the subsequent operating system to start the file system; if the operating system image in the starting medium II fails to load, the operating system image in the starting medium I is loaded, if the operating system image in the starting medium I is loaded successfully, '01' is written into the special register, and the bootargs environment variable is configured, the bootargs is configured to load the file system in the starting medium I for the subsequent operating system to start the file system, otherwise, the information of loading the operating system is printed through the serial port, and the starting process is ended.

[0026] The above technical solution of the present application has the following advantages compared with the prior art:

[0027] The compilation options of multiple boards are supported to support multiple board environments, and the universality of the two-level starting program is realized.

[0028] The redundant process design of the starting medium of SPL and U-Boot is realized, and the success rate and reliability of the image file in the starting medium are improved.

[0029] The dynamic configuration and step-by-step transmission of the starting medium code and the bootargs environment variable are realized, and the system starting speed is accelerated for some starting medium loading failure. BRIEF DESCRIPTION OF DRAWINGS

[0030] In order to make the content of the present application more easily understood, the present application will be further described in detail below according to the specific embodiments of the present application and in combination with the drawings.

[0031] Figure 1 is a schematic diagram of the hardware part of the two-level starting system based on U-Boot of the present application;

[0032] Figure 2 is a schematic diagram of the software process of the two-level starting method based on U-Boot of the present application. DETAILED DESCRIPTION

[0033] As Figure 1As shown in the embodiment, a secondary boot system based on U-Boot is provided, and a hardware part of the secondary boot system includes a master control chip, the master control chip is integrated with a ROM, an SRAM and a special register, the ROM stores a ROMCODE, and the master control chip is connected with a boot medium, a DDR and a serial port through an input and output interface, the boot medium includes a boot medium I and a boot medium II, the boot medium I and the boot medium II store image files (including an SPL, a U-Boot, an operating system and a file system) required by system boot, the DDR provides a loading and running storage space for the image files, and the serial port is used for outputting a system boot log.

[0034] As shown in the embodiment, a secondary boot system based on U-Boot is provided, and a hardware part of the secondary boot system includes a master control chip, the master control chip is integrated with a ROM, an SRAM and a special register, the ROM stores a ROMCODE, and the master control chip is connected with a boot medium, a DDR and a serial port through an input and output interface, the boot medium includes a boot medium I and a boot medium II, the boot medium I and the boot medium II store image files (including an SPL, a U-Boot, an operating system and a file system) required by system boot, the DDR provides a loading and running storage space for the image files, and the serial port is used for outputting a system boot log. Figure 2 As shown in the embodiment, a secondary boot system based on U-Boot is provided, and a hardware part of the secondary boot system includes a master control chip, the master control chip is integrated with a ROM, an SRAM and a special register, the ROM stores a ROMCODE, and the master control chip is connected with a boot medium, a DDR and a serial port through an input and output interface, the boot medium includes a boot medium I and a boot medium II, the boot medium I and the boot medium II store image files (including an SPL, a U-Boot, an operating system and a file system) required by system boot, the DDR provides a loading and running storage space for the image files, and the serial port is used for outputting a system boot log.

[0035] . / build.sh riscv_board_config.

[0036] By executing a make menuconfig command, a U-Boot compiling configuration interface is opened, an SPL configuration is enabled, and the secondary boot program generated by compiling the U-Boot includes two kinds of images, namely, an SPL and a U-Boot, wherein the ROMCODE loads the SPL, and the SPL loads the U-Boot.

[0037] By executing different board-level compiling configurations, the generated U-boot image is divided into two kinds, namely, a u-boot.img without integrating firmware and a u-boot.itb integrating firmware, and the u-boot.itb is a packaging format of the firmware and the u-boot.bin file. Different firmwares are selected for different hardware architectures, and the firmware selected for the RISCV architecture is OpenSBI.

[0038] For the u-boot.itb integrating firmware, an.its source file is added to a corresponding board-level source file directory, a U-Boot compiling configuration interface is opened by executing a make menuconfig, and a corresponding.its source file path is configured. For example, the.its source file of the RISCV architecture can be named riscv_opensbi.its.

[0039] For the above u-boot.img without integrated firmware, no board-level.its source file needs to be added.

[0040] As shown in Figure 1 The master chip is integrated with ROM, SRAM and special registers; the ROMCODE is fixed in the ROM, the ROMCODE starts running after the master chip is powered on, the ROMCODE loads the SPL in the external starting medium, and writes the successfully loaded starting medium code into the special registers for subsequent reading and use after the SPL is started; the SRAM provides loading and running storage space for the integrated firmware of the SPL and U-boot.

[0041] The starting medium I and the starting medium II store the image files required for system startup, including SPL, U-Boot, operating system and file system. The starting medium I and the starting medium II are non-volatile storage media, including MMC, QSPI flash, NOR flash, SATA disk and NVMe SSD, etc., wherein the MMC includes subtypes such as TF card, SD card and eMMC.

[0042] The DDR provides loading and running storage space for U-Boot, operating system and file system.

[0043] The serial port is used to output system startup log, including startup process, U-boot loading result, operating system loading result and other information.

[0044] As shown in Figure 2 Each set of starting medium used in the software flow of the two-stage starting method based on U-Boot includes two types, in the embodiment, the starting medium I uses MMC, and the starting medium II uses NVMe SSD.

[0045] The above flow includes two stages of SPL loading U-boot and U-boot loading operating system.

[0046] In the SPL loading U-boot stage, the SPL first reads the boot medium code, and the boot medium code is divided into '01' and '02', wherein '01' corresponds to the boot medium sequence of MMC, NVMe SSD, and '02' corresponds to the boot medium sequence of NVMe SSD, MMC. When the boot medium code is '01', the SPL first loads the U-boot image in the MMC, and if the U-boot image in the MMC is loaded successfully, '01' is written to the special register; if the U-boot image in the MMC fails to be loaded, the U-boot image in the NVMe SSD is continued to be loaded, and if the U-boot image in the NVMe SSD is loaded successfully, '02' is written to the special register, otherwise the information of U-boot loading failure is printed through the serial port, and the current startup process is ended. When the boot medium code is '02', the SPL first loads the U-boot image in the NVMe SSD, and if the U-boot image in the NVMe SSD is loaded successfully, '02' is written to the special register; if the U-boot image in the NVMe SSD fails to be loaded, the U-boot image in the MMC is continued to be loaded, and if the U-boot image in the MMC is loaded successfully, '01' is written to the special register, otherwise the information of U-boot loading failure is printed through the serial port, and the current startup process is ended.

[0047] During the U-boot operating system loading phase, U-boot first reads the boot media code, which is divided into '01' and '02'. '01' corresponds to the boot media order of MMC, then NVMe SSD, while '02' corresponds to the boot media order of NVMe SSD, then MMC. When the boot media code is '01', U-boot first loads the operating system image from the MMC. If the MMC operating system image loads successfully, '01' is written to a dedicated register, and the bootargs environment variable is configured to load the file system from the MMC for subsequent operating system boots. If the MMC operating system image fails to load, the U-boot continues loading the operating system image from the NVMe SSD. If the NVMe SSD operating system image loads successfully, '02' is written to a dedicated register, and the bootargs environment variable is configured to load the file system from the NVMe SSD for subsequent operating system boots. Otherwise, a failure message is printed via serial port, ending the current boot process. When the boot media code is '02', U-boot first loads the operating system image within the NVMe SSD. If the NVMe SSD operating system image loads successfully, '02' is written to a dedicated register, and the bootargs environment variable is configured to load the file system within the NVMe SSD for use by the subsequent operating system booting file system. If the NVMe SSD operating system image fails to load, it continues to load the operating system image within the MMC. If the MMC operating system image loads successfully, '01' is written to a dedicated register, and the bootargs environment variable is configured to load the file system within the MMC for use by the subsequent operating system booting file system. Otherwise, the boot process ends by printing the operating system loading failure information via the serial port.

[0048] In the two-level startup system described in this embodiment, build.sh is the compilation script, and board1_config and board2_config are the compilation options for board1 and board2, respectively.

[0049] The compilation command to generate the board-level secondary bootloader is: . / build.sh board1_config;

[0050] The compilation command to generate the board2 secondary bootloader is: . / build.sh board2_config.

[0051] By enabling the SPL configuration of U-Boot, the compiled U-Boot generates a secondary boot program including two images of SPL and U-Boot, wherein the ROMCODE loads the SPL, and the SPL loads the U-boot.

[0052] By executing different board-level compilation configurations, the generated U-boot image is divided into two types, namely u-boot.img without firmware integration and u-boot.itb with firmware integration, and the u-boot.itb is a packaging format of the firmware and the u-boot.bin file. For different hardware architectures, different firmwares are selected; preferably, for the RISCV architecture, the selected firmware is OpenSBI.

[0053] Obviously, the above embodiments are only examples for the purpose of clear illustration, and are not limitations on the embodiments. Based on the above description, other different forms of changes or variations can be made by those of ordinary skill in the art. Here, it is not necessary and impossible to enumerate all the embodiments. The obvious changes or variations derived therefrom are still within the protection scope of the present application.

Claims

1. A U-Boot based secondary boot system, characterized in that, The hardware part of the secondary starting system comprises a master control chip, the master control chip is internally integrated with ROM, SRAM and a special register, the ROM is internally solidified with ROMCODE, meanwhile, the master control chip is externally connected with starting media, DDR and a serial port through an input and output interface, the starting media comprises starting media I and starting media II, the starting media I and the starting media II both store image files required by system starting, the DDR provides loading and running storage space for the image files, and the serial port is used for outputting system starting log; Meanwhile, the software part of the secondary starting system comprises a secondary starting program, and the secondary starting program comprises two kinds of images, SPL and U-Boot; by executing different board-level compilation configurations, the U-Boot image is divided into two kinds, u-boot.img without firmware and u-boot.itb with firmware; Different board-level compilation configurations are carried by a compilation script file, which comprises different board-level compilation configurations corresponding to different compilation options, and the secondary starting program suitable for different boards is generated by executing the compilation script + compilation options; The SPL is configured to read the starting media code transmitted by the ROMCODE, load the U-Boot image according to a group of starting media corresponding to the starting media code in sequence, and write the successfully loaded starting media code into the special register to transmit to the U-Boot; The U-Boot is configured to read the starting media code transmitted by the SPL, load the operating system image according to a group of starting media corresponding to the starting media code in sequence, and print the used media type information through the serial port.

2. The two-stage starting system of claim 1, wherein: The SPL first reads the starting media code transmitted by the ROMCODE; then the SPL loads the U-Boot image according to a corresponding group of starting media in sequence, and transmits the successfully loaded starting media code to the U-Boot; The U-Boot loads the operating system image according to the starting media code transmitted by the SPL, according to a corresponding group of starting media in sequence, and prints the used media type information through the serial port.

3. The two-stage starting system of claim 1, wherein: The U-Boot is compiled once, and two kinds of images, SPL and U-Boot, are generated, wherein the ROMCODE starts the SPL, and the SPL starts the U-Boot; by executing different board-level compilation configurations, the U-Boot image is divided into two kinds, u-boot.img without firmware and u-boot.itb with firmware, wherein u-boot.itb is the packaging format of the firmware and u-boot.bin file; for the RISCV architecture, the corresponding firmware is OpenSBI.

4. A U-Boot based secondary boot method, based on the secondary boot system design in claim 1, comprising two stages of SPL loading U-boot and U-boot loading operating system, characterized in that: The SPL loading U-Boot stage comprises the following steps: Step S11: after the SPL starts running, the starting media code transmitted by the ROMCODE is first read, and the starting media code is stored in the special register inside the master control chip; Step S12: Then the U-boot image is loaded in sequence according to the group of boot media corresponding to the boot media code; If the current boot media successfully loads the U-boot image, the subsequent boot media in the group is not loaded any more, and the boot media code is written into the special register; Step S13: If the current boot media fails to load the U-boot image, the U-boot image in the next boot media is loaded in sequence according to the group of boot media; If all the boot media in the group fails to load the U-boot image, the information of the failed U-boot loading is printed through the serial port.

5. The two-stage start-up method of claim 4, wherein: The U-boot loading operation system stage includes the following steps: Step S21: After the U-boot starts running, the boot media code passed by the SPL is read first, and the boot media code is stored in the special register in the main control chip; Step S22: Then the operation system image is loaded in sequence according to the group of boot media corresponding to the boot media code; if the current boot media successfully loads the operation system image, the subsequent boot media in the group is not loaded any more; Step S23: If the current boot media fails to load the operation system image, the operation system image in the next boot media is loaded in sequence according to the group of boot media; If all the boot media in the group fails to load the operation system image, the information of the failed operation system loading is printed through the serial port.

6. The two-stage start-up method of claim 4, wherein: The SPL first reads the boot media code, and the boot media code is divided into '01' and '02', wherein the boot media sequence corresponding to '01' is boot media I and boot media II, and the boot media sequence corresponding to '02' is boot media II and boot media I; When the boot media code is '01', the SPL first loads the U-boot image in the boot media I, if the U-boot image in the boot media I is successfully loaded, '01' is written into the special register; if the U-boot image in the boot media I fails to be loaded, the U-boot image in the boot media II is loaded, if the U-boot image in the boot media II is successfully loaded, '02' is written into the special register, otherwise the information of the failed U-boot loading is printed through the serial port, and the current starting process is ended.

7. The two-stage start-up method of claim 6, wherein: When the boot media code is '02', the SPL first loads the U-boot image in the boot media II, if the U-boot image in the boot media II is successfully loaded, '02' is written into the special register; If the U-boot image in the boot media II fails to be loaded, the U-boot image in the boot media I is loaded, if the U-boot image in the boot media I is successfully loaded, '01' is written into the special register, otherwise the information of the failed U-boot loading is printed through the serial port, and the current starting process is ended.

8. The two-stage start-up method of claim 5, wherein: The U-boot first reads the boot media code, and the boot media code is divided into '01' and '02', wherein the boot media sequence corresponding to '01' is boot media I and boot media II, and the boot media sequence corresponding to '02' is boot media II and boot media I; When the boot medium code is '01', U-boot first loads the operating system image in the boot medium I, if the operating system image in the boot medium I is loaded successfully, '01' is written into the special register, and the bootargs environment variable is configured, the bootargs is configured to load the file system in the boot medium I, for the subsequent operating system to start the file system; If the operating system image in the boot medium I fails to load, the operating system image in the boot medium II is loaded, if the operating system image in the boot medium II is loaded successfully, '02' is written into the special register, and the bootargs environment variable is configured, the bootargs is configured to load the file system in the boot medium II, for the subsequent operating system to start the file system, otherwise the serial port is printed to print the operating system loading failure information, and the current boot process is ended.

9. The two-stage start-up method of claim 8, wherein: When the boot medium code is '02', U-boot first loads the operating system image in the boot medium II, if the operating system image in the boot medium II is loaded successfully, '02' is written into the special register, and the bootargs environment variable is configured, the bootargs is configured to load the file system in the boot medium II, for the subsequent operating system to start the file system; if the operating system image in the boot medium II fails to load, the operating system image in the boot medium I is loaded, if the operating system image in the boot medium I is loaded successfully, '01' is written into the special register, and the bootargs environment variable is configured, the bootargs is configured to load the file system in the boot medium I, for the subsequent operating system to start the file system, otherwise the serial port is printed to print the operating system loading failure information, and the current boot process is ended.

Citation Information

Patent Citations

  • Embedded system, control method and device thereof and storage medium

    CN113485764A

  • Multi-core processor first-level startup program architecture based on U-Boot

    CN114489821A