RISC-v oriented scalable segmented automated image build technology
By using segmented automated image building technology, the problem of Linux system images for RISC-V hardware devices being incompatible and not automatically built has been solved, realizing an efficient and automated image building process that is applicable to a variety of RISC-V hardware and systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- KYLIN CORP
- Filing Date
- 2023-04-17
- Publication Date
- 2026-07-24
AI Technical Summary
Existing technologies cannot quickly build Linux system images suitable for different RISC-V hardware devices, and the building process requires high technical skills and cannot be automated.
The system employs segmented automated image building technology, which divides the image into four partitions by writing scripts and automatically configures the kernel, boot configuration, software sources, etc., based on hardware devices and system types, thereby achieving automated image building.
It improves image building efficiency, is applicable to various RISC-V hardware and system types, reduces technical requirements, and achieves image automation and scalability.
Smart Images

Figure CN116594640B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image building technology, and more specifically to a scalable, segmented, automated image building technology for RISC-V. Background Technology
[0002] CPUs and operating systems are the most fundamental and core technologies in the domestic IT innovation industry. In the past, China was dependent on foreign technology in these two areas. With the development of the domestic IT innovation industry, China has independently developed excellent domestic operating systems such as Kylin, which has alleviated the problem of dependence on foreign operating systems to some extent. In the CPU field, the mainstream CPU architectures are currently x86 and ARM, both of which are closed-source and their technology is monopolized by foreign companies. The domestically developed LoongArch architecture also suffers from weak performance, slow development, and an incomplete ecosystem. Currently, China urgently needs a CPU architecture that is both technologically unrestricted and high-performance.
[0003] RISC-V is an open-source, modular, secure, and reliable instruction set architecture. Through collaboration among open-source developers worldwide, the RISC-V instruction set architecture has developed rapidly and has become the third mainstream CPU architecture after x86 and ARM. China's domestic IT innovation industry has chosen RISC-V as a key development direction for domestically produced CPUs, and several companies, including SiFive, Alibaba's PingTouGe, and CelFive Technology, are currently developing RISC-V architecture CPUs and computers. Therefore, building Linux system images suitable for RISC-V hardware is a crucial task at present.
[0004] The RISC-V architecture is still in its early stages and has attracted many developers. Currently, the hardware interfaces of RISC-V development boards on the market are not standardized. This means that a single Linux system image cannot be adapted to all RISC-V hardware devices, and modifications to the configuration of the Linux kernel, boot process, and other parts of the image are required for it to function properly.
[0005] Currently, RISC-V architecture images cannot be installed using the common ISO method; they can only be installed using IMG images. Therefore, RISC-V architecture images cannot be directly built using ISO image building platforms. They can only be built manually as IMG images. Manual image building has drawbacks: slow build speed, high technical requirements for the builder, and the resulting image is only compatible with a specific RISC-V hardware device.
[0006] Therefore, there is an urgent need for a technology that can extend and automatically build images to solve the above problems. This technology can quickly build images suitable for different RISC-V hardware devices and different system types.
[0007] Chinese invention patent “A method, apparatus, device and medium for building virtual machine disk images” (application number 201911121547.6) describes an invention that builds virtual machine images using Docker containers.
[0008] The Chinese invention patent "A method for automatically generating an image environment" (application number CN115408102A) describes an invention that downloads a Linux system image or a Windows system image, creates a new image environment based on the original image, and automatically uploads the image to a Docker repository or open-source repository after creation. The automation in this patent refers only to the automatic uploading of the image.
[0009] Chinese invention patent “A method and system for constructing a Linux system image, and a Linux system image” (application number CN109614117A) describes an invention that manually constructs the Linux system boot part in the image and stores the root file system therein, constructs the Linux system runtime part in the image, and then packages the Linux system boot part and runtime part to generate a system image file.
[0010] Chinese invention patent "A System Image Construction Method, System, Computing Device, and Storage Medium" (application number CN112114834A) describes an invention that is manually executed in a control terminal. The control terminal connects to multiple execution terminals, receives image customization instructions from the user, creates an image customization interface, receives image customization information from the user through the image customization interface, generates image customization tasks based on the image customization information, inserts the image customization tasks into a customization task list so that the execution terminals can obtain the corresponding image customization tasks and construct the target image, and receives the status attributes of the image customization tasks returned by the execution terminals and updates the status attributes to the customization task list.
[0011] The Korean invention patent "A SECURED LINUX OPERATIONG SYSTEM USING MULTI-LEVELSECURITY" (application number KR101414580B1) describes a system that differentiates access restrictions based on user levels within the Linux operating system's kernel. It provides a configuration including an access control unit, a reference monitoring unit, a kernel-mode encryption unit, and a real-time monitoring unit, which overcomes the limitations of application-level security measures provided on open Linux operating systems.
[0012] Japanese invention patent "LINUX PROGRAM START-UP SYSTEM" (application number JP2010282645A) provides a Linux program startup system for reliably determining the user region corresponding to the kernel in an embedded device with redundant configuration.
[0013] The Korean invention patent "APPARATUS AND METHOD FOR CONFIGURING LINUX KERNEL AND APPLICATION PROGRAM" (application number KR20060063270A) provides a device and method for integrating and configuring the Linux kernel and applications, which allows manual configuration of Linux kernel configuration files, system configuration files, and converted application configuration files in a Linux system image for embedded devices.
[0014] However, none of the above technologies involve scalable segmented automated image building technology for RISC-V. Summary of the Invention
[0015] To address the shortcomings of existing technologies, this invention provides a scalable, segmented, automated image building technology for RISC-V, comprising the following steps: Step S1: Build an empty img image on the computer, divide the image into four partitions: p1, p2, p3, and p4, and format the four partitions. Step S2: Enter the image via chroot, set the software source in the image according to the system type and applicable hardware, install the corresponding kernel in the image and perform the corresponding boot configuration; Step S3: Configure the default language, font, network, and user settings of the image according to the system type, and install the necessary desktop, display, and commonly used application packages; Step S4: After exiting chroot, delete the command history in the image and copy the bootloader files related to booting in the image to the p1 and p2 partitions of the image respectively.
[0016] In step S1, p1 is used to store the .bin binary file of the boot loader, p2 is used to store the .itb device tree file of the boot loader, p3 is the boot partition, which is used to store the boot configuration files of the kernel and boot loader, and p4 is the rootfs partition, which is used to store various software packages and configuration files in the system.
[0017] In step S1, the image is set as a loop device, and in step S4, the image is unmounted and the loop device is removed.
[0018] The scalable, segmented, automated image building technology for RISC-V provided by this invention can build Linux system images suitable for different RISC-V hardware, thus offering better applicability. Furthermore, it enables segmented, automated image building, effectively improving image building efficiency. Attached Figure Description
[0019] Figure 1 The implementation logic diagram of the scalable segmented automated image building technology for RISC-V of this invention. Detailed Implementation
[0020] To gain a better understanding of the technical solution and beneficial effects of the present invention, the technical solution of the present invention and its beneficial effects are described in detail below with reference to the accompanying drawings.
[0021] To address the aforementioned technical problems, this invention proposes a scalable, segmented, automated image building technology for RISC-V. A script for building the image is written and executed during the Linux image building process, thus automating the image creation. The script configures the kernel, bootloader, and other components of the image based on the type of hardware device to build images suitable for different hardware devices. This solves the current problems of Linux images not being compatible with all hardware devices and the inability to automate image building.
[0022] Figure 1 This is a logic diagram of the implementation of the scalable segmented automated image building technology for RISC-V of the present invention, that is, the execution logic diagram of the written image building script: The present invention uses three scripts to select the versions of the five Linux kernel deb packages in the image according to the hardware to be adapted by the image during the image building process. Then, it configures the bootloader for different hardware, such as grub and u-boot. Currently, the present invention supports image building for two types of RISC-V development board computers: the hifive-unmatched computer from Sifive Corporation and the visionfive development board from C5 Technologies. When building an image for the hifive-unmatched computer, the kernel deb package version 5.11.0 from the source is installed in the image; when building an image for the visionfive development board, the kernel deb package version 5.18.0 provided by C5 is installed in the image. Furthermore, the software source, package version, and package list in the image are configured accordingly according to the type of system to be built. Currently, the present invention supports the building of Kylin system images and openKylin system images.
[0023] Therefore, since the image building process requires chrooting into the image and configuring its packages and configuration files, complete automation of the building process is not possible. This invention proposes a segmented automated image building technology. Specifically, the three scripts written in this invention implement the following logic in the aforementioned image building process: 1. Run a script on the computer to automatically build an empty img image. Divide the image into four partitions: p1, p2, p3, and p4. Format each partition, setting its format and name. p1 stores the boot loader's .bin binary file; p2 stores the boot loader's .itb device tree file; p3 is the boot partition, storing the kernel and boot loader's boot configuration files; p4 is the rootfs partition, storing various software packages and configuration files. Set the image as a circular device, mount the p3 and p4 partitions from the image to the system, and use debootstrap to build the basic Linux root file system within the image.
[0024] 2. Enter the image via chroot and run a script to automatically configure the software sources in the image based on the system type and applicable hardware (e.g., for openKylin systems, automatically set the official openKylin software source in the image, and the same applies to Ubuntu Kylin systems). Install the corresponding kernel in the image (e.g., the kernel applicable to hifive-unmatched computers or visionfive), and perform the corresponding boot configuration (e.g., for hifive-unmatched computers, configure the relevant u-boot and extlinux.conf; for visionfive computers, configure the relevant grub.cfg). Configure the default language, fonts, network, user, etc. of the image according to the system type, and install the necessary desktop, display, and commonly used application packages.
[0025] 3. After exiting chroot, run the script to automatically delete the command history in the image and copy the boot loader files related to booting from the image to the image's p1 and p2 partitions respectively. Unmount the image and remove the loop device. This completes the segmented automated build of the image.
[0026] In this invention, "RISC-V" refers to the RISC-V instruction set architecture.
[0027] The technical effects of this invention are as follows: 1. This invention can automatically build Linux system images suitable for various RISC-V hardware; 2. This invention can automatically build Linux system images suitable for various system types; 3. This invention improves the efficiency of building Linux system images suitable for RISC-V hardware; 4. This invention has low requirements for the technical level of personnel and is more widely applicable.
[0028] Although the present invention has been described using the above preferred embodiments, it is not intended to limit the scope of protection of the present invention. Any changes and modifications made by those skilled in the art to the above embodiments without departing from the spirit and scope of the present invention shall still fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be defined by the claims.
Claims
1. A scalable, segmented, automated image building technology for RISC-V, characterized in that, Includes the following steps: Step S1: Run the first script on the computer to automatically build an empty img image. Divide the image into four partitions: p1, p2, p3, and p4. Format the four partitions and set their formats and names. p1 is used to store the bootloader's .bin binary file; p2 is used to store the bootloader's .itb device tree file; p3 is the boot partition, used to store the kernel and bootloader's boot configuration files; p4 is the rootfs partition, used to store various software packages and configuration files in the system. Set the image as a circular device, mount the p3 and p4 partitions in the image to the system, and use debootstrap to build the basic Linux root file system in the image. Step S2: Enter the image via chroot and run the second script to automatically configure the software sources in the image according to the system type and applicable hardware, install the corresponding kernel, and perform the corresponding boot configuration. Specifically, when building an image for the hifive-unmatched computer, install the 5.11.0 version kernel deb package from the source in the image; when building an image for the visionfive development board, install the 5.18.0 version kernel deb package provided by CelFang. For the hifive-unmatched computer, configure the boot-related u-boot and extlinux.conf; for the visionfive computer, configure the boot-related grub.cfg. Configure the software sources, package versions, and package lists in the image according to the system type to be built. Set the default language, font, network, and user of the image according to the system type, and install the necessary desktop, display, and commonly used application packages. Step S3: After exiting chroot, run the third script to automatically delete the history of commands in the image, copy the boot loader files related to booting in the image to the p1 and p2 partitions of the image respectively, and unmount the image and remove the loop device.