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