Coder Social home page Coder Social logo

pengutronix / genimage Goto Github PK

View Code? Open in Web Editor NEW
299.0 299.0 108.0 616 KB

tool to generate multiple filesystem and flash images from a tree

License: GNU General Public License v2.0

Shell 17.46% C 71.66% Makefile 1.62% M4 6.31% Roff 2.95%
disk-image embedded-linux filesystems

genimage's People

Contributors

a3f avatar bastian-krause avatar ee-smuxel avatar ejoerns avatar gportay avatar harvie avatar jacmet avatar jbeptx avatar jluebbe avatar kimonhoffmann avatar leojrfs avatar lynxeye-dev avatar marckleinebudde avatar mgrzeschik avatar michaelolbrich avatar mniestroj avatar onkelulla avatar osterlad avatar pasrom avatar pseiderer avatar rohieb avatar sairon avatar saschahauer avatar ssorensen avatar sudipm-mukherjee avatar texierp avatar thirtythreeforty avatar tobleminer avatar tpetazzoni avatar vivien avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

genimage's Issues

Missing rauc keys cause segfault

Using this sample configuration:

image rauc.upd8 {
  rauc {
    files = {
      u-boot.imx,
      rootfs.ubifs,
    }

    key = private.pem
    cert = public.pem
  }
}

(note the missing manifest), genimage dereferences a null pointer on line 42 of image-rauc.c:

genimage/image-rauc.c

Lines 34 to 42 in 67a2441

char *manifest = cfg_getstr(image->imagesec, "manifest");
char *cert = cfg_getstr(image->imagesec, "cert");
char *key = cfg_getstr(image->imagesec, "key");
char *manifest_file;
image_debug(image, "manifest = '%s'\n", manifest);
xasprintf(&manifest_file, "%s/manifest.raucm", mountpath(image));
ret = insert_data(image, manifest, manifest_file, strlen(manifest), 0);

...leaving only a very confusing "Segmentation fault" error message in its wake.

Could genimage be used to partition an eMMC device?

As currently defined, could genimage be used instead of fdisk to partition an eMMC device?

If not, would this be a consistent feature to add to genimage? (I'm in no way expecting this to be done for my benefit; I'm just curious...)

Files and folders in ext2 partition

In vfat partition you can create folders and files in the following way:
image boot.vfat {
vfat {
files = {
"bcm2708-rpi-b-plus.dtb",
"rpi-firmware/bootcode.bin",
"rpi-firmware/cmdline.txt",
"rpi-firmware/config.txt",
"rpi-firmware/fixup.dat",
"rpi-firmware/start.elf",
"kernel-marked/zImage"
}

file overlays/dwc2.dtbo {
  image = "rpi-firmware/overlays/dwc2.dtbo"
}

}
size = 32M
}

I want to create files and folders in ext2 partitions. How can I do it? This way is not working:
image home.ext2 {
name = "home"
ext2 {
files = {
"bcm2708-rpi-b-plus.dtb",
"rpi-firmware/bootcode.bin"
}
}
size = 128M
mountpoint = "/home"
}

Add BTRFS Support

Hi,

I want to build a project on BTRFS.
But genimage only support ext2, ext3, ext4...
Can you have possibility to add btrfs support.

Best Regards.

rauc files {} directive does not exclude files from rootpath

When using a vfat image, I can add a files { ... } directive that overrides the mountpoint setting and only includes the specified files:

image boot.vfat {
  vfat {
    files = {
      zImage
    }
  }
}

But when I try the same thing with a rauc image, the generated bundle does not exclude rootpath files; rootfs.squashfs is alongside /bin, /etc, etc. This effectively doubles the size of the image.

image update.raucb {
  rauc {
    files = {
      rootfs.squashfs,
      boot.vfat,
    }
    manifest = "(snip)"
    key = "(snip)"
    cert = "(snip)"
  }
}

I can work around this behavior by running this configuration separate from all my other ones, and specifying an empty rootpath. But I expected files to work the same as in vfat. Is this intended behavior or a bug?

genimage 13 unable to create a disk image with more than 3 partitions with type defined

As the title suggests, it seems that genimage 13 is unable to create a valid disk image and errors out when there are more than 3 partitions with their type defined, with hdimage being gpt.

ERROR: hdimage(sdcard.img): hybrid MBR partitions (5) exceeds maximum of 3.

I have 5 partitions of type linux filesystem in my gpt partition table:

  • ssbl
  • 2x rootfs
  • rauc slot storage
  • overlayfs

For what its worth this seems to have appeared only in version 13, because with version 12 it worked fine...

Aren't there ways of making protective mbr instead of hybrid ?

Either way this sounds like either genimage is right and this is not something valid, but should be possible with protective instead of hybrid, or that genimage has now a bug when the type of the partition is defined.

ext4: option "features" ignored when "use-mke2fs" is true

After migrating a ptxdist based BSP from ptxdist-2019.09.0 to ptxdist-2019.10.0 our target board complained when booting with U-Boot 2016.09.x from SD-Card with ext4 partitions:

Unsupported feature found (64bit, possibly metadata_csum), not mounting
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **

Comparing the ext4 flags of the created root.ext2 images revealed this:

-Filesystem features:      has_journal dir_index extent uninit_bg
+Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super dir_nlink extra_isize metadata_csum

The reason was ptxdist switched on use-mke2fs = true in the default genimage config for ext* images, so the old image was build with genext2fs and the new one with mke2fs which is the intend of this option. However, the latter ignores the option features as can be seen when you compare output of genimage (stripped to the necessary lines):

INFO: ext4(root.ext2): cmd: "genext2fs -d '/tmp/ptxdist.Llj64K/genimage.M7vSVP/root' --size-in-blocks=76800 -i 16384 '/home/adahl/Work/bsp/***/platform-v7a/images/root.ext2' " (stderr):
INFO: ext4(root.ext2): cmd: "tune2fs -O 'extents,uninit_bg,dir_index,has_journal' '/home/adahl/Work/bsp/***platform-v7a/images/root.ext2'" (stderr):

vs. just

INFO: ext4(root.ext2): cmd: "mke2fs -t ext4 -E 'root_owner=0:0,lazy_itable_init=0,lazy_journal_init=0' -O '^large_file' -O '^huge_file' -d '/tmp/ptxdist.T2Gf50/genimage.sJEXH6/root'   '/home/adahl/Work/bsp/***/platform-v7a/images/root.ext2' 60416" (stderr):

Without use-mke2fs = true genimage passes the options from "features" to a separate tune2fs run, which is not done in the case where mke2fs is called.

I could confirm this adding the following line to the genimage config:

features = "uninit_bg"

When checking the resulting image with tune2fs that option is not shown.

Maybe one could just pass "features" to the -O option of "mke2fs"?

after creating an Image the file systems are corrupt

genimage.config
`
image PRODUCT-emmc-dev.img {
hdimage {
disk-signature = 0x741ac374
}

partition firmware-slot-0 {
	image = "PRODUCT-rootfs-dev-board.ext4"
	partition-type = 0x83
	size = 6700M
}

partition firmware-slot-1 {
	image = "PRODUCT-rootfs-dev-board.ext4"
	partition-type = 0x83
	size = 6700M
}

}`

After the file PRODUCT-emmc-dev.img is written to the eMMC the system doesn't start. See attached Log.
crash.txt

The whole workflow is working with the partition size of 1808M. Also if I write the file PRODUCT-rootfs-dev-board.ext4 separately to the partitions the system start correctly.

What am I doing wrong ? Thank you for any suggestion.

msdos partition table extended partitions

I'm trying to create a .img for copying to an SD card using genimage, I've included the relevant contents of my genimage.cfg file below.

The issue I'm having is that I cannot configure extended partitions properly, partition Extended should be the extended partition and config and log should be logical partitions inside that.

If I set Extended's size to 0 genimage complains about it needing to have a size > 0
If I set Extended's size to 1 it fills up the remainder of the image with an extended partition but doesn't create the config or log partitions
If I set Extended's size to anything else it complains about config overlapping with a previous partition.

Is there a correct way to deal with Extended partions in genimage or am I just going to have to work this out myself?

Thanks,

// Skutov

image sdcard.img {
  hdimage {
  }

  size = 3G

  partition boot {
    partition-type = 0x06
    in-partition-table = "yes"
    image = "boot.vfat"
    bootable = TRUE
    size = 32M
    offset = 0
  }

  partition rootfsA {
    partition-type = 0x83
    image = "rootfs.squashfs"
    size = 64M
    offset = 33M
  }

  partition rootfsB {
    partition-type = 0x83
    size = 64M
    offset = 98M
  }

  partition Extended {
    partition-type = 0x05
    offset = 163M
    size = 
  }

  partition config {
    partition-type = 0x85
    size = 32M
    offset = 165M
  }

  partition log {
    partition-type = 0x85
    size = 32M
    offset = 198M
  }
}

