Embedded Linux system hardware adaptive method based on extended memory and electronic terminal
By storing boot program and configuration information in the extended memory, hardware adaptation of embedded Linux systems is achieved, which solves the problems of rapid boot and adaptation on different hardware platforms, and improves system compatibility and scalability.
Patent Information
- Application Number
- CN202411538959.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-03-04
AI Technical Summary
When facing different hardware platforms, existing embedded Linux systems are difficult to achieve rapid startup and adaptation, resulting in difficulty in software version management and expansion.
System hardware adaptation is achieved by storing boot program and configuration information in the extended memory and using hardware circuit management to set up the microprocessor to boot from the extended memory.
This method allows embedded Linux systems to quickly start and adapt on different hardware platforms, reduces the workload of adapting to new products, simplifies software version management, and improves the scalability of the hardware platform.
Smart Images

Figure CN119556996A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of embedded operating systems, and in particular to an embedded Linux system hardware self-adaptation method based on extended memory and an electronic terminal. Background Art
[0002] In the existing power grid construction, due to new business needs, a large number of intelligent devices such as energy controllers, data collection terminals, and load management terminals are being used. These intelligent terminals use new technologies such as edge computing and container technology, and need to run on embedded operating systems that follow industry specifications and support new technology access; at the same time, the above intelligent terminal products must meet relevant industry specifications, such as: ESAM-based secure boot solutions.
[0003] Since these characteristics have certain similarities, during product development, devices for different scenarios can be developed by adjusting the hardware based on the basic model. In this case, differentiated boot programs and kernel device trees are required to be compatible with different products. It is impossible to use a universal image to support various products, which brings difficulties to subsequent software version management and expansion.
[0004] The traditional method requires customizing image files for each hardware combination, which is labor-intensive and has poor scalability. In addition, image files are usually fixed in the main memory. Once the hardware configuration changes, the material needs to be replaced and reprogrammed, which is very inconvenient.
[0005] Therefore, how to achieve fast startup and adaptation of embedded Linux systems for different hardware platforms is a key technical issue that needs to be solved urgently. Summary of the invention
[0006] The purpose of the present invention is to solve the problem of how to realize the rapid startup and self-adaptation of embedded Linux system for different hardware platforms, and to propose a method and an electronic terminal for hardware self-adaptation of embedded Linux system based on extended memory. In view of the problem of diversified hardware configuration of embedded Linux system, the system hardware self-adaptation is realized by storing boot program and configuration information in extended memory.
[0007] The technical solution of the present invention is:
[0008] The present invention provides an embedded Linux system hardware adaptation method based on extended memory, comprising:
[0009] Obtaining hardware configuration information of the embedded Linux system;
[0010] According to the hardware configuration information, storing the boot program and the kernel in a preset storage area of the extended memory;
[0011] Setting the microprocessor to start from the extended memory through hardware circuit management;
[0012] The microprocessor automatically loads and executes the boot program in the extended memory to complete system initialization;
[0013] The boot program loads the kernel from the extended memory to a preset address of the internal memory, and guides the kernel to execute;
[0014] The kernel adapts the current hardware configuration to complete the startup according to the hardware configuration information.
[0015] Furthermore, obtaining the hardware configuration information of the embedded Linux system includes:
[0016] The microprocessor model, extended memory model and main memory model of the embedded Linux system are obtained.
[0017] Further, according to the hardware configuration information, storing the boot program and the kernel in a preset storage area of the extended memory includes:
[0018] According to the hardware configuration information, a boot0 program, a device custom initialization program and a kernel device tree are stored in a preset storage area of the extended memory.
[0019] Furthermore, the microprocessor automatically loads and executes the boot program in the extended memory to complete system initialization, including:
[0020] The microprocessor automatically loads and executes the boot0 program in the extended memory, and the boot0 program performs the following operations:
[0021] Initialize the main memory, adjust the PMU output, initialize the external RAM, load the bootloader program in the main memory into the external RAM and jump to execution.
[0022] Further, the boot program loads the kernel from the extended memory to a preset address of the memory, and guides the kernel to execute the following steps:
[0023] The bootloader program loads and executes a device-defined initialization program from the extended memory, and the program executes operations such as LCD driving, power-on LOGO refresh, and specific GPIO initialization, and then returns to the bootloader;
[0024] The bootloader program loads the kernel device tree from the extended memory to a preset address of the memory;
[0025] The bootloader program loads the kernel image from the main memory to a preset address of the memory, and guides the kernel to execute, while passing the memory address of the kernel device tree to the kernel through the startup parameters.
[0026] Furthermore, the extended memory is a NAND Flash memory or an eMMC memory.
[0027] Furthermore, the boot program further includes a uboot program for booting the kernel.
[0028] An embedded Linux system hardware adaptive electronic terminal based on extended memory, comprising:
[0029] Main memory, which stores executable instructions;
[0030] An extended memory storing executable instructions;
[0031] and a microprocessor, wherein the microprocessor runs the executable instructions in the memory and the extended memory to implement the embedded Linux system hardware adaptation method based on the extended memory
[0032] Beneficial effects of the present invention:
[0033] When the method of the present invention is used, product model derivation does not require re-releasing of images, and only requires development of device configuration-related implementations stored in an extended memory, thereby reducing the workload of adapting new products and the difficulty of later management of software versions; at the same time, restrictions on device type expansion are removed, thereby improving the scalability of the hardware platform.
[0034] The present invention first obtains hardware configuration information, including a microprocessor model, an extended memory model, and a main memory model, and then stores a boot0 program, a device custom initialization program, and a kernel device tree in a preset storage area of the extended memory according to the hardware configuration information. When the system is powered on and started, the microprocessor starts from the extended memory, automatically loads and executes the boot0 program, completes the main memory initialization, PMU output adjustment, and external RAM initialization, and loads the bootloader program to the external RAM for execution. The bootloader program loads and executes the device custom initialization program from the extended memory, completes operations such as LCD driving, power-on LOGO refresh, and specific GPIO initialization, and then loads the kernel device tree from the extended memory to the memory, loads the kernel image from the main memory and guides the kernel to execute, and at the same time passes the memory address of the kernel device tree to the kernel through the startup parameter, and the kernel adapts the current hardware configuration according to the memory address of the kernel device tree passed in to complete the startup. The present invention uses the extended memory to store the boot program and configuration information, realizes the hardware adaptation of the embedded Linux system, improves the compatibility and scalability of the system, and simplifies the development and maintenance of the system.
[0035] Other features and advantages of the present invention will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The above and other objects, features and advantages of the present invention will become more apparent through a more detailed description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components throughout the exemplary embodiments of the present invention.
[0037] Figure 1 The hardware structure block diagram of the embedded Linux system hardware adaptive electronic terminal based on extended memory of the present invention is shown;
[0038] Figure 2 The flowchart of the embedded Linux system hardware adaptation method based on extended memory of the present invention is shown. DETAILED DESCRIPTION
[0039] The preferred embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0040] The present invention provides an embedded Linux system hardware adaptation method based on extended memory, comprising:
[0041] Obtaining hardware configuration information of the embedded Linux system;
[0042] According to the hardware configuration information, storing the boot program and the kernel in a preset storage area of the extended memory;
[0043] Setting the microprocessor to start from the extended memory through hardware circuit management;
[0044] The microprocessor automatically loads and executes the boot program in the extended memory to complete system initialization;
[0045] The boot program loads the kernel from the extended memory to a preset address of the internal memory, and guides the kernel to execute;
[0046] The kernel adapts the current hardware configuration to complete the startup according to the hardware configuration information.
[0047] In this embodiment, the device tree file is configured according to the hardware design, and the device tree file of the corresponding hardware is directly stored in the extended memory, and the corresponding device tree file is directly loaded; after power-on startup, the hardware configuration chip is used to load and execute the first-level boot program boot0 in the extended memory, and the microprocessor has requirements for the storage location and format of boot0 in the memory; boot0 loads the bootloader in the main memory into the extended memory and jumps to execute; the bootloader loads and executes the device custom initialization program in the extended memory, the main function of which is to initialize the hardware peripherals, and jumps back to the bootloader after the program is executed; if U-Boot is used as the bootloader, use standalone The app serves as a custom initialization program for the device, which implements functions such as key IO status setting, display device driving and boot LOGO refresh; the bootloader loads the kernel device tree image file corresponding to the hardware configuration in the extended memory to the specified memory address; the bootloader loads the kernel in the extended memory into the memory, and boots the kernel to execute, during which the kernel device tree memory address is transmitted to the kernel through the startup parameters; if the extended memory uses NORFLASH of the SPI interface, it can be set to read-only mode, and the storage file supports verification to enhance the reliability of related data; by implementing operations such as corresponding model extended RAM initialization and PMU management in boot0, the hardware version is optimized to obtain an embedded Linux system adapted to different hardware.
[0048] In one example, obtaining the hardware configuration information of the embedded Linux system includes:
[0049] The microprocessor model, extended memory model and main memory model of the embedded Linux system are obtained.
[0050] In this embodiment, the acquired hardware configuration information such as the microprocessor model, extended memory model and main memory model is written into a designated area in the memory; the bootloader loads and executes the device custom initialization program in the extended memory, which reads the hardware configuration information in the memory to determine whether the hardware model matches; if the hardware model matches, the hardware peripheral initialization operation is executed, if not, the exception handling process is entered.
[0051] In one example, according to the hardware configuration information, storing the boot program and the kernel in a preset storage area of the extended memory includes:
[0052] According to the hardware configuration information, a boot0 program, a device custom initialization program and a kernel device tree are stored in a preset storage area of the extended memory.
[0053] In this embodiment, according to the hardware configuration information, the storage space of the boot0 program, the device custom initialization program and the kernel device tree is divided in the preset storage area of the extended memory; the boot0 program is burned in the boot0 program storage area of the extended memory using the embedded file system format, and the storage address and execution permission of the boot0 program are set; the device custom initialization program is burned in the device custom initialization program storage area of the extended memory, and the storage address and execution permission of the program are set; the kernel device tree source file is obtained, the device tree source file is modified according to the hardware configuration information, and a kernel device tree binary file matching the hardware configuration is generated; the generated kernel device tree binary file is burned to the kernel device tree storage area of the extended memory, and the storage address of the kernel device tree file is set.
[0054] In one example, the microprocessor automatically loads and executes the boot program in the extended memory to complete system initialization, including:
[0055] The microprocessor automatically loads and executes the boot0 program in the extended memory, and the boot0 program performs the following operations:
[0056] Initialize the main memory, adjust the PMU output, initialize the external RAM, load the bootloader program in the main memory into the external RAM and jump to execution.
[0057] In this embodiment, the microprocessor loads and executes the boot0 program in the extended memory. The boot0 program determines the location of the bootloader in the main memory according to the predefined storage location and format; the boot0 program loads the bootloader in the main memory into the extended memory and jumps to execute the bootloader program.
[0058] In one example, the boot program loads the kernel from the extended memory to a preset address of the memory, and guides the kernel to execute the following steps:
[0059] The bootloader program loads and executes a device-defined initialization program from the extended memory, and the program executes operations such as LCD driving, power-on LOGO refresh, and specific GPIO initialization, and then returns to the bootloader;
[0060] The bootloader program loads the kernel device tree from the extended memory to a preset address of the memory;
[0061] The bootloader program loads the kernel image from the main memory to a preset address of the memory, and guides the kernel to execute, while passing the memory address of the kernel device tree to the kernel through the startup parameters.
[0062] In this embodiment, the bootloader loads the device custom initialization program from the extended memory and executes it; after the device custom initialization program completes the hardware peripheral initialization, it jumps back to the bootloader; the bootloader loads the kernel device tree image file and the kernel in the extended memory into the memory, and starts the kernel.
[0063] In one example, the extended memory is a NAND Flash memory or an eMMC memory; the boot program further includes a uboot program for booting a kernel.
[0064] When implementing:
[0065] like Figure 1 and Figure 2 , a hardware adaptive boot method for embedded Linux system based on extended memory, based on Figure 1 The hardware solution is as follows: the microprocessor model is allwinner T3C, the extended memory model is MX25L64, and the microprocessor is interacted with through the SPI bus. The internal storage is distributed as follows:
[0066] The first-level boot program boot0 (boot0_spinor_sun8iw11p10), whose storage starting offset is 0x00000000, is generated by modifying and compiling the BSP provided by the chip manufacturer. It is necessary to increase the Emmc memory support and the second-level boot program loading implementation;
[0067] The device custom initialization program (U-Boot standalone), whose storage starting offset is 0x00080000, can be generated in the U-Boot compilation environment, and related hardware initialization implementation needs to be added;
[0068] The kernel device tree file (dtb) has a storage starting offset of 0x00100000. FIT (Flattened ImageTree) is a firmware packaging and booting solution currently supported and promoted by the U-Boot community. It is an upgraded version of the uImage format. The feature of FIT is that it supports specifying any custom information and packaging any number of image files. FIT uses the its (ImageSource File) file to describe the image information to be packaged, and then uses mkimage to package and generate an itb (ImageTree Blob) image. The its file uses the syntax rules of DTS and is directly parsed using the libfdt library and related tools. U-Boot can easily load FIT format images, so the tool mkimage compiled by U-Boot is used to package the kernel device tree and the kernel into FIT image packages respectively. After modifying the kernel device tree configuration according to the hardware configuration, compile and generate dtb, and then package it into a FIT format image kernel-dtb.itb.
[0069] The main memory model is FEMDRW016G, which interacts with the microprocessor through the eMMC bus. Its internal storage is distributed as follows:
[0070] The secondary boot program (U-Boot) is stored in the mmcblk0p1 partition. U-Boot loads and executes the standalone program from the SPI NOR FLASH. Before loading and running the kernel, the kernel device tree should be loaded from the SPI NOR FLASH to the memory, which is compatible with all related products.
[0071] The kernel image is stored in the mmcblk0p2 partition. It is compiled and generated according to the microprocessor configuration and packaged into a FIT format image kernel.itb, which is compatible with all related products.
[0072] The root file system is stored in the mmcblk0p3 partition and is customized according to industry specifications to adapt to all related products.
[0073] The device adaptive startup process is as follows, including the following steps:
[0074] S1. Hardware circuit management allwinner T3C starts controlling the IO level when the chip starts, sets the microprocessor to start from the SPI interface when powered on, and the on-chip curing program automatically loads boot0_spinor_sun8iw11p10 into the on-chip RAM for execution;
[0075] S2. During the execution of boot0, the following operations are performed:
[0076] The main memory eMMC is initialized;
[0077] PMU output adjustment;
[0078] External RAM initialization;
[0079] Load U-Boot in eMMC to external RAM and jump to execution.
[0080] S3, U-Boot execution process, support loading and running device custom initialization program, the program implements LCD driver,
[0081] Boot LOGO refresh, some specific GPIO initialization and other business functions. The specific implementation uses the U-BootStandalone Applications solution. The program binary file is stored at the offset 0x00080000 of the extended memory. After U-Boot is started, it reads the device custom initialization program from there to the specified address of the memory (such as 0x40007800, which is specified by CONFIG_STANDALONE_LOAD_ADDR), and then calls the go 0x40007800 command to start the custom initialization program;
[0082] S4. During the boot process, U-Boot reads the kernel device tree image (kernel-dtb.itb) from the extended memory at 0x00100000 and loads it to the memory address 0x14000000.
[0083] S5. During the startup process, U-Boot reads the kernel image (kernel.itb) from the main memory mmcblk0p2 partition and loads it to the memory address 0x10000000. Use the bootm command to load the correct kernel image and configure the startup. The specific command is: bootm 0x10000000 0x14000000.
[0084] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments.
Claims
1. A hardware adaptation method for an embedded Linux system based on extended memory, characterized in that: include: Obtaining hardware configuration information of the embedded Linux system; According to the hardware configuration information, storing the boot program and the kernel in a preset storage area of the extended memory; Setting the microprocessor to start from the extended memory through hardware circuit management; The microprocessor automatically loads and executes the boot program in the extended memory to complete system initialization; The boot program loads the kernel from the extended memory to a preset address of the internal memory, and guides the kernel to execute; The kernel adapts the current hardware configuration to complete the startup according to the hardware configuration information.
2. The method for hardware adaptation of an embedded Linux system based on extended memory according to claim 1, characterized in that: Obtaining the hardware configuration information of the embedded Linux system includes: The microprocessor model, extended memory model and main memory model of the embedded Linux system are obtained.
3. The method for hardware adaptation of an embedded Linux system based on extended memory according to claim 1, characterized in that: According to the hardware configuration information, storing the boot program and the kernel in a preset storage area of the extended memory includes: According to the hardware configuration information, a boot0 program, a device custom initialization program and a kernel device tree are stored in a preset storage area of the extended memory.
4. The method for hardware adaptation of an embedded Linux system based on extended memory according to claim 3, characterized in that: The microprocessor automatically loads and executes the boot program in the extended memory to complete system initialization including: The microprocessor automatically loads and executes the boot0 program in the extended memory, and the boot0 program performs the following operations: Initialize the main memory, adjust the PMU output, initialize the external RAM, load the bootloader program in the main memory into the external RAM and jump to execution.
5. The method for hardware adaptation of an embedded Linux system based on extended memory according to claim 4, characterized in that: The boot program loads the kernel from the extended memory to a preset address of the memory and guides the kernel to execute the following steps: The bootloader program loads and executes a device-defined initialization program from the extended memory, and the program executes operations such as LCD driving, power-on LOGO refresh, and specific GPIO initialization, and then returns to the bootloader; The bootloader program loads the kernel device tree from the extended memory to a preset address of the memory; The bootloader program loads the kernel image from the main memory to a preset address of the memory, and guides the kernel to execute, while passing the memory address of the kernel device tree to the kernel through the startup parameters.
6. The method for hardware adaptation of an embedded Linux system based on extended memory according to any one of claims 1 to 5, characterized in that: The extended memory is a NAND Flash memory or an eMMC memory.
7. The method for hardware adaptation of an embedded Linux system based on extended memory according to any one of claims 1 to 6, characterized in that: The boot program further includes a uboot program, which is used to boot the kernel.
8. An embedded Linux system hardware adaptive electronic terminal based on extended memory, characterized in that: include: Main memory, which stores executable instructions; An extended memory storing executable instructions; and a microprocessor, wherein the microprocessor runs the executable instructions in the memory and the extended memory to implement the hardware adaptation method of an embedded Linux system based on extended memory according to any one of claims 1 to 5.
Citation Information
Cited By
Flash memory partition identification multi-hardware automatic adaptation method and system
CN121541839A