1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
QIMG_DEPLOYDIR = "${WORKDIR}/qcom_deploy-${PN}"
python do_qcom_img_deploy() {
import shutil
import subprocess
subdir = d.getVar("KERNEL_DEPLOYSUBDIR")
if subdir is not None:
qcom_deploy_dir = os.path.join(d.getVar("QIMG_DEPLOYDIR"), subdir)
image_dir = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), subdir)
else:
qcom_deploy_dir = d.getVar("QIMG_DEPLOYDIR")
image_dir = d.getVar("DEPLOY_DIR_IMAGE")
B = d.getVar("B")
D = d.getVar("D")
kernel_output_dir = d.getVar("KERNEL_OUTPUT_DIR")
kernel_imagedest = d.getVar("KERNEL_IMAGEDEST")
kernel = os.path.join(B, "kernel-dtb")
definitrd = os.path.join(B, "initrd.img")
mkbootimg = os.path.join(d.getVar("STAGING_BINDIR_NATIVE"), "skales", "mkbootimg")
kernel_image_name = d.getVar("KERNEL_IMAGE_NAME")
kernel_link_name = d.getVar("KERNEL_IMAGE_LINK_NAME")
output_img = os.path.join(qcom_deploy_dir, "boot-%s.img" % (kernel_link_name))
output_sd_img = os.path.join(qcom_deploy_dir, "boot-sd-%s.img" % (kernel_link_name))
arch = d.getVar("ARCH")
if arch is "arm":
kernel_name = "zImage"
elif arch is "arm64":
kernel_name = "Image.gz"
else:
bb.fatal("Unuspported ARCH %s" % arch)
if os.path.exists(output_img):
os.unlink(output_img)
if os.path.exists(output_sd_img):
os.unlink(output_sd_img)
with open(definitrd, "w") as f:
f.write("This is not an initrd\n")
for dtbf in d.getVar("KERNEL_DEVICETREE").split():
dtb = os.path.basename(dtbf)
dtb_name = dtb.rsplit('.', 1)[0]
def getVarDTB(name):
return d.getVarFlag(name, dtb_name) or d.getVar(name)
def make_image(template, rootfs):
output = os.path.join(qcom_deploy_dir, template % (dtb_name, kernel_image_name))
output_link = os.path.join(qcom_deploy_dir, template % (dtb_name, kernel_link_name))
subprocess.check_call([mkbootimg,
"--kernel", kernel,
"--ramdisk", definitrd,
"--output", output,
"--pagesize", getVarDTB("QCOM_BOOTIMG_PAGE_SIZE"),
"--base", getVarDTB("QCOM_BOOTIMG_KERNEL_BASE"),
"--cmdline", "root=%s rw rootwait %s %s" % (rootfs, consoles, getVarDTB("KERNEL_CMDLINE_EXTRA") or "")])
if os.path.exists(output_link):
os.unlink(output_link)
os.symlink(os.path.basename(output), output_link)
return output
consoles = ' '.join(map(lambda c: "console=%(tty)s,%(rate)sn8" % dict(zip(("rate", "tty"), c.split(';'))), getVarDTB("SERIAL_CONSOLES").split()))
# prepare kernel image with appended dtb
with open(kernel, 'wb') as wfd:
with open(os.path.join(kernel_output_dir, kernel_name), 'rb') as rfd:
shutil.copyfileobj(rfd, wfd)
with open(os.path.join(D, kernel_imagedest, dtb), 'rb') as rfd:
shutil.copyfileobj(rfd, wfd)
rootfs = getVarDTB("QCOM_BOOTIMG_ROOTFS")
if not rootfs or rootfs is "":
bb.fatal("QCOM_BOOTIMG_ROOTFS is undefined")
output = make_image("boot-%s-%s.img", rootfs)
if not os.path.exists(output_img):
os.symlink(os.path.basename(output), output_img)
sd_rootfs = getVarDTB("SD_QCOM_BOOTIMG_ROOTFS")
if sd_rootfs:
output = make_image("boot-sd-%s-%s.img", sd_rootfs)
if not os.path.exists(output_sd_img):
os.symlink(os.path.basename(output), output_sd_img)
}
do_qcom_img_deploy[depends] += "skales-native:do_populate_sysroot"
addtask qcom_img_deploy after do_populate_sysroot do_packagedata bundle_initramfs before do_deploy
# Setup sstate, see deploy.bbclass
SSTATETASKS += "do_qcom_img_deploy"
do_qcom_img_deploy[sstate-inputdirs] = "${QIMG_DEPLOYDIR}"
do_qcom_img_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
python do_qcom_img_deploy_setscene () {
sstate_setscene(d)
}
addtask do_qcom_img_deploy_setscene
do_qcom_img_deploy[dirs] = "${QIMG_DEPLOYDIR} ${B}"
do_qcom_img_deploy[cleandirs] = "${QIMG_DEPLOYDIR}"
do_qcom_img_deploy[stamp-extra-info] = "${MACHINE_ARCH}"
|