diff options
Diffstat (limited to 'meta/classes/kernel.bbclass')
-rw-r--r-- | meta/classes/kernel.bbclass | 474 |
1 files changed, 474 insertions, 0 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass new file mode 100644 index 0000000000..f40ea8985d --- /dev/null +++ b/meta/classes/kernel.bbclass | |||
@@ -0,0 +1,474 @@ | |||
1 | inherit linux-kernel-base module_strip kernel-module-split | ||
2 | |||
3 | PROVIDES += "virtual/kernel" | ||
4 | DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross" | ||
5 | |||
6 | # we include gcc above, we dont need virtual/libc | ||
7 | INHIBIT_DEFAULT_DEPS = "1" | ||
8 | |||
9 | KERNEL_IMAGETYPE ?= "zImage" | ||
10 | INITRAMFS_IMAGE ?= "" | ||
11 | INITRAMFS_TASK ?= "" | ||
12 | INITRAMFS_IMAGE_BUNDLE ?= "" | ||
13 | |||
14 | python __anonymous () { | ||
15 | kerneltype = d.getVar('KERNEL_IMAGETYPE', True) or '' | ||
16 | if kerneltype == 'uImage': | ||
17 | depends = d.getVar("DEPENDS", True) | ||
18 | depends = "%s u-boot-mkimage-native" % depends | ||
19 | d.setVar("DEPENDS", depends) | ||
20 | |||
21 | image = d.getVar('INITRAMFS_IMAGE', True) | ||
22 | if image: | ||
23 | d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_rootfs') | ||
24 | |||
25 | # NOTE: setting INITRAMFS_TASK is for backward compatibility | ||
26 | # The preferred method is to set INITRAMFS_IMAGE, because | ||
27 | # this INITRAMFS_TASK has circular dependency problems | ||
28 | # if the initramfs requires kernel modules | ||
29 | image_task = d.getVar('INITRAMFS_TASK', True) | ||
30 | if image_task: | ||
31 | d.appendVarFlag('do_configure', 'depends', ' ${INITRAMFS_TASK}') | ||
32 | } | ||
33 | |||
34 | inherit kernel-arch deploy | ||
35 | |||
36 | PACKAGES_DYNAMIC += "^kernel-module-.*" | ||
37 | PACKAGES_DYNAMIC += "^kernel-image-.*" | ||
38 | PACKAGES_DYNAMIC += "^kernel-firmware-.*" | ||
39 | |||
40 | export OS = "${TARGET_OS}" | ||
41 | export CROSS_COMPILE = "${TARGET_PREFIX}" | ||
42 | |||
43 | KERNEL_PRIORITY ?= "${@int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[0]) * 10000 + \ | ||
44 | int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[1]) * 100 + \ | ||
45 | int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[-1])}" | ||
46 | |||
47 | KERNEL_RELEASE ?= "${KERNEL_VERSION}" | ||
48 | |||
49 | # Where built kernel lies in the kernel tree | ||
50 | KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}" | ||
51 | KERNEL_IMAGEDEST = "boot" | ||
52 | |||
53 | # | ||
54 | # configuration | ||
55 | # | ||
56 | export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE",1) or "ttyS0"}" | ||
57 | |||
58 | KERNEL_VERSION = "${@get_kernelversion('${B}')}" | ||
59 | |||
60 | KERNEL_LOCALVERSION ?= "" | ||
61 | |||
62 | # kernels are generally machine specific | ||
63 | PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
64 | |||
65 | # U-Boot support | ||
66 | UBOOT_ENTRYPOINT ?= "20008000" | ||
67 | UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}" | ||
68 | |||
69 | # Some Linux kernel configurations need additional parameters on the command line | ||
70 | KERNEL_EXTRA_ARGS ?= "" | ||
71 | |||
72 | # For the kernel, we don't want the '-e MAKEFLAGS=' in EXTRA_OEMAKE. | ||
73 | # We don't want to override kernel Makefile variables from the environment | ||
74 | EXTRA_OEMAKE = "" | ||
75 | |||
76 | KERNEL_ALT_IMAGETYPE ??= "" | ||
77 | |||
78 | # Define where the kernel headers are installed on the target as well as where | ||
79 | # they are staged. | ||
80 | KERNEL_SRC_PATH = "/usr/src/kernel" | ||
81 | |||
82 | KERNEL_IMAGETYPE_FOR_MAKE = "${@(lambda s: s[:-3] if s[-3:] == ".gz" else s)(d.getVar('KERNEL_IMAGETYPE', True))}" | ||
83 | |||
84 | copy_initramfs() { | ||
85 | echo "Copying initramfs into ./usr ..." | ||
86 | # In case the directory is not created yet from the first pass compile: | ||
87 | mkdir -p ${B}/usr | ||
88 | # Find and use the first initramfs image archive type we find | ||
89 | rm -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio | ||
90 | for img in cpio.gz cpio.lzo cpio.lzma cpio.xz; do | ||
91 | if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then | ||
92 | cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img ${B}/usr/. | ||
93 | case $img in | ||
94 | *gz) | ||
95 | echo "gzip decompressing image" | ||
96 | gunzip -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img | ||
97 | break | ||
98 | ;; | ||
99 | *lzo) | ||
100 | echo "lzo decompressing image" | ||
101 | lzop -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img | ||
102 | break | ||
103 | ;; | ||
104 | *lzma) | ||
105 | echo "lzma decompressing image" | ||
106 | lzmash -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img | ||
107 | break | ||
108 | ;; | ||
109 | *xz) | ||
110 | echo "xz decompressing image" | ||
111 | xz -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img | ||
112 | break | ||
113 | ;; | ||
114 | esac | ||
115 | fi | ||
116 | done | ||
117 | echo "Finished copy of initramfs into ./usr" | ||
118 | } | ||
119 | |||
120 | INITRAMFS_BASE_NAME = "${KERNEL_IMAGETYPE}-initramfs-${PV}-${PR}-${MACHINE}-${DATETIME}" | ||
121 | INITRAMFS_BASE_NAME[vardepsexclude] = "DATETIME" | ||
122 | do_bundle_initramfs () { | ||
123 | if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then | ||
124 | echo "Creating a kernel image with a bundled initramfs..." | ||
125 | copy_initramfs | ||
126 | if [ -e ${KERNEL_OUTPUT} ] ; then | ||
127 | mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.bak | ||
128 | fi | ||
129 | use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio | ||
130 | kernel_do_compile | ||
131 | mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs | ||
132 | mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT} | ||
133 | # Update install area | ||
134 | echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT}.initramfs" | ||
135 | install -m 0644 ${B}/${KERNEL_OUTPUT}.initramfs ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin | ||
136 | echo "${B}/${KERNEL_OUTPUT}.initramfs" | ||
137 | cd ${B} | ||
138 | # Update deploy directory | ||
139 | if [ -e "${KERNEL_OUTPUT}.initramfs" ]; then | ||
140 | echo "Copying deploy kernel-initramfs image and setting up links..." | ||
141 | initramfs_base_name=${INITRAMFS_BASE_NAME} | ||
142 | initramfs_symlink_name=${KERNEL_IMAGETYPE}-initramfs-${MACHINE} | ||
143 | install -m 0644 ${KERNEL_OUTPUT}.initramfs ${DEPLOY_DIR_IMAGE}/${initramfs_base_name}.bin | ||
144 | cd ${DEPLOY_DIR_IMAGE} | ||
145 | ln -sf ${initramfs_base_name}.bin ${initramfs_symlink_name}.bin | ||
146 | fi | ||
147 | fi | ||
148 | } | ||
149 | do_bundle_initramfs[nostamp] = "1" | ||
150 | |||
151 | python do_devshell_prepend () { | ||
152 | os.environ["LDFLAGS"] = '' | ||
153 | } | ||
154 | |||
155 | addtask bundle_initramfs after do_compile | ||
156 | |||
157 | kernel_do_compile() { | ||
158 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE | ||
159 | # The $use_alternate_initrd is only set from | ||
160 | # do_bundle_initramfs() This variable is specifically for the | ||
161 | # case where we are making a second pass at the kernel | ||
162 | # compilation and we want to force the kernel build to use a | ||
163 | # different initramfs image. The way to do that in the kernel | ||
164 | # is to specify: | ||
165 | # make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio | ||
166 | if [ "$use_alternate_initrd" = "" ] && [ "${INITRAMFS_TASK}" != "" ] ; then | ||
167 | # The old style way of copying an prebuilt image and building it | ||
168 | # is turned on via INTIRAMFS_TASK != "" | ||
169 | copy_initramfs | ||
170 | use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio | ||
171 | fi | ||
172 | oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd | ||
173 | if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then | ||
174 | gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}" | ||
175 | fi | ||
176 | } | ||
177 | |||
178 | do_compile_kernelmodules() { | ||
179 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE | ||
180 | if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then | ||
181 | oe_runmake ${PARALLEL_MAKE} modules CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} | ||
182 | else | ||
183 | bbnote "no modules to compile" | ||
184 | fi | ||
185 | } | ||
186 | addtask compile_kernelmodules after do_compile before do_strip | ||
187 | |||
188 | kernel_do_install() { | ||
189 | # | ||
190 | # First install the modules | ||
191 | # | ||
192 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE | ||
193 | if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then | ||
194 | oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" modules_install | ||
195 | rm "${D}/lib/modules/${KERNEL_VERSION}/build" | ||
196 | rm "${D}/lib/modules/${KERNEL_VERSION}/source" | ||
197 | else | ||
198 | bbnote "no modules to install" | ||
199 | fi | ||
200 | |||
201 | # | ||
202 | # Install various kernel output (zImage, map file, config, module support files) | ||
203 | # | ||
204 | install -d ${D}/${KERNEL_IMAGEDEST} | ||
205 | install -d ${D}/boot | ||
206 | install -m 0644 ${KERNEL_OUTPUT} ${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} | ||
207 | install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} | ||
208 | install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION} | ||
209 | install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION} | ||
210 | [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION} | ||
211 | install -d ${D}${sysconfdir}/modules-load.d | ||
212 | install -d ${D}${sysconfdir}/modprobe.d | ||
213 | |||
214 | # | ||
215 | # Support for external module building - create a minimal copy of the | ||
216 | # kernel source tree. | ||
217 | # | ||
218 | kerneldir=${D}${KERNEL_SRC_PATH} | ||
219 | install -d $kerneldir | ||
220 | |||
221 | # | ||
222 | # Store the kernel version in sysroots for module-base.bbclass | ||
223 | # | ||
224 | |||
225 | echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion | ||
226 | |||
227 | # | ||
228 | # Store kernel image name to allow use during image generation | ||
229 | # | ||
230 | |||
231 | echo "${KERNEL_IMAGE_BASE_NAME}" >$kerneldir/kernel-image-name | ||
232 | |||
233 | # | ||
234 | # Copy the entire source tree. In case an external build directory is | ||
235 | # used, copy the build directory over first, then copy over the source | ||
236 | # dir. This ensures the original Makefiles are used and not the | ||
237 | # redirecting Makefiles in the build directory. | ||
238 | # | ||
239 | # work and sysroots can be on different partitions, so we can't rely on | ||
240 | # hardlinking, unfortunately. | ||
241 | # | ||
242 | find . -depth -not -name "*.cmd" -not -name "*.o" -not -path "./.*" -print0 | cpio --null -pdu $kerneldir | ||
243 | cp .config $kerneldir | ||
244 | if [ "${S}" != "${B}" ]; then | ||
245 | pwd="$PWD" | ||
246 | cd "${S}" | ||
247 | find . -depth -not -path "./.*" -print0 | cpio --null -pdu $kerneldir | ||
248 | cd "$pwd" | ||
249 | fi | ||
250 | install -m 0644 ${KERNEL_OUTPUT} $kerneldir/${KERNEL_IMAGETYPE} | ||
251 | install -m 0644 System.map $kerneldir/System.map-${KERNEL_VERSION} | ||
252 | |||
253 | # | ||
254 | # Clean and remove files not needed for building modules. | ||
255 | # Some distributions go through a lot more trouble to strip out | ||
256 | # unecessary headers, for now, we just prune the obvious bits. | ||
257 | # | ||
258 | # We don't want to leave host-arch binaries in /sysroots, so | ||
259 | # we clean the scripts dir while leaving the generated config | ||
260 | # and include files. | ||
261 | # | ||
262 | oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean | ||
263 | make -C $kerneldir _mrproper_scripts | ||
264 | find $kerneldir -path $kerneldir/lib -prune -o -path $kerneldir/tools -prune -o -path $kerneldir/scripts -prune -o -name "*.[csS]" -exec rm '{}' \; | ||
265 | find $kerneldir/Documentation -name "*.txt" -exec rm '{}' \; | ||
266 | |||
267 | # As of Linux kernel version 3.0.1, the clean target removes | ||
268 | # arch/powerpc/lib/crtsavres.o which is present in | ||
269 | # KBUILD_LDFLAGS_MODULE, making it required to build external modules. | ||
270 | if [ ${ARCH} = "powerpc" ]; then | ||
271 | cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o | ||
272 | fi | ||
273 | |||
274 | # Necessary for building modules like compat-wireless. | ||
275 | if [ -f include/generated/bounds.h ]; then | ||
276 | cp include/generated/bounds.h $kerneldir/include/generated/bounds.h | ||
277 | fi | ||
278 | if [ -d arch/${ARCH}/include/generated ]; then | ||
279 | mkdir -p $kerneldir/arch/${ARCH}/include/generated/ | ||
280 | cp -fR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/ | ||
281 | fi | ||
282 | |||
283 | # Remove the following binaries which cause strip or arch QA errors | ||
284 | # during do_package for cross-compiled platforms | ||
285 | bin_files="arch/powerpc/boot/addnote arch/powerpc/boot/hack-coff \ | ||
286 | arch/powerpc/boot/mktree scripts/kconfig/zconf.tab.o \ | ||
287 | scripts/kconfig/conf.o scripts/kconfig/kxgettext.o" | ||
288 | for entry in $bin_files; do | ||
289 | rm -f $kerneldir/$entry | ||
290 | done | ||
291 | |||
292 | # kernels <2.6.30 don't have $kerneldir/tools directory so we check if it exists before calling sed | ||
293 | if [ -f $kerneldir/tools/perf/Makefile ]; then | ||
294 | # Fix SLANG_INC for slang.h | ||
295 | sed -i 's#-I/usr/include/slang#-I=/usr/include/slang#g' $kerneldir/tools/perf/Makefile | ||
296 | fi | ||
297 | } | ||
298 | do_install[prefuncs] += "package_get_auto_pr" | ||
299 | |||
300 | sysroot_stage_all_append() { | ||
301 | sysroot_stage_dir ${D}${KERNEL_SRC_PATH} ${SYSROOT_DESTDIR}${KERNEL_SRC_PATH} | ||
302 | } | ||
303 | |||
304 | kernel_do_configure() { | ||
305 | # fixes extra + in /lib/modules/2.6.37+ | ||
306 | # $ scripts/setlocalversion . => + | ||
307 | # $ make kernelversion => 2.6.37 | ||
308 | # $ make kernelrelease => 2.6.37+ | ||
309 | touch ${B}/.scmversion ${S}/.scmversion | ||
310 | |||
311 | # Copy defconfig to .config if .config does not exist. This allows | ||
312 | # recipes to manage the .config themselves in do_configure_prepend(). | ||
313 | if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then | ||
314 | cp "${WORKDIR}/defconfig" "${B}/.config" | ||
315 | fi | ||
316 | yes '' | oe_runmake oldconfig | ||
317 | } | ||
318 | |||
319 | do_savedefconfig() { | ||
320 | oe_runmake savedefconfig | ||
321 | } | ||
322 | do_savedefconfig[nostamp] = "1" | ||
323 | addtask savedefconfig after do_configure | ||
324 | |||
325 | inherit cml1 | ||
326 | |||
327 | EXPORT_FUNCTIONS do_compile do_install do_configure | ||
328 | |||
329 | # kernel-base becomes kernel-${KERNEL_VERSION} | ||
330 | # kernel-image becomes kernel-image-${KERNEL_VERISON} | ||
331 | PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-dev kernel-modules" | ||
332 | FILES_${PN} = "" | ||
333 | FILES_kernel-base = "/lib/modules/${KERNEL_VERSION}/modules.order /lib/modules/${KERNEL_VERSION}/modules.builtin" | ||
334 | FILES_kernel-image = "/boot/${KERNEL_IMAGETYPE}*" | ||
335 | FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}" | ||
336 | FILES_kernel-vmlinux = "/boot/vmlinux*" | ||
337 | FILES_kernel-modules = "" | ||
338 | RDEPENDS_kernel = "kernel-base" | ||
339 | # Allow machines to override this dependency if kernel image files are | ||
340 | # not wanted in images as standard | ||
341 | RDEPENDS_kernel-base ?= "kernel-image" | ||
342 | PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}" | ||
343 | PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}" | ||
344 | RPROVIDES_kernel-base += "kernel-${KERNEL_VERSION}" | ||
345 | ALLOW_EMPTY_kernel = "1" | ||
346 | ALLOW_EMPTY_kernel-base = "1" | ||
347 | ALLOW_EMPTY_kernel-image = "1" | ||
348 | ALLOW_EMPTY_kernel-modules = "1" | ||
349 | DESCRIPTION_kernel-modules = "Kernel modules meta package" | ||
350 | |||
351 | pkg_postinst_kernel-image () { | ||
352 | update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true | ||
353 | if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then | ||
354 | mkdir -p $D/lib/modules/${KERNEL_VERSION} | ||
355 | fi | ||
356 | if [ -n "$D" ]; then | ||
357 | depmodwrapper -a -b $D ${KERNEL_VERSION} | ||
358 | else | ||
359 | depmod -a ${KERNEL_VERSION} | ||
360 | fi | ||
361 | } | ||
362 | |||
363 | pkg_postrm_kernel-image () { | ||
364 | update-alternatives --remove ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} || true | ||
365 | } | ||
366 | |||
367 | PACKAGESPLITFUNCS_prepend = "split_kernel_packages " | ||
368 | |||
369 | python split_kernel_packages () { | ||
370 | do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.bin$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') | ||
371 | do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.fw$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') | ||
372 | do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.cis$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') | ||
373 | } | ||
374 | |||
375 | do_strip() { | ||
376 | if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then | ||
377 | if [[ "${KERNEL_IMAGETYPE}" != "vmlinux" ]]; then | ||
378 | bbwarn "image type will not be stripped (not supported): ${KERNEL_IMAGETYPE}" | ||
379 | return | ||
380 | fi | ||
381 | |||
382 | cd ${B} | ||
383 | headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT} | \ | ||
384 | grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \ | ||
385 | sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \ | ||
386 | gawk '{print $1}'` | ||
387 | |||
388 | for str in ${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}; do { | ||
389 | if [[ "$headers" != *"$str"* ]]; then | ||
390 | bbwarn "Section not found: $str"; | ||
391 | fi | ||
392 | |||
393 | "$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT} | ||
394 | }; done | ||
395 | |||
396 | bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \ | ||
397 | "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" | ||
398 | fi; | ||
399 | } | ||
400 | do_strip[dirs] = "${B}" | ||
401 | |||
402 | addtask do_strip before do_sizecheck after do_kernel_link_vmlinux | ||
403 | |||
404 | # Support checking the kernel size since some kernels need to reside in partitions | ||
405 | # with a fixed length or there is a limit in transferring the kernel to memory | ||
406 | do_sizecheck() { | ||
407 | if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then | ||
408 | cd ${B} | ||
409 | size=`ls -lL ${KERNEL_OUTPUT} | awk '{ print $5}'` | ||
410 | if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then | ||
411 | die "This kernel (size=$size > ${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular." | ||
412 | fi | ||
413 | fi | ||
414 | } | ||
415 | do_sizecheck[dirs] = "${B}" | ||
416 | |||
417 | addtask sizecheck before do_install after do_strip | ||
418 | |||
419 | KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}" | ||
420 | # Don't include the DATETIME variable in the sstate package signatures | ||
421 | KERNEL_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME" | ||
422 | KERNEL_IMAGE_SYMLINK_NAME ?= "${KERNEL_IMAGETYPE}-${MACHINE}" | ||
423 | MODULE_IMAGE_BASE_NAME ?= "modules-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}" | ||
424 | MODULE_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME" | ||
425 | MODULE_TARBALL_BASE_NAME ?= "${MODULE_IMAGE_BASE_NAME}.tgz" | ||
426 | # Don't include the DATETIME variable in the sstate package signatures | ||
427 | MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz" | ||
428 | MODULE_TARBALL_DEPLOY ?= "1" | ||
429 | |||
430 | do_uboot_mkimage() { | ||
431 | if test "x${KERNEL_IMAGETYPE}" = "xuImage" ; then | ||
432 | if test "x${KEEPUIMAGE}" != "xyes" ; then | ||
433 | ENTRYPOINT=${UBOOT_ENTRYPOINT} | ||
434 | if test -n "${UBOOT_ENTRYSYMBOL}"; then | ||
435 | ENTRYPOINT=`${HOST_PREFIX}nm ${S}/vmlinux | \ | ||
436 | awk '$3=="${UBOOT_ENTRYSYMBOL}" {print $1}'` | ||
437 | fi | ||
438 | if test -e arch/${ARCH}/boot/compressed/vmlinux ; then | ||
439 | ${OBJCOPY} -O binary -R .note -R .comment -S arch/${ARCH}/boot/compressed/vmlinux linux.bin | ||
440 | uboot-mkimage -A ${UBOOT_ARCH} -O linux -T kernel -C none -a ${UBOOT_LOADADDRESS} -e $ENTRYPOINT -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin arch/${ARCH}/boot/uImage | ||
441 | rm -f linux.bin | ||
442 | else | ||
443 | ${OBJCOPY} -O binary -R .note -R .comment -S vmlinux linux.bin | ||
444 | rm -f linux.bin.gz | ||
445 | gzip -9 linux.bin | ||
446 | uboot-mkimage -A ${UBOOT_ARCH} -O linux -T kernel -C gzip -a ${UBOOT_LOADADDRESS} -e $ENTRYPOINT -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin.gz arch/${ARCH}/boot/uImage | ||
447 | rm -f linux.bin.gz | ||
448 | fi | ||
449 | fi | ||
450 | fi | ||
451 | } | ||
452 | |||
453 | addtask uboot_mkimage before do_install after do_compile | ||
454 | |||
455 | kernel_do_deploy() { | ||
456 | install -m 0644 ${KERNEL_OUTPUT} ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin | ||
457 | if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then | ||
458 | mkdir -p ${D}/lib | ||
459 | tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib | ||
460 | ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME} | ||
461 | fi | ||
462 | |||
463 | ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${DEPLOYDIR}/${KERNEL_IMAGE_SYMLINK_NAME}.bin | ||
464 | ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${DEPLOYDIR}/${KERNEL_IMAGETYPE} | ||
465 | |||
466 | cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOYDIR}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt | ||
467 | } | ||
468 | do_deploy[dirs] = "${DEPLOYDIR} ${B}" | ||
469 | do_deploy[prefuncs] += "package_get_auto_pr" | ||
470 | |||
471 | addtask deploy before do_build after do_install | ||
472 | |||
473 | EXPORT_FUNCTIONS do_deploy | ||
474 | |||