summaryrefslogtreecommitdiffstats
path: root/tools/mkimage.c
Commit message (Collapse)AuthorAgeFilesLines
* mkimage: Add a quiet modeSimon Glass2016-05-231-1/+4
| | | | | | | | | Some build systems want to be quiet unless there is a problem. At present mkimage displays quite a bit of information when generating a FIT file. Add a '-q' flag to silence this. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* mkimage: fix generation of FIT imageAndreas Bießmann2016-05-031-6/+3
| | | | | | | | | | | Commit 7a439cadcf3192eb012a2432ca34670b676c74d2 broke generation of SPL loadable FIT images (CONFIG_SPL_LOAD_FIT). Fix it by removing the unnecessary storage of expected image type. This was a left over of the previous implementation. It is not longer necessary since the mkimage -b switch always has one parameter. Tested-by: Lokesh Vutla <lokeshvutla@ti.com> Signed-off-by: Andreas Bießmann <andreas@biessmann.org>
* mkimage: fix argument parsing on BSD systemsAndreas Bießmann2016-05-021-21/+12
| | | | | | | | | | | The getopt(3) optstring '-' is a GNU extension which is not available on BSD systems like OS X. Remove this dependency by implementing argument parsing in another way. This will also change the lately introduced '-b' switch behaviour. Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* mkimage: Support placing data outside the FITSimon Glass2016-03-141-1/+4
| | | | | | | | | | | | | | | | | | | One limitation of FIT is that all the data is 'inline' within it, using a 'data' property in each image node. This means that to find out what is in the FIT it is necessary to scan the entire file. Once loaded it can be scanned and then the images can be copied to the correct place in memory. In SPL it can take a significant amount of time to copy images around in memory. Also loading data that does not end up being used is wasteful. It would be useful if the FIT were small, acting as a directory, with the actual data stored elsewhere. This allows SPL to load the entire FIT, without the images, then load the images it wants later. Add a -E option to mkimage to request that it output an 'external' FIT. Signed-off-by: Simon Glass <sjg@chromium.org>
* mkimage: Support adding device tree files to a FITSimon Glass2016-03-141-2/+36
| | | | | | | | | | | To make the auto-FIT feature useful we need to be able to provide a list of device tree files on the command line for mkimage to add into the FIT. Add support for this feature. So far there is no support for hashing or verified boot using this method. For those cases, a .its file must still be provided. Signed-off-by: Simon Glass <sjg@chromium.org>
* mkimage: Support automatic creating of a FIT without a .itsSimon Glass2016-03-141-3/+5
| | | | | | | | | | | | | | | | | | At present, when generating a FIT, mkimage requires a .its file containing the structure of the FIT and referring to the images to be included. Creating the .its file is a separate step that makes it harder to use FIT. This is not required for creating legacy images. Often the FIT is pretty standard, consisting of an OS image, some device tree files and a single configuration. We can handle this case automatically and avoid needing a .its file at all. To start with, support automatically generate the FIT using a new '-f auto' option. Initially this only supports adding a single image (e.g. a linux kernel) and a single configuration. Signed-off-by: Simon Glass <sjg@chromium.org>
* mkimage: Allow a FIT to include an image of any typeSimon Glass2016-03-141-5/+28
| | | | | | | | | | At present FIT images are set up by providing a device tree source file which is a file with a .its extension. We want to support automatically creating this file based on the image supplied to mkimage. This means that even though the final file type is always IH_TYPE_FLATDT, the image inside may be something else. Signed-off-by: Simon Glass <sjg@chromium.org>
* mkimage: Make 'params' staticSimon Glass2016-03-141-1/+1
| | | | | | This is not used outside mkimage.c, so make this variable static. Signed-off-by: Simon Glass <sjg@chromium.org>
* mkimage: Show an error message when usage() is calledSimon Glass2016-03-141-8/+9
| | | | | | | Sometimes incorrect arguments are supplied but the reason is not obvious to the user. Add some helpful messages. Signed-off-by: Simon Glass <sjg@chromium.org>
* mkimage: Move usage() up to the topSimon Glass2016-03-141-39/+42
| | | | | | | To avoid a forward declaration, move the usage() function higher in the file. Signed-off-by: Simon Glass <sjg@chromium.org>
* mkimage: Sort the option processing code by optionSimon Glass2016-03-141-25/+25
| | | | | | | Adjust the code so that option alphabetical order matches the order in the switch() statement. This makes it easier to find options. Signed-off-by: Simon Glass <sjg@chromium.org>
* mkimage: Convert to use getopt()Simon Glass2016-03-141-132/+101
| | | | | | | | | The current way of parsing arguments is a bit clumsy. It seems better to use getopt() which is commonly used for this purpose. Convert the code to use getopt() and make a few minor adjustments as needed. Signed-off-by: Simon Glass <sjg@chromium.org>
* mkimage: Move argument processing into its own functionSimon Glass2016-03-141-24/+32
| | | | | | | At present main() is very long. Split out the argument processing to make it easier to follow. Signed-off-by: Simon Glass <sjg@chromium.org>
* Gracefully handle 64-bit signed-extended 32-bit Load addressesWilliam Cohen2016-02-241-2/+2
| | | | | | | | | | | | | | | | | | | | | To follow the MIPS 32-bit and 64-bit memory map conventions (*) recent MIPS Linux kernels are using a 64-bit sign extended value (0xffffffff80010000) for the 32-bit load address (0x80010000) of the Creator CI20 board kernel. When this 64-bit argument was passed to mkimage running on a 32-bit machine such as the Creator CI20 board the load address was incorrectly formed from the upper 32-bit sign-extend bits (0xffffffff) by the strtoul instead of from the lower 32-bits (0x80010000). The mkimage should be able to tolerate the longer sign-extended 64-bit version of the 32-bit arguments with the use of strtoull. Use of the strtoll in place of the strtol in mkimage.c resolves the issue of self hosted kernel builds for the Creator CI20 board (+) and (++). (*) http://techpubs.sgi.com/library/dynaweb_docs/0620/SGI_Developer/books/DevDriver_PG/sgi_html/ch01.html (+) https://github.com/MIPS/CI20_linux/issues/23 (++) https://github.com/MIPS/CI20_linux/issues/22 Signed-off-by: William Cohen <wcohen@redhat.com>
* mkimage: Fix warning from fix for generating multi and script images againMarek Vasut2015-12-071-2/+1
| | | | | | | | | | | | | | | | | | | | | | | Seems 6ae6e160 broke creating images in certain cases, there are two problems with that patch. First is that the expression "!x == 4 || !x == 6" is ambiguous. The intention here was "!(x == 4) || !(x == 6)" based on reading further in the file, where this was borrowed from. This however is interpreted by gcc as "(!x) == 4 || (!x) == 6" and always false. gcc-5.x will warn about this case. The second problem is that we do not want to test for the case of "(NOT x is 4) OR (NOT x is 6)" but instead "(x is not equal to 4) AND (x is not equal to 6)". This is because in those two cases we already execute the code question in another part of the file. Rewrite the expression and add parenthesis for clarity. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Tom Rini <trini@konsulko.com> Cc: Philippe De Swert <philippedeswert@gmail.com> Cc: Simon Glass <sjg@chromium.org> [trini: Re-word Marek's explanation]
* mkimage : Fix generating multi and script imagesPhilippe De Swert2015-12-051-13/+18
| | | | | | | | | | | | | | | Seems 92a655c3 broke creating multi and script type images. Since the file1:file2:file3 string does not get split up, it fails on trying to open an non-existing file. mkimage -A arm -O linux -T multi -C none -d zImage:splash.bmp:device.dtb uimage tools/mkimage: Can't open zImage:splash.bmp:device.dtb: No such file or directory Since the sizes of the different parts seem to get added in the actual routine that handles multi and script type images, we can probably skip the bit of the code that causes the failure for that type of images. Signed-off-by: Philippe De Swert <philippedeswert@gmail.com>
* tools/mkimage.c: Clarify help text for -D slightlyTom Rini2015-10-111-1/+1
| | | | | | | Try and make it clear that -D will replace all arguments passed to dtc and is not appending them. Signed-off-by: Tom Rini <trini@konsulko.com>
* mkimage: Allow padding to any lengthSimon Glass2015-09-021-11/+12
| | | | | | | | At present there is an arbitrary limit of 4KB for padding. Rockchip needs more than that, so remove this restriction. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
* mkimage: Set up a file size parameter and keep it updatedSimon Glass2015-07-211-0/+18
| | | | | | | | | | | Some functions called by mkimage would like to know the output file size. Initially this is the same as the input file size, but it may be affected by adding headers, etc. Add this information to the image parameters. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* mkimage: Display a better list of available image typesSimon Glass2015-07-211-7/+52
| | | | | | | | | | | Offer to display the available image types in help. Also, rather than hacking the genimg_get_type_id() function to display a list of types, do this in the tool. Also, sort the list. The list of image types is quite long, and hard to discover. Print it out when we show help information. Signed-off-by: Simon Glass <sjg@chromium.org>
* dumpimage: add 'T' option to explicitly set the image typeGuilherme Maciel Ferreira2015-01-291-3/+0
| | | | | | | | | | Some image types, like "KeyStone GP", do not have magic numbers to distinguish them from other image types. Thus, the automatic image type discovery does not work correctly. This patch also fix some integer type mismatches. Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
* imagetool: replace image registration function by linker_lists featureGuilherme Maciel Ferreira2015-01-291-42/+2
| | | | | | | | | The registration was introduced in commit f86ed6a8d52c99bb2d17d3cac1647edca0c4399c This commit also removes all registration functions, and the member "next" from image_type_params struct Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
* imagetool: move common code to imagetool moduleGuilherme Maciel Ferreira2015-01-291-67/+5
| | | | | | | The get_type() and verify_print_header() functions have the same code on both dumpimage.c and mkimage.c modules. Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
* mkimage: fix compilation issues on OpenBSDLuka Perkov2014-08-141-0/+2
| | | | Signed-off-by: Luka Perkov <luka@openwrt.org>
* tools: moved code common to all image tools to a separated module.Guilherme Maciel Ferreira2013-12-131-19/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to avoid duplicating code and keep only one point of modification, the functions, structs and defines useful for "dumpimage" were moved from "mkimage" to a common module called "imagetool". This modification also weakens the coupling between image types (FIT, IMX, MXS, and so on) and image tools (mkimage and dumpimage). Any tool may initialize the "imagetool" through register_image_tool() function, while the image types register themselves within an image tool using the register_image_type() function: +---------------+ +------| fit_image | +--------------+ +-----------+ | +---------------+ | mkimage |--------> | | <-----+ +--------------+ | | +---------------+ | imagetool | <------------| imximage | +--------------+ | | +---------------+ | dumpimage |--------> | | <-----+ +--------------+ +-----------+ | +---------------+ +------| default_image | +---------------+ register_image_tool() register_image_type() Also, the struct "mkimage_params" was renamed to "image_tool_params" to make clear its general purpose. Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* mkimage: added 'static' specifier to match function's prototype.Guilherme Maciel Ferreira2013-12-131-2/+1
| | | | | | | This function should be declared static. Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* ARM: mxs: tools: Add mkimage support for MXS bootstreamMarek Vasut2013-08-311-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Add mkimage support for generating and verifying MXS bootstream. The implementation here is mostly a glue code between MXSSB v0.4 and mkimage, but the long-term goal is to rectify this and merge MXSSB with mkimage more tightly. Once this code is properly in U-Boot, MXSSB shall be deprecated in favor of mkimage-mxsimage support. Note that the mxsimage generator needs libcrypto from OpenSSL, I therefore enabled the libcrypto/libssl unconditionally. MXSSB: http://git.denx.de/?p=mxssb.git;a=summary The code is based on research presented at: http://www.rockbox.org/wiki/SbFileFormat Signed-off-by: Marek Vasut <marex@denx.de> Cc: Tom Rini <trini@ti.com> Cc: Fabio Estevam <fabio.estevam@freescale.com> Cc: Stefano Babic <sbabic@denx.de> Cc: Otavio Salvador <otavio@ossystems.com.br>
* tools: add variable padding of data image in mkimageStefano Babic2013-08-311-3/+21
| | | | | | | | | Use previously unused return value of function vrec_header to return a padding size to generic mkimage. This padding size is used in copy_files to pad with zeros after copying the data image. Signed-off-by: Stefano Babic <sbabic@denx.de>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-241-14/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* mkimage: Add -r option to specify keys that must be verifiedSimon Glass2013-06-261-2/+6
| | | | | | | | | | | | | | | | | | | | | | Normally, multiple public keys can be provided and U-Boot is not required to use all of them for verification. This is because some images may not be signed, or may be optionally signed. But we still need a mechanism to determine when a key must be used. This feature cannot be implemented in the FIT itself, since anyone could change it to mark a key as optional. The requirement for key verification must go in with the public keys, in a place that is protected from modification. Add a -r option which tells mkimage to mark all keys that it uses for signing as 'required'. If some keys are optional and some are required, run mkimage several times (perhaps with different key directories if some keys are very secret) using the -F flag to update an existing FIT. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
* mkimage: Add -c option to specify a comment for key signingSimon Glass2013-06-261-1/+7
| | | | | | | | | When signing an image, it is useful to add some details about which tool or person is authorising the signing. Add a comment field which can take care of miscellaneous requirements. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
* mkimage: Add -F option to modify an existing .fit fileSimon Glass2013-06-261-3/+6
| | | | | | | | | | | | | When signing images it is sometimes necessary to sign with different keys at different times, or make the signer entirely separate from the FIT creation to avoid needing the private keys to be publicly available in the system. Add a -F option so that key signing can be a separate step, and possibly done multiple times as different keys are avaiable. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
* mkimage: Add -K to write public keys to an FDT blobSimon Glass2013-06-261-2/+8
| | | | | | | | | | | | | | | | FIT image verification requires public keys. Add a convenient option to mkimage to write the public keys to an FDT blob when it uses then for signing an image. This allows us to use: mkimage -f test.its -K dest.dtb -k keys test.fit and have the signatures written to test.fit and the corresponding public keys written to dest.dtb. Then dest.dtb can be used as the control FDT for U-Boot (CONFIG_OF_CONTROL), thus providing U-Boot with access to the public keys it needs. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
* mkimage: Add -k option to specify key directorySimon Glass2013-06-261-1/+14
| | | | | | | | | | | Keys required for signing images will be in a specific directory. Add a -k option to specify that directory. Also update the mkimage man page with this information and a clearer list of available commands. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de> (v1)
* powerpc/CoreNet: add tool to support pbl image build.Shaohui Xie2012-08-231-0/+15
| | | | | | | | | | Provides a tool to build boot Image for PBL(Pre boot loader) which is used on Freescale CoreNet SoCs, PBL can be used to load some instructions and/or data for pre-initialization. The default output image is u-boot.pbl, for more details please refer to doc/README.pblimage. Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com> Signed-off-by: Andy Fleming <afleming@freescale.com>
* mkimage: Fix variable length header supportChristian Riesch2011-12-241-48/+49
| | | | | | | | | | | | | | Support for variable length images like AIS image was introduced in commit f0662105b674a3874227316abf8536bebc9b5995. A parameter "-s" was also introduced to prohibit copying of the image file automatically in the main program. However, this parameter was implemented incorrectly and the image file was copied nevertheless. Signed-off-by: Christian Riesch <christian.riesch@omicron.at> Cc: Stefano Babic <sbabic@denx.de> Cc: Heiko Schocher <hs@denx.de> Acked-by: Stefano Babic <sbabic@denx.de>
* mkimage: adding support for Davinci AIS imageStefano Babic2011-10-231-0/+2
| | | | | | | | | | | Some Davinci processors supports the Application Image Script (AIS) boot process. The patch adds the generation of the AIS image inside the mkimage tool to make possible to generate a bootable U-boot without external tools (TI Davinci AIS Generator). Signed-off-by: Stefano Babic <sbabic@denx.de> CC: Wolfgang Denk <wd@denx.de>
* mkimage: Add variable lenght header supportStefano Babic2011-10-051-5/+14
| | | | | | | | | Some images have not a header of fix lenght. The patch will be used for the generation of AIS images, because this header has a variable lenght. The patch adds also the parameter "-s" (skip) to not copy automatically the passed image file. Signed-off-by: Stefano Babic <sbabic@denx.de>
* mkimage: Add OMAP boot image supportJohn Rigby2011-08-031-0/+2
| | | | | | | | | | - Add mkimage support for OMAP boot image - Add support for OMAP boot image(MLO) generation in the new SPL framework Signed-off-by: John Rigby <john.rigby@linaro.org> Signed-off-by: Aneesh V <aneesh@ti.com> Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
* mkimage: add UBL header support for booting davinci cpusHeiko Schocher2011-07-281-0/+2
| | | | | | | | creating an u-boot.ubl file, which contains the UBL Header needed for booting from NAND with the RBL from TI. For more information read doc/README.ublimage. Signed-off-by: Heiko Schocher <hs@denx.de>
* mkimage: add "-V" option to print version informationWolfgang Denk2011-04-121-0/+6
| | | | Signed-off-by: Wolfgang Denk <wd@denx.de>
* mkimage: Fix strict-aliasing compiler warningPeter Tyser2010-04-101-5/+3
| | | | | | | | | Version 4.2.4 of gcc produces the following warnings without this change: mkimage.c: In function ‘main’: mkimage.c:204: warning: dereferencing type-punned pointer will break strict-aliasing rules mkimage.c:222: warning: dereferencing type-punned pointer will break strict-aliasing rules Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* mkimage: fix Segmentation Fault when run without "-n name" optionWolfgang Denk2010-03-281-0/+1
| | | | | | | | | The restructuring of the mkimage command in commit 89a4d6b1 ("tools: mkimage: split code into core, default and FIT image specific") introduced a bug that caused mkimage to segfault when run without "-n name" option. Initialize the imagename entry to prevent that. Signed-off-by: Wolfgang Denk <wd@denx.de>
* mkimage: dont force entry point with xipMike Frysinger2010-03-111-14/+0
| | | | | | | | | | | Some people boot images with the entry point in the middle of the blob (like Linux with the head code in discardable .init.text), and there is no no real requirement that the entry point be right after the mkimage header when doing XIP, so let people specify whatever they want. If they do need an entry right after the header, then they still can do that with normal -e behavior. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* mkimage: Add Freescale imx Boot Image support (imximage)Stefano Babic2010-01-251-0/+2
| | | | | | | | | | | | This patch adds support for "imximage" (MX Boot Image) to the mkimage utility. The imximage is used on the Freescales's MX.25, MX.35 and MX.51 processors. Further details under doc/README.imximage. This patch was tested on a Freescale mx51evk board. Signed-off-by: Stefano Babic <sbabic@denx.de>
* tools/mkimage: Remove duplicate line of codePeter Tyser2009-12-071-4/+2
| | | | | | | | | | | | | Recent commits 1a99de2cb4d08eb3bf9fb3f60a9d533150de8c0e and 6a590c5f5fd12cdd27f3153522acfac3854590e7 both fixed the same bug in the same manner. Unfortunately git was "smart" enough to merge both changes which resulted in some duplicate code. Signed-off-by: Peter Tyser <ptyser@xes-inc.com> Reordered code and comment a bit. Signed-off-by: Wolfgang Denk <wd@denx.de>
* tools/mkimage: Print FIT image contents after creationPeter Tyser2009-12-051-25/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, there was no indication to the user that a FIT image was successfully created after executing mkimage. For example: $ mkimage -f uImage.its uImage.itb DTC: dts->dtb on file "uImage.its" Adding some additional output after creating a FIT image lets the user know exactly what is contained in their image, eg: $ mkimage -f uImage.its uImage.itb DTC: dts->dtb on file "uImage.its" FIT description: Linux kernel 2.6.32-rc7-00201-g7550d6f-dirty Created: Tue Nov 24 15:43:01 2009 Image 0 (kernel@1) Description: Linux Kernel 2.6.32-rc7-00201-g7550d6f-dirty Type: Kernel Image Compression: gzip compressed Data Size: 2707311 Bytes = 2643.86 kB = 2.58 MB Architecture: PowerPC OS: Linux Load Address: 0x00000000 Entry Point: 0x00000000 Hash algo: crc32 Hash value: efe0798b Hash algo: sha1 Hash value: ecafba8c95684f2c8fec67e33c41ec88df1534d7 Image 1 (fdt@1) Description: Flattened Device Tree blob Type: Flat Device Tree Compression: uncompressed Data Size: 12288 Bytes = 12.00 kB = 0.01 MB Architecture: PowerPC Hash algo: crc32 Hash value: a5cab676 Hash algo: sha1 Hash value: 168722b13e305283cfd6603dfe8248cc329adea6 Default Configuration: 'config@1' Configuration 0 (config@1) Description: Default Linux kernel Kernel: kernel@1 FDT: fdt@1 This brings the behavior of creating a FIT image in line with creating a standard uImage, which also prints out the uImage contents after creation. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* tools/mkimage: Assume FDT image type for FIT imagesPeter Tyser2009-12-051-0/+6
| | | | | | | | | | | When building a Flattened Image Tree (FIT) the image type needs to be "flat_dt". Commit 89a4d6b12fd6394898b8a454cbabeaf1cd59bae5 introduced a regression which caused the user to need to specify the "-T flat_dt" parameter on the command line when building a FIT image. The "-T flat_dt" parameter should not be needed and is at odds with the current FIT image documentation. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* Building of FIT images does not work.Remy Bohmer2009-11-231-0/+1
| | | | | | | The type is not set for generation of the FIT images, resulting in no images being created without printing or returning an error Signed-off-by: Remy Bohmer <linux@bohmer.net>
* mkimage: Add Kirkwood Boot Image support (kwbimage)Prafulla Wadaskar2009-09-101-0/+2
| | | | | | | | | | | | | | This patch adds support for "kwbimage" (Kirkwood Boot Image) image types to the mkimage code. For details refer to docs/README.kwbimage This patch is tested with Sheevaplug board Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com> Acked-by: Ron Lee <ron@debian.org> Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
OpenPOWER on IntegriCloud