ext4 e2fsck failed

I got this error:
UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY. (i.e., without -a or -p options)
I use genimage to generate root file system. I used chroot into the file system and use apt to install some softwares. There's some softwares would cause this error.
Here's the cfg:

image boot.vfat {
  name = "boot"
	vfat {
		files = {
			"linux/zImage"
		}
	}
	size = 16M
}

image root.ext4 {
  name = "root"
	ext4 {
	  features = metadata_csum
	  #features = "extents,uninit_bg,dir_index,has_journal"
	}
	size = 600M
}


image sdcard.img {
	hdimage {
	}

	partition u-boot {
		in-partition-table = "no"
		image = "uboot/u-boot-sunxi-with-spl.bin"
		offset = 8192
		size = 2088960 # 512KB - 8192
	}

	partition boot {
		partition-type = 0xC
		bootable = "true"
		image = "boot.vfat"
	}
	
	partition rootfs {
		partition-type = 0x83
		image = "root.ext4"
		size = 0
	}
}

How to compile genimage on Ubuntu 18.04

Hi there and excuse me for creating a new issue for my problem as this is a question, not an issue, but just because I did not find any mailing list here to ask my question I created this.
I'm intending to use genimage on Ubuntu 18.04 but I got genimage: not found.
I tried to install it on my OS but, there was not any candidate, even I tried to compile the last release( V13) But there is no build tutorial. I tried ./configure to config the build and seems everything is OK but when I use make I got make: *** No targets specified and no makefile found. Stop.

Attempting to specify /root as a mountpoint fails

I have tried to add a separate partition mounted at /root:

image roothome.ubifs {
	ubifs {
		max-size = 2M
	}
	flashtype = w25q64
	mountpoint = /root
}

This produces an error:

INFO: cmd: "mkdir -p "/.../buildroot/output/build/genimage.tmp"" (stderr):
INFO: cmd: "rm -rf "/.../buildroot/output/build/genimage.tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/.../buildroot/output/images"" (stderr):
INFO: cmd: "mkdir -p "/.../buildroot/output/build/genimage.tmp"" (stderr):
INFO: cmd: "cp -a "/.../buildroot/output/target" "/.../buildroot/output/build/genimage.tmp/root"" (stderr):
INFO: cmd: "mv "/.../buildroot/output/build/genimage.tmp/root/root" "/.../buildroot/output/build/genimage.tmp/root"" (stderr):
mv: '/.../buildroot/output/build/genimage.tmp/root/root' and '/.../buildroot/output/build/genimage.tmp/root/root' are the same file
make: *** [Makefile:815: target-post-image] Error 1

It appears genimage is copying the various partitions into the same folder as the root filesystem, which is contained in a folder named "root." This conflicts with the mountpoint name.

I think the best way to fix this (and not just kick the can to some other more obscure name) is to add another directory alongside:

genimage.tmp/
    root/ <-- the existing root directory
    mountpoints/ <-- new
        root/ <-- the overlay

config examples/docs

looking for an example configuration to install grub2 in a gpt image with a bios boot partition. So far none of my attempts have been bootable.

thanks

error: โ€˜AT_NO_AUTOMOUNTโ€™ undeclared

Hi All,
I am not sure if this is the right place to post this , apologies in advance if it's not.

I am using buildroot to build a linux environment for an FPGA platform.
It gets to the point where it attempts to build genimage which is where it's failing at:

 

        genimage 11
        =====

        prefix:                 /nobackup/user_g/tmp_build/host

        compiler:               /cad/apps/gnu/linux/x86_64/6/local/gcc/9.1.0/bin/gcc
        cflags:                 -O2 -I/nobackup/user_g/tmp_build/host/include  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden
        ldflags:                -L/nobackup/user_g/tmp_build/host/lib -Wl,-rpath,/nobackup/user_g/tmp_build/host/lib  -Wl,--as-needed -Wl,--gc-sections

        debug:                  no
        hide symbols:           yes
        libconfuse:             -L/nobackup/user_g/tmp_build/host/lib -lconfuse

>>> host-genimage 11 Building
PATH="/nobackup/user_g/tmp_build/host/bin:/nobackup/user_g/tmp_build/host/sbin:/cad/apps/gnu/linux/x86_64/6/local/gcc/9.1.0/bin:/home/rs/lintel:/cad/local/bin:/cad/div/bin:/usr/cadtools/local/bin:/usr/cadtools/bin:/cad/bin:/cad/apps/gnu/linux/x86_64/6/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin:/bin" PKG_CONFIG="/nobackup/user_g/tmp_build/host/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_LIBDIR="/nobackup/user_g/tmp_build/host/lib/pkgconfig:/nobackup/user_g/tmp_build/host/share/pkgconfig"  /usr/bin/make   -C /nobackup/user_g/tmp_build/build/host-genimage-11/
/usr/bin/make --no-print-directory all-am
  CC       genimage-genimage.o
  CC       genimage-config.o
  CC       genimage-util.o
  CC       genimage-crc32.o
  CC       genimage-image-cpio.o
