Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | |
| 4 | [[ ${EAPI} != "4" ]] && die "Only EAPI=4 is supported" |
| 5 | |
Mike Frysinger | b5ebdb5 | 2013-02-10 03:25:44 -0500 | [diff] [blame] | 6 | inherit binutils-funcs cros-board toolchain-funcs linux-info |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 7 | |
| 8 | HOMEPAGE="http://www.chromium.org/" |
| 9 | LICENSE="GPL-2" |
| 10 | SLOT="0" |
| 11 | |
| 12 | DEPEND="sys-apps/debianutils |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 13 | initramfs? ( chromeos-base/chromeos-initramfs ) |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 14 | netboot_ramfs? ( chromeos-base/chromeos-initramfs ) |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 15 | " |
| 16 | |
Paul Stewart | 23ead5f | 2013-04-24 22:32:17 -0700 | [diff] [blame] | 17 | IUSE="-device_tree -kernel_sources -wireless34 -wifi_testbed_ap" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 18 | STRIP_MASK="/usr/lib/debug/boot/vmlinux" |
Josh Triplett | 4c03559 | 2012-12-05 15:46:46 -0800 | [diff] [blame] | 19 | |
| 20 | # Build out-of-tree and incremental by default, but allow an ebuild inheriting |
| 21 | # this eclass to explicitly build in-tree. |
| 22 | : ${CROS_WORKON_OUTOFTREE_BUILD:=1} |
| 23 | : ${CROS_WORKON_INCREMENTAL_BUILD:=1} |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 24 | |
| 25 | # Config fragments selected by USE flags |
Doug Anderson | 010887c | 2012-02-04 22:42:54 -0800 | [diff] [blame] | 26 | # ...fragments will have the following variables substitutions |
| 27 | # applied later (needs to be done later since these values |
| 28 | # aren't reliable when used in a global context like this): |
| 29 | # %ROOT% => ${ROOT} |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 30 | |
| 31 | CONFIG_FRAGMENTS=( |
| 32 | blkdevram |
Dylan Reid | f0666ff | 2012-07-01 21:42:38 -0700 | [diff] [blame] | 33 | ca0132 |
Micah Catlin | 0dc2b97 | 2012-08-01 17:44:24 -0700 | [diff] [blame] | 34 | cifs |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 35 | fbconsole |
Ben Chan | e0654d2 | 2012-05-12 00:09:53 -0700 | [diff] [blame] | 36 | gdmwimax |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 37 | gobi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 38 | highmem |
Vic Yang | 1541a70 | 2013-01-10 17:36:06 +0800 | [diff] [blame] | 39 | i2cdev |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 40 | initramfs |
Ronald G. Minnich | 6d888d4 | 2012-02-16 13:45:58 -0800 | [diff] [blame] | 41 | kvm |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 42 | netboot_ramfs |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 43 | nfs |
| 44 | pcserial |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 45 | qmi |
Dave Parker | 9fb68c9 | 2012-05-04 10:34:00 -0700 | [diff] [blame] | 46 | realtekpstor |
Vic Yang | e0d659e | 2013-01-22 21:44:41 +0800 | [diff] [blame] | 47 | samsung_serial |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 48 | systemtap |
Vic Yang | e0d659e | 2013-01-22 21:44:41 +0800 | [diff] [blame] | 49 | tpm |
Vic Yang | 7cc29a9 | 2012-05-18 14:12:10 +0800 | [diff] [blame] | 50 | vfat |
Paul Stewart | 23ead5f | 2013-04-24 22:32:17 -0700 | [diff] [blame] | 51 | wifi_testbed_ap |
Mike Frysinger | 34a5512 | 2013-02-05 14:01:39 -0500 | [diff] [blame] | 52 | x32 |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 53 | ) |
| 54 | |
| 55 | blkdevram_desc="ram block device" |
| 56 | blkdevram_config=" |
| 57 | CONFIG_BLK_DEV_RAM=y |
| 58 | CONFIG_BLK_DEV_RAM_COUNT=16 |
| 59 | CONFIG_BLK_DEV_RAM_SIZE=16384 |
| 60 | " |
| 61 | |
Dylan Reid | f0666ff | 2012-07-01 21:42:38 -0700 | [diff] [blame] | 62 | ca0132_desc="CA0132 ALSA codec" |
| 63 | ca0132_config=" |
| 64 | CONFIG_SND_HDA_CODEC_CA0132=y |
Chih-Chung Chang | 2306b49 | 2012-09-04 19:52:18 +0800 | [diff] [blame] | 65 | CONFIG_SND_HDA_DSP_LOADER=y |
Dylan Reid | f0666ff | 2012-07-01 21:42:38 -0700 | [diff] [blame] | 66 | " |
| 67 | |
Micah Catlin | 0dc2b97 | 2012-08-01 17:44:24 -0700 | [diff] [blame] | 68 | cifs_desc="Samba/CIFS Support" |
| 69 | cifs_config=" |
| 70 | CONFIG_CIFS=m |
| 71 | " |
| 72 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 73 | fbconsole_desc="framebuffer console" |
| 74 | fbconsole_config=" |
| 75 | CONFIG_FRAMEBUFFER_CONSOLE=y |
| 76 | " |
| 77 | |
Ben Chan | e0654d2 | 2012-05-12 00:09:53 -0700 | [diff] [blame] | 78 | gdmwimax_desc="GCT GDM72xx WiMAX support" |
| 79 | gdmwimax_config=" |
| 80 | CONFIG_WIMAX_GDM72XX=m |
Ben Chan | e0654d2 | 2012-05-12 00:09:53 -0700 | [diff] [blame] | 81 | CONFIG_WIMAX_GDM72XX_USB=y |
| 82 | CONFIG_WIMAX_GDM72XX_USB_PM=y |
| 83 | " |
| 84 | |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 85 | gobi_desc="Qualcomm Gobi modem driver" |
| 86 | gobi_config=" |
| 87 | CONFIG_USB_NET_GOBI=m |
| 88 | " |
| 89 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 90 | highmem_desc="highmem" |
| 91 | highmem_config=" |
| 92 | CONFIG_HIGHMEM64G=y |
| 93 | " |
| 94 | |
Vic Yang | 1541a70 | 2013-01-10 17:36:06 +0800 | [diff] [blame] | 95 | i2cdev_desc="I2C device interface" |
| 96 | i2cdev_config=" |
| 97 | CONFIG_I2C_CHARDEV=y |
| 98 | " |
| 99 | |
Vic Yang | e0d659e | 2013-01-22 21:44:41 +0800 | [diff] [blame] | 100 | tpm_desc="TPM support" |
| 101 | tpm_config=" |
| 102 | CONFIG_TCG_TPM=y |
| 103 | CONFIG_TCG_TIS=y |
| 104 | " |
| 105 | |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 106 | initramfs_desc="Initramfs for factory install shim and recovery image" |
| 107 | initramfs_config=' |
| 108 | CONFIG_INITRAMFS_SOURCE="%ROOT%/var/lib/misc/initramfs.cpio.xz" |
Anush Elangovan | f9b66d9 | 2012-12-20 12:16:15 -0800 | [diff] [blame] | 109 | CONFIG_INITRAMFS_COMPRESSION_XZ=y |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 110 | ' |
| 111 | |
| 112 | netboot_ramfs_desc="Network boot install initramfs" |
| 113 | netboot_ramfs_config=' |
| 114 | CONFIG_INITRAMFS_SOURCE="%ROOT%/var/lib/misc/netboot_ramfs.cpio.xz" |
| 115 | CONFIG_INITRAMFS_COMPRESSION_XZ=y |
| 116 | ' |
Vic Yang | 7cc29a9 | 2012-05-18 14:12:10 +0800 | [diff] [blame] | 117 | |
| 118 | vfat_desc="vfat" |
| 119 | vfat_config=" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 120 | CONFIG_NLS_CODEPAGE_437=y |
| 121 | CONFIG_NLS_ISO8859_1=y |
| 122 | CONFIG_FAT_FS=y |
| 123 | CONFIG_VFAT_FS=y |
| 124 | " |
| 125 | |
Ronald G. Minnich | 6d888d4 | 2012-02-16 13:45:58 -0800 | [diff] [blame] | 126 | kvm_desc="KVM" |
| 127 | kvm_config=" |
| 128 | CONFIG_HAVE_KVM=y |
| 129 | CONFIG_HAVE_KVM_IRQCHIP=y |
| 130 | CONFIG_HAVE_KVM_EVENTFD=y |
| 131 | CONFIG_KVM_APIC_ARCHITECTURE=y |
| 132 | CONFIG_KVM_MMIO=y |
| 133 | CONFIG_KVM_ASYNC_PF=y |
| 134 | CONFIG_KVM=m |
| 135 | CONFIG_KVM_INTEL=m |
| 136 | # CONFIG_KVM_AMD is not set |
| 137 | # CONFIG_KVM_MMU_AUDIT is not set |
| 138 | CONFIG_VIRTIO=m |
| 139 | CONFIG_VIRTIO_BLK=m |
| 140 | CONFIG_VIRTIO_NET=m |
| 141 | CONFIG_VIRTIO_CONSOLE=m |
| 142 | CONFIG_VIRTIO_RING=m |
| 143 | CONFIG_VIRTIO_PCI=m |
| 144 | " |
| 145 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 146 | nfs_desc="NFS" |
| 147 | nfs_config=" |
| 148 | CONFIG_USB_NET_AX8817X=y |
| 149 | CONFIG_DNOTIFY=y |
| 150 | CONFIG_DNS_RESOLVER=y |
| 151 | CONFIG_LOCKD=y |
| 152 | CONFIG_LOCKD_V4=y |
| 153 | CONFIG_NETWORK_FILESYSTEMS=y |
| 154 | CONFIG_NFSD=m |
| 155 | CONFIG_NFSD_V3=y |
| 156 | CONFIG_NFSD_V4=y |
| 157 | CONFIG_NFS_COMMON=y |
| 158 | CONFIG_NFS_FS=y |
| 159 | CONFIG_NFS_USE_KERNEL_DNS=y |
| 160 | CONFIG_NFS_V3=y |
| 161 | CONFIG_NFS_V4=y |
| 162 | CONFIG_ROOT_NFS=y |
| 163 | CONFIG_RPCSEC_GSS_KRB5=y |
| 164 | CONFIG_SUNRPC=y |
| 165 | CONFIG_SUNRPC_GSS=y |
| 166 | CONFIG_USB_USBNET=y |
| 167 | CONFIG_IP_PNP=y |
| 168 | CONFIG_IP_PNP_DHCP=y |
| 169 | " |
| 170 | |
| 171 | pcserial_desc="PC serial" |
| 172 | pcserial_config=" |
| 173 | CONFIG_SERIAL_8250=y |
| 174 | CONFIG_SERIAL_8250_CONSOLE=y |
| 175 | CONFIG_SERIAL_8250_PCI=y |
| 176 | CONFIG_PARPORT=y |
| 177 | CONFIG_PARPORT_PC=y |
| 178 | CONFIG_PARPORT_SERIAL=y |
| 179 | " |
| 180 | |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 181 | qmi_desc="QMI WWAN driver" |
| 182 | qmi_config=" |
| 183 | CONFIG_USB_NET_QMI_WWAN=m |
| 184 | " |
| 185 | |
Olof Johansson | 08268b0c | 2012-08-01 00:12:00 -0700 | [diff] [blame] | 186 | samsung_serial_desc="Samsung serialport" |
| 187 | samsung_serial_config=" |
| 188 | CONFIG_SERIAL_SAMSUNG=y |
| 189 | CONFIG_SERIAL_SAMSUNG_CONSOLE=y |
| 190 | " |
| 191 | |
Dave Parker | 9fb68c9 | 2012-05-04 10:34:00 -0700 | [diff] [blame] | 192 | realtekpstor_desc="Realtek PCI card reader" |
| 193 | realtekpstor_config=" |
| 194 | CONFIG_RTS_PSTOR=m |
| 195 | " |
| 196 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 197 | systemtap_desc="systemtap support" |
| 198 | systemtap_config=" |
| 199 | CONFIG_KPROBES=y |
| 200 | CONFIG_DEBUG_INFO=y |
| 201 | " |
| 202 | |
Paul Stewart | 23ead5f | 2013-04-24 22:32:17 -0700 | [diff] [blame] | 203 | wifi_testbed_ap_desc="Defer ath9k EEPROM regulatory" |
| 204 | wifi_testbed_ap_warning=" |
| 205 | Don't use the wifi_testbed_ap flag unless you know what you are doing! |
| 206 | An image built with this flag set must never be run outside a |
| 207 | sealed RF chamber! |
| 208 | " |
| 209 | wifi_testbed_ap_config=" |
| 210 | CONFIG_ATH_DEFER_EEPROM_REGULATORY=y |
| 211 | " |
| 212 | |
Mike Frysinger | 34a5512 | 2013-02-05 14:01:39 -0500 | [diff] [blame] | 213 | x32_desc="x32 ABI support" |
| 214 | x32_config=" |
| 215 | CONFIG_X86_X32=y |
| 216 | " |
| 217 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 218 | # Add all config fragments as off by default |
| 219 | IUSE="${IUSE} ${CONFIG_FRAGMENTS[@]}" |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 220 | REQUIRED_USE=" |
| 221 | initramfs? ( !netboot_ramfs ) |
| 222 | netboot_ramfs? ( !initramfs ) |
| 223 | initramfs? ( i2cdev tpm ) |
| 224 | netboot_ramfs? ( i2cdev tpm ) |
| 225 | " |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 226 | |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 227 | # If an overlay has eclass overrides, but doesn't actually override this |
| 228 | # eclass, we'll have ECLASSDIR pointing to the active overlay's |
| 229 | # eclass/ dir, but this eclass is still in the main chromiumos tree. So |
| 230 | # add a check to locate the cros-kernel/ regardless of what's going on. |
| 231 | ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*} |
| 232 | defconfig_dir() { |
| 233 | local d="${ECLASSDIR}/cros-kernel" |
| 234 | if [[ ! -d ${d} ]] ; then |
| 235 | d="${ECLASSDIR_LOCAL}/cros-kernel" |
| 236 | fi |
| 237 | echo "${d}" |
| 238 | } |
| 239 | |
Josh Triplett | 6df77a7 | 2013-04-26 17:25:37 -0700 | [diff] [blame] | 240 | # @FUNCTION: kernelrelease |
Mike Frysinger | 330c023 | 2013-01-09 17:47:04 -0500 | [diff] [blame] | 241 | # @DESCRIPTION: |
| 242 | # Returns the current compiled kernel version. |
| 243 | # Note: Only valid after src_configure has finished running. |
Josh Triplett | 6df77a7 | 2013-04-26 17:25:37 -0700 | [diff] [blame] | 244 | kernelrelease() { |
| 245 | kmake -s --no-print-directory kernelrelease |
Mike Frysinger | 330c023 | 2013-01-09 17:47:04 -0500 | [diff] [blame] | 246 | } |
| 247 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 248 | # @FUNCTION: install_kernel_sources |
| 249 | # @DESCRIPTION: |
| 250 | # Installs the kernel sources into ${D}/usr/src/${P} and fixes symlinks. |
| 251 | # The package must have already installed a directory under ${D}/lib/modules. |
| 252 | install_kernel_sources() { |
Josh Triplett | 6df77a7 | 2013-04-26 17:25:37 -0700 | [diff] [blame] | 253 | local version=$(kernelrelease) |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 254 | local dest_modules_dir=lib/modules/${version} |
| 255 | local dest_source_dir=usr/src/${P} |
| 256 | local dest_build_dir=${dest_source_dir}/build |
| 257 | |
| 258 | # Fix symlinks in lib/modules |
| 259 | ln -sfvT "../../../${dest_build_dir}" \ |
| 260 | "${D}/${dest_modules_dir}/build" || die |
| 261 | ln -sfvT "../../../${dest_source_dir}" \ |
| 262 | "${D}/${dest_modules_dir}/source" || die |
| 263 | |
| 264 | einfo "Installing kernel source tree" |
| 265 | dodir "${dest_source_dir}" |
| 266 | local f |
| 267 | for f in "${S}"/*; do |
| 268 | [[ "$f" == "${S}/build" ]] && continue |
| 269 | cp -pPR "${f}" "${D}/${dest_source_dir}" || |
| 270 | die "Failed to copy kernel source tree" |
| 271 | done |
| 272 | |
| 273 | dosym "${P}" "/usr/src/linux" |
| 274 | |
| 275 | einfo "Installing kernel build tree" |
| 276 | dodir "${dest_build_dir}" |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 277 | cp -pPR "$(cros-workon_get_build_dir)"/{.config,.version,Makefile,Module.symvers,include} \ |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 278 | "${D}/${dest_build_dir}" || die |
| 279 | |
| 280 | # Modify Makefile to use the ROOT environment variable if defined. |
| 281 | # This path needs to be absolute so that the build directory will |
| 282 | # still work if copied elsewhere. |
| 283 | sed -i -e "s@${S}@\$(ROOT)/${dest_source_dir}@" \ |
| 284 | "${D}/${dest_build_dir}/Makefile" || die |
| 285 | } |
| 286 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 287 | get_build_cfg() { |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 288 | echo "$(cros-workon_get_build_dir)/.config" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 289 | } |
| 290 | |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 291 | get_build_arch() { |
| 292 | if [ "${ARCH}" = "arm" ] ; then |
| 293 | case "${CHROMEOS_KERNEL_SPLITCONFIG}" in |
| 294 | *tegra*) |
| 295 | echo "tegra" |
| 296 | ;; |
| 297 | *exynos*) |
| 298 | echo "exynos5" |
| 299 | ;; |
| 300 | *) |
| 301 | echo "arm" |
| 302 | ;; |
| 303 | esac |
| 304 | else |
| 305 | echo $(tc-arch-kernel) |
| 306 | fi |
| 307 | } |
| 308 | |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 309 | # @FUNCTION: cros_chkconfig_present |
| 310 | # @USAGE: <option to check config for> |
| 311 | # @DESCRIPTION: |
| 312 | # Returns success of the provided option is present in the build config. |
| 313 | cros_chkconfig_present() { |
| 314 | local config=$1 |
| 315 | grep -q "^CONFIG_$1=[ym]$" "$(get_build_cfg)" |
| 316 | } |
| 317 | |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 318 | cros-kernel2_pkg_setup() { |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 319 | # This is needed for running src_test(). The kernel code will need to |
| 320 | # be rebuilt with `make check`. If incremental build were enabled, |
| 321 | # `make check` would have nothing left to build. |
Simon Que | 6324b6f | 2013-02-01 14:56:05 -0800 | [diff] [blame] | 322 | use test && export CROS_WORKON_INCREMENTAL_BUILD=0 |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 323 | cros-workon_pkg_setup |
Mike Frysinger | b5ebdb5 | 2013-02-10 03:25:44 -0500 | [diff] [blame] | 324 | linux-info_pkg_setup |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 325 | } |
| 326 | |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 327 | # @FUNCTION: emit_its_script |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 328 | # @USAGE: <output file> <boot_dir> <dtb_dir> <device trees> |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 329 | # @DESCRIPTION: |
| 330 | # Emits the its script used to build the u-boot fitImage kernel binary |
| 331 | # that contains the kernel as well as device trees used when booting |
| 332 | # it. |
| 333 | |
| 334 | emit_its_script() { |
| 335 | local iter=1 |
| 336 | local its_out=${1} |
| 337 | shift |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 338 | local boot_dir=${1} |
| 339 | shift |
| 340 | local dtb_dir=${1} |
| 341 | shift |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 342 | cat > "${its_out}" <<-EOF || die |
| 343 | /dts-v1/; |
| 344 | |
| 345 | / { |
| 346 | description = "Chrome OS kernel image with one or more FDT blobs"; |
| 347 | #address-cells = <1>; |
| 348 | |
| 349 | images { |
| 350 | kernel@1 { |
| 351 | data = /incbin/("${boot_dir}/zImage"); |
| 352 | type = "$(get_kernel_type)"; |
| 353 | arch = "arm"; |
| 354 | os = "linux"; |
| 355 | compression = "none"; |
| 356 | load = <$(get_load_addr)>; |
| 357 | entry = <$(get_load_addr)>; |
| 358 | }; |
| 359 | EOF |
| 360 | |
| 361 | local dtb |
| 362 | for dtb in "$@" ; do |
| 363 | cat >> "${its_out}" <<-EOF || die |
| 364 | fdt@${iter} { |
| 365 | description = "$(basename ${dtb})"; |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 366 | data = /incbin/("${dtb_dir}/${dtb}"); |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 367 | type = "flat_dt"; |
| 368 | arch = "arm"; |
| 369 | compression = "none"; |
| 370 | hash@1 { |
| 371 | algo = "sha1"; |
| 372 | }; |
| 373 | }; |
| 374 | EOF |
| 375 | ((++iter)) |
| 376 | done |
| 377 | |
| 378 | cat <<-EOF >>"${its_script}" |
| 379 | }; |
| 380 | configurations { |
| 381 | default = "conf@1"; |
| 382 | EOF |
| 383 | |
| 384 | local i |
| 385 | for i in $(seq 1 $((iter-1))) ; do |
| 386 | cat >> "${its_out}" <<-EOF || die |
| 387 | conf@${i} { |
| 388 | kernel = "kernel@1"; |
| 389 | fdt = "fdt@${i}"; |
| 390 | }; |
| 391 | EOF |
| 392 | done |
| 393 | |
| 394 | echo " };" >> "${its_out}" |
| 395 | echo "};" >> "${its_out}" |
| 396 | } |
| 397 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 398 | kmake() { |
| 399 | # Allow override of kernel arch. |
| 400 | local kernel_arch=${CHROMEOS_KERNEL_ARCH:-$(tc-arch-kernel)} |
| 401 | |
| 402 | local cross=${CHOST}- |
Olof Johansson | c0f8a5d | 2013-04-11 18:36:40 -0700 | [diff] [blame] | 403 | |
| 404 | if use wireless34 ; then |
| 405 | set -- "$@" WIFIVERSION="-3.4" |
| 406 | fi |
| 407 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 408 | # Hack for using 64-bit kernel with 32-bit user-space |
Mike Frysinger | 0f008b2 | 2013-03-14 11:54:13 -0400 | [diff] [blame] | 409 | if [[ "${ARCH}" == "x86" && "${kernel_arch}" == "x86_64" ]]; then |
Sonny Rao | 5ebd89f | 2012-08-05 20:31:23 -0700 | [diff] [blame] | 410 | cross=x86_64-cros-linux-gnu- |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 411 | else |
| 412 | # TODO(raymes): Force GNU ld over gold. There are still some |
| 413 | # gold issues to iron out. See: 13209. |
| 414 | tc-export LD CC CXX |
| 415 | |
| 416 | set -- \ |
Mike Frysinger | 0f008b2 | 2013-03-14 11:54:13 -0400 | [diff] [blame] | 417 | LD="$(get_binutils_path_ld)/ld $(usex x32 '-m elf_x86_64' '')" \ |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 418 | CC="${CC} -B$(get_binutils_path_ld)" \ |
| 419 | CXX="${CXX} -B$(get_binutils_path_ld)" \ |
| 420 | "$@" |
| 421 | fi |
| 422 | |
Mike Frysinger | a8ef3cd | 2012-11-01 18:42:18 -0400 | [diff] [blame] | 423 | cw_emake \ |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 424 | ARCH=${kernel_arch} \ |
| 425 | LDFLAGS="$(raw-ldflags)" \ |
| 426 | CROSS_COMPILE="${cross}" \ |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 427 | O="$(cros-workon_get_build_dir)" \ |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 428 | "$@" |
| 429 | } |
| 430 | |
Josh Triplett | 4c03559 | 2012-12-05 15:46:46 -0800 | [diff] [blame] | 431 | cros-kernel2_src_prepare() { |
| 432 | cros-workon_src_prepare |
| 433 | } |
| 434 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 435 | cros-kernel2_src_configure() { |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 436 | # Use a single or split kernel config as specified in the board or variant |
| 437 | # make.conf overlay. Default to the arch specific split config if an |
| 438 | # overlay or variant does not set either CHROMEOS_KERNEL_CONFIG or |
| 439 | # CHROMEOS_KERNEL_SPLITCONFIG. CHROMEOS_KERNEL_CONFIG is set relative |
| 440 | # to the root of the kernel source tree. |
| 441 | local config |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 442 | local cfgarch="$(get_build_arch)" |
| 443 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 444 | if [ -n "${CHROMEOS_KERNEL_CONFIG}" ]; then |
Chris Masone | f888c38 | 2013-03-19 14:19:41 -0700 | [diff] [blame] | 445 | case ${CHROMEOS_KERNEL_CONFIG} in |
| 446 | /*) |
| 447 | config="${CHROMEOS_KERNEL_CONFIG}" |
| 448 | ;; |
| 449 | *) |
| 450 | config="${S}/${CHROMEOS_KERNEL_CONFIG}" |
| 451 | ;; |
| 452 | esac |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 453 | else |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 454 | config=${CHROMEOS_KERNEL_SPLITCONFIG:-"chromiumos-${cfgarch}"} |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 455 | fi |
| 456 | |
| 457 | elog "Using kernel config: ${config}" |
| 458 | |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 459 | # Keep a handle on the old .config in case it hasn't changed. This way |
| 460 | # we can keep the old timestamp which will avoid regenerating stuff that |
| 461 | # hasn't actually changed. |
| 462 | local temp_config="${T}/old-kernel-config" |
| 463 | if [[ -e $(get_build_cfg) ]] ; then |
| 464 | cp -a "$(get_build_cfg)" "${temp_config}" |
| 465 | else |
| 466 | rm -f "${temp_config}" |
| 467 | fi |
| 468 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 469 | if [ -n "${CHROMEOS_KERNEL_CONFIG}" ]; then |
| 470 | cp -f "${config}" "$(get_build_cfg)" || die |
| 471 | else |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 472 | if [ -e chromeos/scripts/prepareconfig ] ; then |
| 473 | chromeos/scripts/prepareconfig ${config} \ |
| 474 | "$(get_build_cfg)" || die |
| 475 | else |
| 476 | config="$(defconfig_dir)/${cfgarch}_defconfig" |
| 477 | ewarn "Can't prepareconfig, falling back to default " \ |
| 478 | "${config}" |
| 479 | cp "${config}" "$(get_build_cfg)" || die |
| 480 | fi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 481 | fi |
| 482 | |
| 483 | local fragment |
| 484 | for fragment in ${CONFIG_FRAGMENTS[@]}; do |
| 485 | use ${fragment} || continue |
| 486 | |
| 487 | local msg="${fragment}_desc" |
| 488 | local config="${fragment}_config" |
| 489 | elog " - adding ${!msg} config" |
Paul Stewart | 23ead5f | 2013-04-24 22:32:17 -0700 | [diff] [blame] | 490 | local warning="${fragment}_warning" |
| 491 | local warning_msg="${!warning}" |
| 492 | if [[ -n "${warning_msg}" ]] ; then |
| 493 | ewarn "${warning_msg}" |
| 494 | fi |
Doug Anderson | 010887c | 2012-02-04 22:42:54 -0800 | [diff] [blame] | 495 | |
| 496 | echo "${!config}" | \ |
| 497 | sed -e "s|%ROOT%|${ROOT}|g" \ |
| 498 | >> "$(get_build_cfg)" || die |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 499 | done |
| 500 | |
| 501 | # Use default for any options not explitly set in splitconfig |
| 502 | yes "" | kmake oldconfig |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 503 | |
| 504 | # Restore the old config if it is unchanged. |
| 505 | if cmp -s "$(get_build_cfg)" "${temp_config}" ; then |
| 506 | touch -r "${temp_config}" "$(get_build_cfg)" |
| 507 | fi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 508 | } |
| 509 | |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 510 | # @FUNCTION: get_dtb_name |
| 511 | # @USAGE: <dtb_dir> |
| 512 | # @DESCRIPTION: |
| 513 | # Get the name(s) of the device tree binary file(s) to include. |
| 514 | |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 515 | get_dtb_name() { |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 516 | local dtb_dir=${1} |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 517 | local board_with_variant=$(get_current_board_with_variant) |
| 518 | |
| 519 | # Do a simple mapping for device trees whose names don't match |
| 520 | # the board_with_variant format; default to just the |
| 521 | # board_with_variant format. |
| 522 | case "${board_with_variant}" in |
| 523 | (tegra2_dev-board) |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 524 | echo tegra-harmony.dtb |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 525 | ;; |
| 526 | (tegra2_seaboard) |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 527 | echo tegra-seaboard.dtb |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 528 | ;; |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 529 | tegra*) |
| 530 | echo ${board_with_variant}.dtb |
Olof Johansson | beaf472 | 2012-04-16 16:57:36 -0700 | [diff] [blame] | 531 | ;; |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 532 | *) |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 533 | local f |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 534 | for f in ${dtb_dir}/*.dtb ; do |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 535 | basename ${f} |
| 536 | done |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 537 | ;; |
| 538 | esac |
| 539 | } |
| 540 | |
Olof Johansson | beaf472 | 2012-04-16 16:57:36 -0700 | [diff] [blame] | 541 | # All current tegra boards ship with an u-boot that won't allow |
| 542 | # use of kernel_noload. Because of this, keep using the traditional |
| 543 | # kernel type for those. This means kernel_type kernel and regular |
| 544 | # load and entry point addresses. |
| 545 | |
| 546 | get_kernel_type() { |
| 547 | case "$(get_current_board_with_variant)" in |
| 548 | tegra*) |
| 549 | echo kernel |
| 550 | ;; |
| 551 | *) |
| 552 | echo kernel_noload |
| 553 | ;; |
| 554 | esac |
| 555 | } |
| 556 | |
| 557 | get_load_addr() { |
| 558 | case "$(get_current_board_with_variant)" in |
| 559 | tegra*) |
| 560 | echo 0x03000000 |
| 561 | ;; |
| 562 | *) |
| 563 | echo 0 |
| 564 | ;; |
| 565 | esac |
| 566 | } |
| 567 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 568 | cros-kernel2_src_compile() { |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 569 | local build_targets=() # use make default target |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 570 | if use arm; then |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 571 | build_targets=( |
Olof Johansson | d2242e1 | 2013-04-24 13:20:44 -0700 | [diff] [blame] | 572 | $(use device_tree && echo "zImage") |
Olof Johansson | 362863f | 2013-04-23 20:00:44 -0700 | [diff] [blame] | 573 | $(use device_tree || echo "uImage") |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 574 | $(cros_chkconfig_present MODULES && echo "modules") |
| 575 | ) |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 576 | fi |
| 577 | |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 578 | local src_dir="$(cros-workon_get_build_dir)/source" |
| 579 | local kernel_arch=${CHROMEOS_KERNEL_ARCH:-$(tc-arch-kernel)} |
| 580 | SMATCH_ERROR_FILE="${src_dir}/chromeos/check/smatch_errors.log" |
| 581 | |
Simon Que | 6324b6f | 2013-02-01 14:56:05 -0800 | [diff] [blame] | 582 | if use test && [[ -e "${SMATCH_ERROR_FILE}" ]]; then |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 583 | local make_check_cmd="smatch -p=kernel" |
| 584 | local test_options=( |
| 585 | CHECK="${make_check_cmd}" |
| 586 | C=1 |
| 587 | ) |
| 588 | SMATCH_LOG_FILE="$(cros-workon_get_build_dir)/make.log" |
| 589 | |
| 590 | # The path names in the log file are build-dependent. Strip out |
| 591 | # the part of the path before "kernel/files" and retains what |
| 592 | # comes after it: the file, line number, and error message. |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 593 | kmake -k ${build_targets[@]} "${test_options[@]}" |& \ |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 594 | tee "${SMATCH_LOG_FILE}" |
| 595 | else |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 596 | kmake -k ${build_targets[@]} |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 597 | fi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 598 | |
| 599 | if use device_tree; then |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 600 | kmake -k dtbs |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 601 | fi |
| 602 | } |
| 603 | |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 604 | cros-kernel2_src_test() { |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 605 | [[ -e ${SMATCH_ERROR_FILE} ]] || \ |
| 606 | die "smatch whitelist file ${SMATCH_ERROR_FILE} not found!" |
| 607 | [[ -e ${SMATCH_LOG_FILE} ]] || \ |
| 608 | die "Log file from src_compile() ${SMATCH_LOG_FILE} not found!" |
| 609 | |
Simon Que | 4851c09 | 2013-01-16 12:04:06 -0800 | [diff] [blame] | 610 | grep -w error: "${SMATCH_LOG_FILE}" | grep -o "kernel/files/.*" \ |
| 611 | | sed s:"kernel/files/"::g > "${SMATCH_LOG_FILE}.errors" |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 612 | local num_errors=$(wc -l < "${SMATCH_LOG_FILE}.errors") |
| 613 | local num_warnings=$(egrep -wc "warn:|warning:" "${SMATCH_LOG_FILE}") |
| 614 | einfo "smatch found ${num_errors} errors and ${num_warnings} warnings." |
| 615 | |
| 616 | # Create a version of the error database that doesn't have line numbers, |
| 617 | # since line numbers will shift as code is added or removed. |
| 618 | local build_dir="$(cros-workon_get_build_dir)" |
| 619 | local no_line_numbers_file="${build_dir}/no_line_numbers.log" |
Chih-Chung Chang | f28e76e | 2013-04-08 11:53:29 +0800 | [diff] [blame] | 620 | sed -r -e "s/(:[0-9]+){1,2}//" \ |
| 621 | -e "s/\(see line [0-9]+\)//" \ |
| 622 | "${SMATCH_ERROR_FILE}" > "${no_line_numbers_file}" |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 623 | |
| 624 | # For every smatch error that came up during the build, check if it is |
| 625 | # in the error database file. |
| 626 | local num_unknown_errors=0 |
| 627 | local line="" |
| 628 | while read line; do |
Simon Que | fc5fc9d | 2013-01-28 15:19:38 -0800 | [diff] [blame] | 629 | local no_line_num=$(echo "${line}" | \ |
Chih-Chung Chang | f28e76e | 2013-04-08 11:53:29 +0800 | [diff] [blame] | 630 | sed -r -e "s/(:[0-9]+){1,2}//" \ |
| 631 | -e "s/\(see line [0-9]+\)//") |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 632 | if ! fgrep -q "${no_line_num}" "${no_line_numbers_file}"; then |
| 633 | eerror "Non-whitelisted error found: \"${line}\"" |
| 634 | : $(( ++num_unknown_errors )) |
| 635 | fi |
| 636 | done < "${SMATCH_LOG_FILE}.errors" |
| 637 | |
| 638 | [[ ${num_unknown_errors} -eq 0 ]] || \ |
| 639 | die "smatch found ${num_unknown_errors} unknown errors." |
| 640 | } |
| 641 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 642 | cros-kernel2_src_install() { |
| 643 | dodir /boot |
| 644 | kmake INSTALL_PATH="${D}/boot" install |
Chris Masone | 6e9b821 | 2013-01-14 11:03:02 -0800 | [diff] [blame] | 645 | if cros_chkconfig_present MODULES; then |
| 646 | kmake INSTALL_MOD_PATH="${D}" modules_install |
| 647 | fi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 648 | kmake INSTALL_MOD_PATH="${D}" firmware_install |
| 649 | |
Josh Triplett | 6df77a7 | 2013-04-26 17:25:37 -0700 | [diff] [blame] | 650 | local version=$(kernelrelease) |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 651 | if use arm; then |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 652 | local boot_dir="$(cros-workon_get_build_dir)/arch/${ARCH}/boot" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 653 | local kernel_bin="${D}/boot/vmlinuz-${version}" |
| 654 | local zimage_bin="${D}/boot/zImage-${version}" |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 655 | local dtb_dir="${boot_dir}" |
| 656 | |
| 657 | # Newer kernels (after linux-next 12/3/12) put dtbs in the dts |
| 658 | # dir. Use that if we we find no dtbs directly in boot_dir. |
| 659 | # Note that we try boot_dir first since the newer kernel will |
| 660 | # actually rm ${boot_dir}/*.dtb so we'll have no stale files. |
| 661 | if ! ls "${dtb_dir}"/*.dtb &> /dev/null; then |
| 662 | dtb_dir="${boot_dir}/dts" |
| 663 | fi |
| 664 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 665 | if use device_tree; then |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 666 | local its_script="$(cros-workon_get_build_dir)/its_script" |
Doug Anderson | f2bb288 | 2012-12-06 15:56:21 -0800 | [diff] [blame] | 667 | emit_its_script "${its_script}" "${boot_dir}" \ |
| 668 | "${dtb_dir}" $(get_dtb_name "${dtb_dir}") |
Andrew Chew | a069542 | 2013-03-19 16:39:58 -0700 | [diff] [blame] | 669 | mkimage -D "-I dts -O dtb -p 512" -f "${its_script}" "${kernel_bin}" || die |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 670 | else |
| 671 | cp -a "${boot_dir}/uImage" "${kernel_bin}" || die |
| 672 | fi |
| 673 | cp -a "${boot_dir}/zImage" "${zimage_bin}" || die |
| 674 | |
| 675 | # TODO(vbendeb): remove the below .uimg link creation code |
| 676 | # after the build scripts have been modified to use the base |
| 677 | # image name. |
| 678 | cd $(dirname "${kernel_bin}") |
| 679 | ln -sf $(basename "${kernel_bin}") vmlinux.uimg || die |
| 680 | ln -sf $(basename "${zimage_bin}") zImage || die |
| 681 | fi |
| 682 | if [ ! -e "${D}/boot/vmlinuz" ]; then |
| 683 | ln -sf "vmlinuz-${version}" "${D}/boot/vmlinuz" || die |
| 684 | fi |
| 685 | |
Vic Yang | 40fff21 | 2012-05-14 10:43:11 +0800 | [diff] [blame] | 686 | # Check the size of kernel image and issue warning when image size is near |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 687 | # the limit. For factory install initramfs, we don't care about kernel |
| 688 | # size limit as the image is downloaded over network. |
Vic Yang | 40fff21 | 2012-05-14 10:43:11 +0800 | [diff] [blame] | 689 | local kernel_image_size=$(stat -c '%s' -L "${D}"/boot/vmlinuz) |
| 690 | einfo "Kernel image size is ${kernel_image_size} bytes." |
Vic Yang | 9aabf9c | 2013-01-23 20:47:59 +0800 | [diff] [blame] | 691 | if use netboot_ramfs; then |
| 692 | # No need to check kernel image size. |
| 693 | true |
| 694 | elif [[ ${kernel_image_size} -gt $((8 * 1024 * 1024)) ]]; then |
Olof Johansson | cbbe887 | 2012-07-30 08:43:31 -0700 | [diff] [blame] | 695 | die "Kernel image is larger than 8 MB." |
| 696 | elif [[ ${kernel_image_size} -gt $((7 * 1024 * 1024)) ]]; then |
| 697 | ewarn "Kernel image is larger than 7 MB. Limit is 8 MB." |
Vic Yang | 40fff21 | 2012-05-14 10:43:11 +0800 | [diff] [blame] | 698 | fi |
| 699 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 700 | # Install uncompressed kernel for debugging purposes. |
| 701 | insinto /usr/lib/debug/boot |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 702 | doins "$(cros-workon_get_build_dir)/vmlinux" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 703 | |
| 704 | if use kernel_sources; then |
| 705 | install_kernel_sources |
Mike Frysinger | b5ebdb5 | 2013-02-10 03:25:44 -0500 | [diff] [blame] | 706 | else |
| 707 | dosym "$(cros-workon_get_build_dir)" "/usr/src/linux" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 708 | fi |
| 709 | } |
| 710 | |
Simon Que | 715e54f3 | 2012-12-20 15:53:13 -0800 | [diff] [blame] | 711 | EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile src_test src_install |