summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-partition.py79
1 files changed, 47 insertions, 32 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py
index 7d61595d04..2e9b9f5ed6 100644
--- a/scripts/lib/wic/plugins/source/bootimg-partition.py
+++ b/scripts/lib/wic/plugins/source/bootimg-partition.py
@@ -30,6 +30,7 @@ import re
30from glob import glob 30from glob import glob
31 31
32from wic import WicError 32from wic import WicError
33from wic.engine import get_custom_config
33from wic.pluginbase import SourcePlugin 34from wic.pluginbase import SourcePlugin
34from wic.misc import exec_cmd, get_bitbake_var 35from wic.misc import exec_cmd, get_bitbake_var
35 36
@@ -114,38 +115,52 @@ class BootimgPartitionPlugin(SourcePlugin):
114 if source_params.get('loader') != "u-boot": 115 if source_params.get('loader') != "u-boot":
115 return 116 return
116 117
117 # The kernel types supported by the sysboot of u-boot 118 configfile = cr.ks.bootloader.configfile
118 kernel_types = ["uImage", "zImage", "Image", "vmlinux", "fitImage"] 119 custom_cfg = None
119 has_dtb = False 120 if configfile:
120 fdt_dir = '/' 121 custom_cfg = get_custom_config(configfile)
121 kernel_name = None 122 if custom_cfg:
122 for task in cls.install_task: 123 # Use a custom configuration for extlinux.conf
123 src, dst = task 124 extlinux_conf = custom_cfg
124 # Find the kernel image name 125 logger.debug("Using custom configuration file "
125 for image in kernel_types: 126 "%s for extlinux.cfg", configfile)
126 if re.match(image, src): 127 else:
127 if not kernel_name: 128 raise WicError("configfile is specified but failed to "
128 kernel_name = os.path.join('/', dst) 129 "get it from %s." % configfile)
129 else: 130
130 raise WicError('Multi kernel file founded') 131 if not custom_cfg:
131 132 # The kernel types supported by the sysboot of u-boot
132 # We suppose that all the dtb are in the same directory 133 kernel_types = ["uImage", "zImage", "Image", "vmlinux", "fitImage"]
133 if re.search(r'\.dtb', src) and fdt_dir == '/': 134 has_dtb = False
134 has_dtb = True 135 fdt_dir = '/'
135 fdt_dir = os.path.join(fdt_dir, os.path.dirname(dst)) 136 kernel_name = None
136 137 for task in cls.install_task:
137 if not kernel_name: 138 src, dst = task
138 raise WicError('No kernel file founded') 139 # Find the kernel image name
139 140 for image in kernel_types:
140 # Compose the extlinux.conf 141 if re.match(image, src):
141 extlinux_conf = "default Yocto\n" 142 if not kernel_name:
142 extlinux_conf += "label Yocto\n" 143 kernel_name = os.path.join('/', dst)
143 extlinux_conf += " kernel %s\n" % kernel_name 144 else:
144 if has_dtb: 145 raise WicError('Multi kernel file founded')
145 extlinux_conf += " fdtdir %s\n" % fdt_dir 146
146 bootloader = cr.ks.bootloader 147 # We suppose that all the dtb are in the same directory
147 extlinux_conf += "append root=%s rootwait %s\n" \ 148 if re.search(r'\.dtb', src) and fdt_dir == '/':
148 % (cr.rootdev, bootloader.append if bootloader.append else '') 149 has_dtb = True
150 fdt_dir = os.path.join(fdt_dir, os.path.dirname(dst))
151
152 if not kernel_name:
153 raise WicError('No kernel file founded')
154
155 # Compose the extlinux.conf
156 extlinux_conf = "default Yocto\n"
157 extlinux_conf += "label Yocto\n"
158 extlinux_conf += " kernel %s\n" % kernel_name
159 if has_dtb:
160 extlinux_conf += " fdtdir %s\n" % fdt_dir
161 bootloader = cr.ks.bootloader
162 extlinux_conf += "append root=%s rootwait %s\n" \
163 % (cr.rootdev, bootloader.append if bootloader.append else '')
149 164
150 install_cmd = "install -d %s/extlinux/" % hdddir 165 install_cmd = "install -d %s/extlinux/" % hdddir
151 exec_cmd(install_cmd) 166 exec_cmd(install_cmd)