util.c: In function โ€˜dir_sizeโ€™:
util.c:648:36: error: โ€˜AT_NO_AUTOMOUNTโ€™ undeclared (first use in this function); did you mean โ€˜S_AUTOMOUNTโ€™?
  648 |   if (fstatat(fd,  d->d_name, &st, AT_NO_AUTOMOUNT) < 0) {
      |                                    ^~~~~~~~~~~~~~~
      |                                    S_AUTOMOUNT
util.c:648:36: note: each undeclared identifier is reported only once for each function it appears in
make[3]: *** [genimage-util.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [all] Error 2
make[1]: *** [/nobackup/user_g/tmp_build/build/host-genimage-11/.stamp_built] Error 2
make: *** [_all] Error 2

I am using v11 apparently.

Any suggestions welcome.
I probably don't have enough environment information here so please let me know and I'll add it.

How to use compressed rootfs with this tool?

I am using the PC x86_64 Buildroot defconfig, with the following CFG configuration for genimage:

image efi-part.vfat {
  vfat {
    file startup.nsh {
      image = "efi-part/startup.nsh"
    }
    file EFI {
      image = "efi-part/EFI"
    }
    file bzImage {
      image = "bzImage"
    }
  }
  size = 16777216
}

image disk.img {
  hdimage {
    gpt = true
  }

  partition boot {
    image = "efi-part.vfat"
    partition-type-uuid = c12a7328-f81f-11d2-ba4b-00a0c93ec93b
    offset = 32768
    size = 16777216
    bootable = true
  }

  partition root {
    partition-type-uuid = 44479540-f297-41b2-9af7-d131d5f0458a
    partition-uuid = UUID_TMP
    image = "rootfs.ext2"
    offset = 16809984
  }
}

the file in question, rootfs.ext2 is set to a size of 500mb (I would love to decrease the size somehow)
However, I either want to compress the image or find some way of decreasing the size automatically. I attempted to use rootfs.ext2.xz, however it went into a kernel panic immediately.

Add all subfolder's files to the root of the image

Hello,

I've been trying to add everything from a folder to the root of a vfat image without success. How can I achieve this ? I'm thinking about something as simple as files { "folder/" } or files { "folder/*" } The first syntaxe creates folder in the image, the second one gives an error. This does work for subfolders (files { "folder/subfolder" } is added as subfolder).

Please note that syntax files { "folder/subfolder" } produces output adding file 'folder/subfolder' as 'folder/subfolder' ... whereas it means adding file 'folder/subfolder' as 'subfolder' ...

Using v9 genimage from Buildroot.

Add support for exfat

I was a bit surprised to see that the exfat file system was not supported by genimage. Would it be possible to add it? Since genimage is used by buildroot (and others), which frequently target embedded systems running on flash drives, it seems like a natural fit.

Thanks for all your hard work on genimage!

Issue generating filesystem image

Hello,

I'm compiling a Linux OS via 2021.05 Buildroot and using 5.10.57 version Linux Kernel.
When it's executing post-image script board/raspberrypi4-64/post-image.sh, i have an error :
Disk full
INFO: vfat(boot.vfat): cmd: "rm -f "/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat"" (stderr):
ERROR: vfat(boot.vfat): failed to generate boot.vfat
make[1]: *** [Makefile:838 : target-post-image] Erreur 1
make: *** [Makefile:23 : _all] Erreur 2

Does anybody know how to solve the problem ?

Thanks for help, have a nice day !!!

Alexandre

Executing post-image script board/raspberrypi4-64/post-image.sh
board/raspberrypi4-64/genimage-raspberrypi4-64.cfg:31: no sub-section title/index for 'config'
INFO: cmd: "mkdir -p "/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/build/genimage.tmp"" (stderr):
INFO: cmd: "rm -rf "/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/build/genimage.tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/build/genimage.tmp"" (stderr):
INFO: cmd: "cp -a "/tmp/tmp.GJN41vc0Bx" "/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/build/genimage.tmp/root"" (stderr):
INFO: cmd: "find '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/build/genimage.tmp/root' -depth -type d -printf '%P\0' | xargs -0 -I {} touch -r '/tmp/tmp.GJN41vc0Bx/{}' '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/build/genimage.tmp/root/{}'" (stderr):
INFO: cmd: "mkdir -p "/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images"" (stderr):
INFO: vfat(boot.vfat): cmd: "dd if=/dev/zero of="/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat" seek=33554432 count=0 bs=1 2>/dev/null" (stderr):
INFO: vfat(boot.vfat): cmd: "mkdosfs '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat'" (stderr):
INFO: vfat(boot.vfat): adding file 'bcm2711-rpi-4-b.dtb' as 'bcm2711-rpi-4-b.dtb' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat' '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/bcm2711-rpi-4-b.dtb' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'rpi-firmware/cmdline.txt' as 'rpi-firmware/cmdline.txt' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat' '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/rpi-firmware/cmdline.txt' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'rpi-firmware/config.txt' as 'rpi-firmware/config.txt' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat' '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/rpi-firmware/config.txt' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'rpi-firmware/fixup.dat' as 'rpi-firmware/fixup.dat' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat' '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/rpi-firmware/fixup.dat' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'rpi-firmware/start.elf' as 'rpi-firmware/start.elf' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat' '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/rpi-firmware/start.elf' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'rpi-firmware/overlays' as 'rpi-firmware/overlays' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat' '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/rpi-firmware/overlays' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'Image' as 'Image' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat' '/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/Image' '::'" (stderr):
Disk full
INFO: vfat(boot.vfat): cmd: "rm -f "/home/heol/stage_heol/br-lab/64bit/systemctl/build-pi4-64/images/boot.vfat"" (stderr):
ERROR: vfat(boot.vfat): failed to generate boot.vfat
make[1]: *** [Makefile:838 : target-post-image] Erreur 1
make: *** [Makefile:23 : _all] Erreur 2

hdimage(disk.img): fwrite 4096: Invalid argument

I'm getting the above error message using genimage with the config file shown below. I'm baffled. Any ideas?

image disk.img {

hdimage {
}

partition boot {
in-partition-table = "no"
image = "boot.img"
offset = 0
size = 512
size = 1048576
}

partition grub {
image = "grub.img"
offset = 1048576
size = 33554432
bootable = "yes"
}

}

Below is the directory with the source files in it - as you can see I'm using it with buildroot.

drwxr-xr-x 2 nicole nicole 4.0K Apr 25 20:25 ./
drwxr-xr-x 6 nicole nicole 4.0K Apr 25 17:24 ../
lrwxrwxrwx 1 nicole nicole 88 Apr 25 20:24 boot.img -> /home/nicole/projects/router-builder/buildroot/output/host/usr/lib/grub/i386-pc/boot.img
-rw-r--r-- 1 nicole nicole 4.6M Apr 25 17:59 bzImage
-rw-r--r-- 1 nicole nicole 1.2M Apr 25 20:25 disk.img
-rw-r--r-- 1 nicole nicole 114K Apr 25 18:01 grub-eltorito.img
-rw-r--r-- 1 nicole nicole 114K Apr 25 18:01 grub.img
-rw-r--r-- 1 nicole nicole 16G Apr 25 20:25 rootfs.ext2
lrwxrwxrwx 1 nicole nicole 11 Apr 25 20:25 rootfs.ext4 -> rootfs.ext2

Fakeroot and SUID

Hi,
When I execute genimage with fakeroot the suid bits are not preserved ,but with sudo it works fine. Am I missing something here? Cause I thought fakeroot was the safest way to go. And needless to say. the root filesystem is extracted from a tar.bz2 archive (with -p and --same-owner tar options) under fakeroot . I also checked the files after exiting the fakeroot, the suid bits are all there (although with my normal user as the owner).

With fakeroot:

ls -l /bin/su
-rwxr-xr-x 1 root root 43924 May 28 14:47 /bin/su

With sudo:

ls -l /bin/su
-rwsr-xr-x 1 root root 43924 May 28 15:12 /bin/su

On the other hand ,when using the Yocto project as a normal user we get images containing files with suid bits set. So that's possible to set suid as a normal user under a fakeroot(ish?) environment.

genimage-10: Test failure in mke2fs

We're trying to package genimage for the Guix distribution.

When we run automated tests, we get a test failure in mke2fs (using genimage-10):

INFO: ext4(mke2fs.ext4): cmd: "MKE2FS_CONFIG="mke2fs.conf" mke2fs -t ext4 -E 'root_owner=0:0,lazy_itable_init=0,lazy_journal_init=0' -O '^large_file' -O '^huge_file' -d '/tmp/guix-build-genim
age-10.drv-0/genimage-10/trash directory.basic-images.test/tmp/root' -U 12345678-1234-1234-1234-1234567890ab -L mke2fs '/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-ima
ges.test/images/mke2fs.ext4' 32768" (stderr+stdout):
mke2fs 1.43.6 (29-Aug-2017)
ext2fs_check_if_mount: Can't check if filesystem is mounted due to missing mtab file while determining whether /tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/
images/mke2fs.ext4 is mounted.
Discarding device blocks: done                            
Creating filesystem with 32768 1k blocks and 8192 inodes
Filesystem UUID: 12345678-1234-1234-1234-1234567890ab
Superblock backups stored on blocks: 
        8193, 24577

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (4096 blocks): done
Copying files into the device: done
Writing superblocks and filesystem accounting information: done

INFO: ext4(mke2fs.ext4): cmd: "e2fsck -pvfD '/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/images/mke2fs.ext4'" (stderr+stdout):
ext2fs_check_if_mount: Can't check if filesystem is mounted due to missing mtab file while determining whether /tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/
images/mke2fs.ext4 is mounted.

          51 inodes used (0.62%, out of 8192)
           0 non-contiguous files (0.0%)
           0 non-contiguous directories (0.0%)
             # of inodes with ind/dind/tind blocks: 0/0/0
             Extent depth histogram: 43
        5970 blocks used (18.22%, out of 32768)
           0 bad blocks
           0 large files

          24 regular files
          18 directories
           0 character device files
           0 block device files
           0 fifos
           0 links
           0 symbolic links (0 fast symbolic links)
           0 sockets
------------
          42 files
INFO: ext4(mke2fs.ext4): cmd: "echo 'set_current_time 20000101000000
set_super_value mkfs_time 20000101000000
set_super_value lastcheck 20000101000000
set_super_value mtime 00000000' | debugfs -w '/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/images/mke2fs.ext4'" (stderr+stdout):
debugfs 1.43.6 (29-Aug-2017)
debugfs:  Setting current time to Sat Jan  1 00:00:00 2000

debugfs:  debugfs:  debugfs:  debugfs:  ++ uuid='Filesystem UUID'
++ seed='Directory Hash Seed:'
++ csum1='Checksum: \|Group 0: (Blocks 1-4095) csum'
++ csum2='Group 0: (Blocks 1-4095) \[ITABLE_ZEROED\]\|  Checksum .*, unused inodes 205'
++ dumpe2fs images/mke2fs.ext4
++ grep -v '^\(Filesystem UUID\|Directory Hash Seed:\|Checksum: \|Group 0: (Blocks 1-4095) csum\|Group 0: (Blocks 1-4095) \[ITABLE_ZEROED\]\|  Checksum .*, unused inodes 205\)'
dumpe2fs 1.43.6 (29-Aug-2017)
++ sed -i 's/^\(Journal size:             \)1029k$/\11024k/' dump
++ sed -i 's/^\(  Block bitmap at .*\),\( Inode bitmap.*\)$/\1\n \2/' dump
++ test_cmp /tmp/guix-build-genimage-10.drv-0/genimage-10/test/mke2fs.dump dump
++ diff -u /tmp/guix-build-genimage-10.drv-0/genimage-10/test/mke2fs.dump dump

--- /tmp/guix-build-genimage-10.drv-0/genimage-10/test/mke2fs.dump      2018-03-29 11:02:02.585752634 +0000
+++ dump        2018-05-18 19:19:03.337721421 +0000
@@ -11,7 +11,7 @@
 Inode count:              8192
 Block count:              32768
 Reserved block count:     1638
-Free blocks:              26838
+Free blocks:              26798
 Free inodes:              8141
 First block:              1
 Block size:               1024
@@ -30,9 +30,9 @@
 Maximum mount count:      -1
 Last checked:             Sat Jan  1 00:00:00 2000
++ func_check
 Check interval:           0 (<none>)
-Lifetime writes:          343 kB
-Reserved blocks uid:      0 (user root)
-Reserved blocks gid:      0 (group root)
++ local ret=1
+Lifetime writes:          389 kB
+Reserved blocks uid:      0 (user unknown)
+Reserved blocks gid:      0 (group unknown)
 First inode:              11
++ set +x
 Inode size:              128
 Journal inode:            8
@@ -46,14 +46,14 @@
 Journal start:            0
 
 
-Group 0: (Blocks 1-8192) csum 0xcb99 [ITABLE_ZEROED]
+Group 0: (Blocks 1-8192) csum 0xe916 [ITABLE_ZEROED]
   Primary superblock at 1, Group descriptors at 2-2
Failed to execute 'check_ext'!
   Reserved GDT blocks at 3-257
-  Block bitmap at 258 (+257), csum 0x064f6fdd
+  Block bitmap at 258 (+257), csum 0x22f720dc
   Inode bitmap at 262 (+261), csum 0xb1052088
   Inode table at 266-521 (+265)
-  6873 free blocks, 1997 free inodes, 18 directories, 1997 unused inodes
-  Free blocks: 1320-8192
+  6833 free blocks, 1997 free inodes, 18 directories, 1997 unused inodes
+  Free blocks: 1360-8192
   Free inodes: 52-2048
 Group 1: (Blocks 8193-16384) csum 0xfabf [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
   Backup superblock at 8193, Group descriptors at 8194-8194
not ok 6 - mke2fs
FAIL: test/basic-images.test 6 - mke2fs

fat filesystem not clean

I'm using genimage v14 to generate harddisk image for an embedded system.
While testing something else I notet that if I flash on my device and run fsck.fat on the fat partitions it reliably reports errors.

Here is a mininal genimage.cfg and test-script to reproduce the issue:

image uboot.img {
    size = 64M
    vfat {
        label = "uboot"
    }
    mountpoint = "uboot"
}


image broken.img {
    hdimage {
        align = 1M
        extended-partition = 2
    }

    partition uboot {
        image = "uboot.img"
        partition-type = 0x0c
    }

}
#!/bin/sh

set -x

mkdir -p root/uboot/test1
mkdir -p root/uboot/test2
echo foo > root/uboot/test2/bar

genimage

LO_DEV=$(sudo losetup --partscan --show --find images/broken.img)
sudo fsck.fat -n ${LO_DEV}p1
sudo losetup -d $LO_DEV

If I run it on my machine I get:

$ ./test.sh
+ mkdir -p root/uboot/test1
+ mkdir -p root/uboot/test2
+ echo foo
+ genimage
INFO: cmd: "mkdir -p "/home/schumb/misc/genimage_test/tmp"" (stderr):
INFO: cmd: "rm -rf "/home/schumb/misc/genimage_test/tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/home/schumb/misc/genimage_test/tmp"" (stderr):
INFO: cmd: "cp -a "/home/schumb/misc/genimage_test/root" "/home/schumb/misc/genimage_test/tmp/root"" (stderr):
INFO: cmd: "mv "/home/schumb/misc/genimage_test/tmp/root/uboot" "/home/schumb/misc/genimage_test/tmp/mp-uboot"" (stderr):
INFO: cmd: "mkdir "/home/schumb/misc/genimage_test/tmp/root/uboot"" (stderr):
INFO: cmd: "chmod --reference="/home/schumb/misc/genimage_test/tmp/mp-uboot" "/home/schumb/misc/genimage_test/tmp/root/uboot"" (stderr):
INFO: cmd: "chown --reference="/home/schumb/misc/genimage_test/tmp/mp-uboot" "/home/schumb/misc/genimage_test/tmp/root/uboot"" (stderr):
INFO: cmd: "find '/home/schumb/misc/genimage_test/tmp/root' -depth -type d -printf '%P\0' | xargs -0 -I {} touch -r '/home/schumb/misc/genimage_test/root/{}' '/home/schumb/misc/genimage_test/tmp/root/{}'" (stderr):
INFO: cmd: "mkdir -p "/home/schumb/misc/genimage_test/images"" (stderr):
INFO: vfat(uboot.img): cmd: "dd if=/dev/zero of="/home/schumb/misc/genimage_test/images/uboot.img" seek=67108864 count=0 bs=1 2>/dev/null" (stderr):
INFO: vfat(uboot.img): cmd: "mkdosfs  -n 'uboot' '/home/schumb/misc/genimage_test/images/uboot.img'" (stderr):
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
INFO: vfat(uboot.img): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/home/schumb/misc/genimage_test/images/uboot.img' '/home/schumb/misc/genimage_test/tmp/mp-uboot'/* ::" (stderr):
INFO: hdimage(broken.img): adding partition 'uboot' (in MBR) from 'uboot.img' ...
INFO: hdimage(broken.img): writing MBR
+ sudo losetup --partscan --show --find images/broken.img
+ LO_DEV=/dev/loop23
+ sudo fsck.fat -n /dev/loop23p1
fsck.fat 4.1 (2017-01-24)
/TEST1/.
  Start (0) does not point to parent (2)
/TEST2/.
  Start (0) does not point to parent (4)
Leaving filesystem unchanged.
/dev/loop23p1: 4 files, 3/32695 clusters
+ sudo losetup -d /dev/loop23

Note the fsck output:

fsck.fat 4.1 (2017-01-24)
/TEST1/.
  Start (0) does not point to parent (2)
/TEST2/.
  Start (0) does not point to parent (4)
Leaving filesystem unchanged.

It does not seem to be an actual problem in this instance.
If I mount the partition and look at the files they seem fine.

Am I doing something wrong here?
Or is it safe to ignore the errors reported by fsck?

additional infos:

  • Ubuntu 18.04.5
  • mcopy (GNU mtools) 4.0.18

create folder on fat partition?

I want to create a image for my sdcard/usb-stick. Some files on the first boot partition should be at a subfolder. Is it possible to create a vfat partition and add the files to a subfolder instead of the root path?

Offset in first extended partition not handled correctly

I was writing this unusual config, and it brought up an issue in genimage.
Part4 is at the correct location, but the ERB of part3 does not point correctly to part4.
Tested on 207ce8d

image test.hdimage {
	hdimage {
		extended-partition = 3
	}
	partition part1 {
		offset = 128K
		size =  256K
		partition-type = 0x83
	}
	partition part2 {
		size = 3072K
		partition-type = 0x83
	}
	partition part3 {
		offset = 3686400
		size = 8126464
		partition-type = 0x83
	}
	partition part4 {
		offset = 11821056
		size = 16252928
		partition-type = 0x83
	}
}

Documentation missing for some ext2 image options

With d2cb2f9 new options "use-mke2fs" and "usage-type" were introduced for image ext*. Those are not documented in README.rst.

(As far as I can see there also was an option "tool", but that one was remove in favor of "use-mke2fs"?)

With dd12f10 another option "root-owner" was introduced, also missing in the documentation.

ERROR: hdimage(disk.img): part root size (366951937) too small for rootfs.ext2 (367001600)

I found that this tool supports the "autoresize" parameter in the configuration, and it seems that that is perfect for what I want to achieve, however, I am unable to compile an image successfully while using it.

image efi-part.vfat {
  vfat {
    file startup.nsh {
      image = "efi-part/startup.nsh"
    }
    file EFI {
      image = "efi-part/EFI"
    }
    file bzImage {
      image = "bzImage"
    }
  }
  size = 16777216
}

image disk.img {
  hdimage {
    gpt = true
  }

  partition boot {
    image = "efi-part.vfat"
    partition-type-uuid = c12a7328-f81f-11d2-ba4b-00a0c93ec93b
    offset = 32768
    size = 16777216
    bootable = true
  }

  partition root {
    partition-type-uuid = 44479540-f297-41b2-9af7-d131d5f0458a
    partition-uuid = UUID_TMP
    image = "rootfs.ext2"
    offset = 16809984

    autoresize = true
  }
size = 383778817
}

Using this configuration, I recieve the following error:
ERROR: hdimage(disk.img): part root size (366951937) too small for rootfs.ext2 (367001600)
It seems that using the autoresize option is a few MB off, am I misiterpreting it? What does the autoresize option actually do? Is it responsible for expanding the last partition when flashed?

New release

There are a lot of cool things sience last release. Is it possible to have a new release? So I can push this into buildroot soon. Actual I handle a lot of patches for this to run it in my own project.

Thanks for this amazing work ๐Ÿ‘

Have partition be sized to minimum to fit specified files

As I expect a number of buildroot users are these days, we use genimage to generate the output file image. Problem: we must explicitly set a size value large enough to fit the built system. Too large, and we're making unwieldy images; too small and the build fails. Even worse, we'll have to tune this again and again as we add features to our product, increasing the size of the contained files.

Would it be possible for genimage to measure the size of the files that will go into the partition (specified using the rootpath property) and then make a partition that can contain those files with little waste?

New Release ?

I imported in buildroot the 0001-image-vfat-Add-label-option-to-set-volume-name.patch patch (commit 516f371) from your repository.
The patch was accepted but I learned that normally they don't take feature patches.
It is a feature that someone needs, so it would be really nice to cut a new release so that this feature is in a tagged release of genimage.
Thanks

#143 leftovers and followups

Some things off the top of my head that should/could be done at some point after #143 is merged, but which I'd rather not include in that already-way-too-long series.

  • check that no partition in the partition table lives before the GPT array (essentially redoing #125)
  • extend insert_image so it can be used as a full replacement for the few remaining uses of pad_file
  • perhaps add a check that when hd->gpt and image size is given that it's a multiple of 4K, to be consistent with the case where the image size is auto-computed to place the end of the gpt backup at a 4K boundary.
  • some code cleanups might be in order - I ended up introducing helpers like partition_end and min_ull/max_ull, and some existing code might benefit from using those.

Multiple rauc images in a config file fails after generating first

If I have a config file that specifies multiple rauc images (say, update.raucb and update-developer.raucb), then generating all but the first fails.

This is because rauc_generate improperly uses insert_data to write data to a file:

genimage/image-rauc.c

Lines 41 to 44 in a58a53b

xasprintf(&manifest_file, "%s/manifest.raucm", mountpath(image));
ret = insert_data(image, manifest, manifest_file, strlen(manifest), 0);
if (ret)
return ret;

This manifest file is presumed not to exist, but if previous RAUC runs have been done, it does exist and the file is not replaced/truncated, but simply pasted into, leaving garbage at the end from the previous RAUC run. (In other words, insert_data is not the appropriate function to use here.)

This creates bizarre errors when RAUC runs again and encounters the garbage data, like:

Failed to update manifest: Key file contains line ?      dff3f29ff09360b59513? which is not a key-value pair, group, or comment

As a workaround, I'm deleting the file before continuing:

diff --git a/image-rauc.c b/image-rauc.c
index c4195a3..8ee5550 100644
--- a/image-rauc.c
+++ b/image-rauc.c
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <unistd.h>
 
 #include "genimage.h"
 
@@ -39,6 +40,7 @@ static int rauc_generate(struct image *image)
    image_debug(image, "manifest = '%s'\n", manifest);
 
    xasprintf(&manifest_file, "%s/manifest.raucm", mountpath(image));
+   ret = unlink(manifest_file);
    ret = insert_data(image, manifest, manifest_file, strlen(manifest), 0);
    if (ret)
        return ret;

Feel free to steal this patch for a quick fix, or if you want to make more sweeping changes, you won't hurt my feelings.

Multi-component directory names in genimage.cfg fail

I'm using a genimage.cfg file that looks like this:

image ad_emmc.img {
        hdimage {}
        partition rootfsA {
                in-partition-table = "yes"
                partition-type = 0x83
                image = "rootfs.ext4"
                bootable = "yes"
                size = 1000M
        }
        partition rootfsB {
                in-partition-table = "yes"
                partition-type = 0x83
                image = "rootfs.ext4"
                bootable = "yes"
                size = 1000M
        }
        partition services {
                in-partition-table = "yes"
                partition-type = 0x83
                image = "services.ext4"
                size = 2000M
        }
        partition var {
                in-partition-table = "yes"
                partition-type = 0x83
                image = "var.ext4"
                size = 500M
        }
        partition skills {
                in-partition-table = "yes"
                partition-type = 0x83
                image = "skills.ext4"
                size = 10000M
        }
}

image rootfs.ext4 {
        name = "rootfs"
        ext4 {
                label = "rootfs"
        }
        size = 1000M
        mountpoint = "/"
}

image var.ext4 {
        name = "var"
        ext4 {
                label = "var"
        }
        size = 500M
        mountpoint = "/var"
}

image services.ext4 {
        name = "services"
        ext4 {
                label = "services"
        }
        size = 2000M
        mountpoint = "/usr/local"
}

image skills.ext4 {
        name = "skills"
        ext4 {
                label = "skills"
        }
        size = 100M
        mountpoint = "/opt"
}

And the post-image.sh looks like this:

#!/bin/sh

GENIMAGE_CFG="board/nvidia/avionic/genimage.cfg"
GENIMAGE_ROOT="${BUILD_DIR}/genimage.root"
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
# Cleanup leftovers

rm -rf ${GENIMAGE_ROOT}
rm -rf ${GENIMAGE_TMP}
# Provide rootfs

mkdir -p ${GENIMAGE_ROOT}
fakeroot tar -C ${GENIMAGE_ROOT} -xf ${BINARIES_DIR}/rootfs.tar

fakeroot genimage \
        --rootpath "${GENIMAGE_ROOT}" \
    --tmppath "${GENIMAGE_TMP}" \
    --inputpath "${BASE_DIR}" \
    --outputpath "${BINARIES_DIR}" \
    --loglevel=10 \
    --config "${GENIMAGE_CFG}"

RET=${?}

IMAGES="${1}"
exit ${RET}

When post-image.sh runs, I get the following output:

cmd: mkdir -p /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp
cmd: rm -rf /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/*
cmd: mkdir -p /home/blair/work/testing/buildroot.jibo/output/images
cmd: mkdir -p /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp
cmd: cp -a /home/blair/work/testing/buildroot.jibo/output/build/genimage.root /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/root
cmd: mv /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/root/var /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp
cmd: mkdir /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/root/var
cmd: chmod --reference=/home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/var /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/root/var
cmd: chown --reference=/home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/var /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/root/var
cmd: mv /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/root/usr/local /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp
cmd: mkdir /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/root/usr/local
cmd: chmod --reference=/home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/usr/local /home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/root/usr/local
chmod: failed to get attributes of โ€˜/home/blair/work/testing/buildroot.jibo/output/build/genimage.tmp/usr/localโ€™: No such file or directory

So the mv command does what it's supposed to do, but the script was expecting it to move the directory tree when it just move the last directory.

When faced with /usr/local the mv command will just recreate the local directory.

How to create cpio image?

How do I define the contents of the cpio image?

I have genimage.cfg file on buildroot and trying to generate a cpio image with a few of the artifacts, but I don't see a way to define the contents of the cpio image.

Thanks

genimage-10: Test failure in jffs2

expecting success: 
        run_genimage jffs2.config test.jffs2 &&
        md5sum -c '/tmp/guix-build-genimage-10.drv-0/genimage-10/test/jffs2.md5'
1+0 records in
1+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00075539 s, 1.4 GB/s
INFO: cmd: "mkdir -p "/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/tmp"" (stderr+stdout):
INFO: cmd: "rm -rf "/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/tmp"/*" (stderr+stdout):
INFO: cmd: "mkdir -p "/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/images"" (stderr+stdout):
INFO: cmd: "mkdir -p "/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/tmp"" (stderr+stdout):
INFO: cmd: "cp -a "/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/root" "/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/tmp/root"" (stderr+stdout):
INFO: jffs2(test.jffs2): cmd: "mkfs.jffs2 --eraseblock=131072 -d '/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/tmp/root' -o '/tmp/guix-build-genimage-10.drv-0/genimage-10/trash directory.basic-images.test/images/test.jffs2' " (stderr+stdout):
md5sum: WARNING: 1 computed checksum did NOT match

images/test.jffs2: FAILED
not ok 10 - jffs2
FAIL: test/basic-images.test 10 - jffs2
#       
#               run_genimage jffs2.config test.jffs2 &&
#               md5sum -c '/tmp/guix-build-genimage-10.drv-0/genimage-10/test/jffs2.md5'
#       

mcopy fails with "Disk full"

Background

I'm using Buildroot to create a custom image for a Raspberry Pi Zero W. I'd like to add an extra VFAT partition that can be mounted on the root filesystem. I've run into a problem trying to do this and I suspect that it's with genimage.

Any help would be greatly appreciated!

Changes to .cfg

The following is the only change I made to the board/raspberrypi/genimage-raspberrypi0w.cfg file. I intentionally have not yet defined the partition on image sdcard.img so that I can narrow down the source of the failure.

Removing these lines allows the make command to complete successfully.

image eric.vfat {
  vfat {}
  size = 1M
}

make error: Disk full

The following shows the relevant output from running the make command. Note the Disk full error after the mcopy command.

INFO: vfat(eric.vfat): cmd: "dd if=/dev/zero of="/home/vagrant/buildroot-2019.08/output/images/eric.vfat" seek=1048576 count=0 bs=1 2>/dev/null" (stderr):
INFO: vfat(eric.vfat): cmd: "mkdosfs  '/home/vagrant/buildroot-2019.08/output/images/eric.vfat'" (stderr):
INFO: vfat(eric.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -bsp -i '/home/vagrant/buildroot-2019.08/output/images/eric.vfat' '/home/vagrant/buildroot-2019.08/output/build/genimage.tmp/root'/* ::" (stderr):
Disk full
INFO: vfat(eric.vfat): cmd: "rm -f "/home/vagrant/buildroot-2019.08/output/images/eric.vfat"" (stderr):
ERROR: vfat(eric.vfat): failed to generate eric.vfat
Makefile:812: recipe for target 'target-post-image' failed
make[1]: *** [target-post-image] Error 1

How to auto fill sd card without expanding the image

I want to make the image and burn it into my sd card.
Suppose the size of the image is 20M, and of sd card is 32G.
I want to know how to make the image automatically fill the rest of the sd card without generate a 32G image.

Not generating correct output image

test.sh

#!/bin/bash
mkdir root input
mkfs.ext4 input/part1.ext4 1M
genimage genimage.cfg
du -sh --apparent-size images/*

genimage.cfg

image disk.img {

  hdimage {
  }

  partition part1 {
    bootable = "true"
    partition-type = 0x83
    image = "part1.ext4"
    size = 10M
  }

  partition part2 {
    partition-type = 0x83
    size = 20M
  }
}

Output:

mke2fs 1.44.3 (10-July-2018)
Creating regular file input/part1.ext4

Filesystem too small for a journal
Creating filesystem with 1024 1k blocks and 128 inodes

Allocating group tables: done                            
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

INFO: cmd: "mkdir -p "/home/kuldeep/Desktop/test-genimage/tmp"" (stderr):
INFO: cmd: "rm -rf "/home/kuldeep/Desktop/test-genimage/tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/home/kuldeep/Desktop/test-genimage/images"" (stderr):
INFO: cmd: "mkdir -p "/home/kuldeep/Desktop/test-genimage/tmp"" (stderr):
INFO: cmd: "cp -a "/home/kuldeep/Desktop/test-genimage/root" "/home/kuldeep/Desktop/test-genimage/tmp/root"" (stderr):
INFO: hdimage(disk.img): adding partition 'part1' (in MBR) from 'part1.ext4' ...
INFO: hdimage(disk.img): adding partition 'part2' (in MBR) ...
INFO: hdimage(disk.img): writing MBR
1.1M	images/disk.img

1.1M images/disk.img Shouldn't images/disk.img be 30M+?

Also, i dont think images/disk.img is a sparse file as du is given --apparent-size.

man du:

      --apparent-size
              print apparent sizes,  rather  than  disk  usage;  although  the
              apparent  size is usually smaller, it may be larger due to holes
              in ('sparse') files, internal  fragmentation,  indirect  blocks,
              and the like

New release ?

There's at least the cool feature of GPT support in the last release, so it would be really nice to cut a new release so that GPT support is in a tagged release of genimage. Thanks!

VFAT: support for file names in cyrilic encoding

Hello,

I'm trying to add file to fat partition with Cyrillic latters and spaces in the file name (oh, I wouldn't do it by my customer asks )

here is the config

image boot.vfat {
	vfat {
		files = {
			"uImage",
			"boot.bin",
			"u-boot.bin"
		}

		file uboot.env {
			image = "uboot-env.bin"
		}
	}
	size = 30M
}

image update.vfat {
	vfat {
                files = {
                        "ะคะฐะนะป ั ะดะปะธะฝะฝั‹ะผ ั€ัƒััะบะธะผ ะธะผะตะฝะตะผ.txt"
                }
	}
	size = 512M
}

image sdcard.img {
	hdimage {
	}

	partition boot {
		partition-type = 0xC
		bootable = "true"
		image = "boot.vfat"
		offset = 1M
	}

	partition update {
		partition-type = 0xC
		image = "update.vfat"
		size = 512M
	}
}

and here is what I get in the output

>>>   Executing post-image script board/econ/ikv3/post-image.sh
Config name genimage-2.6.36
--rootpath /home/rucoder/heat-meter/new_clean/buildroot/output/target
--tmppath /home/rucoder/heat-meter/new_clean/buildroot/output/build/genimage-2.6.36.tmp
--inputpath /home/rucoder/heat-meter/new_clean/buildroot/output/images
--outputpath /home/rucoder/heat-meter/new_clean/buildroot/output/images
--config board/econ/ikv3/genimage-2.6.36.cfg
file(ะคะฐะนะป ั ะดะปะธะฝะฝั‹ะผ ั€ัƒััะบะธะผ ะธะผะตะฝะตะผ.txt): stat(/home/rucoder/heat-meter/new_clean/buildroot/output/images/ะŸั€ะพัˆะธะฒะบะฐ ะธ ะฟั€ะพะฒะตั€ะบะฐ ะ˜ะš 3.txt) failed: No such file or directory
vfat(update.vfat): could not setup ะคะฐะนะป ั ะดะปะธะฝะฝั‹ะผ ั€ัƒััะบะธะผ ะธะผะตะฝะตะผ.txt
Makefile:736: recipe for target 'target-post-image' failed

Forgetting to specify lebsize causes div-by-zero crash in ubifs build

I mistakenly specified my flash without a lebsize:

flash w25q64 {
	pebsize = 4096
	numpebs = 2048
	minimum-io-unit-size = 1
	sub-page-size = 1
	vid-header-offset = 64
}

and tried to build an ubifs image using this definition. I get a crash:

support/scripts/genimage.sh: line 40:  6959 Floating point exception(core dumped) genimage --rootpath "${TARGET_DIR}" --tmppath "${GENIMAGE_TMP}" --inputpath "${BINARIES_DIR}" --outputpath "${BINARIES_DIR}" --config "${GENIMAGE_CFG}"

Analyzing the coredump suggests a div-by-zero problem:

Program terminated with signal SIGFPE, Arithmetic exception.
#0  0x000055f0b21195f2 in ubifs_generate (image=0x55f0b2ab4b30) at image-ubifs.c:33
33          max_leb_cnt = max_size / image->flash_type->lebsize;
(gdb) bt
#0  0x000055f0b21195f2 in ubifs_generate (image=0x55f0b2ab4b30) at image-ubifs.c:33
#1  0x000055f0b2110bb4 in image_generate (image=0x55f0b2ab4b30) at genimage.c:233
#2  0x000055f0b2110a9e in image_generate (image=0x55f0b2ab4c50) at genimage.c:219
#3  0x000055f0b2110a9e in image_generate (image=0x55f0b2ab46d0) at genimage.c:219
#4  0x000055f0b211235f in main (argc=11, argv=0x7fffccf1d1e8) at genimage.c:749

Probably, genimage should check that lebsize is specified if ubifs is expecting to use it (and give an error if not).

For what it's worth, a plain ubi image worked fine without lebsize.

make check: FAIL: test/basic-images.test 7 - mke2fs

https://github.com/pengutronix/genimage/archive/v14.tar.gz

tar xf v14.tar.gz

cd genimage-14

autoreconf --version

autoreconf (GNU Autoconf) 2.71
...
./autogen.sh
configure.ac:10: warning: The macro `AC_PROG_CC_STDC' is obsolete.
configure.ac:10: You should run autoupdate.
./lib/autoconf/c.m4:1666: AC_PROG_CC_STDC is expanded from...
configure.ac:10: the top level
configure.ac:78: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
./lib/autoconf/lang.m4:199: AC_LANG_CONFTEST is expanded from...
./lib/autoconf/general.m4:2894: _AC_LINK_IFELSE is expanded from...
./lib/autoconf/general.m4:2911: AC_LINK_IFELSE is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
m4/attributes.m4:87: CC_CHECK_LDFLAGS is expanded from...
configure.ac:78: the top level
configure.ac:79: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
./lib/autoconf/lang.m4:199: AC_LANG_CONFTEST is expanded from...
./lib/autoconf/general.m4:2894: _AC_LINK_IFELSE is expanded from...
./lib/autoconf/general.m4:2911: AC_LINK_IFELSE is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
m4/attributes.m4:87: CC_CHECK_LDFLAGS is expanded from...
configure.ac:79: the top level
configure.ac:10: installing 'build-aux/compile'
configure.ac:29: installing 'build-aux/config.guess'
configure.ac:29: installing 'build-aux/config.sub'
configure.ac:9: installing 'build-aux/install-sh'
configure.ac:9: installing 'build-aux/missing'
configure.ac:111: installing 'build-aux/tap-driver.sh'
Makefile.am: installing 'build-aux/depcomp'

----------------------------------------------------------------
Initialized build system. For a common configuration please run:
----------------------------------------------------------------

./configure CFLAGS='-g -O0' --prefix=/usr
./configure CFLAGS='-g -O0' --prefix=/usr
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking whether make supports nested variables... (cached) yes
checking for memset... yes
checking for setenv... yes
checking for strdup... yes
checking for strcasecmp... yes
checking for strerror... yes
checking for strstr... yes
checking for strtoull... yes
checking for inline... inline
checking for error_at_line... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for GNU libc compatible malloc... yes
checking for size_t... yes
checking for uint32_t... yes
checking whether to enable debugging... no
checking whether to hide internal symbols... yes
checking if gcc supports -Wl,--as-needed flag... yes
checking if gcc supports -Wl,--gc-sections flag... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for CONFUSE... yes
checking whether the compiler supports -fvisibility=hidden... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands

        genimage 14
        =====

        prefix:                 /usr

        compiler:               gcc
        cflags:                 -g -O0  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden
        ldflags:                  -Wl,--as-needed -Wl,--gc-sections

        debug:                  no
        hide symbols:           yes
        libconfuse:             -lconfuse
make V=1
make --no-print-directory all-am
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-genimage.o -MD -MP -MF .deps/genimage-genimage.Tpo -c -o genimage-genimage.o `test -f 'genimage.c' || echo './'`genimage.c
mv -f .deps/genimage-genimage.Tpo .deps/genimage-genimage.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-config.o -MD -MP -MF .deps/genimage-config.Tpo -c -o genimage-config.o `test -f 'config.c' || echo './'`config.c
mv -f .deps/genimage-config.Tpo .deps/genimage-config.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-util.o -MD -MP -MF .deps/genimage-util.Tpo -c -o genimage-util.o `test -f 'util.c' || echo './'`util.c
mv -f .deps/genimage-util.Tpo .deps/genimage-util.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-crc32.o -MD -MP -MF .deps/genimage-crc32.Tpo -c -o genimage-crc32.o `test -f 'crc32.c' || echo './'`crc32.c
mv -f .deps/genimage-crc32.Tpo .deps/genimage-crc32.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-android-sparse.o -MD -MP -MF .deps/genimage-image-android-sparse.Tpo -c -o genimage-image-android-sparse.o `test -f 'image-android-sparse.c' || echo './'`image-android-sparse.c
mv -f .deps/genimage-image-android-sparse.Tpo .deps/genimage-image-android-sparse.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-cpio.o -MD -MP -MF .deps/genimage-image-cpio.Tpo -c -o genimage-image-cpio.o `test -f 'image-cpio.c' || echo './'`image-cpio.c
mv -f .deps/genimage-image-cpio.Tpo .deps/genimage-image-cpio.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-cramfs.o -MD -MP -MF .deps/genimage-image-cramfs.Tpo -c -o genimage-image-cramfs.o `test -f 'image-cramfs.c' || echo './'`image-cramfs.c
mv -f .deps/genimage-image-cramfs.Tpo .deps/genimage-image-cramfs.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-ext2.o -MD -MP -MF .deps/genimage-image-ext2.Tpo -c -o genimage-image-ext2.o `test -f 'image-ext2.c' || echo './'`image-ext2.c
mv -f .deps/genimage-image-ext2.Tpo .deps/genimage-image-ext2.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-file.o -MD -MP -MF .deps/genimage-image-file.Tpo -c -o genimage-image-file.o `test -f 'image-file.c' || echo './'`image-file.c
mv -f .deps/genimage-image-file.Tpo .deps/genimage-image-file.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-fit.o -MD -MP -MF .deps/genimage-image-fit.Tpo -c -o genimage-image-fit.o `test -f 'image-fit.c' || echo './'`image-fit.c
mv -f .deps/genimage-image-fit.Tpo .deps/genimage-image-fit.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-flash.o -MD -MP -MF .deps/genimage-image-flash.Tpo -c -o genimage-image-flash.o `test -f 'image-flash.c' || echo './'`image-flash.c
mv -f .deps/genimage-image-flash.Tpo .deps/genimage-image-flash.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-hd.o -MD -MP -MF .deps/genimage-image-hd.Tpo -c -o genimage-image-hd.o `test -f 'image-hd.c' || echo './'`image-hd.c
mv -f .deps/genimage-image-hd.Tpo .deps/genimage-image-hd.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-iso.o -MD -MP -MF .deps/genimage-image-iso.Tpo -c -o genimage-image-iso.o `test -f 'image-iso.c' || echo './'`image-iso.c
mv -f .deps/genimage-image-iso.Tpo .deps/genimage-image-iso.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-jffs2.o -MD -MP -MF .deps/genimage-image-jffs2.Tpo -c -o genimage-image-jffs2.o `test -f 'image-jffs2.c' || echo './'`image-jffs2.c
mv -f .deps/genimage-image-jffs2.Tpo .deps/genimage-image-jffs2.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-qemu.o -MD -MP -MF .deps/genimage-image-qemu.Tpo -c -o genimage-image-qemu.o `test -f 'image-qemu.c' || echo './'`image-qemu.c
mv -f .deps/genimage-image-qemu.Tpo .deps/genimage-image-qemu.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-rauc.o -MD -MP -MF .deps/genimage-image-rauc.Tpo -c -o genimage-image-rauc.o `test -f 'image-rauc.c' || echo './'`image-rauc.c
mv -f .deps/genimage-image-rauc.Tpo .deps/genimage-image-rauc.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-squashfs.o -MD -MP -MF .deps/genimage-image-squashfs.Tpo -c -o genimage-image-squashfs.o `test -f 'image-squashfs.c' || echo './'`image-squashfs.c
mv -f .deps/genimage-image-squashfs.Tpo .deps/genimage-image-squashfs.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-tar.o -MD -MP -MF .deps/genimage-image-tar.Tpo -c -o genimage-image-tar.o `test -f 'image-tar.c' || echo './'`image-tar.c
mv -f .deps/genimage-image-tar.Tpo .deps/genimage-image-tar.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-ubi.o -MD -MP -MF .deps/genimage-image-ubi.Tpo -c -o genimage-image-ubi.o `test -f 'image-ubi.c' || echo './'`image-ubi.c
mv -f .deps/genimage-image-ubi.Tpo .deps/genimage-image-ubi.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-ubifs.o -MD -MP -MF .deps/genimage-image-ubifs.Tpo -c -o genimage-image-ubifs.o `test -f 'image-ubifs.c' || echo './'`image-ubifs.c
mv -f .deps/genimage-image-ubifs.Tpo .deps/genimage-image-ubifs.Po
gcc -DHAVE_CONFIG_H -I.  -include ./config.h  -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0 -MT genimage-image-vfat.o -MD -MP -MF .deps/genimage-image-vfat.Tpo -c -o genimage-image-vfat.o `test -f 'image-vfat.c' || echo './'`image-vfat.c
mv -f .deps/genimage-image-vfat.Tpo .deps/genimage-image-vfat.Po
gcc -pipe -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsign-compare -Wchar-subscripts -Wstrict-prototypes -Wshadow -Wformat-security -Wtype-limits -Wno-unused-parameter -ffunction-sections -fdata-sections -fvisibility=hidden  -g -O0   -o genimage genimage-genimage.o genimage-config.o genimage-util.o genimage-crc32.o genimage-image-android-sparse.o genimage-image-cpio.o genimage-image-cramfs.o genimage-image-ext2.o genimage-image-file.o genimage-image-fit.o genimage-image-flash.o genimage-image-hd.o genimage-image-iso.o genimage-image-jffs2.o genimage-image-qemu.o genimage-image-rauc.o genimage-image-squashfs.o genimage-image-tar.o genimage-image-ubi.o genimage-image-ubifs.o genimage-image-vfat.o -lconfuse

mke2fs -V

mke2fs 1.46.2 (28-Feb-2021)
  Using EXT2FS Library version 1.46.2

make V=1 check

make --no-print-directory check-TESTS
PASS: test/basic-images.test 1 - cpio
SKIP: test/basic-images.test 2 # SKIP cramfs (missing mkcramfs)
SKIP: test/basic-images.test 3 # SKIP ext2 (missing genext2fs of genext2fs,e2fsck)
SKIP: test/basic-images.test 4 # SKIP ext2percent (missing genext2fs of genext2fs,e2fsck)
SKIP: test/basic-images.test 5 # SKIP ext3 (missing genext2fs of genext2fs,e2fsck)
SKIP: test/basic-images.test 6 # SKIP ext4 (missing genext2fs of genext2fs,e2fsck)
FAIL: test/basic-images.test 7 - mke2fs
PASS: test/basic-images.test 8 - flash
PASS: test/basic-images.test 9 - hdimage
PASS: test/basic-images.test 10 - hdimage2
PASS: test/basic-images.test 11 - hdimage4
PASS: test/basic-images.test 12 - hdimage5
PASS: test/basic-images.test 13 - iso
SKIP: test/basic-images.test 14 # SKIP jffs2 (missing mkfs_jffs2)
SKIP: test/basic-images.test 15 # SKIP qemu (missing qemu-img of dd,diff,qemu-img)
PASS: test/basic-images.test 16 - squashfs
PASS: test/basic-images.test 17 - tar
SKIP: test/basic-images.test 18 # SKIP ubifs (missing mkfs_ubifs)
SKIP: test/basic-images.test 19 # SKIP ubi (missing ubinize)
PASS: test/basic-images.test 20 - vfat
SKIP: test/basic-images.test 21 # SKIP fit (missing dtc,mkimage of mkimage,dtc)
SKIP: test/basic-images.test 22 # SKIP rauc (missing rauc)
SKIP: test/basic-images.test 23 # SKIP android-sparse (missing simg2img)
PASS: test/basic-images.test 24 - exec
PASS: test/basic-images.test 25 - exec-fail
ERROR: test/basic-images.test - exited with status 1
============================================================================
Testsuite summary for genimage 14
============================================================================
# TOTAL: 26
# PASS:  12
# SKIP:  12
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 1
============================================================================
See ./test-suite.log
Please report to [email protected]
============================================================================
make[2]: *** [Makefile:1148: test-suite.log] Error 1
make[1]: *** [Makefile:1256: check-TESTS] Error 2
make: *** [Makefile:1460: check-am] Error 2

test-suite.log

board/ci20/genimage.cfg:29: no sub-section title/index for 'config'

INFO: cmd: "mkdir -p "/home/nirajtummala/buildroot/output/build/genimage.tmp"" (stderr):
INFO: cmd: "rm -rf "/home/nirajtummala/buildroot/output/build/genimage.tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/home/nirajtummala/buildroot/output/build/genimage.tmp"" (stderr):
INFO: cmd: "cp -a "/tmp/tmp.tU65pvVkfR" "/home/nirajtummala/buildroot/output/build/genimage.tmp/root"" (stderr):
INFO: cmd: "find '/home/nirajtummala/buildroot/output/build/genimage.tmp/root' -depth -type d -printf '%P\0' | xargs -0 -I {} touch -r '/tmp/tmp.tU65pvVkfR/{}' '/home/nirajtummala/buildroot/output/build/genimage.tmp/root/{}'" (stderr):
INFO: cmd: "mkdir -p "/home/nirajtummala/buildroot/output/images"" (stderr):
INFO: hdimage(sdcard.img): adding partition 'uboot-spl' from 'u-boot-spl.bin' ...
INFO: hdimage(sdcard.img): adding partition 'uboot' from 'u-boot.img' ...
INFO: hdimage(sdcard.img): adding partition 'uboot-env' from 'uboot-env.bin' ...
INFO: hdimage(sdcard.img): adding partition 'rootfs' (in MBR) from 'rootfs.ext4' ...
INFO: hdimage(sdcard.img): writing MBR

Usage example for existing partition image + second partition contents

Maybe I'm missing something, but it's not clear to me how to use genimage in cases in which the image file for one partition is given and the image for a second partition should be created by genimage. In my case, I have an image file (rootfs.ext2) containing the ext3 file system for / (generated by Buildroot), and a directory containing the files that should go into /home in a separate partition.

From the documentation and examples I have read so far, I imagine it should look similar to this:

image compactflash.img {
  hdimage {
  }

  partition root {
    partition-type = 0x83
    bootable = true
    # An existing image of the partition's file system.
    image = "rootfs.ext2"
  }

  partition home {
    partition-type = 0x83
    image = "home.ext3"
    size = 1500M
  }
}

image home.ext3 {
  ext3 {
    label = "home"
  }

  name = "home"
  size = 1500M
  mountpoint = "/home"
}

Is this the proper way to do it? I understand mountpoint is relative to the configured rootpath. Where does genimage expect the file rootfs.ext2, though?

Regression in PR #102

PR #102 causes a regression in image-flash.c

Problem is that pad_file behaves differently depending on whether it is called with infile == NULL or infile != NULL.

If called with infile == NULL size is assumed to be an absolute offset in the output file.
Else size is assumed to be the size of infile + padding.

Since https://github.com/pengutronix/genimage/pull/102/files#diff-088cb03e9ae7e9e2f4755d4ccf535699L63 handles those cases the same, output images are no longer created correctly.

Unfortunately I did not discover this during testing because none of my testcases had an empty partition that was preceded by another partition.

#103 contains a suggestion on how to fix the regression

add glob support

For instance, this will allow us to build images using one generic config:

image boot.vfat {
        vfat {
                files = {
                        "zImage",
                        "*.dtb",
                        "boot.scr"
                }
        }
        size = 6M
}

Also if none *.dtb were found, that should be not an error.

"size = 0" gives error "hdimage(sdcard.img) part data size must not be zero"

I'm trying to create an empty FAT partition in the remaining space on an SD card.

My config file:

image boot.vfat {
  vfat {
    files = {
      "bcm2708-rpi-b-plus.dtb",
      "bcm2708-rpi-0-w.dtb",
      "rpi-firmware/bootcode.bin",
      "rpi-firmware/cmdline.txt",
      "rpi-firmware/config.txt",
      "rpi-firmware/fixup.dat",
      "rpi-firmware/start.elf",
      "zImage"
    }

    file overlays/hifiberry-dac.dtbo {
      image = "rpi-firmware/overlays/hifiberry-dac.dtbo"
    }

  }
  size = 32M
}

image sdcard.img {
  hdimage {
  }

  partition boot {
    partition-type = 0xC
    bootable = "true"
    image = "boot.vfat"
  }

  partition rootfs {
    partition-type = 0x83
    image = "rootfs.ext4"
  }

  partition data {
    partition-type = 0xC
    size = 0
  }

}

I cannot get it to accept 0 in order to use up the remaining space, giving me the error:
hdimage(sdcard.img) part data size must not be zero

I am creating this using Buildroot on an 8GB SD card, with the rootfs set to 1GB in the buildroot config.

Syntax error on configure

When I try to compile genimage on my Ubuntu 16.04 LTS with libconfuse-dev installed, I get this:

$ ./autogen.sh
configure.ac:78: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2662: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2679: AC_LINK_IFELSE is expanded from...
../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from...
../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from...
../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from...
m4/attributes.m4:87: CC_CHECK_LDFLAGS is expanded from...
configure.ac:78: the top level
configure.ac:79: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2662: _AC_LINK_IFELSE is expanded from.
........
configure.ac:79: the top level
configure.ac:9: installing `build-aux/install-sh'
configure.ac:9: installing `build-aux/missing'
Makefile.am: installing `build-aux/depcomp'

----------------------------------------------------------------
Initialized build system. For a common configuration please run:
----------------------------------------------------------------

./configure CFLAGS='-g -O0' --prefix=/usr

root@a2be79f92dca:/buildpid/genimage/genimage-master# ./configure CFLAGS='-g -O0' --prefix=/usr
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
.......
checking whether to enable debugging... no
checking whether to hide internal symbols... yes
checking if gcc -std=gnu99 supports -Wl,--as-needed flag... yes
checking if gcc -std=gnu99 supports -Wl,--gc-sections flag... yes
./configure: line 5531: syntax error near unexpected token `CONFUSE,'
./configure: line 5531: `PKG_CHECK_MODULES(CONFUSE, libconfuse)'
$ 

This is with autoconf 2.68

Is there something I'm missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.