summaryrefslogtreecommitdiffstats
path: root/scripts/kwbimage.c
Commit message (Collapse)AuthorAgeFilesLines
* scripts: kwbimage: fix build with non-glibc systemsAhmad Fatoum2019-05-281-2/+6
| | | | | | | | | | | | get_current_dir_name is a glibc extension, thus replace it with a call to standard POSIX pathconf/malloc/gecwd. The result slightly differs, because get_current_dir_name consults the $PWD environment variable as as well, but that's ok, as it's just an error message. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: support empty binary.0 filesUwe Kleine-König2017-06-191-1/+5
| | | | | | | | While it doesn't make sense to use empty binary headers on a machine for first stage, it is convenient to support this for build testing. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: allow to overwrite binaryUwe Kleine-König2017-01-101-5/+35
| | | | | | | This is a preparation to let barebox provide the binary.0. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: use ALIGN_SUP instead of open-coding itUwe Kleine-König2017-01-101-1/+1
| | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: fix typoUwe Kleine-König2017-01-101-1/+1
| | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: fix handling of binary headerUwe Kleine-König2017-01-101-6/+6
| | | | | | | | | | | | | A binary header is 12 bytes + (4 bytes * Number of Arguments) bigger than the actual binary. Before this commit image extraction was wrong an made binary.0 too big by four bytes at the end (which were 0 in all usual cases). Image creation had the same problem which resulted in broken images when the binary doesn't end in 4 bytes containing 0. Further handle binaries with a length that is not aligned to 4 bytes. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: Make BINARY files relative to config fileSascha Hauer2015-10-191-4/+13
| | | | | | | | | | | | The BINARY files given in the config files are expected to be relative to the place kwbimage is called from. This is bad since it breaks where kwbimage is called from the build directory and not the source directory. It makes more sense to make the paths in the config files relative to the config files which works with out of tree builds and is also more what a user normally expects. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: Move configfile opening to the function that reads itSascha Hauer2015-10-191-16/+18
| | | | | | | | The configfile is read in image_create_config_parse(), so move opening the file to there aswell and pass the configfile as filename instead of FILE *. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: fix signedness mixups in printf format specifiersLucas Stach2014-04-231-1/+1
| | | | | | | | | This most likely doesn't fix any real bugs, but it's the right thing to do and reduces the noise level with static checkers. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: Fix resource leak in image_create_payload()Alexander Shiyan2014-02-041-2/+2
| | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: Fix resource leak in image_create()Alexander Shiyan2014-02-041-0/+1
| | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts: kwbimage: fix imagebuild on 32bit host systemMichael Grzeschik2014-01-271-8/+8
| | | | | | | | | | We have to use strtoul to run the tool working on 32bit systems. Otherwise it will generate signed numbers for strings representing values with the 32nd bit set. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts: kwbimage: fix mis-sized payloadSebastian Hesselbarth2013-11-181-3/+13
| | | | | | | | | Image payload size should always be a multiple of 4 bytes. This fixes mis-sized image payload by allocating payload buffer as multiple of 4 but load true filesize into the payload buffer. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: add support for NAND ECC and page size header fieldsThomas Petazzoni2013-05-171-2/+40
| | | | | | | | | | | The v0 header, used on Kirkwood, has some fields to indicate the type of the NAND ECC, and the page size of the NAND. This commit adds support for such fields, which are needed to support the Kirkwood Guruplug platform. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: make image_boot_mode_id() return -1 on failureThomas Petazzoni2013-05-171-3/+3
| | | | | | | | | | | | | | | | | | | | The function image_boot_mode_id() converts the name of a boot media into the corresponding Marvell specific code. However, 0 that we currently used to indicate that the boot media name wasn't found, could potentially be a valid value. So instead we use -1 to indicate a failure. This is also done in preparation to the introduction of image_nand_ecc_mode_id(), which will convert a NAND ECC mode name into the corresponding identifier. And in this case 0 is a valid identifier of a NAND ECC mode, so we cannot use it to indicate a failure. Since we want image_boot_mode_id() and image_nand_ecc_mode_id() to have a consistent behavior, we change the former in this commit. The latter is introduced in the next commit. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: simplify the v1 image creationThomas Petazzoni2013-05-171-81/+70
| | | | | | | | | | | | | | | | We now assume that at most one binary header can be added, so we no longer need to loop for all configuration options to find the binary blobs. We simply find the binary blob configuration option in 'binarye' and use that when we need to generate the corresponding header. Also, just like we did for the v0 image creation, use image_find_option() to find the value of the different options needed to create the main header. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: make the v0 image creation more flexibleThomas Petazzoni2013-05-171-28/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, the v0 image creation function was expecting the configuration parameters to be ordered with first the configuration parameters affecting the main header, then the DATA configuration parameters that affect the extended header, then the payload. However, with the recently added ability to override the destination address or execution address, the configuration options corresponding to those values may now appear at the end of the configuration options. This commit allows to handle that by making the image creation more flexible: - The configuration options for the main header are just searched amongst all options, the first match is used. - When building the extension header with the DATA options, all DATA options from the configuration file are used, in the order in which they appear in the kwbimage.cfg file. This will for example allow a kwbimage.cfg for a v0 image to not specify any destination or execution address, and simply override it from the command line. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: add a few sanity checksThomas Petazzoni2013-05-171-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | This commit uses the newly introduced image_count_options() function to: - See if there is any DATA option that require the creation of an extended header for v0 header. - Verify that no more than one payload has been provided when creating a v0 header. - Verify that no more than one binary payload has been provided when creating a v1 header. Technically speaking, it is possible to support several payloads, but in real life, only one gets used, so we will only support that to make the code simpler for now. It can always be extended later on if needed. - Verify that no more than one payload has been provided when creating a v1 header. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts/kwbimage: add a new function image_count_options()Thomas Petazzoni2013-05-171-0/+14
| | | | | | | | | | This function returns the number of configuration elements that match a given type. Will be used to do some sanity checking of the number of options. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts: kwbimage: add references to Marvell Dove SoCSebastian Hesselbarth2013-05-141-4/+5
| | | | | | | | | This adds some references to Marvell Dove as it is also supported by kwbimage. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* scripts: new kwbimage manipulation tool for Marvell SoC boot imagesThomas Petazzoni2013-05-111-0/+1448
The Marvell EBU SoCs (Kirkwood, Armada 370, Armada XP) have a BootROM that understand a specific image format, composed of a main header, several extension headers and a paylod. This image can be booted from NAND, SPI, SATA, UART, NOR, etc. This patch adds a tool that allows to extract the components and configuration of existing images, and to create new images. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>