diff options
-rw-r--r-- | meta-ti-bsp/classes/kernel-fitimage-deprecated.bbclass | 839 | ||||
-rw-r--r-- | meta-ti-bsp/classes/kernel_deprecated.bbclass | 869 |
2 files changed, 0 insertions, 1708 deletions
diff --git a/meta-ti-bsp/classes/kernel-fitimage-deprecated.bbclass b/meta-ti-bsp/classes/kernel-fitimage-deprecated.bbclass deleted file mode 100644 index b1705818..00000000 --- a/meta-ti-bsp/classes/kernel-fitimage-deprecated.bbclass +++ /dev/null | |||
@@ -1,839 +0,0 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | inherit kernel-uboot-deprecated kernel-artifact-names uboot-config | ||
8 | require conf/image-fitimage.conf | ||
9 | |||
10 | def get_fit_replacement_type(d): | ||
11 | kerneltypes = d.getVar('KERNEL_IMAGETYPES') or "" | ||
12 | replacementtype = "" | ||
13 | if 'fitImage' in kerneltypes.split(): | ||
14 | uarch = d.getVar("UBOOT_ARCH") | ||
15 | if uarch == "arm64": | ||
16 | replacementtype = "Image" | ||
17 | elif uarch == "riscv": | ||
18 | replacementtype = "Image" | ||
19 | elif uarch == "mips": | ||
20 | replacementtype = "vmlinuz.bin" | ||
21 | elif uarch == "x86": | ||
22 | replacementtype = "bzImage" | ||
23 | elif uarch == "microblaze": | ||
24 | replacementtype = "linux.bin" | ||
25 | else: | ||
26 | replacementtype = "zImage" | ||
27 | return replacementtype | ||
28 | |||
29 | KERNEL_IMAGETYPE_REPLACEMENT ?= "${@get_fit_replacement_type(d)}" | ||
30 | DEPENDS:append = " ${@'u-boot-tools-native dtc-native' if 'fitImage' in (d.getVar('KERNEL_IMAGETYPES') or '').split() else ''}" | ||
31 | |||
32 | python __anonymous () { | ||
33 | # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal | ||
34 | # to kernel.bbclass . We have to override it, since we pack zImage | ||
35 | # (at least for now) into the fitImage . | ||
36 | typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE") or "" | ||
37 | if 'fitImage' in typeformake.split(): | ||
38 | d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('fitImage', d.getVar('KERNEL_IMAGETYPE_REPLACEMENT'))) | ||
39 | |||
40 | image = d.getVar('INITRAMFS_IMAGE') | ||
41 | if image and not bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')): | ||
42 | if d.getVar('INITRAMFS_MULTICONFIG'): | ||
43 | mc = d.getVar('BB_CURRENT_MC') | ||
44 | d.appendVarFlag('do_assemble_fitimage_initramfs', 'mcdepends', ' mc:' + mc + ':${INITRAMFS_MULTICONFIG}:${INITRAMFS_IMAGE}:do_image_complete') | ||
45 | else: | ||
46 | d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') | ||
47 | |||
48 | #check if there are any dtb providers | ||
49 | providerdtb = d.getVar("PREFERRED_PROVIDER_virtual/dtb") | ||
50 | if providerdtb: | ||
51 | d.appendVarFlag('do_assemble_fitimage', 'depends', ' virtual/dtb:do_populate_sysroot') | ||
52 | d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' virtual/dtb:do_populate_sysroot') | ||
53 | d.setVar('EXTERNAL_KERNEL_DEVICETREE', "${RECIPE_SYSROOT}/boot/devicetree") | ||
54 | } | ||
55 | |||
56 | # | ||
57 | # Emit the fitImage ITS header | ||
58 | # | ||
59 | # $1 ... .its filename | ||
60 | fitimage_emit_fit_header() { | ||
61 | cat << EOF >> $1 | ||
62 | /dts-v1/; | ||
63 | |||
64 | / { | ||
65 | description = "${FIT_DESC}"; | ||
66 | #address-cells = <${FIT_ADDRESS_CELLS}>; | ||
67 | EOF | ||
68 | } | ||
69 | |||
70 | # | ||
71 | # Emit the fitImage section bits | ||
72 | # | ||
73 | # $1 ... .its filename | ||
74 | # $2 ... Section bit type: imagestart - image section start | ||
75 | # confstart - configuration section start | ||
76 | # sectend - section end | ||
77 | # fitend - fitimage end | ||
78 | # | ||
79 | fitimage_emit_section_maint() { | ||
80 | case $2 in | ||
81 | imagestart) | ||
82 | cat << EOF >> $1 | ||
83 | |||
84 | images { | ||
85 | EOF | ||
86 | ;; | ||
87 | confstart) | ||
88 | cat << EOF >> $1 | ||
89 | |||
90 | configurations { | ||
91 | EOF | ||
92 | ;; | ||
93 | sectend) | ||
94 | cat << EOF >> $1 | ||
95 | }; | ||
96 | EOF | ||
97 | ;; | ||
98 | fitend) | ||
99 | cat << EOF >> $1 | ||
100 | }; | ||
101 | EOF | ||
102 | ;; | ||
103 | esac | ||
104 | } | ||
105 | |||
106 | # | ||
107 | # Emit the fitImage ITS kernel section | ||
108 | # | ||
109 | # $1 ... .its filename | ||
110 | # $2 ... Image counter | ||
111 | # $3 ... Path to kernel image | ||
112 | # $4 ... Compression type | ||
113 | fitimage_emit_section_kernel() { | ||
114 | |||
115 | kernel_csum="${FIT_HASH_ALG}" | ||
116 | kernel_sign_algo="${FIT_SIGN_ALG}" | ||
117 | kernel_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}" | ||
118 | |||
119 | ENTRYPOINT="${UBOOT_ENTRYPOINT}" | ||
120 | if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then | ||
121 | ENTRYPOINT=`${HOST_PREFIX}nm vmlinux | \ | ||
122 | awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'` | ||
123 | fi | ||
124 | |||
125 | cat << EOF >> $1 | ||
126 | kernel-$2 { | ||
127 | description = "Linux kernel"; | ||
128 | data = /incbin/("$3"); | ||
129 | type = "${UBOOT_MKIMAGE_KERNEL_TYPE}"; | ||
130 | arch = "${UBOOT_ARCH}"; | ||
131 | os = "linux"; | ||
132 | compression = "$4"; | ||
133 | load = <${UBOOT_LOADADDRESS}>; | ||
134 | entry = <$ENTRYPOINT>; | ||
135 | hash-1 { | ||
136 | algo = "$kernel_csum"; | ||
137 | }; | ||
138 | }; | ||
139 | EOF | ||
140 | |||
141 | if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$kernel_sign_keyname" ] ; then | ||
142 | sed -i '$ d' $1 | ||
143 | cat << EOF >> $1 | ||
144 | signature-1 { | ||
145 | algo = "$kernel_csum,$kernel_sign_algo"; | ||
146 | key-name-hint = "$kernel_sign_keyname"; | ||
147 | }; | ||
148 | }; | ||
149 | EOF | ||
150 | fi | ||
151 | } | ||
152 | |||
153 | # | ||
154 | # Emit the fitImage ITS DTB section | ||
155 | # | ||
156 | # $1 ... .its filename | ||
157 | # $2 ... Image counter | ||
158 | # $3 ... Path to DTB image | ||
159 | fitimage_emit_section_dtb() { | ||
160 | |||
161 | dtb_csum="${FIT_HASH_ALG}" | ||
162 | dtb_sign_algo="${FIT_SIGN_ALG}" | ||
163 | dtb_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}" | ||
164 | |||
165 | dtb_loadline="" | ||
166 | dtb_ext=${DTB##*.} | ||
167 | if [ "${dtb_ext}" = "dtbo" ]; then | ||
168 | if [ -n "${UBOOT_DTBO_LOADADDRESS}" ]; then | ||
169 | dtb_loadline="load = <${UBOOT_DTBO_LOADADDRESS}>;" | ||
170 | fi | ||
171 | elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then | ||
172 | dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;" | ||
173 | fi | ||
174 | cat << EOF >> $1 | ||
175 | fdt-$2 { | ||
176 | description = "Flattened Device Tree blob"; | ||
177 | data = /incbin/("$3"); | ||
178 | type = "flat_dt"; | ||
179 | arch = "${UBOOT_ARCH}"; | ||
180 | compression = "none"; | ||
181 | $dtb_loadline | ||
182 | hash-1 { | ||
183 | algo = "$dtb_csum"; | ||
184 | }; | ||
185 | }; | ||
186 | EOF | ||
187 | |||
188 | if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$dtb_sign_keyname" ] ; then | ||
189 | sed -i '$ d' $1 | ||
190 | cat << EOF >> $1 | ||
191 | signature-1 { | ||
192 | algo = "$dtb_csum,$dtb_sign_algo"; | ||
193 | key-name-hint = "$dtb_sign_keyname"; | ||
194 | }; | ||
195 | }; | ||
196 | EOF | ||
197 | fi | ||
198 | } | ||
199 | |||
200 | # | ||
201 | # Emit the fitImage ITS u-boot script section | ||
202 | # | ||
203 | # $1 ... .its filename | ||
204 | # $2 ... Image counter | ||
205 | # $3 ... Path to boot script image | ||
206 | fitimage_emit_section_boot_script() { | ||
207 | |||
208 | bootscr_csum="${FIT_HASH_ALG}" | ||
209 | bootscr_sign_algo="${FIT_SIGN_ALG}" | ||
210 | bootscr_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}" | ||
211 | |||
212 | cat << EOF >> $1 | ||
213 | bootscr-$2 { | ||
214 | description = "U-boot script"; | ||
215 | data = /incbin/("$3"); | ||
216 | type = "script"; | ||
217 | arch = "${UBOOT_ARCH}"; | ||
218 | compression = "none"; | ||
219 | hash-1 { | ||
220 | algo = "$bootscr_csum"; | ||
221 | }; | ||
222 | }; | ||
223 | EOF | ||
224 | |||
225 | if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$bootscr_sign_keyname" ] ; then | ||
226 | sed -i '$ d' $1 | ||
227 | cat << EOF >> $1 | ||
228 | signature-1 { | ||
229 | algo = "$bootscr_csum,$bootscr_sign_algo"; | ||
230 | key-name-hint = "$bootscr_sign_keyname"; | ||
231 | }; | ||
232 | }; | ||
233 | EOF | ||
234 | fi | ||
235 | } | ||
236 | |||
237 | # | ||
238 | # Emit the fitImage ITS setup section | ||
239 | # | ||
240 | # $1 ... .its filename | ||
241 | # $2 ... Image counter | ||
242 | # $3 ... Path to setup image | ||
243 | fitimage_emit_section_setup() { | ||
244 | |||
245 | setup_csum="${FIT_HASH_ALG}" | ||
246 | setup_sign_algo="${FIT_SIGN_ALG}" | ||
247 | setup_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}" | ||
248 | |||
249 | cat << EOF >> $1 | ||
250 | setup-$2 { | ||
251 | description = "Linux setup.bin"; | ||
252 | data = /incbin/("$3"); | ||
253 | type = "x86_setup"; | ||
254 | arch = "${UBOOT_ARCH}"; | ||
255 | os = "linux"; | ||
256 | compression = "none"; | ||
257 | load = <0x00090000>; | ||
258 | entry = <0x00090000>; | ||
259 | hash-1 { | ||
260 | algo = "$setup_csum"; | ||
261 | }; | ||
262 | }; | ||
263 | EOF | ||
264 | |||
265 | if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$setup_sign_keyname" ] ; then | ||
266 | sed -i '$ d' $1 | ||
267 | cat << EOF >> $1 | ||
268 | signature-1 { | ||
269 | algo = "$setup_csum,$setup_sign_algo"; | ||
270 | key-name-hint = "$setup_sign_keyname"; | ||
271 | }; | ||
272 | }; | ||
273 | EOF | ||
274 | fi | ||
275 | } | ||
276 | |||
277 | # | ||
278 | # Emit the fitImage ITS ramdisk section | ||
279 | # | ||
280 | # $1 ... .its filename | ||
281 | # $2 ... Image counter | ||
282 | # $3 ... Path to ramdisk image | ||
283 | fitimage_emit_section_ramdisk() { | ||
284 | |||
285 | ramdisk_csum="${FIT_HASH_ALG}" | ||
286 | ramdisk_sign_algo="${FIT_SIGN_ALG}" | ||
287 | ramdisk_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}" | ||
288 | ramdisk_loadline="" | ||
289 | ramdisk_entryline="" | ||
290 | |||
291 | if [ -n "${UBOOT_RD_LOADADDRESS}" ]; then | ||
292 | ramdisk_loadline="load = <${UBOOT_RD_LOADADDRESS}>;" | ||
293 | fi | ||
294 | if [ -n "${UBOOT_RD_ENTRYPOINT}" ]; then | ||
295 | ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;" | ||
296 | fi | ||
297 | |||
298 | cat << EOF >> $1 | ||
299 | ramdisk-$2 { | ||
300 | description = "${INITRAMFS_IMAGE}"; | ||
301 | data = /incbin/("$3"); | ||
302 | type = "ramdisk"; | ||
303 | arch = "${UBOOT_ARCH}"; | ||
304 | os = "linux"; | ||
305 | compression = "none"; | ||
306 | $ramdisk_loadline | ||
307 | $ramdisk_entryline | ||
308 | hash-1 { | ||
309 | algo = "$ramdisk_csum"; | ||
310 | }; | ||
311 | }; | ||
312 | EOF | ||
313 | |||
314 | if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$ramdisk_sign_keyname" ] ; then | ||
315 | sed -i '$ d' $1 | ||
316 | cat << EOF >> $1 | ||
317 | signature-1 { | ||
318 | algo = "$ramdisk_csum,$ramdisk_sign_algo"; | ||
319 | key-name-hint = "$ramdisk_sign_keyname"; | ||
320 | }; | ||
321 | }; | ||
322 | EOF | ||
323 | fi | ||
324 | } | ||
325 | |||
326 | # | ||
327 | # echoes symlink destination if it points below directory | ||
328 | # | ||
329 | # $1 ... file that's a potential symlink | ||
330 | # $2 ... expected parent directory | ||
331 | symlink_points_below() { | ||
332 | file="$2/$1" | ||
333 | dir=$2 | ||
334 | |||
335 | if ! [ -L "$file" ]; then | ||
336 | return | ||
337 | fi | ||
338 | |||
339 | realpath="$(realpath --relative-to=$dir $file)" | ||
340 | if [ -z "${realpath%%../*}" ]; then | ||
341 | return | ||
342 | fi | ||
343 | |||
344 | echo "$realpath" | ||
345 | } | ||
346 | |||
347 | # | ||
348 | # Emit the fitImage ITS configuration section | ||
349 | # | ||
350 | # $1 ... .its filename | ||
351 | # $2 ... Linux kernel ID | ||
352 | # $3 ... DTB image name | ||
353 | # $4 ... ramdisk ID | ||
354 | # $5 ... u-boot script ID | ||
355 | # $6 ... config ID | ||
356 | # $7 ... default flag | ||
357 | # $8 ... default DTB image name | ||
358 | fitimage_emit_section_config() { | ||
359 | |||
360 | conf_csum="${FIT_HASH_ALG}" | ||
361 | conf_sign_algo="${FIT_SIGN_ALG}" | ||
362 | conf_padding_algo="${FIT_PAD_ALG}" | ||
363 | if [ "${UBOOT_SIGN_ENABLE}" = "1" ] ; then | ||
364 | conf_sign_keyname="${UBOOT_SIGN_KEYNAME}" | ||
365 | fi | ||
366 | |||
367 | its_file="$1" | ||
368 | kernel_id="$2" | ||
369 | dtb_image="$3" | ||
370 | ramdisk_id="$4" | ||
371 | bootscr_id="$5" | ||
372 | config_id="$6" | ||
373 | default_flag="$7" | ||
374 | default_dtb_image="$8" | ||
375 | |||
376 | # Test if we have any DTBs at all | ||
377 | sep="" | ||
378 | conf_desc="" | ||
379 | conf_node="${FIT_CONF_PREFIX}" | ||
380 | kernel_line="" | ||
381 | fdt_line="" | ||
382 | ramdisk_line="" | ||
383 | bootscr_line="" | ||
384 | setup_line="" | ||
385 | default_line="" | ||
386 | compatible_line="" | ||
387 | |||
388 | dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}") | ||
389 | if [ -z "$dtb_image_sect" ]; then | ||
390 | dtb_image_sect=$dtb_image | ||
391 | fi | ||
392 | |||
393 | dtb_path="${EXTERNAL_KERNEL_DEVICETREE}/${dtb_image_sect}" | ||
394 | if [ -f "$dtb_path" ] || [ -L "$dtb_path" ]; then | ||
395 | compat=$(fdtget -t s "$dtb_path" / compatible | sed 's/ /", "/g') | ||
396 | if [ -n "$compat" ]; then | ||
397 | compatible_line="compatible = \"$compat\";" | ||
398 | fi | ||
399 | fi | ||
400 | |||
401 | dtb_image=$(echo $dtb_image | tr '/' '_') | ||
402 | dtb_image_sect=$(echo "${dtb_image_sect}" | tr '/' '_') | ||
403 | |||
404 | # conf node name is selected based on dtb ID if it is present, | ||
405 | # otherwise its selected based on kernel ID | ||
406 | if [ -n "$dtb_image" ]; then | ||
407 | conf_node=$conf_node$dtb_image | ||
408 | else | ||
409 | conf_node=$conf_node$kernel_id | ||
410 | fi | ||
411 | |||
412 | if [ -n "$kernel_id" ]; then | ||
413 | conf_desc="Linux kernel" | ||
414 | sep=", " | ||
415 | kernel_line="kernel = \"kernel-$kernel_id\";" | ||
416 | fi | ||
417 | |||
418 | if [ -n "$dtb_image" ]; then | ||
419 | conf_desc="$conf_desc${sep}FDT blob" | ||
420 | sep=", " | ||
421 | fdt_line="fdt = \"fdt-$dtb_image_sect\";" | ||
422 | fi | ||
423 | |||
424 | if [ -n "$ramdisk_id" ]; then | ||
425 | conf_desc="$conf_desc${sep}ramdisk" | ||
426 | sep=", " | ||
427 | ramdisk_line="ramdisk = \"ramdisk-$ramdisk_id\";" | ||
428 | fi | ||
429 | |||
430 | if [ -n "$bootscr_id" ]; then | ||
431 | conf_desc="$conf_desc${sep}u-boot script" | ||
432 | sep=", " | ||
433 | bootscr_line="bootscr = \"bootscr-$bootscr_id\";" | ||
434 | fi | ||
435 | |||
436 | if [ -n "$config_id" ]; then | ||
437 | conf_desc="$conf_desc${sep}setup" | ||
438 | setup_line="setup = \"setup-$config_id\";" | ||
439 | fi | ||
440 | |||
441 | if [ "$default_flag" = "1" ]; then | ||
442 | # default node is selected based on dtb ID if it is present, | ||
443 | # otherwise its selected based on kernel ID | ||
444 | if [ -n "$dtb_image" ]; then | ||
445 | # Select default node as user specified dtb when | ||
446 | # multiple dtb exists. | ||
447 | if [ -n "$default_dtb_image" ]; then | ||
448 | default_line="default = \"${FIT_CONF_PREFIX}$default_dtb_image\";" | ||
449 | else | ||
450 | default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";" | ||
451 | fi | ||
452 | else | ||
453 | default_line="default = \"${FIT_CONF_PREFIX}$kernel_id\";" | ||
454 | fi | ||
455 | fi | ||
456 | |||
457 | cat << EOF >> $its_file | ||
458 | $default_line | ||
459 | $conf_node { | ||
460 | description = "$default_flag $conf_desc"; | ||
461 | $compatible_line | ||
462 | $kernel_line | ||
463 | $fdt_line | ||
464 | $ramdisk_line | ||
465 | $bootscr_line | ||
466 | $setup_line | ||
467 | hash-1 { | ||
468 | algo = "$conf_csum"; | ||
469 | }; | ||
470 | EOF | ||
471 | |||
472 | if [ -n "$conf_sign_keyname" ] ; then | ||
473 | |||
474 | sign_line="sign-images = " | ||
475 | sep="" | ||
476 | |||
477 | if [ -n "$kernel_id" ]; then | ||
478 | sign_line="$sign_line${sep}\"kernel\"" | ||
479 | sep=", " | ||
480 | fi | ||
481 | |||
482 | if [ -n "$dtb_image" ]; then | ||
483 | sign_line="$sign_line${sep}\"fdt\"" | ||
484 | sep=", " | ||
485 | fi | ||
486 | |||
487 | if [ -n "$ramdisk_id" ]; then | ||
488 | sign_line="$sign_line${sep}\"ramdisk\"" | ||
489 | sep=", " | ||
490 | fi | ||
491 | |||
492 | if [ -n "$bootscr_id" ]; then | ||
493 | sign_line="$sign_line${sep}\"bootscr\"" | ||
494 | sep=", " | ||
495 | fi | ||
496 | |||
497 | if [ -n "$config_id" ]; then | ||
498 | sign_line="$sign_line${sep}\"setup\"" | ||
499 | fi | ||
500 | |||
501 | sign_line="$sign_line;" | ||
502 | |||
503 | cat << EOF >> $its_file | ||
504 | signature-1 { | ||
505 | algo = "$conf_csum,$conf_sign_algo"; | ||
506 | key-name-hint = "$conf_sign_keyname"; | ||
507 | padding = "$conf_padding_algo"; | ||
508 | $sign_line | ||
509 | }; | ||
510 | EOF | ||
511 | fi | ||
512 | |||
513 | cat << EOF >> $its_file | ||
514 | }; | ||
515 | EOF | ||
516 | } | ||
517 | |||
518 | # | ||
519 | # Assemble fitImage | ||
520 | # | ||
521 | # $1 ... .its filename | ||
522 | # $2 ... fitImage name | ||
523 | # $3 ... include ramdisk | ||
524 | fitimage_assemble() { | ||
525 | kernelcount=1 | ||
526 | dtbcount="" | ||
527 | DTBS="" | ||
528 | ramdiskcount=$3 | ||
529 | setupcount="" | ||
530 | bootscr_id="" | ||
531 | default_dtb_image="" | ||
532 | rm -f $1 arch/${ARCH}/boot/$2 | ||
533 | |||
534 | if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then | ||
535 | bbfatal "Keys used to sign images and configuration nodes must be different." | ||
536 | fi | ||
537 | |||
538 | fitimage_emit_fit_header $1 | ||
539 | |||
540 | # | ||
541 | # Step 1: Prepare a kernel image section. | ||
542 | # | ||
543 | fitimage_emit_section_maint $1 imagestart | ||
544 | |||
545 | uboot_prep_kimage | ||
546 | fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp" | ||
547 | |||
548 | # | ||
549 | # Step 2: Prepare a DTB image section | ||
550 | # | ||
551 | |||
552 | if [ -n "${KERNEL_DEVICETREE}" ]; then | ||
553 | dtbcount=1 | ||
554 | for DTB in ${KERNEL_DEVICETREE}; do | ||
555 | if echo $DTB | grep -q '/dts/'; then | ||
556 | bbwarn "$DTB contains the full path to the the dts file, but only the dtb name should be used." | ||
557 | DTB=`basename $DTB | sed 's,\.dts$,.dtb,g'` | ||
558 | fi | ||
559 | |||
560 | # Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE} | ||
561 | if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ] && [ -s ${EXTERNAL_KERNEL_DEVICETREE}/${DTB} ]; then | ||
562 | continue | ||
563 | fi | ||
564 | |||
565 | DTB_PATH="${KERNEL_OUTPUT_DIR}/dts/$DTB" | ||
566 | if [ ! -e "$DTB_PATH" ]; then | ||
567 | DTB_PATH="${KERNEL_OUTPUT_DIR}/$DTB" | ||
568 | fi | ||
569 | |||
570 | # Strip off the path component from the filename | ||
571 | if "${@'false' if oe.types.boolean(d.getVar('KERNEL_DTBVENDORED')) else 'true'}"; then | ||
572 | DTB=`basename $DTB` | ||
573 | fi | ||
574 | |||
575 | # Set the default dtb image if it exists in the devicetree. | ||
576 | if [ "${FIT_CONF_DEFAULT_DTB}" = "$DTB" ];then | ||
577 | default_dtb_image=$(echo "$DTB" | tr '/' '_') | ||
578 | fi | ||
579 | |||
580 | DTB=$(echo "$DTB" | tr '/' '_') | ||
581 | |||
582 | # Skip DTB if we've picked it up previously | ||
583 | echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue | ||
584 | |||
585 | DTBS="$DTBS $DTB" | ||
586 | DTB=$(echo $DTB | tr '/' '_') | ||
587 | fitimage_emit_section_dtb $1 $DTB $DTB_PATH | ||
588 | done | ||
589 | fi | ||
590 | |||
591 | if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then | ||
592 | dtbcount=1 | ||
593 | for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" -name '*.dtb' -printf '%P\n' | sort) \ | ||
594 | $(find "${EXTERNAL_KERNEL_DEVICETREE}" -name '*.dtbo' -printf '%P\n' | sort); do | ||
595 | # Set the default dtb image if it exists in the devicetree. | ||
596 | if [ ${FIT_CONF_DEFAULT_DTB} = $DTB ];then | ||
597 | default_dtb_image=$(echo "$DTB" | tr '/' '_') | ||
598 | fi | ||
599 | |||
600 | DTB=$(echo "$DTB" | tr '/' '_') | ||
601 | |||
602 | # Skip DTB/DTBO if we've picked it up previously | ||
603 | echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue | ||
604 | |||
605 | DTBS="$DTBS $DTB" | ||
606 | |||
607 | # Also skip if a symlink. We'll later have each config section point at it | ||
608 | [ $(symlink_points_below $DTB "${EXTERNAL_KERNEL_DEVICETREE}") ] && continue | ||
609 | |||
610 | DTB=$(echo $DTB | tr '/' '_') | ||
611 | fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB" | ||
612 | done | ||
613 | fi | ||
614 | |||
615 | if [ -n "${FIT_CONF_DEFAULT_DTB}" ] && [ -z $default_dtb_image ]; then | ||
616 | bbwarn "${FIT_CONF_DEFAULT_DTB} is not available in the list of device trees." | ||
617 | fi | ||
618 | |||
619 | # | ||
620 | # Step 3: Prepare a u-boot script section | ||
621 | # | ||
622 | |||
623 | if [ -n "${FIT_UBOOT_ENV}" ]; then | ||
624 | cp ${UNPACKDIR}/${FIT_UBOOT_ENV} ${B} | ||
625 | bootscr_id="${FIT_UBOOT_ENV}" | ||
626 | fitimage_emit_section_boot_script $1 "$bootscr_id" ${FIT_UBOOT_ENV} | ||
627 | fi | ||
628 | |||
629 | # | ||
630 | # Step 4: Prepare a setup section. (For x86) | ||
631 | # | ||
632 | if [ -e ${KERNEL_OUTPUT_DIR}/setup.bin ]; then | ||
633 | setupcount=1 | ||
634 | fitimage_emit_section_setup $1 $setupcount ${KERNEL_OUTPUT_DIR}/setup.bin | ||
635 | fi | ||
636 | |||
637 | # | ||
638 | # Step 5: Prepare a ramdisk section. | ||
639 | # | ||
640 | if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then | ||
641 | # Find and use the first initramfs image archive type we find | ||
642 | found= | ||
643 | for img in ${FIT_SUPPORTED_INITRAMFS_FSTYPES}; do | ||
644 | initramfs_path="${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" | ||
645 | if [ -e "$initramfs_path" ]; then | ||
646 | bbnote "Found initramfs image: $initramfs_path" | ||
647 | found=true | ||
648 | fitimage_emit_section_ramdisk $1 "$ramdiskcount" "$initramfs_path" | ||
649 | break | ||
650 | else | ||
651 | bbnote "Did not find initramfs image: $initramfs_path" | ||
652 | fi | ||
653 | done | ||
654 | |||
655 | if [ -z "$found" ]; then | ||
656 | bbfatal "Could not find a valid initramfs type for ${INITRAMFS_IMAGE_NAME}, the supported types are: ${FIT_SUPPORTED_INITRAMFS_FSTYPES}" | ||
657 | fi | ||
658 | fi | ||
659 | |||
660 | fitimage_emit_section_maint $1 sectend | ||
661 | |||
662 | # Force the first Kernel and DTB in the default config | ||
663 | kernelcount=1 | ||
664 | if [ -n "$dtbcount" ]; then | ||
665 | dtbcount=1 | ||
666 | fi | ||
667 | |||
668 | # | ||
669 | # Step 6: Prepare a configurations section | ||
670 | # | ||
671 | fitimage_emit_section_maint $1 confstart | ||
672 | |||
673 | # kernel-fitimage.bbclass currently only supports a single kernel (no less or | ||
674 | # more) to be added to the FIT image along with 0 or more device trees and | ||
675 | # 0 or 1 ramdisk. | ||
676 | # It is also possible to include an initramfs bundle (kernel and rootfs in one binary) | ||
677 | # When the initramfs bundle is used ramdisk is disabled. | ||
678 | # If a device tree is to be part of the FIT image, then select | ||
679 | # the default configuration to be used is based on the dtbcount. If there is | ||
680 | # no dtb present than select the default configuation to be based on | ||
681 | # the kernelcount. | ||
682 | if [ -n "$DTBS" ]; then | ||
683 | i=1 | ||
684 | for DTB in ${DTBS}; do | ||
685 | dtb_ext=${DTB##*.} | ||
686 | if [ "$dtb_ext" = "dtbo" ]; then | ||
687 | fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`" "$default_dtb_image" | ||
688 | else | ||
689 | fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`" "$default_dtb_image" | ||
690 | fi | ||
691 | i=`expr $i + 1` | ||
692 | done | ||
693 | else | ||
694 | defaultconfigcount=1 | ||
695 | fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id" "$setupcount" $defaultconfigcount "$default_dtb_image" | ||
696 | fi | ||
697 | |||
698 | fitimage_emit_section_maint $1 sectend | ||
699 | |||
700 | fitimage_emit_section_maint $1 fitend | ||
701 | |||
702 | # | ||
703 | # Step 7: Assemble the image | ||
704 | # | ||
705 | ${UBOOT_MKIMAGE} \ | ||
706 | ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ | ||
707 | -f $1 \ | ||
708 | ${KERNEL_OUTPUT_DIR}/$2 | ||
709 | |||
710 | # | ||
711 | # Step 8: Sign the image | ||
712 | # | ||
713 | if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then | ||
714 | ${UBOOT_MKIMAGE_SIGN} \ | ||
715 | ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ | ||
716 | -F -k "${UBOOT_SIGN_KEYDIR}" \ | ||
717 | -r ${KERNEL_OUTPUT_DIR}/$2 \ | ||
718 | ${UBOOT_MKIMAGE_SIGN_ARGS} | ||
719 | fi | ||
720 | } | ||
721 | |||
722 | do_assemble_fitimage() { | ||
723 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then | ||
724 | cd ${B} | ||
725 | fitimage_assemble fit-image.its fitImage-none "" | ||
726 | if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then | ||
727 | ln -sf fitImage-none ${B}/${KERNEL_OUTPUT_DIR}/fitImage | ||
728 | fi | ||
729 | fi | ||
730 | } | ||
731 | |||
732 | addtask assemble_fitimage before do_install after do_compile | ||
733 | |||
734 | SYSROOT_DIRS:append = " /sysroot-only" | ||
735 | do_install:append() { | ||
736 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage" && \ | ||
737 | [ "${UBOOT_SIGN_ENABLE}" = "1" ]; then | ||
738 | install -D ${B}/${KERNEL_OUTPUT_DIR}/fitImage-none ${D}/sysroot-only/fitImage | ||
739 | fi | ||
740 | } | ||
741 | |||
742 | do_assemble_fitimage_initramfs() { | ||
743 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage" && \ | ||
744 | test -n "${INITRAMFS_IMAGE}" ; then | ||
745 | cd ${B} | ||
746 | if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then | ||
747 | fitimage_assemble fit-image-${INITRAMFS_IMAGE}.its fitImage-bundle "" | ||
748 | ln -sf fitImage-bundle ${B}/${KERNEL_OUTPUT_DIR}/fitImage | ||
749 | else | ||
750 | fitimage_assemble fit-image-${INITRAMFS_IMAGE}.its fitImage-${INITRAMFS_IMAGE} 1 | ||
751 | fi | ||
752 | fi | ||
753 | } | ||
754 | |||
755 | addtask assemble_fitimage_initramfs before do_deploy after do_bundle_initramfs | ||
756 | |||
757 | do_kernel_generate_rsa_keys() { | ||
758 | if [ "${UBOOT_SIGN_ENABLE}" = "0" ] && [ "${FIT_GENERATE_KEYS}" = "1" ]; then | ||
759 | bbwarn "FIT_GENERATE_KEYS is set to 1 even though UBOOT_SIGN_ENABLE is set to 0. The keys will not be generated as they won't be used." | ||
760 | fi | ||
761 | |||
762 | if [ "${UBOOT_SIGN_ENABLE}" = "1" ] && [ "${FIT_GENERATE_KEYS}" = "1" ]; then | ||
763 | |||
764 | # Generate keys to sign configuration nodes, only if they don't already exist | ||
765 | if [ ! -f "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".key ] || \ | ||
766 | [ ! -f "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".crt ]; then | ||
767 | |||
768 | # make directory if it does not already exist | ||
769 | mkdir -p "${UBOOT_SIGN_KEYDIR}" | ||
770 | |||
771 | bbnote "Generating RSA private key for signing fitImage" | ||
772 | openssl genrsa ${FIT_KEY_GENRSA_ARGS} -out \ | ||
773 | "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".key \ | ||
774 | "${FIT_SIGN_NUMBITS}" | ||
775 | |||
776 | bbnote "Generating certificate for signing fitImage" | ||
777 | openssl req ${FIT_KEY_REQ_ARGS} "${FIT_KEY_SIGN_PKCS}" \ | ||
778 | -key "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".key \ | ||
779 | -out "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".crt | ||
780 | fi | ||
781 | |||
782 | # Generate keys to sign image nodes, only if they don't already exist | ||
783 | if [ ! -f "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_IMG_KEYNAME}".key ] || \ | ||
784 | [ ! -f "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_IMG_KEYNAME}".crt ]; then | ||
785 | |||
786 | # make directory if it does not already exist | ||
787 | mkdir -p "${UBOOT_SIGN_KEYDIR}" | ||
788 | |||
789 | bbnote "Generating RSA private key for signing fitImage" | ||
790 | openssl genrsa ${FIT_KEY_GENRSA_ARGS} -out \ | ||
791 | "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_IMG_KEYNAME}".key \ | ||
792 | "${FIT_SIGN_NUMBITS}" | ||
793 | |||
794 | bbnote "Generating certificate for signing fitImage" | ||
795 | openssl req ${FIT_KEY_REQ_ARGS} "${FIT_KEY_SIGN_PKCS}" \ | ||
796 | -key "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_IMG_KEYNAME}".key \ | ||
797 | -out "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_IMG_KEYNAME}".crt | ||
798 | fi | ||
799 | fi | ||
800 | } | ||
801 | |||
802 | addtask kernel_generate_rsa_keys before do_assemble_fitimage after do_compile | ||
803 | |||
804 | kernel_deprecated_do_deploy[vardepsexclude] = "DATETIME" | ||
805 | kernel_deprecated_do_deploy:append() { | ||
806 | # Update deploy directory | ||
807 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then | ||
808 | |||
809 | if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then | ||
810 | bbnote "Copying fit-image.its source file..." | ||
811 | install -m 0644 ${B}/fit-image.its "$deployDir/fitImage-its-${KERNEL_FIT_NAME}.its" | ||
812 | if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then | ||
813 | ln -snf fitImage-its-${KERNEL_FIT_NAME}.its "$deployDir/fitImage-its-${KERNEL_FIT_LINK_NAME}" | ||
814 | fi | ||
815 | |||
816 | bbnote "Copying linux.bin file..." | ||
817 | install -m 0644 ${B}/linux.bin $deployDir/fitImage-linux.bin-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT} | ||
818 | if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then | ||
819 | ln -snf fitImage-linux.bin-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT} "$deployDir/fitImage-linux.bin-${KERNEL_FIT_LINK_NAME}" | ||
820 | fi | ||
821 | fi | ||
822 | |||
823 | if [ -n "${INITRAMFS_IMAGE}" ]; then | ||
824 | bbnote "Copying fit-image-${INITRAMFS_IMAGE}.its source file..." | ||
825 | install -m 0644 ${B}/fit-image-${INITRAMFS_IMAGE}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its" | ||
826 | if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then | ||
827 | ln -snf fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}" | ||
828 | fi | ||
829 | |||
830 | if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then | ||
831 | bbnote "Copying fitImage-${INITRAMFS_IMAGE} file..." | ||
832 | install -m 0644 ${B}/${KERNEL_OUTPUT_DIR}/fitImage-${INITRAMFS_IMAGE} "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT}" | ||
833 | if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then | ||
834 | ln -snf fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT} "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}" | ||
835 | fi | ||
836 | fi | ||
837 | fi | ||
838 | fi | ||
839 | } | ||
diff --git a/meta-ti-bsp/classes/kernel_deprecated.bbclass b/meta-ti-bsp/classes/kernel_deprecated.bbclass deleted file mode 100644 index 328a08fd..00000000 --- a/meta-ti-bsp/classes/kernel_deprecated.bbclass +++ /dev/null | |||
@@ -1,869 +0,0 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | inherit linux-kernel-base kernel-module-split | ||
8 | |||
9 | COMPATIBLE_HOST = ".*-linux" | ||
10 | |||
11 | KERNEL_PACKAGE_NAME ??= "kernel" | ||
12 | KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }" | ||
13 | |||
14 | PROVIDES += "virtual/kernel" | ||
15 | DEPENDS += "virtual/cross-binutils virtual/cross-cc kmod-native bc-native bison-native" | ||
16 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.lzo", "lzop-native", "", d)}" | ||
17 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.lz4", "lz4-native", "", d)}" | ||
18 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.zst", "zstd-native", "", d)}" | ||
19 | PACKAGE_WRITE_DEPS += "depmodwrapper-cross" | ||
20 | |||
21 | do_deploy[depends] += "depmodwrapper-cross:do_populate_sysroot gzip-native:do_populate_sysroot" | ||
22 | do_clean[depends] += "make-mod-scripts:do_clean" | ||
23 | |||
24 | # CPE entries from NVD use linux_kernel, but the raw CVE entries from the kernel CNA have | ||
25 | # vendor: linux and product: linux. Note that multiple distributions use "linux" as a product | ||
26 | # name, so we need to fill vendor to avoid false positives | ||
27 | CVE_PRODUCT ?= "linux_kernel linux:linux" | ||
28 | |||
29 | S = "${STAGING_KERNEL_DIR}" | ||
30 | B = "${WORKDIR}/build" | ||
31 | KBUILD_OUTPUT = "${B}" | ||
32 | OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT" | ||
33 | |||
34 | # we include gcc above, we dont need virtual/libc | ||
35 | INHIBIT_DEFAULT_DEPS = "1" | ||
36 | |||
37 | KERNEL_IMAGETYPE ?= "zImage" | ||
38 | INITRAMFS_IMAGE ?= "" | ||
39 | INITRAMFS_TASK ?= "" | ||
40 | INITRAMFS_IMAGE_BUNDLE ?= "" | ||
41 | INITRAMFS_DEPLOY_DIR_IMAGE ?= "${DEPLOY_DIR_IMAGE}" | ||
42 | INITRAMFS_MULTICONFIG ?= "" | ||
43 | |||
44 | # KERNEL_VERSION is extracted from source code. It is evaluated as | ||
45 | # None for the first parsing, since the code has not been fetched. | ||
46 | # After the code is fetched, it will be evaluated as real version | ||
47 | # number and cause kernel to be rebuilt. To avoid this, make | ||
48 | # KERNEL_VERSION_NAME and KERNEL_VERSION_PKG_NAME depend on | ||
49 | # LINUX_VERSION which is a constant. | ||
50 | KERNEL_VERSION_NAME = "${@d.getVar('KERNEL_VERSION') or ""}" | ||
51 | KERNEL_VERSION_NAME[vardepvalue] = "${LINUX_VERSION}" | ||
52 | KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" | ||
53 | KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}" | ||
54 | |||
55 | python __anonymous () { | ||
56 | pn = d.getVar("PN") | ||
57 | kpn = d.getVar("KERNEL_PACKAGE_NAME") | ||
58 | |||
59 | # XXX Remove this after bug 11905 is resolved | ||
60 | # FILES:${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly | ||
61 | if kpn == pn: | ||
62 | bb.warn("Some packages (E.g. *-dev) might be missing due to " | ||
63 | "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)") | ||
64 | |||
65 | # The default kernel recipe builds in a shared location defined by | ||
66 | # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR. | ||
67 | # Set these variables to directories under ${WORKDIR} in alternate | ||
68 | # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they | ||
69 | # may build in parallel with the default kernel without clobbering. | ||
70 | if kpn != "kernel": | ||
71 | workdir = d.getVar("WORKDIR") | ||
72 | sourceDir = os.path.join(workdir, 'kernel-source') | ||
73 | artifactsDir = os.path.join(workdir, 'kernel-build-artifacts') | ||
74 | d.setVar("STAGING_KERNEL_DIR", sourceDir) | ||
75 | d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir) | ||
76 | |||
77 | # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES | ||
78 | type = d.getVar('KERNEL_IMAGETYPE') or "" | ||
79 | alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or "" | ||
80 | types = d.getVar('KERNEL_IMAGETYPES') or "" | ||
81 | if type not in types.split(): | ||
82 | types = (type + ' ' + types).strip() | ||
83 | if alttype not in types.split(): | ||
84 | types = (alttype + ' ' + types).strip() | ||
85 | d.setVar('KERNEL_IMAGETYPES', types) | ||
86 | |||
87 | # KERNEL_IMAGETYPES may contain a mixture of image types supported directly | ||
88 | # by the kernel build system and types which are created by post-processing | ||
89 | # the output of the kernel build system (e.g. compressing vmlinux -> | ||
90 | # vmlinux.gz in kernel_deprecated_do_transform_kernel()). | ||
91 | # KERNEL_IMAGETYPE_FOR_MAKE should contain only image types supported | ||
92 | # directly by the kernel build system. | ||
93 | if not d.getVar('KERNEL_IMAGETYPE_FOR_MAKE'): | ||
94 | typeformake = set() | ||
95 | for type in types.split(): | ||
96 | if type == 'vmlinux.gz': | ||
97 | type = 'vmlinux' | ||
98 | typeformake.add(type) | ||
99 | |||
100 | d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', ' '.join(sorted(typeformake))) | ||
101 | |||
102 | kname = d.getVar('KERNEL_PACKAGE_NAME') or "kernel" | ||
103 | imagedest = d.getVar('KERNEL_IMAGEDEST') | ||
104 | |||
105 | for type in types.split(): | ||
106 | if bb.data.inherits_class('nopackages', d): | ||
107 | continue | ||
108 | typelower = type.lower() | ||
109 | d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower)) | ||
110 | d.setVar('FILES:' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type) | ||
111 | d.appendVar('RDEPENDS:%s-image' % kname, ' %s-image-%s (= ${EXTENDPKGV})' % (kname, typelower)) | ||
112 | splitmods = d.getVar("KERNEL_SPLIT_MODULES") | ||
113 | if splitmods != '1': | ||
114 | d.appendVar('RDEPENDS:%s-image' % kname, ' %s-modules (= ${EXTENDPKGV})' % kname) | ||
115 | d.appendVar('RDEPENDS:%s-image-%s' % (kname, typelower), ' %s-modules-${KERNEL_VERSION_PKG_NAME} (= ${EXTENDPKGV})' % kname) | ||
116 | d.setVar('PKG:%s-modules' % kname, '%s-modules-${KERNEL_VERSION_PKG_NAME}' % kname) | ||
117 | d.appendVar('RPROVIDES:%s-modules' % kname, ' %s-modules-${KERNEL_VERSION_PKG_NAME}' % kname) | ||
118 | |||
119 | d.setVar('PKG:%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower)) | ||
120 | d.setVar('ALLOW_EMPTY:%s-image-%s' % (kname, typelower), '1') | ||
121 | |||
122 | if d.getVar('KERNEL_IMAGETYPE_SYMLINK') == '1': | ||
123 | d.prependVar('pkg_postinst:%s-image-%s' % (kname,typelower), """set +e | ||
124 | if [ -n "$D" ]; then | ||
125 | ln -sf %s-${KERNEL_VERSION} $D/${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 | ||
126 | else | ||
127 | ln -sf %s-${KERNEL_VERSION} ${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 | ||
128 | if [ $? -ne 0 ]; then | ||
129 | echo "Filesystem on ${KERNEL_IMAGEDEST}/ doesn't support symlinks, falling back to copied image (%s)." | ||
130 | install -m 0644 ${KERNEL_IMAGEDEST}/%s-${KERNEL_VERSION} ${KERNEL_IMAGEDEST}/%s | ||
131 | fi | ||
132 | fi | ||
133 | set -e | ||
134 | """ % (type, type, type, type, type, type, type)) | ||
135 | d.setVar('pkg_postrm:%s-image-%s' % (kname,typelower), """set +e | ||
136 | if [ -f "${KERNEL_IMAGEDEST}/%s" -o -L "${KERNEL_IMAGEDEST}/%s" ]; then | ||
137 | rm -f ${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 | ||
138 | fi | ||
139 | set -e | ||
140 | """ % (type, type, type)) | ||
141 | |||
142 | |||
143 | image = d.getVar('INITRAMFS_IMAGE') | ||
144 | # If the INTIRAMFS_IMAGE is set but the INITRAMFS_IMAGE_BUNDLE is set to 0, | ||
145 | # the do_bundle_initramfs does nothing, but the INITRAMFS_IMAGE is built | ||
146 | # standalone for use by wic and other tools. | ||
147 | if image: | ||
148 | if d.getVar('INITRAMFS_MULTICONFIG'): | ||
149 | d.appendVarFlag('do_bundle_initramfs', 'mcdepends', ' mc:${BB_CURRENT_MC}:${INITRAMFS_MULTICONFIG}:${INITRAMFS_IMAGE}:do_image_complete') | ||
150 | else: | ||
151 | d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') | ||
152 | if image and bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')): | ||
153 | bb.build.addtask('do_transform_bundled_initramfs', 'do_deploy', 'do_bundle_initramfs', d) | ||
154 | |||
155 | # NOTE: setting INITRAMFS_TASK is for backward compatibility | ||
156 | # The preferred method is to set INITRAMFS_IMAGE, because | ||
157 | # this INITRAMFS_TASK has circular dependency problems | ||
158 | # if the initramfs requires kernel modules | ||
159 | image_task = d.getVar('INITRAMFS_TASK') | ||
160 | if image_task: | ||
161 | d.appendVarFlag('do_configure', 'depends', ' ${INITRAMFS_TASK}') | ||
162 | } | ||
163 | |||
164 | # Here we pull in all various kernel image types which we support. | ||
165 | # | ||
166 | # In case you're wondering why kernel.bbclass inherits the other image | ||
167 | # types instead of the other way around, the reason for that is to | ||
168 | # maintain compatibility with various currently existing meta-layers. | ||
169 | # By pulling in the various kernel image types here, we retain the | ||
170 | # original behavior of kernel.bbclass, so no meta-layers should get | ||
171 | # broken. | ||
172 | # | ||
173 | # KERNEL_CLASSES by default pulls in kernel-uimage.bbclass, since this | ||
174 | # used to be the default behavior when only uImage was supported. This | ||
175 | # variable can be appended by users who implement support for new kernel | ||
176 | # image types. | ||
177 | |||
178 | KERNEL_CLASSES ?= " kernel-uimage " | ||
179 | inherit_defer ${KERNEL_CLASSES} | ||
180 | |||
181 | # Old style kernels may set ${S} = ${WORKDIR}/git for example | ||
182 | # We need to move these over to STAGING_KERNEL_DIR. We can't just | ||
183 | # create the symlink in advance as the git fetcher can't cope with | ||
184 | # the symlink. | ||
185 | do_unpack[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}" | ||
186 | do_clean[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}" | ||
187 | python do_symlink_kernsrc () { | ||
188 | s = d.getVar("S") | ||
189 | kernsrc = d.getVar("STAGING_KERNEL_DIR") | ||
190 | if s != kernsrc: | ||
191 | bb.utils.mkdirhier(kernsrc) | ||
192 | bb.utils.remove(kernsrc, recurse=True) | ||
193 | if s[-1] == '/': | ||
194 | # drop trailing slash, so that os.symlink(kernsrc, s) doesn't use s as | ||
195 | # directory name and fail | ||
196 | s = s[:-1] | ||
197 | if d.getVar("EXTERNALSRC"): | ||
198 | # With EXTERNALSRC S will not be wiped so we can symlink to it | ||
199 | os.symlink(s, kernsrc) | ||
200 | else: | ||
201 | import shutil | ||
202 | shutil.move(s, kernsrc) | ||
203 | os.symlink(kernsrc, s) | ||
204 | } | ||
205 | # do_patch is normally ordered before do_configure, but | ||
206 | # externalsrc.bbclass deletes do_patch, breaking the dependency of | ||
207 | # do_configure on do_symlink_kernsrc. | ||
208 | addtask symlink_kernsrc before do_patch do_configure after do_unpack | ||
209 | |||
210 | inherit kernel-arch deploy | ||
211 | |||
212 | PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*" | ||
213 | PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*" | ||
214 | PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*" | ||
215 | |||
216 | export OS = "${TARGET_OS}" | ||
217 | export CROSS_COMPILE = "${TARGET_PREFIX}" | ||
218 | |||
219 | KERNEL_RELEASE ?= "${KERNEL_VERSION}" | ||
220 | |||
221 | # The directory where built kernel lies in the kernel tree | ||
222 | KERNEL_OUTPUT_DIR ?= "arch/${ARCH}/boot" | ||
223 | KERNEL_IMAGEDEST ?= "boot" | ||
224 | KERNEL_DTBDEST ?= "${KERNEL_IMAGEDEST}" | ||
225 | KERNEL_DTBVENDORED ?= "0" | ||
226 | |||
227 | # | ||
228 | # configuration | ||
229 | # | ||
230 | KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}" | ||
231 | |||
232 | # kernels are generally machine specific | ||
233 | PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
234 | |||
235 | # U-Boot support | ||
236 | UBOOT_ENTRYPOINT ?= "0x20008000" | ||
237 | UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}" | ||
238 | |||
239 | # Some Linux kernel configurations need additional parameters on the command line | ||
240 | KERNEL_EXTRA_ARGS ?= "" | ||
241 | |||
242 | EXTRA_OEMAKE += ' CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" STRIP="${KERNEL_STRIP}"' | ||
243 | EXTRA_OEMAKE += ' HOSTCC="${BUILD_CC}" HOSTCFLAGS="${BUILD_CFLAGS}" HOSTLDFLAGS="${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"' | ||
244 | EXTRA_OEMAKE += ' HOSTCXX="${BUILD_CXX}" HOSTCXXFLAGS="${BUILD_CXXFLAGS}"' | ||
245 | # Only for newer kernels (5.19+), native pkg-config variables are set for older kernels when building kernel and modules | ||
246 | EXTRA_OEMAKE += ' HOSTPKG_CONFIG="pkg-config-native"' | ||
247 | |||
248 | KERNEL_ALT_IMAGETYPE ??= "" | ||
249 | |||
250 | copy_initramfs() { | ||
251 | echo "Copying initramfs into ./usr ..." | ||
252 | # In case the directory is not created yet from the first pass compile: | ||
253 | mkdir -p ${B}/usr | ||
254 | # Find and use the first initramfs image archive type we find | ||
255 | rm -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio | ||
256 | for img in cpio cpio.gz cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst; do | ||
257 | if [ -e "${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" ]; then | ||
258 | cp ${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/. | ||
259 | case $img in | ||
260 | *gz) | ||
261 | echo "gzip decompressing image" | ||
262 | gunzip -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img | ||
263 | break | ||
264 | ;; | ||
265 | *lz4) | ||
266 | echo "lz4 decompressing image" | ||
267 | lz4 -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio | ||
268 | break | ||
269 | ;; | ||
270 | *lzo) | ||
271 | echo "lzo decompressing image" | ||
272 | lzop -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img | ||
273 | break | ||
274 | ;; | ||
275 | *lzma) | ||
276 | echo "lzma decompressing image" | ||
277 | lzma -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img | ||
278 | break | ||
279 | ;; | ||
280 | *xz) | ||
281 | echo "xz decompressing image" | ||
282 | xz -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img | ||
283 | break | ||
284 | ;; | ||
285 | *zst) | ||
286 | echo "zst decompressing image" | ||
287 | zstd -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img | ||
288 | break | ||
289 | ;; | ||
290 | esac | ||
291 | break | ||
292 | fi | ||
293 | done | ||
294 | # Verify that the above loop found a initramfs, fail otherwise | ||
295 | [ -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio ] && echo "Finished copy of initramfs into ./usr" || die "Could not find any ${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.cpio{.gz|.lz4|.lzo|.lzma|.xz|.zst) for bundling; INITRAMFS_IMAGE_NAME might be wrong." | ||
296 | } | ||
297 | |||
298 | do_bundle_initramfs () { | ||
299 | if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then | ||
300 | echo "Creating a kernel image with a bundled initramfs..." | ||
301 | copy_initramfs | ||
302 | # Backing up kernel image relies on its type(regular file or symbolic link) | ||
303 | tmp_path="" | ||
304 | for imageType in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do | ||
305 | if [ -h ${KERNEL_OUTPUT_DIR}/$imageType ] ; then | ||
306 | linkpath=`readlink -n ${KERNEL_OUTPUT_DIR}/$imageType` | ||
307 | realpath=`readlink -fn ${KERNEL_OUTPUT_DIR}/$imageType` | ||
308 | mv -f $realpath $realpath.bak | ||
309 | tmp_path=$tmp_path" "$imageType"#"$linkpath"#"$realpath | ||
310 | elif [ -f ${KERNEL_OUTPUT_DIR}/$imageType ]; then | ||
311 | mv -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.bak | ||
312 | tmp_path=$tmp_path" "$imageType"##" | ||
313 | fi | ||
314 | done | ||
315 | use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio | ||
316 | kernel_deprecated_do_compile | ||
317 | # Restoring kernel image | ||
318 | for tp in $tmp_path ; do | ||
319 | imageType=`echo $tp|cut -d "#" -f 1` | ||
320 | linkpath=`echo $tp|cut -d "#" -f 2` | ||
321 | realpath=`echo $tp|cut -d "#" -f 3` | ||
322 | if [ -n "$realpath" ]; then | ||
323 | mv -f $realpath $realpath.initramfs | ||
324 | mv -f $realpath.bak $realpath | ||
325 | ln -sf $linkpath.initramfs ${B}/${KERNEL_OUTPUT_DIR}/$imageType.initramfs | ||
326 | else | ||
327 | mv -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.initramfs | ||
328 | mv -f ${KERNEL_OUTPUT_DIR}/$imageType.bak ${KERNEL_OUTPUT_DIR}/$imageType | ||
329 | fi | ||
330 | done | ||
331 | fi | ||
332 | } | ||
333 | do_bundle_initramfs[dirs] = "${B}" | ||
334 | |||
335 | kernel_deprecated_do_transform_bundled_initramfs() { | ||
336 | # vmlinux.gz is not built by kernel | ||
337 | if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then | ||
338 | gzip -9cn < ${KERNEL_OUTPUT_DIR}/vmlinux.initramfs > ${KERNEL_OUTPUT_DIR}/vmlinux.gz.initramfs | ||
339 | fi | ||
340 | } | ||
341 | do_transform_bundled_initramfs[dirs] = "${B}" | ||
342 | |||
343 | python do_package:prepend () { | ||
344 | d.setVar('STRIP', d.getVar('KERNEL_STRIP').strip()) | ||
345 | } | ||
346 | |||
347 | python do_devshell:prepend () { | ||
348 | os.environ["LDFLAGS"] = '' | ||
349 | } | ||
350 | |||
351 | addtask bundle_initramfs after do_install before do_deploy | ||
352 | |||
353 | KERNEL_DEBUG_TIMESTAMPS ??= "0" | ||
354 | |||
355 | kernel_deprecated_do_compile() { | ||
356 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE | ||
357 | |||
358 | # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native) | ||
359 | export PKG_CONFIG_DIR="${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig" | ||
360 | export PKG_CONFIG_PATH="$PKG_CONFIG_DIR:${STAGING_DATADIR_NATIVE}/pkgconfig" | ||
361 | export PKG_CONFIG_LIBDIR="$PKG_CONFIG_DIR" | ||
362 | export PKG_CONFIG_SYSROOT_DIR="" | ||
363 | |||
364 | if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then | ||
365 | # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not | ||
366 | # be set.... | ||
367 | if [ "${SOURCE_DATE_EPOCH}" = "" -o "${SOURCE_DATE_EPOCH}" = "0" ]; then | ||
368 | # The source directory is not necessarily a git repository, so we | ||
369 | # specify the git-dir to ensure that git does not query a | ||
370 | # repository in any parent directory. | ||
371 | SOURCE_DATE_EPOCH=`git --git-dir="${S}/.git" log -1 --pretty=%ct 2>/dev/null || echo "${REPRODUCIBLE_TIMESTAMP_ROOTFS}"` | ||
372 | fi | ||
373 | |||
374 | ts=`LC_ALL=C date -d @$SOURCE_DATE_EPOCH` | ||
375 | export KBUILD_BUILD_TIMESTAMP="$ts" | ||
376 | export KCONFIG_NOTIMESTAMP=1 | ||
377 | bbnote "KBUILD_BUILD_TIMESTAMP: $ts" | ||
378 | else | ||
379 | ts=`LC_ALL=C date` | ||
380 | export KBUILD_BUILD_TIMESTAMP="$ts" | ||
381 | bbnote "KBUILD_BUILD_TIMESTAMP: $ts" | ||
382 | fi | ||
383 | # The $use_alternate_initrd is only set from | ||
384 | # do_bundle_initramfs() This variable is specifically for the | ||
385 | # case where we are making a second pass at the kernel | ||
386 | # compilation and we want to force the kernel build to use a | ||
387 | # different initramfs image. The way to do that in the kernel | ||
388 | # is to specify: | ||
389 | # make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio | ||
390 | if [ "$use_alternate_initrd" = "" ] && [ "${INITRAMFS_TASK}" != "" ] ; then | ||
391 | # The old style way of copying an prebuilt image and building it | ||
392 | # is turned on via INTIRAMFS_TASK != "" | ||
393 | copy_initramfs | ||
394 | use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio | ||
395 | fi | ||
396 | for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do | ||
397 | oe_runmake ${PARALLEL_MAKE} ${typeformake} ${KERNEL_EXTRA_ARGS} $use_alternate_initrd | ||
398 | done | ||
399 | } | ||
400 | |||
401 | kernel_deprecated_do_transform_kernel() { | ||
402 | # vmlinux.gz is not built by kernel | ||
403 | if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then | ||
404 | mkdir -p "${KERNEL_OUTPUT_DIR}" | ||
405 | gzip -9cn < ${B}/vmlinux > "${KERNEL_OUTPUT_DIR}/vmlinux.gz" | ||
406 | fi | ||
407 | } | ||
408 | do_transform_kernel[dirs] = "${B}" | ||
409 | addtask transform_kernel after do_compile before do_install | ||
410 | |||
411 | do_compile_kernelmodules() { | ||
412 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE | ||
413 | |||
414 | # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native) | ||
415 | export PKG_CONFIG_DIR="${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig" | ||
416 | export PKG_CONFIG_PATH="$PKG_CONFIG_DIR:${STAGING_DATADIR_NATIVE}/pkgconfig" | ||
417 | export PKG_CONFIG_LIBDIR="$PKG_CONFIG_DIR" | ||
418 | export PKG_CONFIG_SYSROOT_DIR="" | ||
419 | |||
420 | if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then | ||
421 | # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not | ||
422 | # be set.... | ||
423 | if [ "${SOURCE_DATE_EPOCH}" = "" -o "${SOURCE_DATE_EPOCH}" = "0" ]; then | ||
424 | # The source directory is not necessarily a git repository, so we | ||
425 | # specify the git-dir to ensure that git does not query a | ||
426 | # repository in any parent directory. | ||
427 | SOURCE_DATE_EPOCH=`git --git-dir="${S}/.git" log -1 --pretty=%ct 2>/dev/null || echo "${REPRODUCIBLE_TIMESTAMP_ROOTFS}"` | ||
428 | fi | ||
429 | |||
430 | ts=`LC_ALL=C date -d @$SOURCE_DATE_EPOCH` | ||
431 | export KBUILD_BUILD_TIMESTAMP="$ts" | ||
432 | export KCONFIG_NOTIMESTAMP=1 | ||
433 | bbnote "KBUILD_BUILD_TIMESTAMP: $ts" | ||
434 | else | ||
435 | ts=`LC_ALL=C date` | ||
436 | export KBUILD_BUILD_TIMESTAMP="$ts" | ||
437 | bbnote "KBUILD_BUILD_TIMESTAMP: $ts" | ||
438 | fi | ||
439 | if (grep -q -i -e '^CONFIG_MODULES=y$' ${B}/.config); then | ||
440 | oe_runmake -C ${B} ${PARALLEL_MAKE} modules ${KERNEL_EXTRA_ARGS} | ||
441 | |||
442 | # Module.symvers gets updated during the | ||
443 | # building of the kernel modules. We need to | ||
444 | # update this in the shared workdir since some | ||
445 | # external kernel modules has a dependency on | ||
446 | # other kernel modules and will look at this | ||
447 | # file to do symbol lookups | ||
448 | cp ${B}/Module.symvers ${STAGING_KERNEL_BUILDDIR}/ | ||
449 | # 5.10+ kernels have module.lds that we need to copy for external module builds | ||
450 | if [ -e "${B}/scripts/module.lds" ]; then | ||
451 | install -Dm 0644 ${B}/scripts/module.lds ${STAGING_KERNEL_BUILDDIR}/scripts/module.lds | ||
452 | fi | ||
453 | else | ||
454 | bbnote "no modules to compile" | ||
455 | fi | ||
456 | } | ||
457 | addtask compile_kernelmodules after do_compile before do_strip | ||
458 | |||
459 | kernel_deprecated_do_install() { | ||
460 | # | ||
461 | # First install the modules | ||
462 | # | ||
463 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE | ||
464 | if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then | ||
465 | oe_runmake DEPMOD=echo MODLIB=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION} INSTALL_FW_PATH=${D}${nonarch_base_libdir}/firmware modules_install | ||
466 | rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build" | ||
467 | rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source" | ||
468 | # Remove empty module directories to prevent QA issues | ||
469 | [ -d "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" ] && find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete | ||
470 | else | ||
471 | bbnote "no modules to install" | ||
472 | fi | ||
473 | |||
474 | # | ||
475 | # Install various kernel output (zImage, map file, config, module support files) | ||
476 | # | ||
477 | install -d ${D}/${KERNEL_IMAGEDEST} | ||
478 | |||
479 | # | ||
480 | # When including an initramfs bundle inside a FIT image, the fitImage is created after the install task | ||
481 | # by do_assemble_fitimage_initramfs. | ||
482 | # This happens after the generation of the initramfs bundle (done by do_bundle_initramfs). | ||
483 | # So, at the level of the install task we should not try to install the fitImage. fitImage is still not | ||
484 | # generated yet. | ||
485 | # After the generation of the fitImage, the deploy task copies the fitImage from the build directory to | ||
486 | # the deploy folder. | ||
487 | # | ||
488 | |||
489 | for imageType in ${KERNEL_IMAGETYPES} ; do | ||
490 | if [ $imageType != "fitImage" ] || [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ] ; then | ||
491 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType ${D}/${KERNEL_IMAGEDEST}/$imageType-${KERNEL_VERSION} | ||
492 | fi | ||
493 | done | ||
494 | |||
495 | install -m 0644 System.map ${D}/${KERNEL_IMAGEDEST}/System.map-${KERNEL_VERSION} | ||
496 | install -m 0644 .config ${D}/${KERNEL_IMAGEDEST}/config-${KERNEL_VERSION} | ||
497 | install -m 0644 vmlinux ${D}/${KERNEL_IMAGEDEST}/vmlinux-${KERNEL_VERSION} | ||
498 | ! [ -e Module.symvers ] || install -m 0644 Module.symvers ${D}/${KERNEL_IMAGEDEST}/Module.symvers-${KERNEL_VERSION} | ||
499 | } | ||
500 | |||
501 | # Must be ran no earlier than after do_kernel_checkout or else Makefile won't be in ${S}/Makefile | ||
502 | do_kernel_version_sanity_check() { | ||
503 | if [ "x${KERNEL_VERSION_SANITY_SKIP}" = "x1" ]; then | ||
504 | exit 0 | ||
505 | fi | ||
506 | |||
507 | # The Makefile determines the kernel version shown at runtime | ||
508 | # Don't use KERNEL_VERSION because the headers it grabs the version from aren't generated until do_compile | ||
509 | VERSION=$(grep "^VERSION =" ${S}/Makefile | sed s/.*=\ *//) | ||
510 | PATCHLEVEL=$(grep "^PATCHLEVEL =" ${S}/Makefile | sed s/.*=\ *//) | ||
511 | SUBLEVEL=$(grep "^SUBLEVEL =" ${S}/Makefile | sed s/.*=\ *//) | ||
512 | EXTRAVERSION=$(grep "^EXTRAVERSION =" ${S}/Makefile | sed s/.*=\ *//) | ||
513 | |||
514 | # Build a string for regex and a plain version string | ||
515 | reg="^${VERSION}\.${PATCHLEVEL}" | ||
516 | vers="${VERSION}.${PATCHLEVEL}" | ||
517 | if [ -n "${SUBLEVEL}" ]; then | ||
518 | # Ignoring a SUBLEVEL of zero is fine | ||
519 | if [ "${SUBLEVEL}" = "0" ]; then | ||
520 | reg="${reg}(\.${SUBLEVEL})?" | ||
521 | else | ||
522 | reg="${reg}\.${SUBLEVEL}" | ||
523 | vers="${vers}.${SUBLEVEL}" | ||
524 | fi | ||
525 | fi | ||
526 | vers="${vers}${EXTRAVERSION}" | ||
527 | reg="${reg}${EXTRAVERSION}" | ||
528 | |||
529 | if [ -z `echo ${PV} | grep -E "${reg}"` ]; then | ||
530 | bbfatal "Package Version (${PV}) does not match of kernel being built (${vers}). Please update the PV variable to match the kernel source or set KERNEL_VERSION_SANITY_SKIP=\"1\" in your recipe." | ||
531 | fi | ||
532 | exit 0 | ||
533 | } | ||
534 | |||
535 | addtask shared_workdir after do_compile before do_compile_kernelmodules | ||
536 | addtask shared_workdir_setscene | ||
537 | |||
538 | do_shared_workdir_setscene () { | ||
539 | exit 1 | ||
540 | } | ||
541 | |||
542 | emit_depmod_pkgdata() { | ||
543 | # Stash data for depmod | ||
544 | install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/ | ||
545 | echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion | ||
546 | cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION} | ||
547 | } | ||
548 | |||
549 | PACKAGEFUNCS += "emit_depmod_pkgdata" | ||
550 | |||
551 | do_shared_workdir[cleandirs] += " ${STAGING_KERNEL_BUILDDIR}" | ||
552 | do_shared_workdir () { | ||
553 | cd ${B} | ||
554 | |||
555 | kerneldir=${STAGING_KERNEL_BUILDDIR} | ||
556 | install -d $kerneldir | ||
557 | |||
558 | # | ||
559 | # Store the kernel version in sysroots for module-base.bbclass | ||
560 | # | ||
561 | |||
562 | echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion | ||
563 | echo "${KERNEL_LOCALVERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-localversion | ||
564 | |||
565 | # Copy files required for module builds | ||
566 | cp System.map $kerneldir/System.map-${KERNEL_VERSION} | ||
567 | ! [ -e Module.symvers ] || cp Module.symvers $kerneldir/ | ||
568 | cp .config $kerneldir/ | ||
569 | mkdir -p $kerneldir/include/config | ||
570 | cp include/config/kernel.release $kerneldir/include/config/kernel.release | ||
571 | if [ -e certs/signing_key.x509 ]; then | ||
572 | # The signing_key.* files are stored in the certs/ dir in | ||
573 | # newer Linux kernels | ||
574 | mkdir -p $kerneldir/certs | ||
575 | cp certs/signing_key.* $kerneldir/certs/ | ||
576 | elif [ -e signing_key.priv ]; then | ||
577 | cp signing_key.* $kerneldir/ | ||
578 | fi | ||
579 | |||
580 | # We can also copy over all the generated files and avoid special cases | ||
581 | # like version.h, but we've opted to keep this small until file creep starts | ||
582 | # to happen | ||
583 | if [ -e include/linux/version.h ]; then | ||
584 | mkdir -p $kerneldir/include/linux | ||
585 | cp include/linux/version.h $kerneldir/include/linux/version.h | ||
586 | fi | ||
587 | |||
588 | # As of Linux kernel version 3.0.1, the clean target removes | ||
589 | # arch/powerpc/lib/crtsavres.o which is present in | ||
590 | # KBUILD_LDFLAGS_MODULE, making it required to build external modules. | ||
591 | if [ ${ARCH} = "powerpc" ]; then | ||
592 | if [ -e arch/powerpc/lib/crtsavres.o ]; then | ||
593 | mkdir -p $kerneldir/arch/powerpc/lib/ | ||
594 | cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o | ||
595 | fi | ||
596 | fi | ||
597 | |||
598 | if [ -d include/generated ]; then | ||
599 | mkdir -p $kerneldir/include/generated/ | ||
600 | cp -fR include/generated/* $kerneldir/include/generated/ | ||
601 | fi | ||
602 | |||
603 | if [ -d arch/${ARCH}/include/generated ]; then | ||
604 | mkdir -p $kerneldir/arch/${ARCH}/include/generated/ | ||
605 | cp -fR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/ | ||
606 | fi | ||
607 | |||
608 | if (grep -q -i -e '^CONFIG_UNWINDER_ORC=y$' $kerneldir/.config); then | ||
609 | # With CONFIG_UNWINDER_ORC (the default in 4.14), objtool is required for | ||
610 | # out-of-tree modules to be able to generate object files. | ||
611 | if [ -x tools/objtool/objtool ]; then | ||
612 | mkdir -p ${kerneldir}/tools/objtool | ||
613 | cp tools/objtool/objtool ${kerneldir}/tools/objtool/ | ||
614 | fi | ||
615 | fi | ||
616 | |||
617 | # When building with CONFIG_MODVERSIONS=y and CONFIG_RANDSTRUCT=y we need | ||
618 | # to copy the build assets generated for the randstruct seed to | ||
619 | # STAGING_KERNEL_BUILDDIR, otherwise the out-of-tree modules build will | ||
620 | # generate those assets which will result in a different | ||
621 | # RANDSTRUCT_HASHED_SEED | ||
622 | if [ -d scripts/basic ]; then | ||
623 | mkdir -p ${kerneldir}/scripts | ||
624 | cp -r scripts/basic ${kerneldir}/scripts | ||
625 | fi | ||
626 | |||
627 | if [ -d scripts/gcc-plugins ]; then | ||
628 | mkdir -p ${kerneldir}/scripts | ||
629 | cp -r scripts/gcc-plugins ${kerneldir}/scripts | ||
630 | fi | ||
631 | |||
632 | } | ||
633 | |||
634 | # We don't need to stage anything, not the modules/firmware since those would clash with linux-firmware | ||
635 | SYSROOT_DIRS = "" | ||
636 | |||
637 | KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} olddefconfig || oe_runmake -C ${S} O=${B} oldnoconfig" | ||
638 | |||
639 | python check_oldest_kernel() { | ||
640 | oldest_kernel = d.getVar('OLDEST_KERNEL') | ||
641 | kernel_version = d.getVar('KERNEL_VERSION') | ||
642 | tclibc = d.getVar('TCLIBC') | ||
643 | if tclibc == 'glibc': | ||
644 | kernel_version = kernel_version.split('-', 1)[0] | ||
645 | if oldest_kernel and kernel_version: | ||
646 | if bb.utils.vercmp_string(kernel_version, oldest_kernel) < 0: | ||
647 | bb.warn('%s: OLDEST_KERNEL is "%s" but the version of the kernel you are building is "%s" - therefore %s as built may not be compatible with this kernel. Either set OLDEST_KERNEL to an older version, or build a newer kernel.' % (d.getVar('PN'), oldest_kernel, kernel_version, tclibc)) | ||
648 | } | ||
649 | |||
650 | check_oldest_kernel[vardepsexclude] += "OLDEST_KERNEL KERNEL_VERSION" | ||
651 | do_compile[postfuncs] += "check_oldest_kernel" | ||
652 | |||
653 | KERNEL_LOCALVERSION ??= "" | ||
654 | |||
655 | # 6.3+ requires the variable LOCALVERSION to be set to not get a "+" in | ||
656 | # the local version. Having it empty means nothing will be added, and any | ||
657 | # value will be appended to the local kernel version. This replaces the | ||
658 | # use of .scmversion file for setting a localversion without using | ||
659 | # the CONFIG_LOCALVERSION option. | ||
660 | # | ||
661 | # Note: This class saves the value of localversion to a file | ||
662 | # so other recipes like make-mod-scripts can restore it via the | ||
663 | # helper function get_kernellocalversion_file | ||
664 | export LOCALVERSION = "${KERNEL_LOCALVERSION}" | ||
665 | |||
666 | kernel_deprecated_do_configure() { | ||
667 | # fixes extra + in /lib/modules/2.6.37+ | ||
668 | # $ scripts/setlocalversion . => + | ||
669 | # $ make kernelversion => 2.6.37 | ||
670 | # $ make kernelrelease => 2.6.37+ | ||
671 | # See kernel-arch.bbclass for post v6.3 removal of the extra | ||
672 | # + in localversion. .scmversion is no longer used, and the | ||
673 | # variable LOCALVERSION must be used | ||
674 | if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ]; then | ||
675 | echo ${KERNEL_LOCALVERSION} > ${B}/.scmversion | ||
676 | echo ${KERNEL_LOCALVERSION} > ${S}/.scmversion | ||
677 | fi | ||
678 | |||
679 | if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then | ||
680 | mv "${S}/.config" "${B}/.config" | ||
681 | fi | ||
682 | |||
683 | # Copy defconfig to .config if .config does not exist. This allows | ||
684 | # recipes to manage the .config themselves in do_configure:prepend(). | ||
685 | if [ -f "${UNPACKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then | ||
686 | cp "${UNPACKDIR}/defconfig" "${B}/.config" | ||
687 | fi | ||
688 | |||
689 | ${KERNEL_CONFIG_COMMAND} | ||
690 | } | ||
691 | |||
692 | inherit cml1 pkgconfig | ||
693 | |||
694 | EXPORT_FUNCTIONS do_compile do_transform_kernel do_transform_bundled_initramfs do_install do_configure | ||
695 | |||
696 | # kernel-base becomes kernel-${KERNEL_VERSION} | ||
697 | # kernel-image becomes kernel-image-${KERNEL_VERSION} | ||
698 | PACKAGES = "${KERNEL_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules ${KERNEL_PACKAGE_NAME}-dbg" | ||
699 | FILES:${PN} = "" | ||
700 | FILES:${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin.modinfo" | ||
701 | FILES:${KERNEL_PACKAGE_NAME}-image = "" | ||
702 | FILES:${KERNEL_PACKAGE_NAME}-dev = "/${KERNEL_IMAGEDEST}/System.map* /${KERNEL_IMAGEDEST}/Module.symvers* /${KERNEL_IMAGEDEST}/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build" | ||
703 | FILES:${KERNEL_PACKAGE_NAME}-vmlinux = "/${KERNEL_IMAGEDEST}/vmlinux-${KERNEL_VERSION_NAME}" | ||
704 | FILES:${KERNEL_PACKAGE_NAME}-modules = "" | ||
705 | FILES:${KERNEL_PACKAGE_NAME}-dbg = "/usr/lib/debug /usr/src/debug" | ||
706 | RDEPENDS:${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base (= ${EXTENDPKGV})" | ||
707 | # Allow machines to override this dependency if kernel image files are | ||
708 | # not wanted in images as standard | ||
709 | RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image (= ${EXTENDPKGV})" | ||
710 | PKG:${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" | ||
711 | RPROVIDES:${KERNEL_PACKAGE_NAME}-image += "${KERNEL_PACKAGE_NAME}-image" | ||
712 | RDEPENDS:${KERNEL_PACKAGE_NAME}-image += "${@oe.utils.conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux (= ${EXTENDPKGV})', '', d)}" | ||
713 | PKG:${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" | ||
714 | RPROVIDES:${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION} ${KERNEL_PACKAGE_NAME}-base" | ||
715 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME} = "1" | ||
716 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-base = "1" | ||
717 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-image = "1" | ||
718 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-modules = "1" | ||
719 | DESCRIPTION:${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package" | ||
720 | |||
721 | pkg_postinst:${KERNEL_PACKAGE_NAME}-base () { | ||
722 | if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then | ||
723 | mkdir -p $D/lib/modules/${KERNEL_VERSION} | ||
724 | fi | ||
725 | if [ -n "$D" ]; then | ||
726 | depmodwrapper -a -b $D ${KERNEL_VERSION} ${KERNEL_PACKAGE_NAME} | ||
727 | else | ||
728 | depmod -a ${KERNEL_VERSION} | ||
729 | fi | ||
730 | } | ||
731 | |||
732 | PACKAGESPLITFUNCS =+ "split_kernel_packages" | ||
733 | |||
734 | python split_kernel_packages () { | ||
735 | do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex=r'^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') | ||
736 | } | ||
737 | |||
738 | # Many scripts want to look in arch/$arch/boot for the bootable | ||
739 | # image. This poses a problem for vmlinux and vmlinuz based | ||
740 | # booting. This task arranges to have vmlinux and vmlinuz appear | ||
741 | # in the normalized directory location. | ||
742 | do_kernel_link_images() { | ||
743 | if [ ! -d "${B}/arch/${ARCH}/boot" ]; then | ||
744 | mkdir ${B}/arch/${ARCH}/boot | ||
745 | fi | ||
746 | cd ${B}/arch/${ARCH}/boot | ||
747 | ln -sf ../../../vmlinux | ||
748 | if [ -f ../../../vmlinuz ]; then | ||
749 | ln -sf ../../../vmlinuz | ||
750 | fi | ||
751 | if [ -f ../../../vmlinuz.bin ]; then | ||
752 | ln -sf ../../../vmlinuz.bin | ||
753 | fi | ||
754 | if [ -f ../../../vmlinux.64 ]; then | ||
755 | ln -sf ../../../vmlinux.64 | ||
756 | fi | ||
757 | } | ||
758 | addtask kernel_link_images after do_compile before do_strip | ||
759 | |||
760 | python do_strip() { | ||
761 | import shutil | ||
762 | |||
763 | strip = d.getVar('KERNEL_STRIP') | ||
764 | extra_sections = d.getVar('KERNEL_IMAGE_STRIP_EXTRA_SECTIONS') | ||
765 | kernel_image = d.getVar('B') + "/" + d.getVar('KERNEL_OUTPUT_DIR') + "/vmlinux" | ||
766 | |||
767 | if (extra_sections and kernel_image.find(d.getVar('KERNEL_IMAGEDEST') + '/vmlinux') != -1): | ||
768 | kernel_image_stripped = kernel_image + ".stripped" | ||
769 | shutil.copy2(kernel_image, kernel_image_stripped) | ||
770 | oe.package.runstrip((kernel_image_stripped, 8, strip, extra_sections)) | ||
771 | bb.debug(1, "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections: " + \ | ||
772 | extra_sections) | ||
773 | } | ||
774 | do_strip[dirs] = "${B}" | ||
775 | |||
776 | addtask strip before do_sizecheck after do_kernel_link_images | ||
777 | |||
778 | # Support checking the kernel size since some kernels need to reside in partitions | ||
779 | # with a fixed length or there is a limit in transferring the kernel to memory. | ||
780 | # If more than one image type is enabled, warn on any that don't fit but only fail | ||
781 | # if none fit. | ||
782 | do_sizecheck() { | ||
783 | if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then | ||
784 | invalid=`echo ${KERNEL_IMAGE_MAXSIZE} | sed 's/[0-9]//g'` | ||
785 | if [ -n "$invalid" ]; then | ||
786 | die "Invalid KERNEL_IMAGE_MAXSIZE: ${KERNEL_IMAGE_MAXSIZE}, should be an integer (The unit is Kbytes)" | ||
787 | fi | ||
788 | at_least_one_fits= | ||
789 | for imageType in ${KERNEL_IMAGETYPES} ; do | ||
790 | size=`du -ks ${B}/${KERNEL_OUTPUT_DIR}/$imageType | awk '{print $1}'` | ||
791 | if [ $size -gt ${KERNEL_IMAGE_MAXSIZE} ]; then | ||
792 | bbwarn "This kernel $imageType (size=$size(K) > ${KERNEL_IMAGE_MAXSIZE}(K)) is too big for your device." | ||
793 | else | ||
794 | at_least_one_fits=y | ||
795 | fi | ||
796 | done | ||
797 | if [ -z "$at_least_one_fits" ]; then | ||
798 | die "All kernel images are too big for your device. Please reduce the size of the kernel by making more of it modular." | ||
799 | fi | ||
800 | fi | ||
801 | } | ||
802 | do_sizecheck[dirs] = "${B}" | ||
803 | |||
804 | addtask sizecheck before do_install after do_strip | ||
805 | |||
806 | inherit kernel-artifact-names | ||
807 | |||
808 | kernel_deprecated_do_deploy() { | ||
809 | deployDir="${DEPLOYDIR}" | ||
810 | if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then | ||
811 | deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}" | ||
812 | mkdir "$deployDir" | ||
813 | fi | ||
814 | |||
815 | for imageType in ${KERNEL_IMAGETYPES} ; do | ||
816 | baseName=$imageType-${KERNEL_IMAGE_NAME} | ||
817 | |||
818 | if [ -s ${KERNEL_OUTPUT_DIR}/$imageType.stripped ] ; then | ||
819 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.stripped $deployDir/$baseName${KERNEL_IMAGE_BIN_EXT} | ||
820 | else | ||
821 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$baseName${KERNEL_IMAGE_BIN_EXT} | ||
822 | fi | ||
823 | if [ -n "${KERNEL_IMAGE_LINK_NAME}" ] ; then | ||
824 | ln -sf $baseName${KERNEL_IMAGE_BIN_EXT} $deployDir/$imageType-${KERNEL_IMAGE_LINK_NAME}${KERNEL_IMAGE_BIN_EXT} | ||
825 | fi | ||
826 | if [ "${KERNEL_IMAGETYPE_SYMLINK}" = "1" ] ; then | ||
827 | ln -sf $baseName${KERNEL_IMAGE_BIN_EXT} $deployDir/$imageType | ||
828 | fi | ||
829 | done | ||
830 | |||
831 | if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then | ||
832 | mkdir -p ${D}${root_prefix}/lib | ||
833 | if [ -n "${SOURCE_DATE_EPOCH}" ]; then | ||
834 | TAR_ARGS="--sort=name --clamp-mtime --mtime=@${SOURCE_DATE_EPOCH}" | ||
835 | else | ||
836 | TAR_ARGS="" | ||
837 | fi | ||
838 | TAR_ARGS="$TAR_ARGS --owner=0 --group=0" | ||
839 | tar $TAR_ARGS -cv -C ${D}${root_prefix} lib | gzip -9n > $deployDir/modules-${MODULE_TARBALL_NAME}.tgz | ||
840 | |||
841 | if [ -n "${MODULE_TARBALL_LINK_NAME}" ] ; then | ||
842 | ln -sf modules-${MODULE_TARBALL_NAME}.tgz $deployDir/modules-${MODULE_TARBALL_LINK_NAME}.tgz | ||
843 | fi | ||
844 | fi | ||
845 | |||
846 | if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then | ||
847 | for imageType in ${KERNEL_IMAGETYPES} ; do | ||
848 | if [ "$imageType" = "fitImage" ] ; then | ||
849 | continue | ||
850 | fi | ||
851 | initramfsBaseName=$imageType-${INITRAMFS_NAME} | ||
852 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.initramfs $deployDir/$initramfsBaseName${KERNEL_IMAGE_BIN_EXT} | ||
853 | if [ -n "${INITRAMFS_LINK_NAME}" ] ; then | ||
854 | ln -sf $initramfsBaseName${KERNEL_IMAGE_BIN_EXT} $deployDir/$imageType-${INITRAMFS_LINK_NAME}${KERNEL_IMAGE_BIN_EXT} | ||
855 | fi | ||
856 | done | ||
857 | fi | ||
858 | } | ||
859 | |||
860 | # We deploy to filenames that include PKGV and PKGR, read the saved data to | ||
861 | # ensure we get the right values for both | ||
862 | do_deploy[prefuncs] += "read_subpackage_metadata" | ||
863 | |||
864 | addtask deploy after do_populate_sysroot do_packagedata | ||
865 | |||
866 | EXPORT_FUNCTIONS do_deploy | ||
867 | |||
868 | # Add using Device Tree support | ||
869 | inherit kernel-devicetree | ||