When trying to use genimage on an embedded target, I hit
find: unrecognized: -printf
xargs: invalid option -- '0'
because the busybox I have apparently has somewhat limited "find" and
"xargs" applets. OTOH, I'm not using the "split a rootfs"
functionality - in fact, I'm just pointing rootpath at an empty dir
which won't be used for anything, so the whole thing is redundant.
When there are no non-trivial mountpoint=... options, we might as well
skip the timestamp fixup.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
libconfuse has a cfg_print() function for sort-of pretty-printing a
cfg_t* object. Let's expose that via a --configdump option, to make
debugging of complicated setups with several layers of include() a
little easier.
If I can get it to work, I will also be using the output dump directly
on target, i.e. merely using the host genimage as a preprocessor - so
that I can still reuse include() fragments in my image definition, but
I don't have to copy all those files to target when bootstrapping the
eMMC.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
When ${B} was made distinct from ${S} and ${WORKDIR} in
genimage.bbclass in meta-ptx commit 9eaa29b7, use of include() in the
main configuration file to include other fragments from SRC_URI broke.
It can be worked around in a recipe by copying all the fragments to
${B} in a do_genimage[prefunc], but that's awkward. It's more natural
for genimage to take a --includepath option and genimage.bbclass to
pass --includepath ${S}.
This does require libconfuse >= 2.8, while meta-ptx currently has a
recipe for 2.7 (the last release downloadable from savannah, but the
project has moved to github).
confuse.h says:
* Note that the current directory is not added to the searchpath
* by default.
That's probably not expected, so when this option is used, always add
"." as well.
In order for this to be meaningful in a config{} section inside the
configuration file, one would have to get libconfuse to call a custom
function when encountering this; it cannot just be a simple
CFG_STR. Because if it doesn't take effect immediately, parsing the
rest of the config file will most likely fail when it hits the
include()s. But the whole option parsing machinery is basically built
around the assumption that options take single string arguments (which
is also why this had to accept a colon-separated list instead of
supporting --includepath being given multiple times). I don't think
it's a huge loss, C files also don't have the proper values of -I
embedded into them. But it does require relaxing the wording in
README.rst a bit.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
There have been situations where the hybrid mode was accidentally used
because a config contained a bogus partition-type entry.
So lets make this explicit: There is now a new 'partition-table-type'
option where the hybrid mode must be selected explicitly.
The relevant options for mbr and gpt are only acceptable if the
corresponding type (or hybrid) is selected.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
For partitions in the partition table, this defaults to the image's
alignment value, while partitions not listed there use a value of 1,
i.e. no particular alignment requirements.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
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>
If the image mountpoint is not explicitly defined, then IMAGEMOUNTPATH is
currently no exported. This is incorrect, because the default mountpoint
for any image is '/'.
Use mountpath() to get the correct path. It handles the default mountpoint
correctly.
Make sure that IMAGEMOUNTPATH is not set if the image is explicitly marked
as empty.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
The "ret" variable in image_setup is not initialized when an image does
not contain any partitions and the image handler does not provide a
setup function. This can cause image_setup to error out erroneously.
These conditions are fulfilled by the cpio test case, but this bug only
becomes visible when the stack content aligns accordingly.
Initialize ret to 0, as image_setup can be considered successful in this
case.
Signed-off-by: Florian Larysch <fl@n621.de>
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>
Specifying an image with mountpoint "/root" would cause the mountpoint's
location to be "root", which conflicts with the location for the actual
filesystem root.
Fix this by appending a prefix.
Closes#67 on GitHub.
Signed-off-by: George Hilliard <thirtythreeforty@gmail.com>
After the mv/mkdir of the mountpoints the timestamps of the mountpoint and all
parent dirs are changed.
This patch adds a find/touch loop to fix the timestamp of all directories.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
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>
genimage does not handle pathes with whitespaces correctly whenever
it invokes an external command. Escape all pathes with quotation
marks to make that work.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
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>
As we now sanitize the mount path for partitions, the path should be considered
implementation defined and should not be guessed. Use the environment variable
IMAGEMOUNTPATH in pre and post scripts instead.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
genimage works on partitions from sub dirs (e.g.: /opt), but it fails from
sub-sub dirs (e.g.: /usr/local). This patch fixes the problem by using a
sanitized sub dir name instead, where slashes '/' are replaces by minuses '-'.
Fixes: Issue #2.
Suggested-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
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>
setenv may fail on invalid key, or segfault on empty value string.
This patch introduces an overwriteenv wrapper to overwrite a given
environment variable, and use an empty string if its value is NULL.
Finally, add 2 functions, setenv_paths and setenv_image to simplify
error checking when overwriting the related environment variables.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This avoids allocating a freeing a string for the image size.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Change the "err_out" label for "cleanup" and check the value of ret to
use a single return path from the main function.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
With a configuration similar to this:
image flash.img {
flash {}
flashtype = "foo-8mb"
partition kernel {
image = "zImage"
size = 6M
}
partition config {
size = 2M
}
}
genimage segfaults in set_flash_type() because image_get() calls
strcmp() with part->image being NULL.
To fix this, skip partitions with no image when setting the flash type.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This reverts commit 020a15d10c.
Allowing includes in image sections is a feature. This makes it possible to
define some partitions, e.g. bootloader configuration, in a separate file.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
"include" is a top-level option, so remove it from the "image" section.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>