1*4882a593SmuzhiyunU-Boot new uImage source file format (bindings definition) 2*4882a593Smuzhiyun========================================================== 3*4882a593Smuzhiyun 4*4882a593SmuzhiyunAuthor: Marian Balakowicz <m8@semihalf.com> 5*4882a593SmuzhiyunExternal data additions, 25/1/16 Simon Glass <sjg@chromium.org> 6*4882a593Smuzhiyun 7*4882a593Smuzhiyun1) Introduction 8*4882a593Smuzhiyun--------------- 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunEvolution of the 2.6 Linux kernel for embedded PowerPC systems introduced new 11*4882a593Smuzhiyunbooting method which requires that hardware description is available to the 12*4882a593Smuzhiyunkernel in the form of Flattened Device Tree. 13*4882a593Smuzhiyun 14*4882a593SmuzhiyunBooting with a Flattened Device Tree is much more flexible and is intended to 15*4882a593Smuzhiyunreplace direct passing of 'struct bd_info' which was used to boot pre-FDT 16*4882a593Smuzhiyunkernels. 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunHowever, U-Boot needs to support both techniques to provide backward 19*4882a593Smuzhiyuncompatibility for platforms which are not FDT ready. Number of elements 20*4882a593Smuzhiyunplaying role in the booting process has increased and now includes the FDT 21*4882a593Smuzhiyunblob. Kernel image, FDT blob and possibly ramdisk image - all must be placed 22*4882a593Smuzhiyunin the system memory and passed to bootm as a arguments. Some of them may be 23*4882a593Smuzhiyunmissing: FDT is not present for legacy platforms, ramdisk is always optional. 24*4882a593SmuzhiyunAdditionally, old uImage format has been extended to support multi sub-images 25*4882a593Smuzhiyunbut the support is limited by simple format of the legacy uImage structure. 26*4882a593SmuzhiyunSingle binary header 'struct image_header' is not flexible enough to cover all 27*4882a593Smuzhiyunpossible scenarios. 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunAll those factors combined clearly show that there is a need for new, more 30*4882a593Smuzhiyunflexible, multi component uImage format. 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun2) New uImage format assumptions 34*4882a593Smuzhiyun-------------------------------- 35*4882a593Smuzhiyun 36*4882a593Smuzhiyuna) Implementation 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunLibfdt has been selected for the new uImage format implementation as (1) it 39*4882a593Smuzhiyunprovides needed functionality, (2) is actively maintained and developed and 40*4882a593Smuzhiyun(3) increases code reuse as it is already part of the U-Boot source tree. 41*4882a593Smuzhiyun 42*4882a593Smuzhiyunb) Terminology 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunThis document defines new uImage structure by providing FDT bindings for new 45*4882a593SmuzhiyunuImage internals. Bindings are defined from U-Boot perspective, i.e. describe 46*4882a593Smuzhiyunfinal form of the uImage at the moment when it reaches U-Boot. User 47*4882a593Smuzhiyunperspective may be simpler, as some of the properties (like timestamps and 48*4882a593Smuzhiyunhashes) will need to be filled in automatically by the U-Boot mkimage tool. 49*4882a593Smuzhiyun 50*4882a593SmuzhiyunTo avoid confusion with the kernel FDT the following naming convention is 51*4882a593Smuzhiyunproposed for the new uImage format related terms: 52*4882a593Smuzhiyun 53*4882a593SmuzhiyunFIT - Flattened uImage Tree 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunFIT is formally a flattened device tree (in the libfdt meaning), which 56*4882a593Smuzhiyunconforms to bindings defined in this document. 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun.its - image tree source 59*4882a593Smuzhiyun.itb - flattened image tree blob 60*4882a593Smuzhiyun 61*4882a593Smuzhiyunc) Image building procedure 62*4882a593Smuzhiyun 63*4882a593SmuzhiyunThe following picture shows how the new uImage is prepared. Input consists of 64*4882a593Smuzhiyunimage source file (.its) and a set of data files. Image is created with the 65*4882a593Smuzhiyunhelp of standard U-Boot mkimage tool which in turn uses dtc (device tree 66*4882a593Smuzhiyuncompiler) to produce image tree blob (.itb). Resulting .itb file is the 67*4882a593Smuzhiyunactual binary of a new uImage. 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun 70*4882a593Smuzhiyuntqm5200.its 71*4882a593Smuzhiyun+ 72*4882a593Smuzhiyunvmlinux.bin.gz mkimage + dtc xfer to target 73*4882a593Smuzhiyuneldk-4.2-ramdisk --------------> tqm5200.itb --------------> bootm 74*4882a593Smuzhiyuntqm5200.dtb /|\ 75*4882a593Smuzhiyun... | 76*4882a593Smuzhiyun 'new uImage' 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun - create .its file, automatically filled-in properties are omitted 79*4882a593Smuzhiyun - call mkimage tool on a .its file 80*4882a593Smuzhiyun - mkimage calls dtc to create .itb image and assures that 81*4882a593Smuzhiyun missing properties are added 82*4882a593Smuzhiyun - .itb (new uImage) is uploaded onto the target and used therein 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun 85*4882a593Smuzhiyund) Unique identifiers 86*4882a593Smuzhiyun 87*4882a593SmuzhiyunTo identify FIT sub-nodes representing images, hashes, configurations (which 88*4882a593Smuzhiyunare defined in the following sections), the "unit name" of the given sub-node 89*4882a593Smuzhiyunis used as it's identifier as it assures uniqueness without additional 90*4882a593Smuzhiyunchecking required. 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun3) Root node properties 94*4882a593Smuzhiyun----------------------- 95*4882a593Smuzhiyun 96*4882a593SmuzhiyunRoot node of the uImage Tree should have the following layout: 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun/ o image-tree 99*4882a593Smuzhiyun |- description = "image description" 100*4882a593Smuzhiyun |- timestamp = <12399321> 101*4882a593Smuzhiyun |- #address-cells = <1> 102*4882a593Smuzhiyun | 103*4882a593Smuzhiyun o images 104*4882a593Smuzhiyun | | 105*4882a593Smuzhiyun | o image@1 {...} 106*4882a593Smuzhiyun | o image@2 {...} 107*4882a593Smuzhiyun | ... 108*4882a593Smuzhiyun | 109*4882a593Smuzhiyun o configurations 110*4882a593Smuzhiyun |- default = "conf@1" 111*4882a593Smuzhiyun | 112*4882a593Smuzhiyun o conf@1 {...} 113*4882a593Smuzhiyun o conf@2 {...} 114*4882a593Smuzhiyun ... 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun Optional property: 118*4882a593Smuzhiyun - description : Textual description of the uImage 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun Mandatory property: 121*4882a593Smuzhiyun - timestamp : Last image modification time being counted in seconds since 122*4882a593Smuzhiyun 1970-01-01 00:00:00 - to be automatically calculated by mkimage tool. 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun Conditionally mandatory property: 125*4882a593Smuzhiyun - #address-cells : Number of 32bit cells required to represent entry and 126*4882a593Smuzhiyun load addresses supplied within sub-image nodes. May be omitted when no 127*4882a593Smuzhiyun entry or load addresses are used. 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun Mandatory node: 130*4882a593Smuzhiyun - images : This node contains a set of sub-nodes, each of them representing 131*4882a593Smuzhiyun single component sub-image (like kernel, ramdisk, etc.). At least one 132*4882a593Smuzhiyun sub-image is required. 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun Optional node: 135*4882a593Smuzhiyun - configurations : Contains a set of available configuration nodes and 136*4882a593Smuzhiyun defines a default configuration. 137*4882a593Smuzhiyun 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun4) '/images' node 140*4882a593Smuzhiyun----------------- 141*4882a593Smuzhiyun 142*4882a593SmuzhiyunThis node is a container node for component sub-image nodes. Each sub-node of 143*4882a593Smuzhiyunthe '/images' node should have the following layout: 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun o image@1 146*4882a593Smuzhiyun |- description = "component sub-image description" 147*4882a593Smuzhiyun |- data = /incbin/("path/to/data/file.bin") 148*4882a593Smuzhiyun |- type = "sub-image type name" 149*4882a593Smuzhiyun |- arch = "ARCH name" 150*4882a593Smuzhiyun |- os = "OS name" 151*4882a593Smuzhiyun |- compression = "compression name" 152*4882a593Smuzhiyun |- load = <00000000> 153*4882a593Smuzhiyun |- entry = <00000000> 154*4882a593Smuzhiyun | 155*4882a593Smuzhiyun o hash@1 {...} 156*4882a593Smuzhiyun o hash@2 {...} 157*4882a593Smuzhiyun ... 158*4882a593Smuzhiyun 159*4882a593Smuzhiyun Mandatory properties: 160*4882a593Smuzhiyun - description : Textual description of the component sub-image 161*4882a593Smuzhiyun - type : Name of component sub-image type, supported types are: 162*4882a593Smuzhiyun "standalone", "kernel", "kernel_noload", "ramdisk", "firmware", "script", 163*4882a593Smuzhiyun "filesystem", "flat_dt" and others (see uimage_type in common/image.c). 164*4882a593Smuzhiyun - data : Path to the external file which contains this node's binary data. 165*4882a593Smuzhiyun - compression : Compression used by included data. Supported compressions 166*4882a593Smuzhiyun are "gzip" and "bzip2". If no compression is used compression property 167*4882a593Smuzhiyun should be set to "none". 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun Conditionally mandatory property: 170*4882a593Smuzhiyun - os : OS name, mandatory for types "kernel" and "ramdisk". Valid OS names 171*4882a593Smuzhiyun are: "openbsd", "netbsd", "freebsd", "4_4bsd", "linux", "svr4", "esix", 172*4882a593Smuzhiyun "solaris", "irix", "sco", "dell", "ncr", "lynxos", "vxworks", "psos", "qnx", 173*4882a593Smuzhiyun "u_boot", "rtems", "unity", "integrity". 174*4882a593Smuzhiyun - arch : Architecture name, mandatory for types: "standalone", "kernel", 175*4882a593Smuzhiyun "firmware", "ramdisk" and "fdt". Valid architecture names are: "alpha", 176*4882a593Smuzhiyun "arm", "i386", "ia64", "mips", "mips64", "ppc", "s390", "sh", "sparc", 177*4882a593Smuzhiyun "sparc64", "m68k", "microblaze", "nios2", "blackfin", "avr32", "st200", 178*4882a593Smuzhiyun "sandbox". 179*4882a593Smuzhiyun - entry : entry point address, address size is determined by 180*4882a593Smuzhiyun '#address-cells' property of the root node. Mandatory for for types: 181*4882a593Smuzhiyun "standalone" and "kernel". 182*4882a593Smuzhiyun - load : load address, address size is determined by '#address-cells' 183*4882a593Smuzhiyun property of the root node. Mandatory for types: "standalone" and "kernel". 184*4882a593Smuzhiyun 185*4882a593Smuzhiyun Optional nodes: 186*4882a593Smuzhiyun - hash@1 : Each hash sub-node represents separate hash or checksum 187*4882a593Smuzhiyun calculated for node's data according to specified algorithm. 188*4882a593Smuzhiyun 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun5) Hash nodes 191*4882a593Smuzhiyun------------- 192*4882a593Smuzhiyun 193*4882a593Smuzhiyuno hash@1 194*4882a593Smuzhiyun |- algo = "hash or checksum algorithm name" 195*4882a593Smuzhiyun |- value = [hash or checksum value] 196*4882a593Smuzhiyun 197*4882a593Smuzhiyun Mandatory properties: 198*4882a593Smuzhiyun - algo : Algorithm name, supported are "crc32", "md5" and "sha1". 199*4882a593Smuzhiyun - value : Actual checksum or hash value, correspondingly 4, 16 or 20 bytes 200*4882a593Smuzhiyun long. 201*4882a593Smuzhiyun 202*4882a593Smuzhiyun 203*4882a593Smuzhiyun6) '/configurations' node 204*4882a593Smuzhiyun------------------------- 205*4882a593Smuzhiyun 206*4882a593SmuzhiyunThe 'configurations' node is optional. If present, it allows to create a 207*4882a593Smuzhiyunconvenient, labeled boot configurations, which combine together kernel images 208*4882a593Smuzhiyunwith their ramdisks and fdt blobs. 209*4882a593Smuzhiyun 210*4882a593SmuzhiyunThe 'configurations' node has has the following structure: 211*4882a593Smuzhiyun 212*4882a593Smuzhiyuno configurations 213*4882a593Smuzhiyun |- default = "default configuration sub-node unit name" 214*4882a593Smuzhiyun | 215*4882a593Smuzhiyun o config@1 {...} 216*4882a593Smuzhiyun o config@2 {...} 217*4882a593Smuzhiyun ... 218*4882a593Smuzhiyun 219*4882a593Smuzhiyun 220*4882a593Smuzhiyun Optional property: 221*4882a593Smuzhiyun - default : Selects one of the configuration sub-nodes as a default 222*4882a593Smuzhiyun configuration. 223*4882a593Smuzhiyun 224*4882a593Smuzhiyun Mandatory nodes: 225*4882a593Smuzhiyun - configuration-sub-node-unit-name : At least one of the configuration 226*4882a593Smuzhiyun sub-nodes is required. 227*4882a593Smuzhiyun 228*4882a593Smuzhiyun 229*4882a593Smuzhiyun7) Configuration nodes 230*4882a593Smuzhiyun---------------------- 231*4882a593Smuzhiyun 232*4882a593SmuzhiyunEach configuration has the following structure: 233*4882a593Smuzhiyun 234*4882a593Smuzhiyuno config@1 235*4882a593Smuzhiyun |- description = "configuration description" 236*4882a593Smuzhiyun |- kernel = "kernel sub-node unit name" 237*4882a593Smuzhiyun |- ramdisk = "ramdisk sub-node unit name" 238*4882a593Smuzhiyun |- fdt = "fdt sub-node unit-name" [, "fdt overlay sub-node unit-name", ...] 239*4882a593Smuzhiyun |- fpga = "fpga sub-node unit-name" 240*4882a593Smuzhiyun |- loadables = "loadables sub-node unit-name" 241*4882a593Smuzhiyun 242*4882a593Smuzhiyun 243*4882a593Smuzhiyun Mandatory properties: 244*4882a593Smuzhiyun - description : Textual configuration description. 245*4882a593Smuzhiyun - kernel : Unit name of the corresponding kernel image (image sub-node of a 246*4882a593Smuzhiyun "kernel" type). 247*4882a593Smuzhiyun 248*4882a593Smuzhiyun Optional properties: 249*4882a593Smuzhiyun - ramdisk : Unit name of the corresponding ramdisk image (component image 250*4882a593Smuzhiyun node of a "ramdisk" type). 251*4882a593Smuzhiyun - fdt : Unit name of the corresponding fdt blob (component image node of a 252*4882a593Smuzhiyun "fdt type"). Additional fdt overlay nodes can be supplied which signify 253*4882a593Smuzhiyun that the resulting device tree blob is generated by the first base fdt 254*4882a593Smuzhiyun blob with all subsequent overlays applied. 255*4882a593Smuzhiyun - setup : Unit name of the corresponding setup binary (used for booting 256*4882a593Smuzhiyun an x86 kernel). This contains the setup.bin file built by the kernel. 257*4882a593Smuzhiyun - fpga : Unit name of the corresponding fpga bitstream blob 258*4882a593Smuzhiyun (component image node of a "fpga type"). 259*4882a593Smuzhiyun - loadables : Unit name containing a list of additional binaries to be 260*4882a593Smuzhiyun loaded at their given locations. "loadables" is a comma-separated list 261*4882a593Smuzhiyun of strings. U-Boot will load each binary at its given start-address and 262*4882a593Smuzhiyun may optionaly invoke additional post-processing steps on this binary based 263*4882a593Smuzhiyun on its component image node type. 264*4882a593Smuzhiyun 265*4882a593SmuzhiyunThe FDT blob is required to properly boot FDT based kernel, so the minimal 266*4882a593Smuzhiyunconfiguration for 2.6 FDT kernel is (kernel, fdt) pair. 267*4882a593Smuzhiyun 268*4882a593SmuzhiyunOlder, 2.4 kernel and 2.6 non-FDT kernel do not use FDT blob, in such cases 269*4882a593Smuzhiyun'struct bd_info' must be passed instead of FDT blob, thus fdt property *must 270*4882a593Smuzhiyunnot* be specified in a configuration node. 271*4882a593Smuzhiyun 272*4882a593Smuzhiyun 273*4882a593Smuzhiyun8) External data 274*4882a593Smuzhiyun---------------- 275*4882a593Smuzhiyun 276*4882a593SmuzhiyunThe above format shows a 'data' property which holds the data for each image. 277*4882a593SmuzhiyunIt is also possible for this data to reside outside the FIT itself. This 278*4882a593Smuzhiyunallows the FIT to be quite small, so that it can be loaded and scanned 279*4882a593Smuzhiyunwithout loading a large amount of data. Then when an image is needed it can 280*4882a593Smuzhiyunbe loaded from an external source. 281*4882a593Smuzhiyun 282*4882a593SmuzhiyunIn this case the 'data' property is omitted. Instead you can use: 283*4882a593Smuzhiyun 284*4882a593Smuzhiyun - data-offset : offset of the data in a separate image store. The image 285*4882a593Smuzhiyun store is placed immediately after the last byte of the device tree binary, 286*4882a593Smuzhiyun aligned to a 4-byte boundary. 287*4882a593Smuzhiyun - data-size : size of the data in bytes 288*4882a593Smuzhiyun 289*4882a593SmuzhiyunThe 'data-offset' property can be substituted with 'data-position', which 290*4882a593Smuzhiyundefines an absolute position or address as the offset. This is helpful when 291*4882a593Smuzhiyunbooting U-Boot proper before performing relocation. Pass '-p [offset]' to 292*4882a593Smuzhiyunmkimage to enable 'data-position'. 293*4882a593Smuzhiyun 294*4882a593SmuzhiyunNormal kernel FIT image has data embedded within FIT structure. U-Boot image 295*4882a593Smuzhiyunfor SPL boot has external data. Existence of 'data-offset' can be used to 296*4882a593Smuzhiyunidentify which format is used. 297*4882a593Smuzhiyun 298*4882a593Smuzhiyun9) Examples 299*4882a593Smuzhiyun----------- 300*4882a593Smuzhiyun 301*4882a593SmuzhiyunPlease see doc/uImage.FIT/*.its for actual image source files. 302