1bf7fd50bSSimon Glass# SPDX-License-Identifier: GPL-2.0+ 283d290c5STom Rini# Copyright (c) 2016 Google, Inc 3bf7fd50bSSimon Glass 4bf7fd50bSSimon GlassIntroduction 5bf7fd50bSSimon Glass------------ 6bf7fd50bSSimon Glass 7bf7fd50bSSimon GlassFirmware often consists of several components which must be packaged together. 8bf7fd50bSSimon GlassFor example, we may have SPL, U-Boot, a device tree and an environment area 9bf7fd50bSSimon Glassgrouped together and placed in MMC flash. When the system starts, it must be 10bf7fd50bSSimon Glassable to find these pieces. 11bf7fd50bSSimon Glass 12bf7fd50bSSimon GlassSo far U-Boot has not provided a way to handle creating such images in a 13bf7fd50bSSimon Glassgeneral way. Each SoC does what it needs to build an image, often packing or 14bf7fd50bSSimon Glassconcatenating images in the U-Boot build system. 15bf7fd50bSSimon Glass 16bf7fd50bSSimon GlassBinman aims to provide a mechanism for building images, from simple 17bf7fd50bSSimon GlassSPL + U-Boot combinations, to more complex arrangements with many parts. 18bf7fd50bSSimon Glass 19bf7fd50bSSimon Glass 20bf7fd50bSSimon GlassWhat it does 21bf7fd50bSSimon Glass------------ 22bf7fd50bSSimon Glass 23bf7fd50bSSimon GlassBinman reads your board's device tree and finds a node which describes the 24bf7fd50bSSimon Glassrequired image layout. It uses this to work out what to place where. The 25bf7fd50bSSimon Glassoutput file normally contains the device tree, so it is in principle possible 26bf7fd50bSSimon Glassto read an image and extract its constituent parts. 27bf7fd50bSSimon Glass 28bf7fd50bSSimon Glass 29bf7fd50bSSimon GlassFeatures 30bf7fd50bSSimon Glass-------- 31bf7fd50bSSimon Glass 32bf7fd50bSSimon GlassSo far binman is pretty simple. It supports binary blobs, such as 'u-boot', 33bf7fd50bSSimon Glass'spl' and 'fdt'. It supports empty entries (such as setting to 0xff). It can 34bf7fd50bSSimon Glassplace entries at a fixed location in the image, or fit them together with 35bf7fd50bSSimon Glasssuitable padding and alignment. It provides a way to process binaries before 36bf7fd50bSSimon Glassthey are included, by adding a Python plug-in. The device tree is available 37bf7fd50bSSimon Glassto U-Boot at run-time so that the images can be interpreted. 38bf7fd50bSSimon Glass 39bf7fd50bSSimon GlassBinman does not yet update the device tree with the final location of 40bf7fd50bSSimon Glasseverything when it is done. A simple C structure could be generated for 41bf7fd50bSSimon Glassconstrained environments like SPL (using dtoc) but this is also not 42bf7fd50bSSimon Glassimplemented. 43bf7fd50bSSimon Glass 44bf7fd50bSSimon GlassBinman can also support incorporating filesystems in the image if required. 45bf7fd50bSSimon GlassFor example x86 platforms may use CBFS in some cases. 46bf7fd50bSSimon Glass 47bf7fd50bSSimon GlassBinman is intended for use with U-Boot but is designed to be general enough 48bf7fd50bSSimon Glassto be useful in other image-packaging situations. 49bf7fd50bSSimon Glass 50bf7fd50bSSimon Glass 51bf7fd50bSSimon GlassMotivation 52bf7fd50bSSimon Glass---------- 53bf7fd50bSSimon Glass 54bf7fd50bSSimon GlassPackaging of firmware is quite a different task from building the various 55bf7fd50bSSimon Glassparts. In many cases the various binaries which go into the image come from 56bf7fd50bSSimon Glassseparate build systems. For example, ARM Trusted Firmware is used on ARMv8 57bf7fd50bSSimon Glassdevices but is not built in the U-Boot tree. If a Linux kernel is included 58bf7fd50bSSimon Glassin the firmware image, it is built elsewhere. 59bf7fd50bSSimon Glass 60bf7fd50bSSimon GlassIt is of course possible to add more and more build rules to the U-Boot 61bf7fd50bSSimon Glassbuild system to cover these cases. It can shell out to other Makefiles and 62bf7fd50bSSimon Glassbuild scripts. But it seems better to create a clear divide between building 63bf7fd50bSSimon Glasssoftware and packaging it. 64bf7fd50bSSimon Glass 65bf7fd50bSSimon GlassAt present this is handled by manual instructions, different for each board, 66bf7fd50bSSimon Glasson how to create images that will boot. By turning these instructions into a 67bf7fd50bSSimon Glassstandard format, we can support making valid images for any board without 68bf7fd50bSSimon Glassmanual effort, lots of READMEs, etc. 69bf7fd50bSSimon Glass 70bf7fd50bSSimon GlassBenefits: 71bf7fd50bSSimon Glass- Each binary can have its own build system and tool chain without creating 72bf7fd50bSSimon Glassany dependencies between them 73bf7fd50bSSimon Glass- Avoids the need for a single-shot build: individual parts can be updated 74bf7fd50bSSimon Glassand brought in as needed 75bf7fd50bSSimon Glass- Provides for a standard image description available in the build and at 76bf7fd50bSSimon Glassrun-time 77bf7fd50bSSimon Glass- SoC-specific image-signing tools can be accomodated 78bf7fd50bSSimon Glass- Avoids cluttering the U-Boot build system with image-building code 79bf7fd50bSSimon Glass- The image description is automatically available at run-time in U-Boot, 80bf7fd50bSSimon GlassSPL. It can be made available to other software also 81bf7fd50bSSimon Glass- The image description is easily readable (it's a text file in device-tree 82bf7fd50bSSimon Glassformat) and permits flexible packing of binaries 83bf7fd50bSSimon Glass 84bf7fd50bSSimon Glass 85bf7fd50bSSimon GlassTerminology 86bf7fd50bSSimon Glass----------- 87bf7fd50bSSimon Glass 88bf7fd50bSSimon GlassBinman uses the following terms: 89bf7fd50bSSimon Glass 90bf7fd50bSSimon Glass- image - an output file containing a firmware image 91bf7fd50bSSimon Glass- binary - an input binary that goes into the image 92bf7fd50bSSimon Glass 93bf7fd50bSSimon Glass 94bf7fd50bSSimon GlassRelationship to FIT 95bf7fd50bSSimon Glass------------------- 96bf7fd50bSSimon Glass 97bf7fd50bSSimon GlassFIT is U-Boot's official image format. It supports multiple binaries with 98bf7fd50bSSimon Glassload / execution addresses, compression. It also supports verification 99bf7fd50bSSimon Glassthrough hashing and RSA signatures. 100bf7fd50bSSimon Glass 101bf7fd50bSSimon GlassFIT was originally designed to support booting a Linux kernel (with an 102bf7fd50bSSimon Glassoptional ramdisk) and device tree chosen from various options in the FIT. 103bf7fd50bSSimon GlassNow that U-Boot supports configuration via device tree, it is possible to 104bf7fd50bSSimon Glassload U-Boot from a FIT, with the device tree chosen by SPL. 105bf7fd50bSSimon Glass 106bf7fd50bSSimon GlassBinman considers FIT to be one of the binaries it can place in the image. 107bf7fd50bSSimon Glass 108bf7fd50bSSimon GlassWhere possible it is best to put as much as possible in the FIT, with binman 109bf7fd50bSSimon Glassused to deal with cases not covered by FIT. Examples include initial 110bf7fd50bSSimon Glassexecution (since FIT itself does not have an executable header) and dealing 111bf7fd50bSSimon Glasswith device boundaries, such as the read-only/read-write separation in SPI 112bf7fd50bSSimon Glassflash. 113bf7fd50bSSimon Glass 114bf7fd50bSSimon GlassFor U-Boot, binman should not be used to create ad-hoc images in place of 115bf7fd50bSSimon GlassFIT. 116bf7fd50bSSimon Glass 117bf7fd50bSSimon Glass 118bf7fd50bSSimon GlassRelationship to mkimage 119bf7fd50bSSimon Glass----------------------- 120bf7fd50bSSimon Glass 121bf7fd50bSSimon GlassThe mkimage tool provides a means to create a FIT. Traditionally it has 122bf7fd50bSSimon Glassneeded an image description file: a device tree, like binman, but in a 123bf7fd50bSSimon Glassdifferent format. More recently it has started to support a '-f auto' mode 124bf7fd50bSSimon Glasswhich can generate that automatically. 125bf7fd50bSSimon Glass 126bf7fd50bSSimon GlassMore relevant to binman, mkimage also permits creation of many SoC-specific 127bf7fd50bSSimon Glassimage types. These can be listed by running 'mkimage -T list'. Examples 128bf7fd50bSSimon Glassinclude 'rksd', the Rockchip SD/MMC boot format. The mkimage tool is often 129bf7fd50bSSimon Glasscalled from the U-Boot build system for this reason. 130bf7fd50bSSimon Glass 131bf7fd50bSSimon GlassBinman considers the output files created by mkimage to be binary blobs 132bf7fd50bSSimon Glasswhich it can place in an image. Binman does not replace the mkimage tool or 133383d2568SMichael Heimpoldthis purpose. It would be possible in some situations to create a new entry 134bf7fd50bSSimon Glasstype for the images in mkimage, but this would not add functionality. It 135383d2568SMichael Heimpoldseems better to use the mkimage tool to generate binaries and avoid blurring 136bf7fd50bSSimon Glassthe boundaries between building input files (mkimage) and packaging then 137bf7fd50bSSimon Glassinto a final image (binman). 138bf7fd50bSSimon Glass 139bf7fd50bSSimon Glass 140bf7fd50bSSimon GlassExample use of binman in U-Boot 141bf7fd50bSSimon Glass------------------------------- 142bf7fd50bSSimon Glass 143bf7fd50bSSimon GlassBinman aims to replace some of the ad-hoc image creation in the U-Boot 144bf7fd50bSSimon Glassbuild system. 145bf7fd50bSSimon Glass 146bf7fd50bSSimon GlassConsider sunxi. It has the following steps: 147bf7fd50bSSimon Glass 148bf7fd50bSSimon Glass1. It uses a custom mksunxiboot tool to build an SPL image called 149bf7fd50bSSimon Glasssunxi-spl.bin. This should probably move into mkimage. 150bf7fd50bSSimon Glass 151bf7fd50bSSimon Glass2. It uses mkimage to package U-Boot into a legacy image file (so that it can 152bf7fd50bSSimon Glasshold the load and execution address) called u-boot.img. 153bf7fd50bSSimon Glass 154bf7fd50bSSimon Glass3. It builds a final output image called u-boot-sunxi-with-spl.bin which 155bf7fd50bSSimon Glassconsists of sunxi-spl.bin, some padding and u-boot.img. 156bf7fd50bSSimon Glass 157bf7fd50bSSimon GlassBinman is intended to replace the last step. The U-Boot build system builds 158bf7fd50bSSimon Glassu-boot.bin and sunxi-spl.bin. Binman can then take over creation of 159bf7fd50bSSimon Glasssunxi-spl.bin (by calling mksunxiboot, or hopefully one day mkimage). In any 160bf7fd50bSSimon Glasscase, it would then create the image from the component parts. 161bf7fd50bSSimon Glass 162bf7fd50bSSimon GlassThis simplifies the U-Boot Makefile somewhat, since various pieces of logic 163bf7fd50bSSimon Glasscan be replaced by a call to binman. 164bf7fd50bSSimon Glass 165bf7fd50bSSimon Glass 166bf7fd50bSSimon GlassExample use of binman for x86 167bf7fd50bSSimon Glass----------------------------- 168bf7fd50bSSimon Glass 169bf7fd50bSSimon GlassIn most cases x86 images have a lot of binary blobs, 'black-box' code 170bf7fd50bSSimon Glassprovided by Intel which must be run for the platform to work. Typically 171bf7fd50bSSimon Glassthese blobs are not relocatable and must be placed at fixed areas in the 172383d2568SMichael Heimpoldfirmware image. 173bf7fd50bSSimon Glass 174bf7fd50bSSimon GlassCurrently this is handled by ifdtool, which places microcode, FSP, MRC, VGA 175bf7fd50bSSimon GlassBIOS, reference code and Intel ME binaries into a u-boot.rom file. 176bf7fd50bSSimon Glass 177bf7fd50bSSimon GlassBinman is intended to replace all of this, with ifdtool left to handle only 178bf7fd50bSSimon Glassthe configuration of the Intel-format descriptor. 179bf7fd50bSSimon Glass 180bf7fd50bSSimon Glass 181bf7fd50bSSimon GlassRunning binman 182bf7fd50bSSimon Glass-------------- 183bf7fd50bSSimon Glass 184bf7fd50bSSimon GlassType: 185bf7fd50bSSimon Glass 186bf7fd50bSSimon Glass binman -b <board_name> 187bf7fd50bSSimon Glass 188bf7fd50bSSimon Glassto build an image for a board. The board name is the same name used when 189bf7fd50bSSimon Glassconfiguring U-Boot (e.g. for sandbox_defconfig the board name is 'sandbox'). 190bf7fd50bSSimon GlassBinman assumes that the input files for the build are in ../b/<board_name>. 191bf7fd50bSSimon Glass 192bf7fd50bSSimon GlassOr you can specify this explicitly: 193bf7fd50bSSimon Glass 194bf7fd50bSSimon Glass binman -I <build_path> 195bf7fd50bSSimon Glass 196bf7fd50bSSimon Glasswhere <build_path> is the build directory containing the output of the U-Boot 197bf7fd50bSSimon Glassbuild. 198bf7fd50bSSimon Glass 199bf7fd50bSSimon Glass(Future work will make this more configurable) 200bf7fd50bSSimon Glass 201bf7fd50bSSimon GlassIn either case, binman picks up the device tree file (u-boot.dtb) and looks 202bf7fd50bSSimon Glassfor its instructions in the 'binman' node. 203bf7fd50bSSimon Glass 204bf7fd50bSSimon GlassBinman has a few other options which you can see by running 'binman -h'. 205bf7fd50bSSimon Glass 206bf7fd50bSSimon Glass 2079c0a8b1fSSimon GlassEnabling binman for a board 2089c0a8b1fSSimon Glass--------------------------- 2099c0a8b1fSSimon Glass 2109c0a8b1fSSimon GlassAt present binman is invoked from a rule in the main Makefile. Typically you 2119c0a8b1fSSimon Glasswill have a rule like: 2129c0a8b1fSSimon Glass 2139c0a8b1fSSimon Glassifneq ($(CONFIG_ARCH_<something>),) 2149c0a8b1fSSimon Glassu-boot-<your_suffix>.bin: <input_file_1> <input_file_2> checkbinman FORCE 2159c0a8b1fSSimon Glass $(call if_changed,binman) 2169c0a8b1fSSimon Glassendif 2179c0a8b1fSSimon Glass 2189c0a8b1fSSimon GlassThis assumes that u-boot-<your_suffix>.bin is a target, and is the final file 2199c0a8b1fSSimon Glassthat you need to produce. You can make it a target by adding it to ALL-y 2209c0a8b1fSSimon Glasseither in the main Makefile or in a config.mk file in your arch subdirectory. 2219c0a8b1fSSimon Glass 2229c0a8b1fSSimon GlassOnce binman is executed it will pick up its instructions from a device-tree 2239c0a8b1fSSimon Glassfile, typically <soc>-u-boot.dtsi, where <soc> is your CONFIG_SYS_SOC value. 2249c0a8b1fSSimon GlassYou can use other, more specific CONFIG options - see 'Automatic .dtsi 2259c0a8b1fSSimon Glassinclusion' below. 2269c0a8b1fSSimon Glass 2279c0a8b1fSSimon Glass 228bf7fd50bSSimon GlassImage description format 229bf7fd50bSSimon Glass------------------------ 230bf7fd50bSSimon Glass 231bf7fd50bSSimon GlassThe binman node is called 'binman'. An example image description is shown 232bf7fd50bSSimon Glassbelow: 233bf7fd50bSSimon Glass 234bf7fd50bSSimon Glass binman { 235bf7fd50bSSimon Glass filename = "u-boot-sunxi-with-spl.bin"; 236bf7fd50bSSimon Glass pad-byte = <0xff>; 237bf7fd50bSSimon Glass blob { 238bf7fd50bSSimon Glass filename = "spl/sunxi-spl.bin"; 239bf7fd50bSSimon Glass }; 240bf7fd50bSSimon Glass u-boot { 2413ab9598dSSimon Glass offset = <CONFIG_SPL_PAD_TO>; 242bf7fd50bSSimon Glass }; 243bf7fd50bSSimon Glass }; 244bf7fd50bSSimon Glass 245bf7fd50bSSimon Glass 246bf7fd50bSSimon GlassThis requests binman to create an image file called u-boot-sunxi-with-spl.bin 247bf7fd50bSSimon Glassconsisting of a specially formatted SPL (spl/sunxi-spl.bin, built by the 248bf7fd50bSSimon Glassnormal U-Boot Makefile), some 0xff padding, and a U-Boot legacy image. The 249bf7fd50bSSimon Glasspadding comes from the fact that the second binary is placed at 250bf7fd50bSSimon GlassCONFIG_SPL_PAD_TO. If that line were omitted then the U-Boot binary would 251bf7fd50bSSimon Glassimmediately follow the SPL binary. 252bf7fd50bSSimon Glass 253bf7fd50bSSimon GlassThe binman node describes an image. The sub-nodes describe entries in the 254bf7fd50bSSimon Glassimage. Each entry represents a region within the overall image. The name of 255bf7fd50bSSimon Glassthe entry (blob, u-boot) tells binman what to put there. For 'blob' we must 256bf7fd50bSSimon Glassprovide a filename. For 'u-boot', binman knows that this means 'u-boot.bin'. 257bf7fd50bSSimon Glass 258bf7fd50bSSimon GlassEntries are normally placed into the image sequentially, one after the other. 259bf7fd50bSSimon GlassThe image size is the total size of all entries. As you can see, you can 2603ab9598dSSimon Glassspecify the start offset of an entry using the 'offset' property. 261bf7fd50bSSimon Glass 262bf7fd50bSSimon GlassNote that due to a device tree requirement, all entries must have a unique 263bf7fd50bSSimon Glassname. If you want to put the same binary in the image multiple times, you can 264bf7fd50bSSimon Glassuse any unique name, with the 'type' property providing the type. 265bf7fd50bSSimon Glass 266bf7fd50bSSimon GlassThe attributes supported for entries are described below. 267bf7fd50bSSimon Glass 2683ab9598dSSimon Glassoffset: 2693ab9598dSSimon Glass This sets the offset of an entry within the image or section containing 2703ab9598dSSimon Glass it. The first byte of the image is normally at offset 0. If 'offset' is 2713ab9598dSSimon Glass not provided, binman sets it to the end of the previous region, or the 2723ab9598dSSimon Glass start of the image's entry area (normally 0) if there is no previous 2733ab9598dSSimon Glass region. 274bf7fd50bSSimon Glass 275bf7fd50bSSimon Glassalign: 2763ab9598dSSimon Glass This sets the alignment of the entry. The entry offset is adjusted 277bf7fd50bSSimon Glass so that the entry starts on an aligned boundary within the image. For 278bf7fd50bSSimon Glass example 'align = <16>' means that the entry will start on a 16-byte 279bf7fd50bSSimon Glass boundary. Alignment shold be a power of 2. If 'align' is not 280bf7fd50bSSimon Glass provided, no alignment is performed. 281bf7fd50bSSimon Glass 282bf7fd50bSSimon Glasssize: 283bf7fd50bSSimon Glass This sets the size of the entry. The contents will be padded out to 284bf7fd50bSSimon Glass this size. If this is not provided, it will be set to the size of the 285bf7fd50bSSimon Glass contents. 286bf7fd50bSSimon Glass 287bf7fd50bSSimon Glasspad-before: 288bf7fd50bSSimon Glass Padding before the contents of the entry. Normally this is 0, meaning 289bf7fd50bSSimon Glass that the contents start at the beginning of the entry. This can be 290bf7fd50bSSimon Glass offset the entry contents a little. Defaults to 0. 291bf7fd50bSSimon Glass 292bf7fd50bSSimon Glasspad-after: 293bf7fd50bSSimon Glass Padding after the contents of the entry. Normally this is 0, meaning 294bf7fd50bSSimon Glass that the entry ends at the last byte of content (unless adjusted by 295bf7fd50bSSimon Glass other properties). This allows room to be created in the image for 296bf7fd50bSSimon Glass this entry to expand later. Defaults to 0. 297bf7fd50bSSimon Glass 298bf7fd50bSSimon Glassalign-size: 299bf7fd50bSSimon Glass This sets the alignment of the entry size. For example, to ensure 300bf7fd50bSSimon Glass that the size of an entry is a multiple of 64 bytes, set this to 64. 301bf7fd50bSSimon Glass If 'align-size' is not provided, no alignment is performed. 302bf7fd50bSSimon Glass 303bf7fd50bSSimon Glassalign-end: 304bf7fd50bSSimon Glass This sets the alignment of the end of an entry. Some entries require 305bf7fd50bSSimon Glass that they end on an alignment boundary, regardless of where they 306844e5b20SSimon Glass start. This does not move the start of the entry, so the contents of 307844e5b20SSimon Glass the entry will still start at the beginning. But there may be padding 308844e5b20SSimon Glass at the end. If 'align-end' is not provided, no alignment is performed. 309bf7fd50bSSimon Glass 310bf7fd50bSSimon Glassfilename: 311bf7fd50bSSimon Glass For 'blob' types this provides the filename containing the binary to 312bf7fd50bSSimon Glass put into the entry. If binman knows about the entry type (like 313bf7fd50bSSimon Glass u-boot-bin), then there is no need to specify this. 314bf7fd50bSSimon Glass 315bf7fd50bSSimon Glasstype: 316bf7fd50bSSimon Glass Sets the type of an entry. This defaults to the entry name, but it is 317bf7fd50bSSimon Glass possible to use any name, and then add (for example) 'type = "u-boot"' 318bf7fd50bSSimon Glass to specify the type. 319bf7fd50bSSimon Glass 3203ab9598dSSimon Glassoffset-unset: 3213ab9598dSSimon Glass Indicates that the offset of this entry should not be set by placing 322258fb0e6SSimon Glass it immediately after the entry before. Instead, is set by another 323258fb0e6SSimon Glass entry which knows where this entry should go. When this boolean 324258fb0e6SSimon Glass property is present, binman will give an error if another entry does 3253ab9598dSSimon Glass not set the offset (with the GetOffsets() method). 326258fb0e6SSimon Glass 327dbf6be9fSSimon Glassimage-pos: 328dbf6be9fSSimon Glass This cannot be set on entry (or at least it is ignored if it is), but 329dbf6be9fSSimon Glass with the -u option, binman will set it to the absolute image position 330dbf6be9fSSimon Glass for each entry. This makes it easy to find out exactly where the entry 331dbf6be9fSSimon Glass ended up in the image, regardless of parent sections, etc. 332dbf6be9fSSimon Glass 333ba64a0bbSSimon Glassexpand-size: 334ba64a0bbSSimon Glass Expand the size of this entry to fit available space. This space is only 335ba64a0bbSSimon Glass limited by the size of the image/section and the position of the next 336ba64a0bbSSimon Glass entry. 337bf7fd50bSSimon Glass 3389c888ccaSSimon GlassThe attributes supported for images and sections are described below. Several 3399c888ccaSSimon Glassare similar to those for entries. 340bf7fd50bSSimon Glass 341bf7fd50bSSimon Glasssize: 342bf7fd50bSSimon Glass Sets the image size in bytes, for example 'size = <0x100000>' for a 343bf7fd50bSSimon Glass 1MB image. 344bf7fd50bSSimon Glass 345bf7fd50bSSimon Glassalign-size: 346bf7fd50bSSimon Glass This sets the alignment of the image size. For example, to ensure 347bf7fd50bSSimon Glass that the image ends on a 512-byte boundary, use 'align-size = <512>'. 348bf7fd50bSSimon Glass If 'align-size' is not provided, no alignment is performed. 349bf7fd50bSSimon Glass 350bf7fd50bSSimon Glasspad-before: 351bf7fd50bSSimon Glass This sets the padding before the image entries. The first entry will 3523ab9598dSSimon Glass be positioned after the padding. This defaults to 0. 353bf7fd50bSSimon Glass 354bf7fd50bSSimon Glasspad-after: 355bf7fd50bSSimon Glass This sets the padding after the image entries. The padding will be 356bf7fd50bSSimon Glass placed after the last entry. This defaults to 0. 357bf7fd50bSSimon Glass 358bf7fd50bSSimon Glasspad-byte: 359bf7fd50bSSimon Glass This specifies the pad byte to use when padding in the image. It 360bf7fd50bSSimon Glass defaults to 0. To use 0xff, you would add 'pad-byte = <0xff>'. 361bf7fd50bSSimon Glass 362bf7fd50bSSimon Glassfilename: 363bf7fd50bSSimon Glass This specifies the image filename. It defaults to 'image.bin'. 364bf7fd50bSSimon Glass 3653ab9598dSSimon Glasssort-by-offset: 366bf7fd50bSSimon Glass This causes binman to reorder the entries as needed to make sure they 367bf7fd50bSSimon Glass are in increasing positional order. This can be used when your entry 368bf7fd50bSSimon Glass order may not match the positional order. A common situation is where 3693ab9598dSSimon Glass the 'offset' properties are set by CONFIG options, so their ordering is 370bf7fd50bSSimon Glass not known a priori. 371bf7fd50bSSimon Glass 372bf7fd50bSSimon Glass This is a boolean property so needs no value. To enable it, add a 3733ab9598dSSimon Glass line 'sort-by-offset;' to your description. 374bf7fd50bSSimon Glass 375bf7fd50bSSimon Glassmultiple-images: 376bf7fd50bSSimon Glass Normally only a single image is generated. To create more than one 377bf7fd50bSSimon Glass image, put this property in the binman node. For example, this will 378bf7fd50bSSimon Glass create image1.bin containing u-boot.bin, and image2.bin containing 379bf7fd50bSSimon Glass both spl/u-boot-spl.bin and u-boot.bin: 380bf7fd50bSSimon Glass 381bf7fd50bSSimon Glass binman { 382bf7fd50bSSimon Glass multiple-images; 383bf7fd50bSSimon Glass image1 { 384bf7fd50bSSimon Glass u-boot { 385bf7fd50bSSimon Glass }; 386bf7fd50bSSimon Glass }; 387bf7fd50bSSimon Glass 388bf7fd50bSSimon Glass image2 { 389bf7fd50bSSimon Glass spl { 390bf7fd50bSSimon Glass }; 391bf7fd50bSSimon Glass u-boot { 392bf7fd50bSSimon Glass }; 393bf7fd50bSSimon Glass }; 394bf7fd50bSSimon Glass }; 395bf7fd50bSSimon Glass 396bf7fd50bSSimon Glassend-at-4gb: 3973ab9598dSSimon Glass For x86 machines the ROM offsets start just before 4GB and extend 398bf7fd50bSSimon Glass up so that the image finished at the 4GB boundary. This boolean 399bf7fd50bSSimon Glass option can be enabled to support this. The image size must be 400bf7fd50bSSimon Glass provided so that binman knows when the image should start. For an 4013ab9598dSSimon Glass 8MB ROM, the offset of the first entry would be 0xfff80000 with 402bf7fd50bSSimon Glass this option, instead of 0 without this option. 403bf7fd50bSSimon Glass 40494b57db0SJagdish Gediyaskip-at-start: 40594b57db0SJagdish Gediya This property specifies the entry offset of the first entry. 40694b57db0SJagdish Gediya 40794b57db0SJagdish Gediya For PowerPC mpc85xx based CPU, CONFIG_SYS_TEXT_BASE is the entry 40894b57db0SJagdish Gediya offset of the first entry. It can be 0xeff40000 or 0xfff40000 for 40994b57db0SJagdish Gediya nor flash boot, 0x201000 for sd boot etc. 41094b57db0SJagdish Gediya 41194b57db0SJagdish Gediya 'end-at-4gb' property is not applicable where CONFIG_SYS_TEXT_BASE + 41294b57db0SJagdish Gediya Image size != 4gb. 413bf7fd50bSSimon Glass 414bf7fd50bSSimon GlassExamples of the above options can be found in the tests. See the 415bf7fd50bSSimon Glasstools/binman/test directory. 416bf7fd50bSSimon Glass 417dd57c13bSSimon GlassIt is possible to have the same binary appear multiple times in the image, 418dd57c13bSSimon Glasseither by using a unit number suffix (u-boot@0, u-boot@1) or by using a 419dd57c13bSSimon Glassdifferent name for each and specifying the type with the 'type' attribute. 420dd57c13bSSimon Glass 421bf7fd50bSSimon Glass 422383d2568SMichael HeimpoldSections and hierachical images 4231854695bSSimon Glass------------------------------- 4241854695bSSimon Glass 4251854695bSSimon GlassSometimes it is convenient to split an image into several pieces, each of which 4261854695bSSimon Glasscontains its own set of binaries. An example is a flash device where part of 4271854695bSSimon Glassthe image is read-only and part is read-write. We can set up sections for each 4281854695bSSimon Glassof these, and place binaries in them independently. The image is still produced 4291854695bSSimon Glassas a single output file. 4301854695bSSimon Glass 4311854695bSSimon GlassThis feature provides a way of creating hierarchical images. For example here 4327ae5f315SSimon Glassis an example image with two copies of U-Boot. One is read-only (ro), intended 4337ae5f315SSimon Glassto be written only in the factory. Another is read-write (rw), so that it can be 4341854695bSSimon Glassupgraded in the field. The sizes are fixed so that the ro/rw boundary is known 4351854695bSSimon Glassand can be programmed: 4361854695bSSimon Glass 4371854695bSSimon Glass binman { 4381854695bSSimon Glass section@0 { 4391854695bSSimon Glass read-only; 440c8d48efbSSimon Glass name-prefix = "ro-"; 4411854695bSSimon Glass size = <0x100000>; 4421854695bSSimon Glass u-boot { 4431854695bSSimon Glass }; 4441854695bSSimon Glass }; 4451854695bSSimon Glass section@1 { 446c8d48efbSSimon Glass name-prefix = "rw-"; 4471854695bSSimon Glass size = <0x100000>; 4481854695bSSimon Glass u-boot { 4491854695bSSimon Glass }; 4501854695bSSimon Glass }; 4511854695bSSimon Glass }; 4521854695bSSimon Glass 4531854695bSSimon GlassThis image could be placed into a SPI flash chip, with the protection boundary 4541854695bSSimon Glassset at 1MB. 4551854695bSSimon Glass 4561854695bSSimon GlassA few special properties are provided for sections: 4571854695bSSimon Glass 4581854695bSSimon Glassread-only: 4591854695bSSimon Glass Indicates that this section is read-only. This has no impact on binman's 4601854695bSSimon Glass operation, but his property can be read at run time. 4611854695bSSimon Glass 462c8d48efbSSimon Glassname-prefix: 463c8d48efbSSimon Glass This string is prepended to all the names of the binaries in the 464c8d48efbSSimon Glass section. In the example above, the 'u-boot' binaries which actually be 465c8d48efbSSimon Glass renamed to 'ro-u-boot' and 'rw-u-boot'. This can be useful to 466c8d48efbSSimon Glass distinguish binaries with otherwise identical names. 467c8d48efbSSimon Glass 4681854695bSSimon Glass 4695a5da7ceSSimon GlassEntry Documentation 4705a5da7ceSSimon Glass------------------- 4715a5da7ceSSimon Glass 4725a5da7ceSSimon GlassFor details on the various entry types supported by binman and how to use them, 4735a5da7ceSSimon Glasssee README.entries. This is generated from the source code using: 4745a5da7ceSSimon Glass 4755a5da7ceSSimon Glass binman -E >tools/binman/README.entries 4765a5da7ceSSimon Glass 4775a5da7ceSSimon Glass 478e0e5df93SSimon GlassHashing Entries 479e0e5df93SSimon Glass--------------- 480e0ff8551SSimon Glass 481e0e5df93SSimon GlassIt is possible to ask binman to hash the contents of an entry and write that 482e0e5df93SSimon Glassvalue back to the device-tree node. For example: 483e0ff8551SSimon Glass 484e0e5df93SSimon Glass binman { 485e0e5df93SSimon Glass u-boot { 486e0e5df93SSimon Glass hash { 487e0e5df93SSimon Glass algo = "sha256"; 488e0e5df93SSimon Glass }; 489e0e5df93SSimon Glass }; 490e0e5df93SSimon Glass }; 491e0e5df93SSimon Glass 492e0e5df93SSimon GlassHere, a new 'value' property will be written to the 'hash' node containing 493e0e5df93SSimon Glassthe hash of the 'u-boot' entry. Only SHA256 is supported at present. Whole 494e0e5df93SSimon Glasssections can be hased if desired, by adding the 'hash' node to the section. 495e0e5df93SSimon Glass 496e0e5df93SSimon GlassThe has value can be chcked at runtime by hashing the data actually read and 497e0e5df93SSimon Glasscomparing this has to the value in the device tree. 498e0ff8551SSimon Glass 499e0ff8551SSimon Glass 500bf7fd50bSSimon GlassOrder of image creation 501bf7fd50bSSimon Glass----------------------- 502bf7fd50bSSimon Glass 503bf7fd50bSSimon GlassImage creation proceeds in the following order, for each entry in the image. 504bf7fd50bSSimon Glass 505078ab1a2SSimon Glass1. AddMissingProperties() - binman can add calculated values to the device 5063ab9598dSSimon Glasstree as part of its processing, for example the offset and size of each 507078ab1a2SSimon Glassentry. This method adds any properties associated with this, expanding the 508078ab1a2SSimon Glassdevice tree as needed. These properties can have placeholder values which are 509078ab1a2SSimon Glassset later by SetCalculatedProperties(). By that stage the size of sections 510078ab1a2SSimon Glasscannot be changed (since it would cause the images to need to be repacked), 511078ab1a2SSimon Glassbut the correct values can be inserted. 512078ab1a2SSimon Glass 513078ab1a2SSimon Glass2. ProcessFdt() - process the device tree information as required by the 514ecab8973SSimon Glassparticular entry. This may involve adding or deleting properties. If the 515ecab8973SSimon Glassprocessing is complete, this method should return True. If the processing 516ecab8973SSimon Glasscannot complete because it needs the ProcessFdt() method of another entry to 517ecab8973SSimon Glassrun first, this method should return False, in which case it will be called 518ecab8973SSimon Glassagain later. 519ecab8973SSimon Glass 520078ab1a2SSimon Glass3. GetEntryContents() - the contents of each entry are obtained, normally by 521bf7fd50bSSimon Glassreading from a file. This calls the Entry.ObtainContents() to read the 522bf7fd50bSSimon Glasscontents. The default version of Entry.ObtainContents() calls 523bf7fd50bSSimon GlassEntry.GetDefaultFilename() and then reads that file. So a common mechanism 524bf7fd50bSSimon Glassto select a file to read is to override that function in the subclass. The 525bf7fd50bSSimon Glassfunctions must return True when they have read the contents. Binman will 526bf7fd50bSSimon Glassretry calling the functions a few times if False is returned, allowing 527bf7fd50bSSimon Glassdependencies between the contents of different entries. 528bf7fd50bSSimon Glass 5293ab9598dSSimon Glass4. GetEntryOffsets() - calls Entry.GetOffsets() for each entry. This can 530bf7fd50bSSimon Glassreturn a dict containing entries that need updating. The key should be the 5313ab9598dSSimon Glassentry name and the value is a tuple (offset, size). This allows an entry to 5323ab9598dSSimon Glassprovide the offset and size for other entries. The default implementation 5333ab9598dSSimon Glassof GetEntryOffsets() returns {}. 534bf7fd50bSSimon Glass 5353ab9598dSSimon Glass5. PackEntries() - calls Entry.Pack() which figures out the offset and 5363ab9598dSSimon Glasssize of an entry. The 'current' image offset is passed in, and the function 5373ab9598dSSimon Glassreturns the offset immediately after the entry being packed. The default 538bf7fd50bSSimon Glassimplementation of Pack() is usually sufficient. 539bf7fd50bSSimon Glass 540078ab1a2SSimon Glass6. CheckSize() - checks that the contents of all the entries fits within 541bf7fd50bSSimon Glassthe image size. If the image does not have a defined size, the size is set 542bf7fd50bSSimon Glasslarge enough to hold all the entries. 543bf7fd50bSSimon Glass 544078ab1a2SSimon Glass7. CheckEntries() - checks that the entries do not overlap, nor extend 545bf7fd50bSSimon Glassoutside the image. 546bf7fd50bSSimon Glass 547078ab1a2SSimon Glass8. SetCalculatedProperties() - update any calculated properties in the device 5483ab9598dSSimon Glasstree. This sets the correct 'offset' and 'size' vaues, for example. 549078ab1a2SSimon Glass 550078ab1a2SSimon Glass9. ProcessEntryContents() - this calls Entry.ProcessContents() on each entry. 551bf7fd50bSSimon GlassThe default implementatoin does nothing. This can be overriden to adjust the 552bf7fd50bSSimon Glasscontents of an entry in some way. For example, it would be possible to create 553bf7fd50bSSimon Glassan entry containing a hash of the contents of some other entries. At this 5543ab9598dSSimon Glassstage the offset and size of entries should not be adjusted. 555bf7fd50bSSimon Glass 556078ab1a2SSimon Glass10. WriteSymbols() - write the value of symbols into the U-Boot SPL binary. 5573ab9598dSSimon GlassSee 'Access to binman entry offsets at run time' below for a description of 5580a4357c4SSimon Glasswhat happens in this stage. 55939c1502cSSimon Glass 560078ab1a2SSimon Glass11. BuildImage() - builds the image and writes it to a file. This is the final 561bf7fd50bSSimon Glassstep. 562bf7fd50bSSimon Glass 563bf7fd50bSSimon Glass 5646d427c6bSSimon GlassAutomatic .dtsi inclusion 5656d427c6bSSimon Glass------------------------- 5666d427c6bSSimon Glass 5676d427c6bSSimon GlassIt is sometimes inconvenient to add a 'binman' node to the .dts file for each 5686d427c6bSSimon Glassboard. This can be done by using #include to bring in a common file. Another 5696d427c6bSSimon Glassapproach supported by the U-Boot build system is to automatically include 5706d427c6bSSimon Glassa common header. You can then put the binman node (and anything else that is 5716d427c6bSSimon Glassspecific to U-Boot, such as u-boot,dm-pre-reloc properies) in that header 5726d427c6bSSimon Glassfile. 5736d427c6bSSimon Glass 5746d427c6bSSimon GlassBinman will search for the following files in arch/<arch>/dts: 5756d427c6bSSimon Glass 5766d427c6bSSimon Glass <dts>-u-boot.dtsi where <dts> is the base name of the .dts file 5776d427c6bSSimon Glass <CONFIG_SYS_SOC>-u-boot.dtsi 5786d427c6bSSimon Glass <CONFIG_SYS_CPU>-u-boot.dtsi 5796d427c6bSSimon Glass <CONFIG_SYS_VENDOR>-u-boot.dtsi 5806d427c6bSSimon Glass u-boot.dtsi 5816d427c6bSSimon Glass 5826d427c6bSSimon GlassU-Boot will only use the first one that it finds. If you need to include a 5836d427c6bSSimon Glassmore general file you can do that from the more specific file using #include. 5846d427c6bSSimon GlassIf you are having trouble figuring out what is going on, you can uncomment 5856d427c6bSSimon Glassthe 'warning' line in scripts/Makefile.lib to see what it has found: 5866d427c6bSSimon Glass 5876d427c6bSSimon Glass # Uncomment for debugging 588511fd0b2SSimon Glass # This shows all the files that were considered and the one that we chose. 589511fd0b2SSimon Glass # u_boot_dtsi_options_debug = $(u_boot_dtsi_options_raw) 5906d427c6bSSimon Glass 5916d427c6bSSimon Glass 592dbf6be9fSSimon GlassAccess to binman entry offsets at run time (symbols) 593dbf6be9fSSimon Glass---------------------------------------------------- 59439c1502cSSimon Glass 59539c1502cSSimon GlassBinman assembles images and determines where each entry is placed in the image. 59639c1502cSSimon GlassThis information may be useful to U-Boot at run time. For example, in SPL it 59739c1502cSSimon Glassis useful to be able to find the location of U-Boot so that it can be executed 59839c1502cSSimon Glasswhen SPL is finished. 59939c1502cSSimon Glass 60039c1502cSSimon GlassBinman allows you to declare symbols in the SPL image which are filled in 60139c1502cSSimon Glasswith their correct values during the build. For example: 60239c1502cSSimon Glass 6033ab9598dSSimon Glass binman_sym_declare(ulong, u_boot_any, offset); 60439c1502cSSimon Glass 6053ab9598dSSimon Glassdeclares a ulong value which will be assigned to the offset of any U-Boot 60639c1502cSSimon Glassimage (u-boot.bin, u-boot.img, u-boot-nodtb.bin) that is present in the image. 60739c1502cSSimon GlassYou can access this value with something like: 60839c1502cSSimon Glass 6093ab9598dSSimon Glass ulong u_boot_offset = binman_sym(ulong, u_boot_any, offset); 61039c1502cSSimon Glass 6113ab9598dSSimon GlassThus u_boot_offset will be set to the offset of U-Boot in memory, assuming that 61239c1502cSSimon Glassthe whole image has been loaded, or is available in flash. You can then jump to 61339c1502cSSimon Glassthat address to start U-Boot. 61439c1502cSSimon Glass 61539c1502cSSimon GlassAt present this feature is only supported in SPL. In principle it is possible 61639c1502cSSimon Glassto fill in such symbols in U-Boot proper, as well. 61739c1502cSSimon Glass 61839c1502cSSimon Glass 619dbf6be9fSSimon GlassAccess to binman entry offsets at run time (fdt) 620dbf6be9fSSimon Glass------------------------------------------------ 621dbf6be9fSSimon Glass 622dbf6be9fSSimon GlassBinman can update the U-Boot FDT to include the final position and size of 623dbf6be9fSSimon Glasseach entry in the images it processes. The option to enable this is -u and it 624dbf6be9fSSimon Glasscauses binman to make sure that the 'offset', 'image-pos' and 'size' properties 625dbf6be9fSSimon Glassare set correctly for every entry. Since it is not necessary to specify these in 626dbf6be9fSSimon Glassthe image definition, binman calculates the final values and writes these to 627dbf6be9fSSimon Glassthe device tree. These can be used by U-Boot at run-time to find the location 628dbf6be9fSSimon Glassof each entry. 629dbf6be9fSSimon Glass 630dbf6be9fSSimon Glass 63183d73c2fSSimon GlassCompression 63283d73c2fSSimon Glass----------- 63383d73c2fSSimon Glass 63483d73c2fSSimon GlassBinman support compression for 'blob' entries (those of type 'blob' and 63583d73c2fSSimon Glassderivatives). To enable this for an entry, add a 'compression' property: 63683d73c2fSSimon Glass 63783d73c2fSSimon Glass blob { 63883d73c2fSSimon Glass filename = "datafile"; 63983d73c2fSSimon Glass compression = "lz4"; 64083d73c2fSSimon Glass }; 64183d73c2fSSimon Glass 64283d73c2fSSimon GlassThe entry will then contain the compressed data, using the 'lz4' compression 64383d73c2fSSimon Glassalgorithm. Currently this is the only one that is supported. 64483d73c2fSSimon Glass 64583d73c2fSSimon Glass 64683d73c2fSSimon Glass 6473b0c3821SSimon GlassMap files 6483b0c3821SSimon Glass--------- 6493b0c3821SSimon Glass 6503b0c3821SSimon GlassThe -m option causes binman to output a .map file for each image that it 6513ab9598dSSimon Glassgenerates. This shows the offset and size of each entry. For example: 6523b0c3821SSimon Glass 6533ab9598dSSimon Glass Offset Size Name 6548122f396SSimon Glass 00000000 00000028 main-section 6553b0c3821SSimon Glass 00000000 00000010 section@0 6563b0c3821SSimon Glass 00000000 00000004 u-boot 6573b0c3821SSimon Glass 00000010 00000010 section@1 6583b0c3821SSimon Glass 00000000 00000004 u-boot 6593b0c3821SSimon Glass 6603b0c3821SSimon GlassThis shows a hierarchical image with two sections, each with a single entry. The 6613ab9598dSSimon Glassoffsets of the sections are absolute hex byte offsets within the image. The 6623ab9598dSSimon Glassoffsets of the entries are relative to their respective sections. The size of 6633b0c3821SSimon Glasseach entry is also shown, in bytes (hex). The indentation shows the entries 6643b0c3821SSimon Glassnested inside their sections. 6653b0c3821SSimon Glass 6663b0c3821SSimon Glass 66753af22a9SSimon GlassPassing command-line arguments to entries 66853af22a9SSimon Glass----------------------------------------- 66953af22a9SSimon Glass 67053af22a9SSimon GlassSometimes it is useful to pass binman the value of an entry property from the 67153af22a9SSimon Glasscommand line. For example some entries need access to files and it is not 67253af22a9SSimon Glassalways convenient to put these filenames in the image definition (device tree). 67353af22a9SSimon Glass 67453af22a9SSimon GlassThe-a option supports this: 67553af22a9SSimon Glass 67653af22a9SSimon Glass -a<prop>=<value> 67753af22a9SSimon Glass 67853af22a9SSimon Glasswhere 67953af22a9SSimon Glass 68053af22a9SSimon Glass <prop> is the property to set 68153af22a9SSimon Glass <value> is the value to set it to 68253af22a9SSimon Glass 68353af22a9SSimon GlassNot all properties can be provided this way. Only some entries support it, 68453af22a9SSimon Glasstypically for filenames. 68553af22a9SSimon Glass 68653af22a9SSimon Glass 6876d427c6bSSimon GlassCode coverage 6886d427c6bSSimon Glass------------- 6896d427c6bSSimon Glass 6906d427c6bSSimon GlassBinman is a critical tool and is designed to be very testable. Entry 6916d427c6bSSimon Glassimplementations target 100% test coverage. Run 'binman -T' to check this. 6926d427c6bSSimon Glass 6936d427c6bSSimon GlassTo enable Python test coverage on Debian-type distributions (e.g. Ubuntu): 6946d427c6bSSimon Glass 69516d836cdSTom Rini $ sudo apt-get install python-coverage python-pytest 6966d427c6bSSimon Glass 6976d427c6bSSimon Glass 698bf7fd50bSSimon GlassAdvanced Features / Technical docs 699bf7fd50bSSimon Glass---------------------------------- 700bf7fd50bSSimon Glass 701bf7fd50bSSimon GlassThe behaviour of entries is defined by the Entry class. All other entries are 702bf7fd50bSSimon Glassa subclass of this. An important subclass is Entry_blob which takes binary 703bf7fd50bSSimon Glassdata from a file and places it in the entry. In fact most entry types are 704bf7fd50bSSimon Glasssubclasses of Entry_blob. 705bf7fd50bSSimon Glass 706bf7fd50bSSimon GlassEach entry type is a separate file in the tools/binman/etype directory. Each 707bf7fd50bSSimon Glassfile contains a class called Entry_<type> where <type> is the entry type. 708bf7fd50bSSimon GlassNew entry types can be supported by adding new files in that directory. 709bf7fd50bSSimon GlassThese will automatically be detected by binman when needed. 710bf7fd50bSSimon Glass 711bf7fd50bSSimon GlassEntry properties are documented in entry.py. The entry subclasses are free 712bf7fd50bSSimon Glassto change the values of properties to support special behaviour. For example, 713bf7fd50bSSimon Glasswhen Entry_blob loads a file, it sets content_size to the size of the file. 714bf7fd50bSSimon GlassEntry classes can adjust other entries. For example, an entry that knows 7153ab9598dSSimon Glasswhere other entries should be positioned can set up those entries' offsets 716bf7fd50bSSimon Glassso they don't need to be set in the binman decription. It can also adjust 717bf7fd50bSSimon Glassentry contents. 718bf7fd50bSSimon Glass 719bf7fd50bSSimon GlassMost of the time such essoteric behaviour is not needed, but it can be 720bf7fd50bSSimon Glassessential for complex images. 721bf7fd50bSSimon Glass 7223ed0de31SSimon GlassIf you need to specify a particular device-tree compiler to use, you can define 7233ed0de31SSimon Glassthe DTC environment variable. This can be useful when the system dtc is too 7243ed0de31SSimon Glassold. 7253ed0de31SSimon Glass 726*a3c00550SSimon GlassTo enable a full backtrace and other debugging features in binman, pass 727*a3c00550SSimon GlassBINMAN_DEBUG=1 to your build: 728*a3c00550SSimon Glass 729*a3c00550SSimon Glass make sandbox_defconfig 730*a3c00550SSimon Glass make BINMAN_DEBUG=1 731*a3c00550SSimon Glass 732bf7fd50bSSimon Glass 733bf7fd50bSSimon GlassHistory / Credits 734bf7fd50bSSimon Glass----------------- 735bf7fd50bSSimon Glass 736bf7fd50bSSimon GlassBinman takes a lot of inspiration from a Chrome OS tool called 737bf7fd50bSSimon Glass'cros_bundle_firmware', which I wrote some years ago. That tool was based on 738bf7fd50bSSimon Glassa reasonably simple and sound design but has expanded greatly over the 739bf7fd50bSSimon Glassyears. In particular its handling of x86 images is convoluted. 740bf7fd50bSSimon Glass 7417ae5f315SSimon GlassQuite a few lessons have been learned which are hopefully applied here. 742bf7fd50bSSimon Glass 743bf7fd50bSSimon Glass 744bf7fd50bSSimon GlassDesign notes 745bf7fd50bSSimon Glass------------ 746bf7fd50bSSimon Glass 747bf7fd50bSSimon GlassOn the face of it, a tool to create firmware images should be fairly simple: 748bf7fd50bSSimon Glassjust find all the input binaries and place them at the right place in the 749bf7fd50bSSimon Glassimage. The difficulty comes from the wide variety of input types (simple 750bf7fd50bSSimon Glassflat binaries containing code, packaged data with various headers), packing 751bf7fd50bSSimon Glassrequirments (alignment, spacing, device boundaries) and other required 752bf7fd50bSSimon Glassfeatures such as hierarchical images. 753bf7fd50bSSimon Glass 754bf7fd50bSSimon GlassThe design challenge is to make it easy to create simple images, while 755bf7fd50bSSimon Glassallowing the more complex cases to be supported. For example, for most 756bf7fd50bSSimon Glassimages we don't much care exactly where each binary ends up, so we should 757bf7fd50bSSimon Glassnot have to specify that unnecessarily. 758bf7fd50bSSimon Glass 759bf7fd50bSSimon GlassNew entry types should aim to provide simple usage where possible. If new 760bf7fd50bSSimon Glasscore features are needed, they can be added in the Entry base class. 761bf7fd50bSSimon Glass 762bf7fd50bSSimon Glass 763bf7fd50bSSimon GlassTo do 764bf7fd50bSSimon Glass----- 765bf7fd50bSSimon Glass 766bf7fd50bSSimon GlassSome ideas: 767bf7fd50bSSimon Glass- Use of-platdata to make the information available to code that is unable 768bf7fd50bSSimon Glass to use device tree (such as a very small SPL image) 769bf7fd50bSSimon Glass- Allow easy building of images by specifying just the board name 77016b8d6b7SSimon Glass- Produce a full Python binding for libfdt (for upstream). This is nearing 77116b8d6b7SSimon Glass completion but some work remains 772bf7fd50bSSimon Glass- Add an option to decode an image into the constituent binaries 773bf7fd50bSSimon Glass- Support building an image for a board (-b) more completely, with a 774bf7fd50bSSimon Glass configurable build directory 775bf7fd50bSSimon Glass- Consider making binman work with buildman, although if it is used in the 776bf7fd50bSSimon Glass Makefile, this will be automatic 777bf7fd50bSSimon Glass 778bf7fd50bSSimon Glass-- 779bf7fd50bSSimon GlassSimon Glass <sjg@chromium.org> 780bf7fd50bSSimon Glass7/7/2016 781