Commit Graph

49 Commits

Author SHA1 Message Date
Rasmus Villemoes
9ffd5e0fbb add macro for compile-time assertions
Compile-time assertions can be helpful to ensure the compiler actually
lays out sturcts as one expects, and for a lot of other things as
well.

<assert.h> exposes a static_assert() macro that maps to _Static_assert
if one compiles with -std=c11 or later, but I don't think we can
mandate that. Also, that standard macro suffers from the defect of
requiring a separate string message - it's usually completely obvious
from the stringification of the expression what it is that is being
asserted. So just define our own ct_assert().

[Side note: We seem to be relying implicitly on gcc defaulting to some
gnuXX mode - building with -std=c99 or -std=c89 breaks with complaints
about the use of typeof().]

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2021-03-28 12:52:36 +02:00
Rasmus Villemoes
9e59a27099 change insert_data() to take const void* instead of const char*
Arbitrary blobs of data should be passed around via a void pointer (as
evidenced by the need for casts in the majority of callers). If one
doesn't want to rely the compiler extension allowing arithmetic on
void pointers, there's a single conversion to do inside the
implementation.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2021-03-26 16:42:34 +01:00
Michael Olbrich
84c04645a9 add new image type for android sparse images
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2021-01-13 09:02:51 +01:00
Michael Olbrich
a6dff044c2 util: export some more functions
The will be needed in future commits.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2021-01-12 08:45:30 +01:00
Michael Olbrich
a7cd4bb8f7 crc32: add function to allow splitting the crc calculation
This is needed when the input data is not available in on continuous block.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2021-01-12 08:43:46 +01:00
Michael Olbrich
f69064ead3 util: introduce and use xrealloc
Just like xzalloc(). Abort when memory allocations fail.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-11-27 11:35:09 +01:00
Rasmus Villemoes
15875c15ba allow specifying an image as temporary
When using something like

image @IMAGE@ {
    ....
    partition sysdata {
        image = "sysdata"
	in-partition-table = true
	partition-type-uuid = "L"
    }
}

image sysdata {
    size = 200M
    ext4 {}
    empty = true
}

to create a partition containing an empty file system, it's
undesirable to leave such an empty file system image in the output
directory (especially when building with Yocto, where it then gets
copied to the shared deploy directory).

So allow specifying an image as temporary, putting it in in tmppath()
rather than imagepath().

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2020-11-17 20:03:42 +01:00
Michael Olbrich
e8cb9b6f49 genimage: make mountpath() argument const
It not modified and this will be needed in the next commit.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-28 15:37:18 +02:00
Andri Yngvason
075db5e0ae image-hd: Add GPT attributes for hiding partitions on Windows
This allows users to instruct Windows 10 to ignore certain partitions to
various extent.

Signed-off-by: Andri Yngvason <andri.yngvason@marel.com>
2020-03-26 10:53:27 +00:00
Michael Olbrich
fb65bd97f8 genimage: allow sanitize_path() to be used elsewhere
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-01-31 12:53:13 +01:00
Michael Olbrich
f4c889b5fc make it easier to create empty filesystems
This is useful when creating multiple images with on config and some of
them should be empty. Also, vfat filesystems cannot be empty right now, so
this makes it possible.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-09-22 15:07:52 +02:00
Michael Olbrich
f05d2b5292
Merge pull request #62 from michaelolbrich/hd-fill
image-hd: add option to extend the image to the full size
2019-05-11 14:06:22 +00:00
Michael Olbrich
8d9c1a2bd3 genimage: allow percentages for image sizes
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-05-07 13:05:20 +02:00
Michael Olbrich
9370489c3c util: add helper to extend images to a specified size
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-05-07 12:40:41 +02:00
Michael Olbrich
3938972096 util: add helper to calculate directory size
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-05-06 08:59:08 +02:00
Michael Olbrich
e2f88d5af0 config: allow parsing percentages
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-05-06 08:59:08 +02:00
Michael Olbrich
3552a4d30d image-hd: re-read partition table for block devices
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-03-01 16:38:16 +01:00
Michael Olbrich
8687e9c639 pad_file/insert_data: support writing to block devices
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-03-01 16:38:16 +01:00
Michael Olbrich
1033272349 pad_file: use the imageoutfile()
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2019-03-01 12:44:01 +01:00
Stefan Sørensen
2c92297e8a hdimage: Add GPT support
Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
2019-02-12 09:29:54 +01:00
Alexandre Fournier
9e1e7c5860 add qemu handler 2018-03-19 21:55:28 +01:00
Sascha Hauer
ec65ecc5b4 Add FIT image support
This adds support for U-Boot FIT images to the genimage tool.

