summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Hao <kexin.hao@windriver.com>2018-08-14 09:31:24 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-15 21:45:10 +0100
commitbdf8ae540af12ecc9ad60efd3651b0f71d12d3bd (patch)
tree164004351479975356cbc78fd7715bfc7afe818b
parent3203037471c761f635d1f1c512cb623ff6977a41 (diff)
downloadopenembedded-core-contrib-bdf8ae540af12ecc9ad60efd3651b0f71d12d3bd.tar.gz
openembedded-core-contrib-bdf8ae540af12ecc9ad60efd3651b0f71d12d3bd.tar.bz2
openembedded-core-contrib-bdf8ae540af12ecc9ad60efd3651b0f71d12d3bd.zip
wic: bootimg-partition: Add support to create the u-boot boot config file
By leveraging the distro boot command feature in the u-boot, we can compose the corresponding extlinux.conf when creating the wic image, and let u-boot boot the kernel automatically. For more detail about the u-boot distro boot command feature, please see doc/README.distro in u-boot source files. Signed-off-by: Kevin Hao <kexin.hao@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-partition.py51
1 files changed, 48 insertions, 3 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py
index 364b189758..7d61595d04 100644
--- a/scripts/lib/wic/plugins/source/bootimg-partition.py
+++ b/scripts/lib/wic/plugins/source/bootimg-partition.py
@@ -48,8 +48,12 @@ class BootimgPartitionPlugin(SourcePlugin):
oe_builddir, bootimg_dir, kernel_dir,
native_sysroot):
"""
- Called before do_prepare_partition()
+ Called before do_prepare_partition(), create u-boot specific boot config
"""
+ hdddir = "%s/boot.%d" % (cr_workdir, part.lineno)
+ install_cmd = "install -d %s" % hdddir
+ exec_cmd(install_cmd)
+
if not kernel_dir:
kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
if not kernel_dir:
@@ -107,6 +111,49 @@ class BootimgPartitionPlugin(SourcePlugin):
else:
cls.install_task.append((src, dst))
+ if source_params.get('loader') != "u-boot":
+ return
+
+ # The kernel types supported by the sysboot of u-boot
+ kernel_types = ["uImage", "zImage", "Image", "vmlinux", "fitImage"]
+ has_dtb = False
+ fdt_dir = '/'
+ kernel_name = None
+ for task in cls.install_task:
+ src, dst = task
+ # Find the kernel image name
+ for image in kernel_types:
+ if re.match(image, src):
+ if not kernel_name:
+ kernel_name = os.path.join('/', dst)
+ else:
+ raise WicError('Multi kernel file founded')
+
+ # We suppose that all the dtb are in the same directory
+ if re.search(r'\.dtb', src) and fdt_dir == '/':
+ has_dtb = True
+ fdt_dir = os.path.join(fdt_dir, os.path.dirname(dst))
+
+ if not kernel_name:
+ raise WicError('No kernel file founded')
+
+ # Compose the extlinux.conf
+ extlinux_conf = "default Yocto\n"
+ extlinux_conf += "label Yocto\n"
+ extlinux_conf += " kernel %s\n" % kernel_name
+ if has_dtb:
+ extlinux_conf += " fdtdir %s\n" % fdt_dir
+ bootloader = cr.ks.bootloader
+ extlinux_conf += "append root=%s rootwait %s\n" \
+ % (cr.rootdev, bootloader.append if bootloader.append else '')
+
+ install_cmd = "install -d %s/extlinux/" % hdddir
+ exec_cmd(install_cmd)
+ cfg = open("%s/extlinux/extlinux.conf" % hdddir, "w")
+ cfg.write(extlinux_conf)
+ cfg.close()
+
+
@classmethod
def do_prepare_partition(cls, part, source_params, cr, cr_workdir,
oe_builddir, bootimg_dir, kernel_dir,
@@ -119,8 +166,6 @@ class BootimgPartitionPlugin(SourcePlugin):
- copies all files listed in IMAGE_BOOT_FILES variable
"""
hdddir = "%s/boot.%d" % (cr_workdir, part.lineno)
- install_cmd = "install -d %s" % hdddir
- exec_cmd(install_cmd)
if not kernel_dir:
kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")