A kind of method and system for supporting more DTB in single linux system mirror image
Technical field
The present invention relates to computer communication technology fields, and in particular to one kind supports more DTB in single linux system mirror image
Method and system.
Background technique
Device tree (Device tree) is a set of rule for being used to describe hardware symbolic animal of the birth year in linux system, it is with tree-like
Data structure describes the parameter of target hardware;DTS (Device tree syntax) is device tree source file, using text
This format;And DTB (Device tree blob) is then the binary file being compiled by DTS file, is being stored by programming
In medium.DTC (Device treecompiler) is a small tool, is responsible for DTS being converted into DTB (Devicetree
blob).When linux system starting, and bootstrap boot program (such as: Uboot, bootloader) starting
DTB file is read in memory before linux system mirror image, is jumped to DTB initial address while linux system mirror image executes
It is transmitted to system image.Linux system mirror image can be completed by initial address according to the structure elucidation whole equipment tree of DTB
The initialization of hardware driving.It is the change supporting new hardware and needing that the introducing of device tree, which reduces system image, improves code
It reuses, accelerates the exploitation that Linux supports packet, single linux system mirror image is enabled to support multiple systems.
When carrying out Linux product development, the operation system image (OS Image) that a usual product ultimately produces is logical
Chang Yousan file is packaged: a system image system image file (uImage or zImage), a DTB file and one
A root file system file (RootFS).Due to the difference of device tree file, the packaging file for causing each product is each not
Identical, i.e., company is still necessary for a set of linux system mirror image of each product maintenance.No matter in terms of product development angle, still
In terms of product maintenance angle, this is all uneconomic.
Summary of the invention
In view of the deficiencies in the prior art, the purpose of the present invention is to provide one kind in single linux system mirror image
Support the method and system of more DTB, multiple and different DTB files is supported in realization in the same linux system mirror image.
In a first aspect, providing a kind of method for supporting more DTB in single linux system mirror image, comprising:
By multiple and different DTB integrating documents at a DTB integrating document, by DTB integrating document and comprising same
The linux system mirror image mirror image of all products driving under linux system image release, is packaged into linux system image file;
When bootstrap starts, the corresponding DTB file of each product is loaded by modification boot code.
It is described by multiple and different DTB integrating documents according in a first aspect, in the first implementation of first aspect
At a DTB integrating document, specifically includes the following steps:
The DTB file of multiple products is generated using the compiling of DTC tool;
Each DTB file of generation is filled into the file being sized using wscript.exe, or is existed using DTC tool
Specified DTB file size is to be sized when generating DTB file;
The DTB integrating document for being sized multiple DTB file mergencess being sized at a n* using script, n are
The sum of DTB file.
It is described by DTB integrating document and comprising same according in a first aspect, in second of implementation of first aspect
The linux system mirror image mirror image of all products driving under a linux system image release is packaged into linux system mirror image text
Part, specifically includes the following steps:
Using mkimage tool by DTB integrating document, include all products under the same linux system image release
The linux system mirror image mirror image and root file system of driving are packaged into linux system image file.
According in a first aspect, when the bootstrap starts, passing through modification in the third implementation of first aspect
Boot code is loaded into the corresponding DTB file of each product, specifically includes the following steps:
Judge whether have product identification mechanism;
If so, modification boot code, is jumped in corresponding code branch by product identification mechanism and is automatically loaded respectively
The corresponding DTB file of product;If it is not, being loaded into the corresponding DTB file of each product by setting.
It is described by setting in the 4th kind of implementation of first aspect according to the third implementation of first aspect
Environmental variance is set, the corresponding DTB file of each product is loaded into, specifically includes the following steps:
It sets are as follows: UBoot > fdt addrDTB_BASE+m*file size, in which:
Fdt addr DTB_BASE is that DTB is loaded into base address, and m is the serial number for the DTB file that specified needs are loaded into,
File size is being sized for DTB file.
Second aspect provides a kind of system that more DTB are supported in single linux system mirror image, comprising:
Integrating documents module is used for multiple and different DTB integrating documents into a DTB integrating document;
Mirror image packetization module is used for by DTB integrating document and comprising all under the same linux system image release
The linux system mirror image mirror image of product driving, is packaged into linux system image file;
File load module, is used for when bootstrap starts, and is loaded into each product pair by modification boot code
The DTB file answered.
According to second aspect, in the first implementation of second aspect, the integrating documents module will be multiple and different
DTB integrating documents at a DTB integrating document, specifically includes the following steps:
The DTB file of multiple products is generated using the compiling of DTC tool;
Each DTB file of generation is filled into the file being sized using wscript.exe, or is existed using DTC tool
Specified DTB file size is to be sized when generating DTB file;
The DTB integrating document for being sized multiple DTB file mergencess being sized at a n* using script, n are
The sum of DTB file.
According to second aspect, in second of implementation of second aspect, DTB is integrated text by the mirror image packetization module
Part and the linux system mirror image mirror image driven comprising all products under the same linux system image release, are packaged into
Linux system image file, specifically includes the following steps:
Using mkimage tool by DTB integrating document, include all products under the same linux system image release
The linux system mirror image mirror image and root file system of driving are packaged into linux system image file.
According to second aspect, in the third implementation of second aspect, the file load module is in bootstrap
When starting, the corresponding DTB file of each product is loaded by modification boot code, specifically includes the following steps:
Judge whether have product identification mechanism;
If so, modification boot code, is jumped in corresponding code branch by product identification mechanism and is automatically loaded respectively
The corresponding DTB file of product;If it is not, being loaded into the corresponding DTB file of each product by setting.
According to the third implementation of second aspect, in the 4th kind of implementation of second aspect, the file adds
Load module, which passes through, to set, and is loaded into the corresponding DTB file of each product, specifically includes the following steps:
It sets are as follows: UBoot > fdt addr DTB_BASE+m*file size, in which:
Fdt addr DTB_BASE is that DTB is loaded into base address, and m is the serial number for the DTB file that specified needs are loaded into,
File size is being sized for DTB file.
Compared with the prior art, the advantages of the present invention are as follows:
The present invention by multiple and different DTB files by being integrated into a unified DTB integrating document, and and comprising same
The linux system mirror image mirror image of all products driving under a linux system image release is packaged into linux system mirror image text
Part.When bootstrap guides system, multiple products use the same linux system image file, pass through corresponding strategy
It is loaded into corresponding DTB file, multiple and different DTB files is supported in realization in the same linux system mirror image, to reach more
A product uniformly uses the purpose of a linux system mirror image.
Detailed description of the invention
Fig. 1 is the generation DTB integration text for the method for supporting more DTB in the embodiment of the present invention in single linux system mirror image
The flow diagram of part;
Fig. 2 is the generation linux system for supporting the method for more DTB in the embodiment of the present invention in single linux system mirror image
The flow diagram of image file;
Fig. 3 be the embodiment of the present invention in supported in single linux system mirror image more DTB method by modification guide journey
Sequence code is loaded into the flow diagram of the corresponding DTB file of each product.
Specific embodiment
Term explanation:
UBoot: full name Universal Boot Loader, it is to follow GPL (GNU General Public License
Abbreviation, be the general public informal translator of Chinese of authorization of GNU) the open source code project of clause.The effect of UBoot is system
Guidance.The source code catalogue of UBoot, compiling form and linux system mirror image are much like, in fact, much UBoot source code is exactly root
According to corresponding linux system mirror image source program carry out simplify and formed, the driver of especially some equipment, this from
This point can be embodied in the annotation of UBoot source code.UBoot not only supports the guidance of embedded Linux system, it is also supported
NetBSD, VxWorks, QNX, RTEMS, ARTOS, LynxOS, the embedded OSs such as android.What it to be supported at present
Destination OS is OpenBSD, NetBSD, FreeBSD, 4.4BSD, Linux, SVR4, Esix, Solaris, Irix, SCO,
Dell, NCR, VxWorks, LynxOS, pSOS, QNX, RTEMS, ARTOS, android.This is one of Universal in UBoot
Layer meaning, in addition one layer of meaning is then UBoot in addition to supporting PowerPC (Performance Optimization With
Enhanced RISC-Performance Computing, abbreviation PPC, is a kind of centre of reduced instruction set computer framework sometimes
Manage device) series processor outside, moreover it is possible to support the processor of many common series such as MIPS, x86, ARM, NIOS, XScale.This
Two features are exactly the development goal of UBoot project, that is, support embeded processor and embedded OS as much as possible.
Just at present, UBoot supports PowerPC series processors the abundantest, most perfect to the support of Linux.
Mkimage tool: the tool under the tools/ catalogue of UBoot source code, this tool can be used to make do not press
Contracting or a variety of of compression start image file.Mkimage when making image file, executable is reflected original
Head as adding a 0x40 byte before file, information specified by recording parameters, such UBoot could identify that this is reflected
As if it is directed to which CPU architecture, and which OS's, which kind of type, which of load memory, entrance is in memory
That position and image name what is.
FPGA:(Field-Programmable GateArray), i.e. field programmable gate array, it is in PAL
(abbreviation of Phase Alteration Line, mean line-by-line inversion), (Lattice is designed GAL on the basis of PAL
Device, i.e. Common Language Runtime), CPLD (Complex Programmable Logic Device, complex programmable
Logical device is the device come out from PAL and GAL device development) etc. the product that further develops on the basis of programming devices.
It is that occur as one of the field specific integrated circuit (ASIC) semi-custom circuit, has both solved custom circuit not
Foot, and overcome the limited disadvantage of original programming device gate circuit number.
Toggle switch: the type of toggle switch has very much, and cardinal principle is exactly binary combination, each has 0 and 1 liang
Kind of combination, combines in 24 powers so sharing, is exactly 16 kinds, MCU (Microcontroller Unit, micro-control unit) knows
It is clipped to this combination and then makes different responses.
Image:Image is that is handled by objcopy only includes the system image code of binary data, it is not
It is elf format, but the system image mirror image of this format has not gone through compression.Objcopy is GNU (GNU is Not
The abbreviation of Unix is a free operating system) implementing procedure is used, objcopy effect is one file destination of copy
Content is into another file destination, that is to say, that a kind of file destination of format can be converted into the mesh of another format
Mark file.By using binary system as output target, an original binary file can produce, it substantially will be all
Symbol and relocation information will all be abandoned, only remaining binary data.
ZImage:zImage is ARM (Advanced RISC Machines, a kind of risc microcontroller) linux common
A kind of compression image file, it be by unpressed system image (vmlinux) plus decompression code compressed, order
Format is that the Linux image file of this format of #make zImage. is stored in NAND (NAND flash memory, calculating more
Machine flash memory device) on.The case where suitable for mini system mirror image, its presence are for compatibility backward.
Invention is further described in detail with reference to the accompanying drawings and embodiments.
Embodiment 1:
Shown in Figure 1, the embodiment of the present invention provides a kind of method that more DTB are supported in single linux system mirror image, packet
It includes:
By multiple and different DTB integrating documents at a DTB integrating document (i.e. DEV.DTB in Fig. 1), DTB is integrated
File and the linux system mirror image mirror image driven comprising all products under the same linux system image release, are packaged into
Linux system image file (i.e. Linux.kernel.Image in Fig. 1);
When bootstrap (Uboot or bootloader etc.) starts, each product pair is loaded by modification boot code
The DTB file answered.
The present invention by multiple and different DTB files by being integrated into a unified DTB integrating document, and and comprising same
The linux system mirror image mirror image of all products driving under a linux system image release is packaged into linux system mirror image text
Part.When bootstrap guides system, multiple products use the same linux system image file, pass through corresponding strategy
It is loaded into corresponding DTB file, multiple and different DTB files is supported in realization in the same linux system mirror image, to reach more
A product uniformly uses the purpose of a linux system mirror image.
Embodiment 2:
On the basis of embodiment 1, shown in Figure 2, it is described that multiple and different DTB integrating documents are whole at a DTB
File is closed, specifically includes the following steps:
The DTB file of multiple products is generated using the compiling of DTC tool;
Each DTB file of generation is filled into the file being sized using wscript.exe.
Multiple DTB file mergencess being sized are sized to the DTB integrating document of size using script at a n*,
N is the sum of DTB file.
Due to common storage medium now, such as flash with n*32K byte for a sector unit, it is contemplated that DTB text
Part is generally no greater than 50K byte, so each DTB file of generation is filled into the file of 64K size using wscript.exe, or
It is to specify DTB file size for 64K byte when generating DTB file using DTC tool;
When each DTB file of generation being filled into the file of 64K size using wscript.exe, device tree file is actually big
Small by file to carry attribute available, and residue filling content is 0 or 1 to be all possible, finally plus product feature code,
MD5 etc. character is also all possible, by user's self-defining.Filling content and device tree file can regard 2 as mutually
The file not interfered.
Filling size is not limited to 64KB, and 64KB is an empirical value or recommended value.Using 64KB, this value is mainly former
Because there is several points:
1, DTB file is generally less than 30KB, and 64KB has been very big.Certainly it is implicitly present in very big file,
It is also possible using the numerical value bigger than 64KB.
2, DTB file is stored in storage equipment such as NOR flash, NAND flash.Due to often making on NOR flash
With RAW mode (no file system) accessing file, the size of mono- sector NOR flash of present mainstream is 64KB or 128KB,
So reasonable using upper comparison using the multiple of 64KB;Simultaneously as the NOR flash of many equipment is 512KB, if producer
Uboot mirror image and multiple DTB files are stored simultaneously using 512KB NOR flash for save the cost, then the use of 64KB being phase
To reasonable setting.NAND flash is generally bigger and has file system, then there is no this limitations.
In summary two o'clock, and since bigger file reading speed is slower, the access speed of NOR flash compared with
Slowly, so using the smallest 64KB relative efficiency.
It is described by DTB integrating document and comprising under the same linux system image release all products driving Linux
System image mirror image is packaged into linux system image file, specifically includes the following steps:
Using mkimage tool by DTB integrating document, include all products under the same linux system image release
The linux system mirror image mirror image (uImage or zImage) and root file system of driving are packaged into linux system image file.
Embodiment 3:
On the basis of embodiment 1, shown in Figure 3, when the bootstrap starts, by modifying boot code
It is loaded into the corresponding DTB file of each product, specifically includes the following steps:
Judge whether have product identification mechanism (FPGA identification or toggle switch identification etc.);
FPGA identification process are as follows: be stored in the specified register of FPGA into have the product identification being burned to coding.Guidance
When program starts, CPU accesses the specified register of FPGA by the specified interface (Local Bus or SPI etc.) communicated with FPGA,
Product identification coding is read, corresponding DTB file is loaded into according to identification code.
Toggle switch identification process are as follows: toggle switch can be equal to the resistance of one group of changeable setting value, a product
The resistance value fixed corresponding to one group, i.e., one fixed toggle switch preset value.When bootstrap starts, CPU passes through specific
Interface (usually GPIO) reads toggle switch preset value, obtains product identification coding, is loaded into corresponding DTB text according to identification code
Part.
If so, modification boot code, is jumped in corresponding code branch by product identification mechanism and is automatically loaded respectively
The corresponding DTB file of product;If it is not, being loaded into the corresponding DTB file of each product by setting.
It is described to be loaded into the corresponding DTB file of each product by setting, specifically includes the following steps:
It sets are as follows: UBoot > fdt addr DTB_BASE+m*file size, in which:
Fdt addr DTB_BASE is that DTB is loaded into base address, and m is the serial number for the DTB file that specified needs are loaded into,
File size is being sized for DTB file.
For example, when being sized as 64kb of DTB file, sets are as follows: UBoot > fdt addr DTB_BASE
+m*0x10000。
Embodiment 4:
The embodiment of the invention discloses a kind of systems that more DTB are supported in single linux system mirror image, comprising:
Integrating documents module is used for multiple and different DTB integrating documents into a DTB integrating document;
Mirror image packetization module is used for by DTB integrating document and comprising all under the same linux system image release
The linux system mirror image mirror image of product driving, is packaged into linux system image file;
When being used for bootstrap starting, it is corresponding to be loaded into each product by modification boot code for file load module
DTB file.
Embodiment 5:
On the basis of embodiment 4, the integrating documents module is whole at a DTB by multiple and different DTB integrating documents
File is closed, specifically includes the following steps:
The DTB file of multiple products is generated using the compiling of DTC tool.
Each DTB file of generation is filled into the file being sized using wscript.exe, or is existed using DTC tool
Specified DTB file size is to be sized when generating DTB file;
The DTB integrating document for being sized multiple DTB file mergencess being sized at a n* using script, n are
The sum of DTB file.
The mirror image packetization module is by DTB integrating document and includes all productions under the same linux system image release
The linux system mirror image mirror image of product driving, is packaged into linux system image file, specifically includes the following steps:
Using mkimage tool by DTB integrating document, include all products under the same linux system image release
The linux system mirror image mirror image and root file system of driving are packaged into linux system image file.
Embodiment 6:
On the basis of embodiment 4, the file load module is when bootstrap starts, by modifying bootstrap generation
Code is loaded into the corresponding DTB file of each product, specifically includes the following steps:
Judge whether have product identification mechanism (FPGA identification or toggle switch identification etc.);
If so, modification boot code, is jumped in corresponding code branch by product identification mechanism and is automatically loaded respectively
The corresponding DTB file of product;If it is not, being loaded into the corresponding DTB file of each product by setting.
The file load module is loaded into the corresponding DTB file of each product, specifically includes following by setting
Step:
It sets are as follows: UBoot > fdt addr DTB_BASE+m*file size, in which:
Fdt addr DTB_BASE is that DTB is loaded into base address, and m is the serial number for the DTB file that specified needs are loaded into,
File size is being sized for DTB file.
For example, when being sized as 64kb of DTB file, sets are as follows: UBoot > fdt addr DTB_BASE
+m*0x10000。
The present invention is not limited to the above-described embodiments, for those skilled in the art, is not departing from
Under the premise of the principle of the invention, several improvements and modifications can also be made, these improvements and modifications are also considered as protection of the invention
Within the scope of.The content being not described in detail in this specification belongs to the prior art well known to professional and technical personnel in the field.