Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image size in % does not work #227

Open
Zlika opened this issue Oct 18, 2023 · 3 comments
Open

Image size in % does not work #227

Zlika opened this issue Oct 18, 2023 · 3 comments

Comments

@Zlika
Copy link

Zlika commented Oct 18, 2023

Hello,
I'm using genimage 15 (through buildroot 2022.02.8) and specifying an image size in % does not seem to work.
My configuration file is:

image boot.vfat {
	vfat {
		files = {
			"zImage",
			"socfpga_cyclone5_de10_standard.dtb"
		}
		file extlinux/extlinux.conf {
			image = "extlinux.conf"
		}
	}

	size = 20M
}

image sdcard.img {
	hdimage {
	}

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

	partition uboot {
		partition-type = 0xa2
		image = "u-boot-with-spl.sfp"
	}
}

This config file works, but if I replace the "size = 20M" with a percent value (e.g. "size=120%" or even "size=200%") I always have the following error message:
mkdosfs: Attempting to create a too small or too large filesystem.

Here is the full log with --loglevel=3:

>>>   Executing post-image script support/scripts/genimage.sh
INFO: cmd: "mkdir -p "/home/thomas/git/buildroot/output/build/genimage.tmp"" (stderr+stdout):
INFO: cmd: "rm -rf "/home/thomas/git/buildroot/output/build/genimage.tmp"/*" (stderr+stdout):
DEBUG: vfat(boot.vfat): adding implicit file rule for 'extlinux.conf'
DEBUG: vfat(boot.vfat): adding implicit file rule for 'zImage'
DEBUG: vfat(boot.vfat): adding implicit file rule for 'socfpga_cyclone5_de10_standard.dtb'
DEBUG: hdimage(sdcard.img): adding implicit file rule for 'u-boot-with-spl.sfp'
INFO: cmd: "mkdir -p "/home/thomas/git/buildroot/output/build/genimage.tmp"" (stderr+stdout):
INFO: cmd: "cp -a "/tmp/tmp.sOOkd31ndS" "/home/thomas/git/buildroot/output/build/genimage.tmp/root"" (stderr+stdout):
INFO: cmd: "find '/home/thomas/git/buildroot/output/build/genimage.tmp/root' -depth -type d -printf '%P\0' | xargs -0 -I {} touch -r '/tmp/tmp.sOOkd31ndS/{}' '/home/thomas/git/buildroot/output/build/genimage.tmp/root/{}'" (stderr+stdout):
INFO: cmd: "mkdir -p "/home/thomas/git/buildroot/output/images"" (stderr+stdout):
INFO: vfat(boot.vfat): cmd: "dd if=/dev/zero of="/home/thomas/git/buildroot/output/images/boot.vfat" seek=6144 count=0 bs=1 2>/dev/null" (stderr+stdout):
INFO: vfat(boot.vfat): cmd: "mkdosfs   '/home/thomas/git/buildroot/output/images/boot.vfat'" (stderr+stdout):
mkfs.fat 4.2 (2021-01-31)
mkdosfs: Attempting to create a too small or a too large filesystem
INFO: vfat(boot.vfat): cmd: "rm -f "/home/thomas/git/buildroot/output/images/boot.vfat"" (stderr+stdout):
ERROR: vfat(boot.vfat): failed to generate boot.vfat
@michaelolbrich
Copy link
Member

Ah, I see the issue. For vfat images there are two ways to provide content:

  1. The rootpath / mountpount stuff also used by other filesystems
  2. The special file / files properties

The automatic size calculation only takes the rootpath into account.

@Zlika
Copy link
Author

Zlika commented Oct 18, 2023

Ok, thanks for your quick answer. Is it a possible future improvement to make it work on this use case?

@michaelolbrich
Copy link
Member

Certainly. But I'm not sure when I'll find the time to do that. The fastest way would be to implement it yourself and open a pull request. Basically you need to modify vfat_setup() and there

if (image->size_is_percent) {
    for all  extra files
        image->size += file size
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants