blob: 4c4fd99ff4aca6de40ceb0b07fea3d97a2a3cec0 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001inherit kernel-uboot kernel-artifact-names uboot-sign
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002
3python __anonymous () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -05004 kerneltypes = d.getVar('KERNEL_IMAGETYPES') or ""
He Zhefe76b1e2016-05-25 04:47:16 -04005 if 'fitImage' in kerneltypes.split():
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006 depends = d.getVar("DEPENDS")
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007 depends = "%s u-boot-mkimage-native dtc-native" % depends
8 d.setVar("DEPENDS", depends)
9
Brad Bishopd7bf8c12018-02-25 22:55:05 -050010 uarch = d.getVar("UBOOT_ARCH")
11 if uarch == "arm64":
12 replacementtype = "Image"
13 elif uarch == "mips":
Brad Bishop6e60e8b2018-02-01 10:27:11 -050014 replacementtype = "vmlinuz.bin"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050015 elif uarch == "x86":
Patrick Williamsc0f7c042017-02-23 20:41:17 -060016 replacementtype = "bzImage"
Brad Bishop316dfdd2018-06-25 12:45:53 -040017 elif uarch == "microblaze":
18 replacementtype = "linux.bin"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019 else:
20 replacementtype = "zImage"
21
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal
23 # to kernel.bbclass . We have to override it, since we pack zImage
24 # (at least for now) into the fitImage .
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025 typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE") or ""
He Zhefe76b1e2016-05-25 04:47:16 -040026 if 'fitImage' in typeformake.split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -060027 d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('fitImage', replacementtype))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028
Brad Bishop6e60e8b2018-02-01 10:27:11 -050029 image = d.getVar('INITRAMFS_IMAGE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030 if image:
George McCollister185c8ae2016-05-26 08:55:16 -050031 d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
32
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033 # Verified boot will sign the fitImage and append the public key to
Brad Bishop6e60e8b2018-02-01 10:27:11 -050034 # U-Boot dtb. We ensure the U-Boot dtb is deployed before assembling
Patrick Williamsc0f7c042017-02-23 20:41:17 -060035 # the fitImage:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050036 if d.getVar('UBOOT_SIGN_ENABLE') == "1":
37 uboot_pn = d.getVar('PREFERRED_PROVIDER_u-boot') or 'u-boot'
Patrick Williamsc0f7c042017-02-23 20:41:17 -060038 d.appendVarFlag('do_assemble_fitimage', 'depends', ' %s:do_deploy' % uboot_pn)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039}
40
Yannick Gicqueld5813b42016-04-27 16:20:55 +020041# Options for the device tree compiler passed to mkimage '-D' feature:
42UBOOT_MKIMAGE_DTCOPTS ??= ""
43
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044#
45# Emit the fitImage ITS header
46#
George McCollister185c8ae2016-05-26 08:55:16 -050047# $1 ... .its filename
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048fitimage_emit_fit_header() {
George McCollister185c8ae2016-05-26 08:55:16 -050049 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050/dts-v1/;
51
52/ {
53 description = "U-Boot fitImage for ${DISTRO_NAME}/${PV}/${MACHINE}";
54 #address-cells = <1>;
55EOF
56}
57
58#
59# Emit the fitImage section bits
60#
George McCollister185c8ae2016-05-26 08:55:16 -050061# $1 ... .its filename
62# $2 ... Section bit type: imagestart - image section start
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063# confstart - configuration section start
64# sectend - section end
65# fitend - fitimage end
66#
67fitimage_emit_section_maint() {
George McCollister185c8ae2016-05-26 08:55:16 -050068 case $2 in
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069 imagestart)
George McCollister185c8ae2016-05-26 08:55:16 -050070 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071
72 images {
73EOF
74 ;;
75 confstart)
George McCollister185c8ae2016-05-26 08:55:16 -050076 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077
78 configurations {
79EOF
80 ;;
81 sectend)
George McCollister185c8ae2016-05-26 08:55:16 -050082 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083 };
84EOF
85 ;;
86 fitend)
George McCollister185c8ae2016-05-26 08:55:16 -050087 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088};
89EOF
90 ;;
91 esac
92}
93
94#
95# Emit the fitImage ITS kernel section
96#
George McCollister185c8ae2016-05-26 08:55:16 -050097# $1 ... .its filename
98# $2 ... Image counter
99# $3 ... Path to kernel image
100# $4 ... Compression type
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101fitimage_emit_section_kernel() {
102
103 kernel_csum="sha1"
104
Brad Bishop316dfdd2018-06-25 12:45:53 -0400105 ENTRYPOINT="${UBOOT_ENTRYPOINT}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500106 if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then
107 ENTRYPOINT=`${HOST_PREFIX}nm vmlinux | \
108 awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500109 fi
110
George McCollister185c8ae2016-05-26 08:55:16 -0500111 cat << EOF >> ${1}
112 kernel@${2} {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113 description = "Linux kernel";
George McCollister185c8ae2016-05-26 08:55:16 -0500114 data = /incbin/("${3}");
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500115 type = "kernel";
116 arch = "${UBOOT_ARCH}";
117 os = "linux";
George McCollister185c8ae2016-05-26 08:55:16 -0500118 compression = "${4}";
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119 load = <${UBOOT_LOADADDRESS}>;
120 entry = <${ENTRYPOINT}>;
121 hash@1 {
122 algo = "${kernel_csum}";
123 };
124 };
125EOF
126}
127
128#
129# Emit the fitImage ITS DTB section
130#
George McCollister185c8ae2016-05-26 08:55:16 -0500131# $1 ... .its filename
132# $2 ... Image counter
133# $3 ... Path to DTB image
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134fitimage_emit_section_dtb() {
135
136 dtb_csum="sha1"
137
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800138 dtb_loadline=""
139 dtb_ext=${DTB##*.}
140 if [ "${dtb_ext}" = "dtbo" ]; then
141 if [ -n "${UBOOT_DTBO_LOADADDRESS}" ]; then
142 dtb_loadline="load = <${UBOOT_DTBO_LOADADDRESS}>;"
143 fi
144 elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then
145 dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;"
146 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500147 cat << EOF >> ${1}
148 fdt@${2} {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500149 description = "Flattened Device Tree blob";
George McCollister185c8ae2016-05-26 08:55:16 -0500150 data = /incbin/("${3}");
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500151 type = "flat_dt";
152 arch = "${UBOOT_ARCH}";
153 compression = "none";
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800154 ${dtb_loadline}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500155 hash@1 {
156 algo = "${dtb_csum}";
157 };
158 };
159EOF
160}
161
162#
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600163# Emit the fitImage ITS setup section
164#
165# $1 ... .its filename
166# $2 ... Image counter
167# $3 ... Path to setup image
168fitimage_emit_section_setup() {
169
170 setup_csum="sha1"
171
172 cat << EOF >> ${1}
173 setup@${2} {
174 description = "Linux setup.bin";
175 data = /incbin/("${3}");
176 type = "x86_setup";
177 arch = "${UBOOT_ARCH}";
178 os = "linux";
179 compression = "none";
180 load = <0x00090000>;
181 entry = <0x00090000>;
182 hash@1 {
183 algo = "${setup_csum}";
184 };
185 };
186EOF
187}
188
189#
George McCollister185c8ae2016-05-26 08:55:16 -0500190# Emit the fitImage ITS ramdisk section
191#
192# $1 ... .its filename
193# $2 ... Image counter
194# $3 ... Path to ramdisk image
195fitimage_emit_section_ramdisk() {
196
197 ramdisk_csum="sha1"
Rick Altherrbc1b8802017-01-20 11:28:53 -0800198 ramdisk_ctype="none"
Nathan Rossib4a4dc02016-10-21 22:07:27 +1000199 ramdisk_loadline=""
200 ramdisk_entryline=""
201
202 if [ -n "${UBOOT_RD_LOADADDRESS}" ]; then
203 ramdisk_loadline="load = <${UBOOT_RD_LOADADDRESS}>;"
204 fi
205 if [ -n "${UBOOT_RD_ENTRYPOINT}" ]; then
206 ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;"
207 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500208
Rick Altherrbc1b8802017-01-20 11:28:53 -0800209 case $3 in
210 *.gz)
211 ramdisk_ctype="gzip"
212 ;;
213 *.bz2)
214 ramdisk_ctype="bzip2"
215 ;;
216 *.lzma)
217 ramdisk_ctype="lzma"
218 ;;
219 *.lzo)
220 ramdisk_ctype="lzo"
221 ;;
222 *.lz4)
223 ramdisk_ctype="lz4"
224 ;;
225 esac
226
George McCollister185c8ae2016-05-26 08:55:16 -0500227 cat << EOF >> ${1}
228 ramdisk@${2} {
Rick Altherrbc1b8802017-01-20 11:28:53 -0800229 description = "${INITRAMFS_IMAGE}";
George McCollister185c8ae2016-05-26 08:55:16 -0500230 data = /incbin/("${3}");
231 type = "ramdisk";
232 arch = "${UBOOT_ARCH}";
233 os = "linux";
Rick Altherrbc1b8802017-01-20 11:28:53 -0800234 compression = "${ramdisk_ctype}";
Nathan Rossib4a4dc02016-10-21 22:07:27 +1000235 ${ramdisk_loadline}
236 ${ramdisk_entryline}
George McCollister185c8ae2016-05-26 08:55:16 -0500237 hash@1 {
238 algo = "${ramdisk_csum}";
239 };
240 };
241EOF
242}
243
244#
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500245# Emit the fitImage ITS configuration section
246#
George McCollister185c8ae2016-05-26 08:55:16 -0500247# $1 ... .its filename
248# $2 ... Linux kernel ID
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500249# $3 ... DTB image name
George McCollister185c8ae2016-05-26 08:55:16 -0500250# $4 ... ramdisk ID
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600251# $5 ... config ID
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500252# $6 ... default flag
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500253fitimage_emit_section_config() {
254
255 conf_csum="sha1"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600256 if [ -n "${UBOOT_SIGN_ENABLE}" ] ; then
257 conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
258 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500259
260 # Test if we have any DTBs at all
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800261 sep=""
262 conf_desc=""
263 kernel_line=""
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600264 fdt_line=""
265 ramdisk_line=""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500266 setup_line=""
267 default_line=""
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600268
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800269 if [ -n "${2}" ]; then
270 conf_desc="Linux kernel"
271 sep=", "
272 kernel_line="kernel = \"kernel@${2}\";"
273 fi
274
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600275 if [ -n "${3}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800276 conf_desc="${conf_desc}${sep}FDT blob"
277 sep=", "
George McCollister185c8ae2016-05-26 08:55:16 -0500278 fdt_line="fdt = \"fdt@${3}\";"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600279 fi
280
281 if [ -n "${4}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800282 conf_desc="${conf_desc}${sep}ramdisk"
283 sep=", "
George McCollister185c8ae2016-05-26 08:55:16 -0500284 ramdisk_line="ramdisk = \"ramdisk@${4}\";"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500285 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600286
287 if [ -n "${5}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800288 conf_desc="${conf_desc}${sep}setup"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600289 setup_line="setup = \"setup@${5}\";"
290 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500291
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500292 if [ "${6}" = "1" ]; then
293 default_line="default = \"conf@${3}\";"
294 fi
295
George McCollister185c8ae2016-05-26 08:55:16 -0500296 cat << EOF >> ${1}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500297 ${default_line}
298 conf@${3} {
299 description = "${6} ${conf_desc}";
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500300 ${kernel_line}
301 ${fdt_line}
George McCollister185c8ae2016-05-26 08:55:16 -0500302 ${ramdisk_line}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600303 ${setup_line}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500304 hash@1 {
305 algo = "${conf_csum}";
306 };
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600307EOF
308
309 if [ ! -z "${conf_sign_keyname}" ] ; then
310
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800311 sign_line="sign-images = "
312 sep=""
313
314 if [ -n "${2}" ]; then
315 sign_line="${sign_line}${sep}\"kernel\""
316 sep=", "
317 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600318
319 if [ -n "${3}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800320 sign_line="${sign_line}${sep}\"fdt\""
321 sep=", "
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600322 fi
323
324 if [ -n "${4}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800325 sign_line="${sign_line}${sep}\"ramdisk\""
326 sep=", "
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600327 fi
328
329 if [ -n "${5}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800330 sign_line="${sign_line}${sep}\"setup\""
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600331 fi
332
333 sign_line="${sign_line};"
334
335 cat << EOF >> ${1}
336 signature@1 {
337 algo = "${conf_csum},rsa2048";
338 key-name-hint = "${conf_sign_keyname}";
339 ${sign_line}
340 };
341EOF
342 fi
343
344 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500345 };
346EOF
347}
348
George McCollister185c8ae2016-05-26 08:55:16 -0500349#
350# Assemble fitImage
351#
352# $1 ... .its filename
353# $2 ... fitImage name
354# $3 ... include ramdisk
355fitimage_assemble() {
356 kernelcount=1
357 dtbcount=""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500358 DTBS=""
George McCollister185c8ae2016-05-26 08:55:16 -0500359 ramdiskcount=${3}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600360 setupcount=""
George McCollister185c8ae2016-05-26 08:55:16 -0500361 rm -f ${1} arch/${ARCH}/boot/${2}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500362
George McCollister185c8ae2016-05-26 08:55:16 -0500363 fitimage_emit_fit_header ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500364
George McCollister185c8ae2016-05-26 08:55:16 -0500365 #
366 # Step 1: Prepare a kernel image section.
367 #
368 fitimage_emit_section_maint ${1} imagestart
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500369
George McCollister185c8ae2016-05-26 08:55:16 -0500370 uboot_prep_kimage
371 fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin "${linux_comp}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500372
George McCollister185c8ae2016-05-26 08:55:16 -0500373 #
374 # Step 2: Prepare a DTB image section
375 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500376 if [ -n "${KERNEL_DEVICETREE}" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500377 dtbcount=1
George McCollister185c8ae2016-05-26 08:55:16 -0500378 for DTB in ${KERNEL_DEVICETREE}; do
379 if echo ${DTB} | grep -q '/dts/'; then
380 bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
381 DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
382 fi
383 DTB_PATH="arch/${ARCH}/boot/dts/${DTB}"
384 if [ ! -e "${DTB_PATH}" ]; then
385 DTB_PATH="arch/${ARCH}/boot/${DTB}"
386 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500387
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500388 DTB=$(echo "${DTB}" | tr '/' '_')
389 DTBS="${DTBS} ${DTB}"
390 fitimage_emit_section_dtb ${1} ${DTB} ${DTB_PATH}
George McCollister185c8ae2016-05-26 08:55:16 -0500391 done
392 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500393
George McCollister185c8ae2016-05-26 08:55:16 -0500394 #
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600395 # Step 3: Prepare a setup section. (For x86)
396 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500397 if [ -e arch/${ARCH}/boot/setup.bin ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600398 setupcount=1
399 fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin
400 fi
401
402 #
403 # Step 4: Prepare a ramdisk section.
George McCollister185c8ae2016-05-26 08:55:16 -0500404 #
405 if [ "x${ramdiskcount}" = "x1" ] ; then
Rick Altherrbc1b8802017-01-20 11:28:53 -0800406 # Find and use the first initramfs image archive type we find
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800407 for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.gz ext2.gz cpio; do
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500408 initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.${img}"
Rick Altherrbc1b8802017-01-20 11:28:53 -0800409 echo "Using $initramfs_path"
410 if [ -e "${initramfs_path}" ]; then
411 fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}"
412 break
413 fi
414 done
George McCollister185c8ae2016-05-26 08:55:16 -0500415 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500416
George McCollister185c8ae2016-05-26 08:55:16 -0500417 fitimage_emit_section_maint ${1} sectend
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500418
George McCollister185c8ae2016-05-26 08:55:16 -0500419 # Force the first Kernel and DTB in the default config
420 kernelcount=1
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500421 if [ -n "${dtbcount}" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600422 dtbcount=1
423 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500424
George McCollister185c8ae2016-05-26 08:55:16 -0500425 #
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600426 # Step 5: Prepare a configurations section
George McCollister185c8ae2016-05-26 08:55:16 -0500427 #
428 fitimage_emit_section_maint ${1} confstart
429
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500430 if [ -n "${DTBS}" ]; then
431 i=1
432 for DTB in ${DTBS}; do
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800433 dtb_ext=${DTB##*.}
434 if [ "${dtb_ext}" = "dtbo" ]; then
435 fitimage_emit_section_config ${1} "" "${DTB}" "" "" "`expr ${i} = ${dtbcount}`"
436 else
437 fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${setupcount}" "`expr ${i} = ${dtbcount}`"
438 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500439 i=`expr ${i} + 1`
440 done
441 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500442
443 fitimage_emit_section_maint ${1} sectend
444
445 fitimage_emit_section_maint ${1} fitend
446
447 #
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600448 # Step 6: Assemble the image
George McCollister185c8ae2016-05-26 08:55:16 -0500449 #
450 uboot-mkimage \
451 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
452 -f ${1} \
453 arch/${ARCH}/boot/${2}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600454
455 #
456 # Step 7: Sign the image and add public key to U-Boot dtb
457 #
458 if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then
459 uboot-mkimage \
460 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
461 -F -k "${UBOOT_SIGN_KEYDIR}" \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800462 ${@'-K "${DEPLOY_DIR_IMAGE}/${UBOOT_DTB_BINARY}"' if len('${UBOOT_DTB_BINARY}') else ''} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600463 -r arch/${ARCH}/boot/${2}
464 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500465}
466
467do_assemble_fitimage() {
468 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
469 cd ${B}
470 fitimage_assemble fit-image.its fitImage
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500471 fi
472}
473
474addtask assemble_fitimage before do_install after do_compile
475
George McCollister185c8ae2016-05-26 08:55:16 -0500476do_assemble_fitimage_initramfs() {
477 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage" && \
478 test -n "${INITRAMFS_IMAGE}" ; then
479 cd ${B}
480 fitimage_assemble fit-image-${INITRAMFS_IMAGE}.its fitImage-${INITRAMFS_IMAGE} 1
481 fi
482}
483
484addtask assemble_fitimage_initramfs before do_deploy after do_install
485
486
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500487kernel_do_deploy[vardepsexclude] = "DATETIME"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500488kernel_do_deploy_append() {
489 # Update deploy directory
He Zhefe76b1e2016-05-25 04:47:16 -0400490 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500491 echo "Copying fit-image.its source file..."
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800492 install -m 0644 ${B}/fit-image.its ${DEPLOYDIR}/fitImage-its-${KERNEL_FIT_NAME}.its
493 ln -snf fitImage-its-${KERNEL_FIT_NAME}.its ${DEPLOYDIR}/fitImage-its-${KERNEL_FIT_LINK_NAME}
494
495 echo "Copying linux.bin file..."
496 install -m 0644 ${B}/linux.bin ${DEPLOYDIR}/fitImage-linux.bin-${KERNEL_FIT_NAME}.bin
497 ln -snf fitImage-linux.bin-${KERNEL_FIT_NAME}.bin ${DEPLOYDIR}/fitImage-linux.bin-${KERNEL_FIT_LINK_NAME}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500498
George McCollister185c8ae2016-05-26 08:55:16 -0500499 if [ -n "${INITRAMFS_IMAGE}" ]; then
500 echo "Copying fit-image-${INITRAMFS_IMAGE}.its source file..."
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800501 install -m 0644 ${B}/fit-image-${INITRAMFS_IMAGE}.its ${DEPLOYDIR}/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its
502 ln -snf fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its ${DEPLOYDIR}/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}
George McCollister185c8ae2016-05-26 08:55:16 -0500503
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800504 echo "Copying fitImage-${INITRAMFS_IMAGE} file..."
505 install -m 0644 ${B}/arch/${ARCH}/boot/fitImage-${INITRAMFS_IMAGE} ${DEPLOYDIR}/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.bin
506 ln -snf fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.bin ${DEPLOYDIR}/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}
George McCollister185c8ae2016-05-26 08:55:16 -0500507 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500508 fi
509}