您当前的位置:首页 > 计算机 > 系统应用 > Linux

genimage 打包镜像

时间:11-21来源:作者:点击数:
城东书院 www.cdsy.xyz

前言

buildroot 使用 genimage 工具打包镜像

工作原理

用户准备好待打包的原料:uboot.bin、zImage、rootfs 等,然后编写一个配置文件 genimage.cfg,描述如何进行打包,然后执行命令 genimage -c genimage.cfg 就可以打包好一个镜像。

实例分析

原料:

liyongjun@Box:~/project/board/buildroot/LCzero/images_lyj$ ls
boot.scr  genimage.cfg  rootfs.ext2  rootfs.ext4  sun8i-v3s-licheepi-zero-dock.dtb  sun8i-v3s-licheepi-zero.dtb  u-boot-sunxi-with-spl.bin  zImage

genimage.cfg

image boot.vfat {
	vfat {
		files = {
			"zImage",
			"sun8i-v3s-licheepi-zero-dock.dtb",
			"sun8i-v3s-licheepi-zero.dtb",
			"boot.scr"
		}
	}

	size = 8M
}

image sdcard.img {
	hdimage {
	}

	partition u-boot {
		in-partition-table = "no"
		image = "u-boot-sunxi-with-spl.bin"
		offset = 8K
		size = 504K # 512KB - 8KB
	}

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

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

生成:

liyongjun@Box:~/project/board/buildroot/LCzero/images_lyj$ ../host/bin/genimage --rootpath /tmp/tmp.fdst8UdlaK --tmppath /home/liyongjun/project/board/buildroot/DIY_V3S/images_lyj/genimage.tmp --inputpath ./  --outputpath ./ --config genimage.cfg
INFO: cmd: "rm -rf "/home/liyongjun/project/board/buildroot/DIY_V3S/images_lyj/genimage.tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/home/liyongjun/project/board/buildroot/DIY_V3S/images_lyj/genimage.tmp"" (stderr):
INFO: cmd: "cp -a "/tmp/tmp.fdst8UdlaK" "/home/liyongjun/project/board/buildroot/DIY_V3S/images_lyj/genimage.tmp/root"" (stderr):
INFO: cmd: "mkdir -p "/home/liyongjun/project/board/buildroot/LCzero/images_lyj/./"" (stderr):
INFO: vfat(boot.vfat): cmd: "mkdosfs   '/home/liyongjun/project/board/buildroot/LCzero/images_lyj/.//boot.vfat'" (stderr):
INFO: vfat(boot.vfat): adding file 'zImage' as 'zImage' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -sp -i '/home/liyongjun/project/board/buildroot/LCzero/images_lyj/.//boot.vfat' '/home/liyongjun/project/board/buildroot/LCzero/images_lyj/.//zImage' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'sun8i-v3s-licheepi-zero-dock.dtb' as 'sun8i-v3s-licheepi-zero-dock.dtb' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -sp -i '/home/liyongjun/project/board/buildroot/LCzero/images_lyj/.//boot.vfat' '/home/liyongjun/project/board/buildroot/LCzero/images_lyj/.//sun8i-v3s-licheepi-zero-dock.dtb' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'sun8i-v3s-licheepi-zero.dtb' as 'sun8i-v3s-licheepi-zero.dtb' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -sp -i '/home/liyongjun/project/board/buildroot/LCzero/images_lyj/.//boot.vfat' '/home/liyongjun/project/board/buildroot/LCzero/images_lyj/.//sun8i-v3s-licheepi-zero.dtb' '::'" (stderr):
INFO: vfat(boot.vfat): adding file 'boot.scr' as 'boot.scr' ...
INFO: vfat(boot.vfat): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -sp -i '/home/liyongjun/project/board/buildroot/LCzero/images_lyj/.//boot.vfat' '/home/liyongjun/project/board/buildroot/LCzero/images_lyj/.//boot.scr' '::'" (stderr):
INFO: hdimage(sdcard.img): adding partition 'u-boot' from 'u-boot-sunxi-with-spl.bin' ...
INFO: hdimage(sdcard.img): adding partition 'boot' (in MBR) from 'boot.vfat' ...
INFO: hdimage(sdcard.img): adding partition 'rootfs' (in MBR) from 'rootfs.ext4' ...
INFO: hdimage(sdcard.img): adding partition '[MBR]' ...
INFO: hdimage(sdcard.img): writing MBR
INFO: cmd: "rm -rf "/home/liyongjun/project/board/buildroot/DIY_V3S/images_lyj/genimage.tmp"/*" (stderr):

liyongjun@Box:~/project/board/buildroot/LCzero/images_lyj$ ls
boot.scr   genimage.cfg  rootfs.ext4  sun8i-v3s-licheepi-zero-dock.dtb  u-boot-sunxi-with-spl.bin
boot.vfat  rootfs.ext2   sdcard.img   sun8i-v3s-licheepi-zero.dtb       zImage

生成了 sdcard.img

城东书院 www.cdsy.xyz
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