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 | |
| 6 | inherit binutils-funcs cros-board toolchain-funcs |
| 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 ) |
| 14 | " |
| 15 | |
| 16 | IUSE="-device_tree -kernel_sources" |
| 17 | STRIP_MASK="/usr/lib/debug/boot/vmlinux" |
Jonathan Kliegman | 8e55790 | 2012-05-08 15:46:40 -0400 | [diff] [blame] | 18 | CROS_WORKON_OUTOFTREE_BUILD=1 |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 19 | CROS_WORKON_INCREMENTAL_BUILD=1 |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 20 | |
| 21 | # Config fragments selected by USE flags |
Doug Anderson | 010887c | 2012-02-04 22:42:54 -0800 | [diff] [blame] | 22 | # ...fragments will have the following variables substitutions |
| 23 | # applied later (needs to be done later since these values |
| 24 | # aren't reliable when used in a global context like this): |
| 25 | # %ROOT% => ${ROOT} |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 26 | |
| 27 | CONFIG_FRAGMENTS=( |
| 28 | blkdevram |
Dylan Reid | f0666ff | 2012-07-01 21:42:38 -0700 | [diff] [blame] | 29 | ca0132 |
Micah Catlin | 0dc2b97 | 2012-08-01 17:44:24 -0700 | [diff] [blame] | 30 | cifs |
Mike Frysinger | 1bddd68 | 2012-10-05 14:52:25 -0400 | [diff] [blame] | 31 | debug |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 32 | fbconsole |
Ben Chan | e0654d2 | 2012-05-12 00:09:53 -0700 | [diff] [blame] | 33 | gdmwimax |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 34 | gobi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 35 | highmem |
| 36 | initramfs |
Ronald G. Minnich | 6d888d4 | 2012-02-16 13:45:58 -0800 | [diff] [blame] | 37 | kvm |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 38 | nfs |
| 39 | pcserial |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 40 | qmi |
Olof Johansson | 08268b0c | 2012-08-01 00:12:00 -0700 | [diff] [blame] | 41 | samsung_serial |
Dave Parker | 9fb68c9 | 2012-05-04 10:34:00 -0700 | [diff] [blame] | 42 | realtekpstor |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 43 | systemtap |
Vic Yang | 7cc29a9 | 2012-05-18 14:12:10 +0800 | [diff] [blame] | 44 | vfat |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 45 | ) |
| 46 | |
| 47 | blkdevram_desc="ram block device" |
| 48 | blkdevram_config=" |
| 49 | CONFIG_BLK_DEV_RAM=y |
| 50 | CONFIG_BLK_DEV_RAM_COUNT=16 |
| 51 | CONFIG_BLK_DEV_RAM_SIZE=16384 |
| 52 | " |
| 53 | |
Dylan Reid | f0666ff | 2012-07-01 21:42:38 -0700 | [diff] [blame] | 54 | ca0132_desc="CA0132 ALSA codec" |
| 55 | ca0132_config=" |
| 56 | CONFIG_SND_HDA_CODEC_CA0132=y |
Chih-Chung Chang | 2306b49 | 2012-09-04 19:52:18 +0800 | [diff] [blame] | 57 | CONFIG_SND_HDA_DSP_LOADER=y |
Dylan Reid | f0666ff | 2012-07-01 21:42:38 -0700 | [diff] [blame] | 58 | " |
| 59 | |
Micah Catlin | 0dc2b97 | 2012-08-01 17:44:24 -0700 | [diff] [blame] | 60 | cifs_desc="Samba/CIFS Support" |
| 61 | cifs_config=" |
| 62 | CONFIG_CIFS=m |
| 63 | " |
| 64 | |
Mike Frysinger | 1bddd68 | 2012-10-05 14:52:25 -0400 | [diff] [blame] | 65 | debug_desc="debug settings" |
| 66 | debug_config=" |
| 67 | CONFIG_DEBUG_INFO=y |
| 68 | " |
| 69 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 70 | fbconsole_desc="framebuffer console" |
| 71 | fbconsole_config=" |
| 72 | CONFIG_FRAMEBUFFER_CONSOLE=y |
| 73 | " |
| 74 | |
Ben Chan | e0654d2 | 2012-05-12 00:09:53 -0700 | [diff] [blame] | 75 | gdmwimax_desc="GCT GDM72xx WiMAX support" |
| 76 | gdmwimax_config=" |
| 77 | CONFIG_WIMAX_GDM72XX=m |
Ben Chan | e0654d2 | 2012-05-12 00:09:53 -0700 | [diff] [blame] | 78 | CONFIG_WIMAX_GDM72XX_USB=y |
| 79 | CONFIG_WIMAX_GDM72XX_USB_PM=y |
| 80 | " |
| 81 | |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 82 | gobi_desc="Qualcomm Gobi modem driver" |
| 83 | gobi_config=" |
| 84 | CONFIG_USB_NET_GOBI=m |
| 85 | " |
| 86 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 87 | highmem_desc="highmem" |
| 88 | highmem_config=" |
| 89 | CONFIG_HIGHMEM64G=y |
| 90 | " |
| 91 | |
| 92 | # We want to avoid copying modules into the initramfs so we need |
| 93 | # to enable the functionality required for the initramfs here. |
| 94 | # NOTES: |
| 95 | # - TPM support to ensure proper locking. |
Hung-Te Lin | 0c82629 | 2012-08-17 11:38:42 +0800 | [diff] [blame] | 96 | # - I2C-DEV support to make /dev/i2c-* available, for all devices having |
| 97 | # components on I2C bus and will be used during recovery / factory install |
| 98 | # stage. Ex: Ethernet, EC, ... etc. |
Vic Yang | 7cc29a9 | 2012-05-18 14:12:10 +0800 | [diff] [blame] | 99 | # - We need VFAT FS support for EFI System Partition updates, but it is not |
| 100 | # included here. We need to set USE="initramfs vfat" for recovery and factory |
| 101 | # install. |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 102 | initramfs_desc="initramfs" |
| 103 | initramfs_config=" |
Olof Johansson | 2290f06 | 2012-03-12 11:54:45 -0700 | [diff] [blame] | 104 | CONFIG_INITRAMFS_SOURCE=\"%ROOT%/var/lib/misc/initramfs.cpio.xz\" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 105 | CONFIG_TCG_TPM=y |
| 106 | CONFIG_TCG_TIS=y |
Hung-Te Lin | 0c82629 | 2012-08-17 11:38:42 +0800 | [diff] [blame] | 107 | CONFIG_I2C_CHARDEV=y |
Vic Yang | 7cc29a9 | 2012-05-18 14:12:10 +0800 | [diff] [blame] | 108 | " |
| 109 | |
| 110 | vfat_desc="vfat" |
| 111 | vfat_config=" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 112 | CONFIG_NLS_CODEPAGE_437=y |
| 113 | CONFIG_NLS_ISO8859_1=y |
| 114 | CONFIG_FAT_FS=y |
| 115 | CONFIG_VFAT_FS=y |
| 116 | " |
| 117 | |
Ronald G. Minnich | 6d888d4 | 2012-02-16 13:45:58 -0800 | [diff] [blame] | 118 | kvm_desc="KVM" |
| 119 | kvm_config=" |
| 120 | CONFIG_HAVE_KVM=y |
| 121 | CONFIG_HAVE_KVM_IRQCHIP=y |
| 122 | CONFIG_HAVE_KVM_EVENTFD=y |
| 123 | CONFIG_KVM_APIC_ARCHITECTURE=y |
| 124 | CONFIG_KVM_MMIO=y |
| 125 | CONFIG_KVM_ASYNC_PF=y |
| 126 | CONFIG_KVM=m |
| 127 | CONFIG_KVM_INTEL=m |
| 128 | # CONFIG_KVM_AMD is not set |
| 129 | # CONFIG_KVM_MMU_AUDIT is not set |
| 130 | CONFIG_VIRTIO=m |
| 131 | CONFIG_VIRTIO_BLK=m |
| 132 | CONFIG_VIRTIO_NET=m |
| 133 | CONFIG_VIRTIO_CONSOLE=m |
| 134 | CONFIG_VIRTIO_RING=m |
| 135 | CONFIG_VIRTIO_PCI=m |
| 136 | " |
| 137 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 138 | nfs_desc="NFS" |
| 139 | nfs_config=" |
| 140 | CONFIG_USB_NET_AX8817X=y |
| 141 | CONFIG_DNOTIFY=y |
| 142 | CONFIG_DNS_RESOLVER=y |
| 143 | CONFIG_LOCKD=y |
| 144 | CONFIG_LOCKD_V4=y |
| 145 | CONFIG_NETWORK_FILESYSTEMS=y |
| 146 | CONFIG_NFSD=m |
| 147 | CONFIG_NFSD_V3=y |
| 148 | CONFIG_NFSD_V4=y |
| 149 | CONFIG_NFS_COMMON=y |
| 150 | CONFIG_NFS_FS=y |
| 151 | CONFIG_NFS_USE_KERNEL_DNS=y |
| 152 | CONFIG_NFS_V3=y |
| 153 | CONFIG_NFS_V4=y |
| 154 | CONFIG_ROOT_NFS=y |
| 155 | CONFIG_RPCSEC_GSS_KRB5=y |
| 156 | CONFIG_SUNRPC=y |
| 157 | CONFIG_SUNRPC_GSS=y |
| 158 | CONFIG_USB_USBNET=y |
| 159 | CONFIG_IP_PNP=y |
| 160 | CONFIG_IP_PNP_DHCP=y |
| 161 | " |
| 162 | |
| 163 | pcserial_desc="PC serial" |
| 164 | pcserial_config=" |
| 165 | CONFIG_SERIAL_8250=y |
| 166 | CONFIG_SERIAL_8250_CONSOLE=y |
| 167 | CONFIG_SERIAL_8250_PCI=y |
| 168 | CONFIG_PARPORT=y |
| 169 | CONFIG_PARPORT_PC=y |
| 170 | CONFIG_PARPORT_SERIAL=y |
| 171 | " |
| 172 | |
Ben Chan | a179ebb | 2012-10-11 01:02:35 -0700 | [diff] [blame] | 173 | qmi_desc="QMI WWAN driver" |
| 174 | qmi_config=" |
| 175 | CONFIG_USB_NET_QMI_WWAN=m |
| 176 | " |
| 177 | |
Olof Johansson | 08268b0c | 2012-08-01 00:12:00 -0700 | [diff] [blame] | 178 | samsung_serial_desc="Samsung serialport" |
| 179 | samsung_serial_config=" |
| 180 | CONFIG_SERIAL_SAMSUNG=y |
| 181 | CONFIG_SERIAL_SAMSUNG_CONSOLE=y |
| 182 | " |
| 183 | |
Dave Parker | 9fb68c9 | 2012-05-04 10:34:00 -0700 | [diff] [blame] | 184 | realtekpstor_desc="Realtek PCI card reader" |
| 185 | realtekpstor_config=" |
| 186 | CONFIG_RTS_PSTOR=m |
| 187 | " |
| 188 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 189 | systemtap_desc="systemtap support" |
| 190 | systemtap_config=" |
| 191 | CONFIG_KPROBES=y |
| 192 | CONFIG_DEBUG_INFO=y |
| 193 | " |
| 194 | |
| 195 | # Add all config fragments as off by default |
| 196 | IUSE="${IUSE} ${CONFIG_FRAGMENTS[@]}" |
| 197 | |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 198 | # If an overlay has eclass overrides, but doesn't actually override this |
| 199 | # eclass, we'll have ECLASSDIR pointing to the active overlay's |
| 200 | # eclass/ dir, but this eclass is still in the main chromiumos tree. So |
| 201 | # add a check to locate the cros-kernel/ regardless of what's going on. |
| 202 | ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*} |
| 203 | defconfig_dir() { |
| 204 | local d="${ECLASSDIR}/cros-kernel" |
| 205 | if [[ ! -d ${d} ]] ; then |
| 206 | d="${ECLASSDIR_LOCAL}/cros-kernel" |
| 207 | fi |
| 208 | echo "${d}" |
| 209 | } |
| 210 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 211 | # @FUNCTION: install_kernel_sources |
| 212 | # @DESCRIPTION: |
| 213 | # Installs the kernel sources into ${D}/usr/src/${P} and fixes symlinks. |
| 214 | # The package must have already installed a directory under ${D}/lib/modules. |
| 215 | install_kernel_sources() { |
| 216 | local version=$(ls "${D}"/lib/modules) |
| 217 | local dest_modules_dir=lib/modules/${version} |
| 218 | local dest_source_dir=usr/src/${P} |
| 219 | local dest_build_dir=${dest_source_dir}/build |
| 220 | |
| 221 | # Fix symlinks in lib/modules |
| 222 | ln -sfvT "../../../${dest_build_dir}" \ |
| 223 | "${D}/${dest_modules_dir}/build" || die |
| 224 | ln -sfvT "../../../${dest_source_dir}" \ |
| 225 | "${D}/${dest_modules_dir}/source" || die |
| 226 | |
| 227 | einfo "Installing kernel source tree" |
| 228 | dodir "${dest_source_dir}" |
| 229 | local f |
| 230 | for f in "${S}"/*; do |
| 231 | [[ "$f" == "${S}/build" ]] && continue |
| 232 | cp -pPR "${f}" "${D}/${dest_source_dir}" || |
| 233 | die "Failed to copy kernel source tree" |
| 234 | done |
| 235 | |
| 236 | dosym "${P}" "/usr/src/linux" |
| 237 | |
| 238 | einfo "Installing kernel build tree" |
| 239 | dodir "${dest_build_dir}" |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 240 | 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] | 241 | "${D}/${dest_build_dir}" || die |
| 242 | |
| 243 | # Modify Makefile to use the ROOT environment variable if defined. |
| 244 | # This path needs to be absolute so that the build directory will |
| 245 | # still work if copied elsewhere. |
| 246 | sed -i -e "s@${S}@\$(ROOT)/${dest_source_dir}@" \ |
| 247 | "${D}/${dest_build_dir}/Makefile" || die |
| 248 | } |
| 249 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 250 | get_build_cfg() { |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 251 | echo "$(cros-workon_get_build_dir)/.config" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 254 | get_build_arch() { |
| 255 | if [ "${ARCH}" = "arm" ] ; then |
| 256 | case "${CHROMEOS_KERNEL_SPLITCONFIG}" in |
| 257 | *tegra*) |
| 258 | echo "tegra" |
| 259 | ;; |
| 260 | *exynos*) |
| 261 | echo "exynos5" |
| 262 | ;; |
| 263 | *) |
| 264 | echo "arm" |
| 265 | ;; |
| 266 | esac |
| 267 | else |
| 268 | echo $(tc-arch-kernel) |
| 269 | fi |
| 270 | } |
| 271 | |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 272 | cros-kernel2_pkg_setup() { |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 273 | cros-workon_pkg_setup |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 274 | } |
| 275 | |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 276 | # @FUNCTION: emit_its_script |
| 277 | # @USAGE: <output file> <device trees> |
| 278 | # @DESCRIPTION: |
| 279 | # Emits the its script used to build the u-boot fitImage kernel binary |
| 280 | # that contains the kernel as well as device trees used when booting |
| 281 | # it. |
| 282 | |
| 283 | emit_its_script() { |
| 284 | local iter=1 |
| 285 | local its_out=${1} |
| 286 | shift |
| 287 | cat > "${its_out}" <<-EOF || die |
| 288 | /dts-v1/; |
| 289 | |
| 290 | / { |
| 291 | description = "Chrome OS kernel image with one or more FDT blobs"; |
| 292 | #address-cells = <1>; |
| 293 | |
| 294 | images { |
| 295 | kernel@1 { |
| 296 | data = /incbin/("${boot_dir}/zImage"); |
| 297 | type = "$(get_kernel_type)"; |
| 298 | arch = "arm"; |
| 299 | os = "linux"; |
| 300 | compression = "none"; |
| 301 | load = <$(get_load_addr)>; |
| 302 | entry = <$(get_load_addr)>; |
| 303 | }; |
| 304 | EOF |
| 305 | |
| 306 | local dtb |
| 307 | for dtb in "$@" ; do |
| 308 | cat >> "${its_out}" <<-EOF || die |
| 309 | fdt@${iter} { |
| 310 | description = "$(basename ${dtb})"; |
| 311 | data = /incbin/("${boot_dir}/${dtb}"); |
| 312 | type = "flat_dt"; |
| 313 | arch = "arm"; |
| 314 | compression = "none"; |
| 315 | hash@1 { |
| 316 | algo = "sha1"; |
| 317 | }; |
| 318 | }; |
| 319 | EOF |
| 320 | ((++iter)) |
| 321 | done |
| 322 | |
| 323 | cat <<-EOF >>"${its_script}" |
| 324 | }; |
| 325 | configurations { |
| 326 | default = "conf@1"; |
| 327 | EOF |
| 328 | |
| 329 | local i |
| 330 | for i in $(seq 1 $((iter-1))) ; do |
| 331 | cat >> "${its_out}" <<-EOF || die |
| 332 | conf@${i} { |
| 333 | kernel = "kernel@1"; |
| 334 | fdt = "fdt@${i}"; |
| 335 | }; |
| 336 | EOF |
| 337 | done |
| 338 | |
| 339 | echo " };" >> "${its_out}" |
| 340 | echo "};" >> "${its_out}" |
| 341 | } |
| 342 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 343 | kmake() { |
| 344 | # Allow override of kernel arch. |
| 345 | local kernel_arch=${CHROMEOS_KERNEL_ARCH:-$(tc-arch-kernel)} |
| 346 | |
| 347 | local cross=${CHOST}- |
| 348 | # Hack for using 64-bit kernel with 32-bit user-space |
| 349 | if [ "${ARCH}" = "x86" -a "${kernel_arch}" = "x86_64" ]; then |
Sonny Rao | 5ebd89f | 2012-08-05 20:31:23 -0700 | [diff] [blame] | 350 | cross=x86_64-cros-linux-gnu- |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 351 | else |
| 352 | # TODO(raymes): Force GNU ld over gold. There are still some |
| 353 | # gold issues to iron out. See: 13209. |
| 354 | tc-export LD CC CXX |
| 355 | |
| 356 | set -- \ |
| 357 | LD="$(get_binutils_path_ld)/ld" \ |
| 358 | CC="${CC} -B$(get_binutils_path_ld)" \ |
| 359 | CXX="${CXX} -B$(get_binutils_path_ld)" \ |
| 360 | "$@" |
| 361 | fi |
| 362 | |
Mike Frysinger | a8ef3cd | 2012-11-01 18:42:18 -0400 | [diff] [blame^] | 363 | cw_emake \ |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 364 | ARCH=${kernel_arch} \ |
| 365 | LDFLAGS="$(raw-ldflags)" \ |
| 366 | CROSS_COMPILE="${cross}" \ |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 367 | O="$(cros-workon_get_build_dir)" \ |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 368 | "$@" |
| 369 | } |
| 370 | |
| 371 | cros-kernel2_src_configure() { |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 372 | # Use a single or split kernel config as specified in the board or variant |
| 373 | # make.conf overlay. Default to the arch specific split config if an |
| 374 | # overlay or variant does not set either CHROMEOS_KERNEL_CONFIG or |
| 375 | # CHROMEOS_KERNEL_SPLITCONFIG. CHROMEOS_KERNEL_CONFIG is set relative |
| 376 | # to the root of the kernel source tree. |
| 377 | local config |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 378 | local cfgarch="$(get_build_arch)" |
| 379 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 380 | if [ -n "${CHROMEOS_KERNEL_CONFIG}" ]; then |
| 381 | config="${S}/${CHROMEOS_KERNEL_CONFIG}" |
| 382 | else |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 383 | config=${CHROMEOS_KERNEL_SPLITCONFIG:-"chromiumos-${cfgarch}"} |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 384 | fi |
| 385 | |
| 386 | elog "Using kernel config: ${config}" |
| 387 | |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 388 | # Keep a handle on the old .config in case it hasn't changed. This way |
| 389 | # we can keep the old timestamp which will avoid regenerating stuff that |
| 390 | # hasn't actually changed. |
| 391 | local temp_config="${T}/old-kernel-config" |
| 392 | if [[ -e $(get_build_cfg) ]] ; then |
| 393 | cp -a "$(get_build_cfg)" "${temp_config}" |
| 394 | else |
| 395 | rm -f "${temp_config}" |
| 396 | fi |
| 397 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 398 | if [ -n "${CHROMEOS_KERNEL_CONFIG}" ]; then |
| 399 | cp -f "${config}" "$(get_build_cfg)" || die |
| 400 | else |
Olof Johansson | cd9c9fe | 2012-06-27 20:58:10 -0700 | [diff] [blame] | 401 | if [ -e chromeos/scripts/prepareconfig ] ; then |
| 402 | chromeos/scripts/prepareconfig ${config} \ |
| 403 | "$(get_build_cfg)" || die |
| 404 | else |
| 405 | config="$(defconfig_dir)/${cfgarch}_defconfig" |
| 406 | ewarn "Can't prepareconfig, falling back to default " \ |
| 407 | "${config}" |
| 408 | cp "${config}" "$(get_build_cfg)" || die |
| 409 | fi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 410 | fi |
| 411 | |
| 412 | local fragment |
| 413 | for fragment in ${CONFIG_FRAGMENTS[@]}; do |
| 414 | use ${fragment} || continue |
| 415 | |
| 416 | local msg="${fragment}_desc" |
| 417 | local config="${fragment}_config" |
| 418 | elog " - adding ${!msg} config" |
Doug Anderson | 010887c | 2012-02-04 22:42:54 -0800 | [diff] [blame] | 419 | |
| 420 | echo "${!config}" | \ |
| 421 | sed -e "s|%ROOT%|${ROOT}|g" \ |
| 422 | >> "$(get_build_cfg)" || die |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 423 | done |
| 424 | |
| 425 | # Use default for any options not explitly set in splitconfig |
| 426 | yes "" | kmake oldconfig |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 427 | |
| 428 | # Restore the old config if it is unchanged. |
| 429 | if cmp -s "$(get_build_cfg)" "${temp_config}" ; then |
| 430 | touch -r "${temp_config}" "$(get_build_cfg)" |
| 431 | fi |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 432 | } |
| 433 | |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 434 | get_dtb_name() { |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 435 | local board_with_variant=$(get_current_board_with_variant) |
| 436 | |
| 437 | # Do a simple mapping for device trees whose names don't match |
| 438 | # the board_with_variant format; default to just the |
| 439 | # board_with_variant format. |
| 440 | case "${board_with_variant}" in |
| 441 | (tegra2_dev-board) |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 442 | echo tegra-harmony.dtb |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 443 | ;; |
| 444 | (tegra2_seaboard) |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 445 | echo tegra-seaboard.dtb |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 446 | ;; |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 447 | tegra*) |
| 448 | echo ${board_with_variant}.dtb |
Olof Johansson | beaf472 | 2012-04-16 16:57:36 -0700 | [diff] [blame] | 449 | ;; |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 450 | *) |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 451 | local f |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 452 | for f in $(cros-workon_get_build_dir)/arch/arm/boot/*.dtb ; do |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 453 | basename ${f} |
| 454 | done |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 455 | ;; |
| 456 | esac |
| 457 | } |
| 458 | |
Olof Johansson | beaf472 | 2012-04-16 16:57:36 -0700 | [diff] [blame] | 459 | # All current tegra boards ship with an u-boot that won't allow |
| 460 | # use of kernel_noload. Because of this, keep using the traditional |
| 461 | # kernel type for those. This means kernel_type kernel and regular |
| 462 | # load and entry point addresses. |
| 463 | |
| 464 | get_kernel_type() { |
| 465 | case "$(get_current_board_with_variant)" in |
| 466 | tegra*) |
| 467 | echo kernel |
| 468 | ;; |
| 469 | *) |
| 470 | echo kernel_noload |
| 471 | ;; |
| 472 | esac |
| 473 | } |
| 474 | |
| 475 | get_load_addr() { |
| 476 | case "$(get_current_board_with_variant)" in |
| 477 | tegra*) |
| 478 | echo 0x03000000 |
| 479 | ;; |
| 480 | *) |
| 481 | echo 0 |
| 482 | ;; |
| 483 | esac |
| 484 | } |
| 485 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 486 | cros-kernel2_src_compile() { |
| 487 | local build_targets= # use make default target |
| 488 | if use arm; then |
| 489 | build_targets="uImage modules" |
| 490 | fi |
| 491 | |
| 492 | kmake -k ${build_targets} |
| 493 | |
| 494 | if use device_tree; then |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 495 | kmake -k dtbs |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 496 | fi |
| 497 | } |
| 498 | |
| 499 | cros-kernel2_src_install() { |
| 500 | dodir /boot |
| 501 | kmake INSTALL_PATH="${D}/boot" install |
| 502 | kmake INSTALL_MOD_PATH="${D}" modules_install |
| 503 | kmake INSTALL_MOD_PATH="${D}" firmware_install |
| 504 | |
| 505 | local version=$(ls "${D}"/lib/modules) |
| 506 | if use arm; then |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 507 | local boot_dir="$(cros-workon_get_build_dir)/arch/${ARCH}/boot" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 508 | local kernel_bin="${D}/boot/vmlinuz-${version}" |
| 509 | local zimage_bin="${D}/boot/zImage-${version}" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 510 | if use device_tree; then |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 511 | local its_script="$(cros-workon_get_build_dir)/its_script" |
Olof Johansson | b62cf89 | 2012-04-27 14:50:24 -0700 | [diff] [blame] | 512 | emit_its_script "${its_script}" $(get_dtb_name) |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 513 | mkimage -f "${its_script}" "${kernel_bin}" || die |
| 514 | else |
| 515 | cp -a "${boot_dir}/uImage" "${kernel_bin}" || die |
| 516 | fi |
| 517 | cp -a "${boot_dir}/zImage" "${zimage_bin}" || die |
| 518 | |
| 519 | # TODO(vbendeb): remove the below .uimg link creation code |
| 520 | # after the build scripts have been modified to use the base |
| 521 | # image name. |
| 522 | cd $(dirname "${kernel_bin}") |
| 523 | ln -sf $(basename "${kernel_bin}") vmlinux.uimg || die |
| 524 | ln -sf $(basename "${zimage_bin}") zImage || die |
| 525 | fi |
| 526 | if [ ! -e "${D}/boot/vmlinuz" ]; then |
| 527 | ln -sf "vmlinuz-${version}" "${D}/boot/vmlinuz" || die |
| 528 | fi |
| 529 | |
Vic Yang | 40fff21 | 2012-05-14 10:43:11 +0800 | [diff] [blame] | 530 | # Check the size of kernel image and issue warning when image size is near |
| 531 | # the limit. |
| 532 | local kernel_image_size=$(stat -c '%s' -L "${D}"/boot/vmlinuz) |
| 533 | einfo "Kernel image size is ${kernel_image_size} bytes." |
Olof Johansson | cbbe887 | 2012-07-30 08:43:31 -0700 | [diff] [blame] | 534 | if [[ ${kernel_image_size} -gt $((8 * 1024 * 1024)) ]]; then |
| 535 | die "Kernel image is larger than 8 MB." |
| 536 | elif [[ ${kernel_image_size} -gt $((7 * 1024 * 1024)) ]]; then |
| 537 | ewarn "Kernel image is larger than 7 MB. Limit is 8 MB." |
Vic Yang | 40fff21 | 2012-05-14 10:43:11 +0800 | [diff] [blame] | 538 | fi |
| 539 | |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 540 | # Install uncompressed kernel for debugging purposes. |
| 541 | insinto /usr/lib/debug/boot |
Mike Frysinger | 833d5f7 | 2012-08-07 18:11:59 -0400 | [diff] [blame] | 542 | doins "$(cros-workon_get_build_dir)/vmlinux" |
Doug Anderson | f291dba | 2012-01-19 14:26:10 -0800 | [diff] [blame] | 543 | |
| 544 | if use kernel_sources; then |
| 545 | install_kernel_sources |
| 546 | fi |
| 547 | } |
| 548 | |
Mike Frysinger | 3f4eaee | 2012-07-24 17:47:28 -0400 | [diff] [blame] | 549 | EXPORT_FUNCTIONS pkg_setup src_configure src_compile src_install |