summaryrefslogtreecommitdiffstats
path: root/scripts
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:58 +0100
commitbce531d503c1f7944671021704e39bcd13d67790 (patch)
treebeed545fa5f2f5106195fc53f89a8d5c7444480b /scripts
parentcb78ff423ee89835c55c0e33be840503be861fe5 (diff)
downloadpoky-bce531d503c1f7944671021704e39bcd13d67790.tar.gz
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. (From OE-Core rev: bdf8ae540af12ecc9ad60efd3651b0f71d12d3bd) Signed-off-by: Kevin Hao <kexin.hao@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-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):
48 oe_builddir, bootimg_dir, kernel_dir, 48 oe_builddir, bootimg_dir, kernel_dir,
49 native_sysroot): 49 native_sysroot):
50 """ 50 """
51 Called before do_prepare_partition() 51 Called before do_prepare_partition(), create u-boot specific boot config
52 """ 52 """
53 hdddir = "%s/boot.%d" % (cr_workdir, part.lineno)
54 install_cmd = "install -d %s" % hdddir
55 exec_cmd(install_cmd)
56
53 if not kernel_dir: 57 if not kernel_dir:
54 kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 58 kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
55 if not kernel_dir: 59 if not kernel_dir:
@@ -107,6 +111,49 @@ class BootimgPartitionPlugin(SourcePlugin):
107 else: 111 else:
108 cls.install_task.append((src, dst)) 112 cls.install_task.append((src, dst))
109 113
114 if source_params.get('loader') != "u-boot":
115 return
116
117 # The kernel types supported by the sysboot of u-boot
118 kernel_types = ["uImage", "zImage", "Image", "vmlinux", "fitImage"]
119 has_dtb = False
120 fdt_dir = '/'
121 kernel_name = None
122 for task in cls.install_task:
123 src, dst = task
124 # Find the kernel image name
125 for image in kernel_types:
126 if re.match(image, src):
127 if not kernel_name:
128 kernel_name = os.path.join('/', dst)
129 else:
130 raise WicError('Multi kernel file founded')
131
132 # We suppose that all the dtb are in the same directory
133 if re.search(r'\.dtb', src) and fdt_dir == '/':
134 has_dtb = True
135 fdt_dir = os.path.join(fdt_dir, os.path.dirname(dst))
136
137 if not kernel_name:
138 raise WicError('No kernel file founded')
139
140 # Compose the extlinux.conf
141 extlinux_conf = "default Yocto\n"
142 extlinux_conf += "label Yocto\n"
143 extlinux_conf += " kernel %s\n" % kernel_name
144 if has_dtb:
145 extlinux_conf += " fdtdir %s\n" % fdt_dir
146 bootloader = cr.ks.bootloader
147 extlinux_conf += "append root=%s rootwait %s\n" \
148 % (cr.rootdev, bootloader.append if bootloader.append else '')
149
150 install_cmd = "install -d %s/extlinux/" % hdddir
151 exec_cmd(install_cmd)
152 cfg = open("%s/extlinux/extlinux.conf" % hdddir, "w")
153 cfg.write(extlinux_conf)
154 cfg.close()
155
156
110 @classmethod 157 @classmethod
111 def do_prepare_partition(cls, part, source_params, cr, cr_workdir, 158 def do_prepare_partition(cls, part, source_params, cr, cr_workdir,
112 oe_builddir, bootimg_dir, kernel_dir, 159 oe_builddir, bootimg_dir, kernel_dir,
@@ -119,8 +166,6 @@ class BootimgPartitionPlugin(SourcePlugin):
119 - copies all files listed in IMAGE_BOOT_FILES variable 166 - copies all files listed in IMAGE_BOOT_FILES variable
120 """ 167 """
121 hdddir = "%s/boot.%d" % (cr_workdir, part.lineno) 168 hdddir = "%s/boot.%d" % (cr_workdir, part.lineno)
122 install_cmd = "install -d %s" % hdddir
123 exec_cmd(install_cmd)
124 169
125 if not kernel_dir: 170 if not kernel_dir:
126 kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") 171 kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")