FIT images are effectively device tree blobs (dtbs) which have
the actual image data as binary properties in the device tree.

FIT image support works by invoking the U-Boot mkimage tool
with a device tree source file (its) as input. The its file
must be handwritten, but the image data is included automatically
by genimage which generates suitable /incbin/ directives on the
fly.

Images in the its file are in a /images/<imagename> node. The
FIT image is seen as a partitioned device, for each /images/<imagename>
there must be a partition named <imagename> in the genimage config
file section for a FIT image.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[mol: add test files to Makefile.am, handle readonly .its file]
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2018-03-19 15:53:26 +01:00
Sascha Hauer
51aac203af cleanup logging
We have image_error, image_log, error and logmsg which all do the
actual printing themselves. Create a set of error(), info() and
debug() functions which all do the actual printing in the same
function. Also add the same set of functions with a image_ prefix
to do image specific logging. All messages now get a [type] prefix
to make it easier to distinguish them from the stdout/stderr from
invoked commands (see next patch).

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[mol: don't change the loglevel numbers]
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2018-03-19 14:58:34 +01:00
Michael Olbrich
520c4f8bfc util: check asprintf()/vasprintf() return values
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2017-11-12 09:33:04 +01:00
Julien Viard de Galbert
5984e56a7f cramfs: add handler to create cramfs filesystem images
Signed-off-by: Julien Viard de Galbert <julien.viarddegalbert@openwide.fr>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2016-09-13 14:51:29 +02:00
Michael Olbrich
6de3e5aaa5 add image type to create rauc bundles
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2016-08-15 12:35:48 +02:00
Ladislav Michl
14c17c745c genimage: Add static UBI volumes support
Bare images (kernel, U-Boot, its environment) need to reside inside
static UBI volumes. Add read-only partition flag and use it for that
purpose. Also make partition's "image" voluntary as ubinize will yell
anyway. Once this behavior gets modified eventually, it will bring us
possibility to create empty volumes ready for runtime update.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2016-01-12 17:07:31 +01:00
Vivien Didelot
971a17ee5b genimage: constify image in imageoutfile
Since imageoutfile does not modify the image, make it const.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-14 08:42:52 +02:00
Michael Olbrich
a0d4704f69 cleanup logging
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2014-08-12 11:41:46 +02:00
Juergen Beisert
3171e7020d squashfs: add handler to create squashfs filesystem images
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
2014-03-10 15:56:58 +01:00
Michael Olbrich
dff2d7c88e cleanup error output
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2013-05-02 20:49:21 +02:00
Michael Olbrich
4edee07408 sort image handler
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2012-11-24 22:59:58 +01:00
Michael Olbrich
a23519e5bf add cpio image support
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2012-09-21 10:22:48 +02:00
Michael Olbrich
e52ea6f9c3 insert_data: fix warning
util.c: In function ‘insert_data’:
util.c:269:8: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2012-06-30 13:06:29 +02:00
Michael Olbrich
067aafb7b3 add vfat handler
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2012-06-30 13:06:29 +02:00
Michael Olbrich
b074ce1fa7 genimage: add parse function to the image handler
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2012-06-26 08:39:54 +02:00
Michael Olbrich
c1bbf2bdb7 image-hd: support extended patitions
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-11-07 08:35:24 +01:00
Michael Olbrich
ceaafa9eb7 image-ext2: add support for ext3/ext4
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-10-12 09:14:40 +02:00
Michael Olbrich
18c28b8e14 add option to execute an arbitrary command before and after generating the image
useful for bootloaders that need more than just putting an image
at the right position.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-10-11 08:56:10 +02:00
Michael Olbrich
0daeb9ee1f add option to make partitions bootable
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-10-11 08:56:10 +02:00
Michael Olbrich
38eb8cf230 image-hd: allow partitions that are not listed in the partition table
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-10-11 08:56:10 +02:00
Michael Olbrich
eb72f4eb22 add insert_data() function
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-10-11 08:56:09 +02:00
Sascha Hauer
b57a2e06b3 remove unused 'offset' entry from images
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-06-27 10:52:06 +02:00
Sascha Hauer
7e369140c9 detect recursive dependencies
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-06-27 10:52:05 +02:00
Sascha Hauer
92757aea26 add imageoutfile() function and use it
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-06-27 10:52:01 +02:00
Sascha Hauer
9a9875f33b move cfg_getint_suffix to config.c
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-06-27 09:47:48 +02:00
Sascha Hauer
e99e74fdaf remove unused function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-06-27 09:43:30 +02:00
Sascha Hauer
432dbea2e2 add commandline parsing, add some function documentation
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-06-27 09:38:33 +02:00
Sascha Hauer
7e5122f621 initial import
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-06-27 08:39:51 +02:00