summaryrefslogtreecommitdiffstats
path: root/bsp/meta-freescale/classes
diff options
context:
space:
mode:
Diffstat (limited to 'bsp/meta-freescale/classes')
-rw-r--r--bsp/meta-freescale/classes/dtc-145.bbclass7
-rw-r--r--bsp/meta-freescale/classes/fsl-dynamic-packagearch.bbclass69
-rw-r--r--bsp/meta-freescale/classes/fsl-eula-unpack.bbclass68
-rw-r--r--bsp/meta-freescale/classes/fsl-kernel-localversion.bbclass43
-rw-r--r--bsp/meta-freescale/classes/fsl-u-boot-localversion.bbclass27
-rw-r--r--bsp/meta-freescale/classes/fsl-vivante-kernel-driver-handler.bbclass63
-rw-r--r--bsp/meta-freescale/classes/image_types_fsl.bbclass44
-rw-r--r--bsp/meta-freescale/classes/kernel-imximage.bbclass60
-rw-r--r--bsp/meta-freescale/classes/kernel-itbimage.bbclass493
-rw-r--r--bsp/meta-freescale/classes/machine-overrides-extender.bbclass56
-rw-r--r--bsp/meta-freescale/classes/mfgtool-initramfs-image.bbclass41
-rw-r--r--bsp/meta-freescale/classes/qoriq_build_64bit_kernel.bbclass18
-rw-r--r--bsp/meta-freescale/classes/use-imx-headers.bbclass19
13 files changed, 1008 insertions, 0 deletions
diff --git a/bsp/meta-freescale/classes/dtc-145.bbclass b/bsp/meta-freescale/classes/dtc-145.bbclass
new file mode 100644
index 00000000..d4a30711
--- /dev/null
+++ b/bsp/meta-freescale/classes/dtc-145.bbclass
@@ -0,0 +1,7 @@
+# Use this class for U-Boot 2017.03 or older.
+
+DEPENDS_append = " dtc-145-native"
+
+do_configure_prepend () {
+ sed -i -e 's/^DTC[[:space:]]*=[[:space:]]*dtc[[:space:]]*$/DTC = dtc-145/' ${S}/Makefile
+}
diff --git a/bsp/meta-freescale/classes/fsl-dynamic-packagearch.bbclass b/bsp/meta-freescale/classes/fsl-dynamic-packagearch.bbclass
new file mode 100644
index 00000000..a7cc53fc
--- /dev/null
+++ b/bsp/meta-freescale/classes/fsl-dynamic-packagearch.bbclass
@@ -0,0 +1,69 @@
+# Automatically set PACKAGE_ARCH for MACHINE_SOCARCH
+#
+# This allow to easy reuse of binary packages among similar SoCs. The
+# usual use for this is to share SoC specific packages among different
+# boards.
+#
+# MACHINE_SOCARCH_FILTER list all packages associated with
+# MACHINE_SOCARCH and, when match, will set PACKAGE_ARCH as MACHINE_SOCARCH
+#
+# MACHINE_ARCH_FILTER list all packages associated with
+# MACHINE_ARCH and, when match, will set PACKAGE_ARCH as MACHINE_ARCH
+#
+# For example, in meta-fsl-arm, this is used to share GPU packages for
+# i.MX53 boards (as all them share the AMD GPU) and i.MX6 based boards
+# (as all them share Vivante GPU).
+#
+# To use the class, specify, for example:
+#
+# MACHINE_SOCARCH_SUFFIX_soc = "-soc"
+#
+# and the need filters, as:
+#
+# MACHINE_ARCH_FILTER = "virtual/kernel"
+# MACHINE_SOCARCH_FILTER_soc = "virtual/libgles1 ... virtual/libgl"
+#
+# Copyright 2013-2016 (C) O.S. Systems Software LTDA.
+
+python __anonymous () {
+ machine_arch_filter = set((d.getVar("MACHINE_ARCH_FILTER", True) or "").split())
+ machine_socarch_filter = set((d.getVar("MACHINE_SOCARCH_FILTER", True) or "").split())
+ if machine_socarch_filter or machine_arch_filter:
+ provides = set((d.getVar("PROVIDES", True) or "").split())
+ depends = set((d.getVar("DEPENDS", True) or "").split())
+ PN = d.getVar("PN", True)
+
+ package_arch = None
+ if list(machine_arch_filter & (provides | depends)):
+ package_arch = d.getVar("MACHINE_ARCH", True)
+ elif list(machine_socarch_filter & (provides | depends)):
+ package_arch = d.getVar("MACHINE_SOCARCH", True)
+ if not package_arch:
+ raise bb.parse.SkipPackage("You must set MACHINE_SOCARCH as MACHINE_SOCARCH_FILTER is set for this SoC.")
+
+ machine_socarch_suffix = d.getVar("MACHINE_SOCARCH_SUFFIX", True)
+ if not machine_socarch_suffix:
+ raise bb.parse.SkipPackage("You must set MACHINE_SOCARCH_SUFFIX as MACHINE_SOCARCH_FILTER is set for this SoC.")
+
+ if package_arch:
+ bb.debug(1, "Use '%s' as package architecture for '%s'" % (package_arch, PN))
+ d.setVar("PACKAGE_ARCH", package_arch)
+
+ cur_package_archs = (d.getVar("PACKAGE_ARCHS", True) or "").split()
+ machine_socarch = (d.getVar("MACHINE_SOCARCH", True) or "")
+ if not machine_socarch in cur_package_archs:
+ d.appendVar("PACKAGE_EXTRA_ARCHS", " %s" % machine_socarch)
+
+ if d.getVar("TUNE_ARCH", True) == "arm":
+ # For ARM we have two possible machine_socarch values, one for the arm and one for the thumb instruction set
+ # add the other value to extra archs also, so that a image recipe searches both for packages.
+ if d.getVar("ARM_INSTRUCTION_SET", True) == "thumb":
+ d.appendVar("PACKAGE_EXTRA_ARCHS", " %s" % d.getVar("ARM_EXTRA_SOCARCH", True))
+ else:
+ d.appendVar("PACKAGE_EXTRA_ARCHS", " %s" % d.getVar("THUMB_EXTRA_SOCARCH", True))
+}
+
+MACHINE_SOCARCH = "${TUNE_PKGARCH}${MACHINE_SOCARCH_SUFFIX}"
+
+ARM_EXTRA_SOCARCH = "${ARMPKGARCH}${ARMPKGSFX_DSP}${ARMPKGSFX_EABI}${ARMPKGSFX_ENDIAN}${ARMPKGSFX_FPU}${MACHINE_SOCARCH_SUFFIX}"
+THUMB_EXTRA_SOCARCH = "${ARMPKGARCH}${ARM_THUMB_SUFFIX}${ARMPKGSFX_DSP}${ARMPKGSFX_EABI}${ARMPKGSFX_ENDIAN}${ARMPKGSFX_FPU}${MACHINE_SOCARCH_SUFFIX}"
diff --git a/bsp/meta-freescale/classes/fsl-eula-unpack.bbclass b/bsp/meta-freescale/classes/fsl-eula-unpack.bbclass
new file mode 100644
index 00000000..198a1944
--- /dev/null
+++ b/bsp/meta-freescale/classes/fsl-eula-unpack.bbclass
@@ -0,0 +1,68 @@
+# fsl-eula-unpack.bbclass provides the mechanism used for unpacking
+# the .bin file downloaded by HTTP and handle the EULA acceptance.
+#
+# To use it, the 'fsl-eula' parameter needs to be added to the
+# SRC_URI entry, e.g:
+#
+# SRC_URI = "${FSL_MIRROR}/firmware-imx-${PV};fsl-eula=true"
+
+LIC_FILES_CHKSUM_append = " file://${FSL_EULA_FILE};md5=ab61cab9599935bfe9f700405ef00f28"
+
+LIC_FILES_CHKSUM[vardepsexclude] += "FSL_EULA_FILE"
+
+python fsl_bin_do_unpack() {
+ src_uri = (d.getVar('SRC_URI', True) or "").split()
+ if len(src_uri) == 0:
+ return
+
+ localdata = bb.data.createCopy(d)
+ bb.data.update_data(localdata)
+
+ rootdir = localdata.getVar('WORKDIR', True)
+ fetcher = bb.fetch2.Fetch(src_uri, localdata)
+
+ for url in fetcher.ud.values():
+ save_cwd = os.getcwd()
+ # Check for supported fetchers
+ if url.type in ['http', 'https', 'ftp', 'file']:
+ if url.parm.get('fsl-eula', False):
+ # If download has failed, do nothing
+ if not os.path.exists(url.localpath):
+ bb.debug(1, "Exiting as '%s' cannot be found" % url.basename)
+ return
+
+ # Change to the working directory
+ bb.note("Handling file '%s' as a Freescale's EULA binary." % url.basename)
+ save_cwd = os.getcwd()
+ os.chdir(rootdir)
+
+ cmd = "sh %s --auto-accept --force" % (url.localpath)
+ bb.fetch2.runfetchcmd(cmd, d, quiet=True)
+
+ # Return to the previous directory
+ os.chdir(save_cwd)
+}
+
+python do_unpack() {
+ eula = d.getVar('ACCEPT_FSL_EULA', True)
+ eula_file = d.getVar('FSL_EULA_FILE', True)
+ pkg = d.getVar('PN', True)
+ if eula == None:
+ bb.fatal("To use '%s' you need to accept the Freescale EULA at '%s'. "
+ "Please read it and in case you accept it, write: "
+ "ACCEPT_FSL_EULA = \"1\" in your local.conf." % (pkg, eula_file))
+ elif eula == '0':
+ bb.fatal("To use '%s' you need to accept the Freescale EULA." % pkg)
+ else:
+ bb.note("Freescale EULA has been accepted for '%s'" % pkg)
+
+ # The binary unpack needs to be done first so 'S' is valid
+ bb.build.exec_func('fsl_bin_do_unpack', d)
+
+ try:
+ bb.build.exec_func('base_do_unpack', d)
+ except:
+ raise
+}
+
+do_unpack[vardepsexclude] += "FSL_EULA_FILE"
diff --git a/bsp/meta-freescale/classes/fsl-kernel-localversion.bbclass b/bsp/meta-freescale/classes/fsl-kernel-localversion.bbclass
new file mode 100644
index 00000000..ff1075e5
--- /dev/null
+++ b/bsp/meta-freescale/classes/fsl-kernel-localversion.bbclass
@@ -0,0 +1,43 @@
+# Freescale Kernel LOCALVERSION extension
+#
+# This allow to easy reuse of code between different kernel recipes
+#
+# The following options are supported:
+#
+# SCMVERSION Puts the Git hash in kernel local version
+# LOCALVERSION Value used in LOCALVERSION (default to '+fslc')
+#
+# Copyright 2014, 2015 (C) O.S. Systems Software LTDA.
+
+SCMVERSION ??= "y"
+LOCALVERSION ??= "+fslc"
+
+kernel_conf_variable() {
+ CONF_SED_SCRIPT="$CONF_SED_SCRIPT /CONFIG_$1[ =]/d;"
+ if test "$2" = "n"
+ then
+ echo "# CONFIG_$1 is not set" >> ${B}/.config
+ else
+ echo "CONFIG_$1=$2" >> ${B}/.config
+ fi
+}
+
+do_preconfigure() {
+ mkdir -p ${B}
+ echo "" > ${B}/.config
+ CONF_SED_SCRIPT=""
+
+ kernel_conf_variable LOCALVERSION "\"${LOCALVERSION}\""
+ if [ "${SCMVERSION}" = "y" ]; then
+ kernel_conf_variable LOCALVERSION_AUTO y
+ fi
+
+ sed -e "${CONF_SED_SCRIPT}" < '${WORKDIR}/defconfig' >> '${B}/.config'
+
+ if [ "${SCMVERSION}" = "y" ]; then
+ # Add GIT revision to the local version
+ head=`git --git-dir=${S}/.git rev-parse --verify --short HEAD 2> /dev/null`
+ printf "%s%s" +g $head > ${S}/.scmversion
+ fi
+}
+addtask preconfigure before do_configure after do_unpack do_patch
diff --git a/bsp/meta-freescale/classes/fsl-u-boot-localversion.bbclass b/bsp/meta-freescale/classes/fsl-u-boot-localversion.bbclass
new file mode 100644
index 00000000..617aae1d
--- /dev/null
+++ b/bsp/meta-freescale/classes/fsl-u-boot-localversion.bbclass
@@ -0,0 +1,27 @@
+# Freescale U-Boot LOCALVERSION extension
+#
+# This allow to easy reuse of code between different U-Boot recipes
+#
+# The following options are supported:
+#
+# SCMVERSION Puts the Git hash in U-Boot local version
+# LOCALVERSION Value used in LOCALVERSION (default to '+fslc')
+#
+# Copyright 2014 (C) O.S. Systems Software LTDA.
+
+SCMVERSION ??= "y"
+LOCALVERSION ??= "+fslc"
+
+UBOOT_LOCALVERSION = "${LOCALVERSION}"
+
+do_compile_prepend() {
+ if [ "${SCMVERSION}" = "y" ]; then
+ # Add GIT revision to the local version
+ head=`cd ${S} ; git rev-parse --verify --short HEAD 2> /dev/null`
+ printf "%s%s%s" "${UBOOT_LOCALVERSION}" +g $head > ${S}/.scmversion
+ printf "%s%s%s" "${UBOOT_LOCALVERSION}" +g $head > ${B}/.scmversion
+ else
+ printf "%s" "${UBOOT_LOCALVERSION}" > ${S}/.scmversion
+ printf "%s" "${UBOOT_LOCALVERSION}" > ${B}/.scmversion
+ fi
+}
diff --git a/bsp/meta-freescale/classes/fsl-vivante-kernel-driver-handler.bbclass b/bsp/meta-freescale/classes/fsl-vivante-kernel-driver-handler.bbclass
new file mode 100644
index 00000000..e0578f4e
--- /dev/null
+++ b/bsp/meta-freescale/classes/fsl-vivante-kernel-driver-handler.bbclass
@@ -0,0 +1,63 @@
+# Freescale Kernel Vivante Kernel Driver handler
+#
+# Enable the kernel to provide or not the Vivante kernel driver and
+# dynamically set the proper providers per machine.
+#
+# The following options are supported:
+#
+# MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT
+#
+# Machine does or does not have support for the Vivante kernel
+# driver, options are:
+#
+# 0 - machine does not have Vivante GPU driver support
+# 1 - machine has Vivante GPU driver support
+#
+# MACHINE_USES_VIVANTE_KERNEL_DRIVER_MODULE
+#
+# Machine uses the Vivante kernel driver as module, options are:
+#
+# 0 - enable the builtin kernel driver module
+# 1 - enable the external kernel module
+#
+# Copyright 2015, 2016 (C) O.S. Systems Software LTDA.
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+# Handle Vivante kernel driver setting:
+# 0 - machine does not have Vivante GPU driver support
+# 1 - machine has Vivante GPU driver support
+MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT ??= "0"
+
+# Use Vivante kernel driver module:
+# 0 - enable the builtin kernel driver module
+# 1 - enable the external kernel module
+MACHINE_USES_VIVANTE_KERNEL_DRIVER_MODULE ??= "${@d.getVar('MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT', False) or '0'}"
+
+python fsl_vivante_kernel_driver_handler () {
+ has_vivante_kernel_driver_support = e.data.getVar('MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT', True) or "0"
+ use_vivante_kernel_driver_module = e.data.getVar('MACHINE_USES_VIVANTE_KERNEL_DRIVER_MODULE', True) or "0"
+
+ if has_vivante_kernel_driver_support != "1":
+ return
+
+ if use_vivante_kernel_driver_module != "1":
+ e.data.appendVar('RPROVIDES_kernel-base', ' kernel-module-imx-gpu-viv')
+ e.data.appendVar('RREPLACES_kernel-base', ' kernel-module-imx-gpu-viv')
+ e.data.appendVar('RCONFLICTS_kernel-base', ' kernel-module-imx-gpu-viv')
+}
+
+addhandler fsl_vivante_kernel_driver_handler
+fsl_vivante_kernel_driver_handler[eventmask] = "bb.event.RecipePreFinalise"
+
+do_configure_append () {
+ if [ "${MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT}" = "1" ]; then
+ config="${B}/.config"
+
+ sed -i "/CONFIG_MXC_GPU_VIV[ =]/d" $config
+ if [ "${MACHINE_USES_VIVANTE_KERNEL_DRIVER_MODULE}" = "1" ]; then
+ echo "# CONFIG_MXC_GPU_VIV is not set" >> $config
+ else
+ echo "CONFIG_MXC_GPU_VIV=y" >> $config
+ fi
+ fi
+}
diff --git a/bsp/meta-freescale/classes/image_types_fsl.bbclass b/bsp/meta-freescale/classes/image_types_fsl.bbclass
new file mode 100644
index 00000000..c49c51b7
--- /dev/null
+++ b/bsp/meta-freescale/classes/image_types_fsl.bbclass
@@ -0,0 +1,44 @@
+inherit image_types
+
+# Handle u-boot suffixes
+UBOOT_SUFFIX ?= "bin"
+
+#
+# Handles i.MX mxs bootstream generation
+#
+MXSBOOT_NAND_ARGS ?= ""
+
+# U-Boot mxsboot generation for uSD
+do_image_uboot_mxsboot_sdcard[depends] += "u-boot-mxsboot-native:do_populate_sysroot \
+ u-boot:do_deploy"
+IMAGE_CMD_uboot-mxsboot-sdcard() {
+ mxsboot sd ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} \
+ ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot-mxsboot-sdcard
+ ln -sf ${IMAGE_NAME}.rootfs.uboot-mxsboot-sdcard \
+ ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.uboot-mxsboot-sdcard
+}
+
+# U-Boot mxsboot generation for NAND
+do_image_uboot_mxsboot_nand[depends] += "u-boot-mxsboot-native:do_populate_sysroot \
+ u-boot:do_deploy"
+IMAGE_CMD_uboot-mxsboot-nand() {
+ mxsboot ${MXSBOOT_NAND_ARGS} nand \
+ ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} \
+ ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.uboot-mxsboot-nand
+ ln -sf ${IMAGE_NAME}.rootfs.uboot-mxsboot-nand \
+ ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.uboot-mxsboot-nand
+}
+
+# In case we are building for i.MX23 or i.MX28 we need to have the
+# image stream built before the wic generation
+do_image_wic[depends] += " \
+ ${@bb.utils.contains('IMAGE_FSTYPES', 'uboot-mxsboot-sdcard', \
+ '${IMAGE_BASENAME}:do_image_uboot_mxsboot_sdcard', '', d)} \
+"
+
+# We need to apply a fixup inside of the partition table
+IMAGE_CMD_wic_append_mxs() {
+ # Change partition type for mxs processor family
+ bbnote "Setting partition type to 0x53 as required for mxs' SoC family."
+ echo -n S | dd of=$out${IMAGE_NAME_SUFFIX}.wic bs=1 count=1 seek=450 conv=notrunc
+}
diff --git a/bsp/meta-freescale/classes/kernel-imximage.bbclass b/bsp/meta-freescale/classes/kernel-imximage.bbclass
new file mode 100644
index 00000000..234cc00d
--- /dev/null
+++ b/bsp/meta-freescale/classes/kernel-imximage.bbclass
@@ -0,0 +1,60 @@
+# -*- python -*-
+# Linux kernel with DCD headers
+#
+# This new image type adds support to generate a Linux kernel with DCD
+# headers. Essentially it adds support to directly boot a Linux kernel
+# without a bootloader.
+#
+# As the Linux kernel will be boot directly, it required that the Device
+# Tree is appended to the kernel image. To have the Linux kernel
+# generated with the DCD headers, following steps must be followed:
+#
+# - Linux kernel recipe must inherit kernel-imximage class;
+# - Device Tree appended Linux kernel must be used
+# (KERNEL_DEVICETREE_BUNDLE = "1");
+# - DCD header configuration must be provided (dcd.cfg or
+# dcd-<devicetree>.cfg);
+#
+# Copyright 2017 (C) O.S. Systems Software LTDA.
+
+DEPENDS_append = ' u-boot-mkimage-native'
+
+IMXIMAGE_ENTRYPOINT ?= "${UBOOT_ENTRYPOINT}"
+
+imx_mkimage() {
+ uboot-mkimage -n $1 -T imximage -e ${IMXIMAGE_ENTRYPOINT} -d $2 $2.imx
+}
+
+gen_imximage() {
+ if [ -z "${IMXIMAGE_ENTRYPOINT}" ]; then
+ bbfatal "IMXIMAGE_ENTRYPOINT must have a valid value"
+ fi
+
+ for DTB in ${KERNEL_DEVICETREE}; do
+ DTB=`normalize_dtb "${DTB}"`
+ DTB_EXT=${DTB##*.}
+ DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
+ base_name="zImage-"${KERNEL_IMAGE_BASE_NAME}
+ symlink_name="zImage-"${KERNEL_IMAGE_SYMLINK_NAME}
+ DTB_NAME=`echo ${base_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
+ DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
+ for DCD in dcd-${DTB}.cfg dcd.cfg; do
+ if [ -e "${WORKDIR}/${DCD}" ]; then
+ if [ -e ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT}.bin ]; then
+ imx_mkimage ${WORKDIR}/${DCD} ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT}.bin
+ ln -sf ${DTB_NAME}.${DTB_EXT}.bin.imx ${DEPLOYDIR}/$type-${DTB_BASE_NAME}.${DTB_EXT}.bin.imx
+ fi
+
+ if [ -e ${DEPLOYDIR}/zImage-${INITRAMFS_BASE_NAME}-${DTB_BASE_NAME}.${DTB_EXT}.bin ]; then
+ imx_mkimage ${WORKDIR}/${DCD} ${DEPLOYDIR}/zImage-${INITRAMFS_BASE_NAME}-${DTB_BASE_NAME}.${DTB_EXT}.bin
+ ln -sf zImage-${INITRAMFS_BASE_NAME}-${DTB_BASE_NAME}.${DTB_EXT}.bin.imx \
+ ${DEPLOYDIR}/zImage-initramfs-${DTB_BASE_NAME}.${DTB_EXT}-${MACHINE}.bin.imx
+ fi
+ fi
+ done
+ done
+}
+
+do_deploy_append() {
+ gen_imximage
+}
diff --git a/bsp/meta-freescale/classes/kernel-itbimage.bbclass b/bsp/meta-freescale/classes/kernel-itbimage.bbclass
new file mode 100644
index 00000000..703fa616
--- /dev/null
+++ b/bsp/meta-freescale/classes/kernel-itbimage.bbclass
@@ -0,0 +1,493 @@
+inherit kernel-uboot uboot-sign
+
+python __anonymous () {
+ kerneltypes = d.getVar('KERNEL_IMAGETYPES') or ""
+ if 'itbImage' in kerneltypes.split():
+ depends = d.getVar("DEPENDS")
+ depends = "%s u-boot-mkimage-native dtc-native" % depends
+ d.setVar("DEPENDS", depends)
+
+ if d.getVar("UBOOT_ARCH") == "x86":
+ replacementtype = "bzImage"
+ else:
+ replacementtype = "vmlinux"
+
+ # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal
+ # to kernel.bbclass . We have to override it, since we pack zImage
+ # (at least for now) into the fitImage .
+ typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE") or ""
+ if 'itbImage' in typeformake.split():
+ d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('itbImage', replacementtype))
+
+ image = d.getVar('INITRAMFS_IMAGE')
+ if image:
+ d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
+ def extraimage_getdepends(task):
+ deps = ""
+ for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split():
+ deps += " %s:%s" % (dep, task)
+ return deps
+
+ d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_populate_lic'))
+ d.appendVarFlag('do_image_complete', 'depends', extraimage_getdepends('do_populate_sysroot'))
+
+ # Verified boot will sign the fitImage and append the public key to
+ # U-Boot dtb. We ensure the U-Boot dtb is deployed before assembling
+ # the fitImage:
+ if d.getVar('UBOOT_SIGN_ENABLE') == "1":
+ uboot_pn = d.getVar('PREFERRED_PROVIDER_u-boot') or 'u-boot'
+ d.appendVarFlag('do_assemble_fitimage', 'depends', ' %s:do_deploy' % uboot_pn)
+}
+
+# Options for the device tree compiler passed to mkimage '-D' feature:
+UBOOT_MKIMAGE_DTCOPTS ??= ""
+
+#
+# Emit the fitImage ITS header
+#
+# $1 ... .its filename
+fitimage_emit_fit_header() {
+ cat << EOF >> ${1}
+/dts-v1/;
+
+/ {
+ description = "U-Boot fitImage for ${DISTRO_NAME}/${PV}/${MACHINE}";
+ #address-cells = <1>;
+EOF
+}
+
+#
+# Emit the fitImage section bits
+#
+# $1 ... .its filename
+# $2 ... Section bit type: imagestart - image section start
+# confstart - configuration section start
+# sectend - section end
+# fitend - fitimage end
+#
+fitimage_emit_section_maint() {
+ case $2 in
+ imagestart)
+ cat << EOF >> ${1}
+
+ images {
+EOF
+ ;;
+ confstart)
+ cat << EOF >> ${1}
+
+ configurations {
+EOF
+ ;;
+ sectend)
+ cat << EOF >> ${1}
+ };
+EOF
+ ;;
+ fitend)
+ cat << EOF >> ${1}
+};
+EOF
+ ;;
+ esac
+}
+
+#
+# Emit the fitImage ITS kernel section
+#
+# $1 ... .its filename
+# $2 ... Image counter
+# $3 ... Path to kernel image
+# $4 ... Compression type
+fitimage_emit_section_kernel() {
+
+ kernel_csum="sha1"
+
+ ENTRYPOINT=${UBOOT_ENTRYPOINT}
+ if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then
+ ENTRYPOINT=`${HOST_PREFIX}nm ${S}/vmlinux | \
+ awk '$4=="${UBOOT_ENTRYSYMBOL}" {print $2}'`
+ fi
+
+ cat << EOF >> ${1}
+ kernel@${2} {
+ description = "Linux kernel";
+ data = /incbin/("${3}");
+ type = "kernel";
+ arch = "${UBOOT_ARCH}";
+ os = "linux";
+ compression = "${4}";
+ load = <${UBOOT_LOADADDRESS}>;
+ entry = <${ENTRYPOINT}>;
+ hash@1 {
+ algo = "${kernel_csum}";
+ };
+ };
+EOF
+}
+
+#
+# Emit the fitImage ITS DTB section
+#
+# $1 ... .its filename
+# $2 ... Image counter
+# $3 ... Path to DTB image
+fitimage_emit_section_dtb() {
+
+ dtb_csum="sha1"
+
+ if [ -n "${DTB_LOAD}" ]; then
+ dtb_loadline="load = <${DTB_LOAD}>;"
+ fi
+
+ cat << EOF >> ${1}
+ fdt@${2} {
+ description = "Flattened Device Tree blob";
+ data = /incbin/("${3}");
+ type = "flat_dt";
+ arch = "${UBOOT_ARCH}";
+ compression = "none";
+ ${dtb_loadline}
+ hash@1 {
+ algo = "${dtb_csum}";
+ };
+ };
+EOF
+}
+
+#
+# Emit the fitImage ITS setup section
+#
+# $1 ... .its filename
+# $2 ... Image counter
+# $3 ... Path to setup image
+fitimage_emit_section_setup() {
+
+ setup_csum="sha1"
+
+ cat << EOF >> ${1}
+ setup@${2} {
+ description = "Linux setup.bin";
+ data = /incbin/("${3}");
+ type = "x86_setup";
+ arch = "${UBOOT_ARCH}";
+ os = "linux";
+ compression = "none";
+ load = <0x00090000>;
+ entry = <0x00090000>;
+ hash@1 {
+ algo = "${setup_csum}";
+ };
+ };
+EOF
+}
+
+#
+# Emit the fitImage ITS ramdisk section
+#
+# $1 ... .its filename
+# $2 ... Image counter
+# $3 ... Path to ramdisk image
+fitimage_emit_section_ramdisk() {
+
+ ramdisk_csum="sha1"
+ ramdisk_ctype="none"
+ ramdisk_loadline=""
+ ramdisk_entryline=""
+
+ if [ -n "${UBOOT_RD_LOADADDRESS}" ]; then
+ ramdisk_loadline="load = <${UBOOT_RD_LOADADDRESS}>;"
+ fi
+ if [ -n "${UBOOT_RD_ENTRYPOINT}" ]; then
+ ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;"
+ fi
+
+ case $3 in
+ *.gz)
+ ramdisk_ctype="gzip"
+ ;;
+ *.bz2)
+ ramdisk_ctype="bzip2"
+ ;;
+ *.lzma)
+ ramdisk_ctype="lzma"
+ ;;
+ *.lzo)
+ ramdisk_ctype="lzo"
+ ;;
+ *.lz4)
+ ramdisk_ctype="lz4"
+ ;;
+ esac
+
+ cat << EOF >> ${1}
+ ramdisk@${2} {
+ description = "${INITRAMFS_IMAGE}";
+ data = /incbin/("${3}");
+ type = "ramdisk";
+ arch = "${UBOOT_ARCH}";
+ os = "linux";
+ compression = "${ramdisk_ctype}";
+ ${ramdisk_loadline}
+ ${ramdisk_entryline}
+ hash@1 {
+ algo = "${ramdisk_csum}";
+ };
+ };
+EOF
+}
+
+#
+# Emit the fitImage ITS configuration section
+#
+# $1 ... .its filename
+# $2 ... Linux kernel ID
+# $3 ... DTB image name
+# $4 ... ramdisk ID
+# $5 ... config ID
+# $6 ... default flag
+fitimage_emit_section_config() {
+
+ conf_csum="sha1"
+ if [ -n "${UBOOT_SIGN_ENABLE}" ] ; then
+ conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
+ fi
+
+ # Test if we have any DTBs at all
+ conf_desc="Linux kernel"
+ kernel_line="kernel = \"kernel@${2}\";"
+ fdt_line=""
+ ramdisk_line=""
+ setup_line=""
+ default_line=""
+
+ if [ -n "${3}" ]; then
+ conf_desc="${conf_desc}, FDT blob"
+ fdt_line="fdt = \"fdt@${3}\";"
+ fi
+
+ if [ -n "${4}" ]; then
+ conf_desc="${conf_desc}, ramdisk"
+ ramdisk_line="ramdisk = \"ramdisk@${4}\";"
+ fi
+
+ if [ -n "${5}" ]; then
+ conf_desc="${conf_desc}, setup"
+ setup_line="setup = \"setup@${5}\";"
+ fi
+
+ if [ "${6}" = "1" ]; then
+ default_line="default = \"conf@${3}\";"
+ fi
+
+ cat << EOF >> ${1}
+ ${default_line}
+ conf@${3} {
+ description = "${6} ${conf_desc}";
+ ${kernel_line}
+ ${fdt_line}
+ ${ramdisk_line}
+ ${setup_line}
+ hash@1 {
+ algo = "${conf_csum}";
+ };
+EOF
+
+ if [ ! -z "${conf_sign_keyname}" ] ; then
+
+ sign_line="sign-images = \"kernel\""
+
+ if [ -n "${3}" ]; then
+ sign_line="${sign_line}, \"fdt\""
+ fi
+
+ if [ -n "${4}" ]; then
+ sign_line="${sign_line}, \"ramdisk\""
+ fi
+
+ if [ -n "${5}" ]; then
+ sign_line="${sign_line}, \"setup\""
+ fi
+
+ sign_line="${sign_line};"
+
+ cat << EOF >> ${1}
+ signature@1 {
+ algo = "${conf_csum},rsa2048";
+ key-name-hint = "${conf_sign_keyname}";
+ ${sign_line}
+ };
+EOF
+ fi
+
+ cat << EOF >> ${1}
+ };
+EOF
+}
+
+#
+# Assemble fitImage
+#
+# $1 ... .its filename
+# $2 ... fitImage name
+# $3 ... include ramdisk
+fitimage_assemble() {
+ kernelcount=1
+ dtbcount=""
+ DTBS=""
+ ramdiskcount=${3}
+ setupcount=""
+ rm -f ${1} arch/${ARCH}/boot/${2}
+
+ fitimage_emit_fit_header ${1}
+
+ #
+ # Step 1: Prepare a kernel image section.
+ #
+ fitimage_emit_section_maint ${1} imagestart
+
+ uboot_prep_kimage
+ fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin "${linux_comp}"
+
+ #
+ # Step 2: Prepare a DTB image section
+ #
+ if [ -n "${KERNEL_DEVICETREE}" ]; then
+ dtbcount=1
+ for DTB in ${KERNEL_DEVICETREE}; do
+ if echo ${DTB} | grep -q '/dts/'; then
+ bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
+ DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
+ fi
+ DTB_PATH="arch/${ARCH}/boot/dts/${DTB}"
+ DTB=`basename ${DTB}`
+ if [ ! -e "${DTB_PATH}" ]; then
+ DTB_PATH="arch/${ARCH}/boot/${DTB}"
+ fi
+
+ DTBS="${DTBS} ${DTB}"
+ fitimage_emit_section_dtb ${1} ${DTB} ${DTB_PATH}
+ done
+ fi
+
+ #
+ # Step 3: Prepare a setup section. (For x86)
+ #
+ if [ -e arch/${ARCH}/boot/setup.bin ]; then
+ setupcount=1
+ fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin
+ fi
+
+ #
+ # Step 4: Prepare a ramdisk section.
+ #
+ if [ "x${ramdiskcount}" = "x1" ] ; then
+ # Find and use the first initramfs image archive type we find
+ for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.gz ext2.gz cpio; do
+ initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.${img}"
+ echo "Using $initramfs_path"
+ if [ -e "${initramfs_path}" ]; then
+ fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}"
+ break
+ fi
+ done
+ fi
+
+ fitimage_emit_section_maint ${1} sectend
+
+ # Force the first Kernel and DTB in the default config
+ kernelcount=1
+ if [ -n "${dtbcount}" ]; then
+ dtbcount=1
+ fi
+
+ #
+ # Step 5: Prepare a configurations section
+ #
+ fitimage_emit_section_maint ${1} confstart
+
+ if [ -n "${DTBS}" ]; then
+ i=1
+ for DTB in ${DTBS}; do
+ fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${setupcount}" "`expr ${i} = ${dtbcount}`"
+ i=`expr ${i} + 1`
+ done
+ fi
+
+ fitimage_emit_section_maint ${1} sectend
+
+ fitimage_emit_section_maint ${1} fitend
+
+ #
+ # Step 6: Assemble the image
+ #
+ uboot-mkimage \
+ ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
+ -f ${1} \
+ arch/${ARCH}/boot/${2}
+
+ #
+ # Step 7: Sign the image and add public key to U-Boot dtb
+ #
+ if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then
+ uboot-mkimage \
+ ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
+ -F -k "${UBOOT_SIGN_KEYDIR}" \
+ -K "${DEPLOY_DIR_IMAGE}/${UBOOT_DTB_BINARY}" \
+ -r arch/${ARCH}/boot/${2}
+ fi
+}
+
+do_assemble_fitimage() {
+ if echo ${KERNEL_IMAGETYPES} | grep -wq "itbImage"; then
+ cd ${B}
+ fitimage_assemble itb-image.its itbImage
+ fi
+}
+
+addtask assemble_fitimage before do_install after do_compile
+
+do_assemble_fitimage_initramfs() {
+ if echo ${KERNEL_IMAGETYPES} | grep -wq "itbImage" && \
+ test -n "${INITRAMFS_IMAGE}" ; then
+ cd ${B}
+ fitimage_assemble itb-image-${INITRAMFS_IMAGE}.its itbImage-${INITRAMFS_IMAGE} 1
+ fi
+}
+
+addtask assemble_fitimage_initramfs before do_deploy after do_install
+
+
+kernel_do_deploy[vardepsexclude] = "DATETIME"
+kernel_do_deploy_append() {
+ # Update deploy directory
+ if echo ${KERNEL_IMAGETYPES} | grep -wq "itbImage"; then
+ cd ${B}
+ echo "Copying fit-image.its source file..."
+ its_base_name="itbImage-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
+ its_symlink_name=itbImage-its-${MACHINE}
+ install -m 0644 itb-image.its ${DEPLOYDIR}/${its_base_name}.its
+ linux_bin_base_name="itbImage-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
+ linux_bin_symlink_name=itbImage-linux.bin-${MACHINE}
+ install -m 0644 linux.bin ${DEPLOYDIR}/${linux_bin_base_name}.bin
+
+ if [ -n "${INITRAMFS_IMAGE}" ]; then
+ echo "Copying fit-image-${INITRAMFS_IMAGE}.its source file..."
+ its_initramfs_base_name="itbImage-its-${INITRAMFS_IMAGE_NAME}-${PV}-${PR}-${DATETIME}"
+ its_initramfs_symlink_name=itbImage-its-${INITRAMFS_IMAGE_NAME}
+ install -m 0644 itb-image-${INITRAMFS_IMAGE}.its ${DEPLOYDIR}/${its_initramfs_base_name}.its
+ fit_initramfs_base_name="itbImage-${INITRAMFS_IMAGE_NAME}-${PV}-${PR}-${DATETIME}"
+ fit_initramfs_symlink_name=itbImage-${INITRAMFS_IMAGE_NAME}
+ install -m 0644 arch/${ARCH}/boot/itbImage-${INITRAMFS_IMAGE} ${DEPLOYDIR}/${fit_initramfs_base_name}.bin
+ fi
+
+ cd ${DEPLOYDIR}
+ ln -sf ${its_base_name}.its ${its_symlink_name}.its
+ ln -sf ${linux_bin_base_name}.bin ${linux_bin_symlink_name}.bin
+
+ if [ -n "${INITRAMFS_IMAGE}" ]; then
+ ln -sf ${its_initramfs_base_name}.its ${its_initramfs_symlink_name}.its
+ ln -sf ${fit_initramfs_base_name}.bin ${fit_initramfs_symlink_name}.bin
+ fi
+ fi
+}
diff --git a/bsp/meta-freescale/classes/machine-overrides-extender.bbclass b/bsp/meta-freescale/classes/machine-overrides-extender.bbclass
new file mode 100644
index 00000000..959fdc16
--- /dev/null
+++ b/bsp/meta-freescale/classes/machine-overrides-extender.bbclass
@@ -0,0 +1,56 @@
+# -*- python -*-
+# Automatically set extend the MACHINEOVERRIDES
+#
+# This allow to grouping of different settings for similar platforms.
+#
+# To indicate that a SoC contains following set of overrides, you can use:
+#
+# MACHINEOVERRIDES_EXTENDER_soc = "group1:group2"
+#
+# However to indicate that an override replaces a set of other
+# overrides, you can use:
+#
+# MACHINEOVERRIDES_EXTENDER_FILTER_OUT_override = "group1 group2"
+#
+# Copyright 2016-2018 (C) O.S. Systems Software LTDA.
+
+def machine_overrides_extender(d):
+ machine_overrides = (d.getVar('PRISTINE_MACHINEOVERRIDES', True) or '').split(':')
+
+ # Gather the list of overrides to filter out
+ machine_overrides_filter_out = []
+ for override in machine_overrides:
+ machine_overrides_filter_out += (d.getVar('MACHINEOVERRIDES_EXTENDER_FILTER_OUT_%s' % override, True) or '').split()
+
+ # Drop any overrides of filter_out prior extending
+ machine_overrides = [o for o in machine_overrides if o not in machine_overrides_filter_out]
+
+ for override in machine_overrides:
+ extender = d.getVar('MACHINEOVERRIDES_EXTENDER_%s' % override, True)
+
+ if extender:
+ extender = extender.split(':')
+
+ # Drop any extension if in filter_out
+ extender = [e for e in extender if e not in machine_overrides_filter_out]
+
+ extender.reverse()
+ if not set(extender).issubset(set(machine_overrides)):
+ index = machine_overrides.index(override)
+ for e in extender:
+ machine_overrides.insert(index, e)
+
+ return ':'.join(machine_overrides)
+
+python machine_overrides_extender_handler() {
+ # Ideally we'd use a separate variable name for this however
+ # historically NXP BSPs used this. We save it to a known good name
+ # so we can reprocess OVERRIDES if/as/when needed.
+ d.renameVar("MACHINEOVERRIDES", "PRISTINE_MACHINEOVERRIDES")
+
+ # Now we add our own function intercept in instead
+ d.setVar("MACHINEOVERRIDES", "${@machine_overrides_extender(d)}")
+}
+
+machine_overrides_extender_handler[eventmask] = "bb.event.ConfigParsed"
+addhandler machine_overrides_extender_handler
diff --git a/bsp/meta-freescale/classes/mfgtool-initramfs-image.bbclass b/bsp/meta-freescale/classes/mfgtool-initramfs-image.bbclass
new file mode 100644
index 00000000..65028b8f
--- /dev/null
+++ b/bsp/meta-freescale/classes/mfgtool-initramfs-image.bbclass
@@ -0,0 +1,41 @@
+# Generates a Manufacturing Tool Initramfs image
+#
+# This generates the initramfs used for the installation process. The
+# image provides the utilities which are used, in the target, during
+# the process and receive the commands from the MfgTool application.
+#
+# Copyright 2014-2017 (C) O.S. Systems Software LTDA.
+
+DEPENDS += "u-boot-mfgtool linux-mfgtool"
+
+FEATURE_PACKAGES_mtd = "packagegroup-fsl-mfgtool-mtd"
+FEATURE_PACKAGES_extfs = "packagegroup-fsl-mfgtool-extfs"
+FEATURE_PACKAGES_f2fs = "packagegroup-fsl-mfgtool-f2fs"
+
+IMAGE_FSTYPES = "cpio.gz.u-boot"
+IMAGE_FSTYPES_mxs = "cpio.gz.u-boot"
+IMAGE_ROOTFS_SIZE ?= "8192"
+
+# Filesystems enabled by default
+DEFAULT_FS_SUPPORT = " \
+ mtd \
+ extfs \
+"
+
+IMAGE_FEATURES = " \
+ ${DEFAULT_FS_SUPPORT} \
+ \
+ read-only-rootfs \
+"
+
+# Avoid installation of syslog
+BAD_RECOMMENDATIONS += "busybox-syslog"
+
+# Avoid static /dev
+USE_DEVFS = "1"
+
+inherit core-image
+
+CORE_IMAGE_BASE_INSTALL = " \
+ ${CORE_IMAGE_EXTRA_INSTALL} \
+"
diff --git a/bsp/meta-freescale/classes/qoriq_build_64bit_kernel.bbclass b/bsp/meta-freescale/classes/qoriq_build_64bit_kernel.bbclass
new file mode 100644
index 00000000..2209e339
--- /dev/null
+++ b/bsp/meta-freescale/classes/qoriq_build_64bit_kernel.bbclass
@@ -0,0 +1,18 @@
+inherit distro_features_check
+REQUIRED_DISTRO_FEATURES_e6500 += "multiarch"
+
+python () {
+ promote_kernel = d.getVar('BUILD_64BIT_KERNEL', False)
+ if promote_kernel == "1":
+ sys_multilib = 'powerpc64' + d.getVar('TARGET_VENDOR', False) + 'mllib64-' + d.getVar('HOST_OS', False)
+ tc_options = d.getVar('TOOLCHAIN_OPTIONS', False) + '/../lib64-' + d.getVar("MACHINE", False)
+ d.setVar('DEPENDS_append', ' lib64-gcc-cross-powerpc64 lib64-libgcc')
+ d.setVar('PATH_append', ':' + d.getVar('STAGING_BINDIR_NATIVE', False) + '/' + sys_multilib)
+ d.setVar('KERNEL_CC', d.getVar('CCACHE', False) + sys_multilib + '-' + 'gcc' + d.getVar('HOST_CC_KERNEL_ARCH', False) + tc_options)
+ d.setVar('KERNEL_LD', d.getVar('CCACHE', False) + sys_multilib + '-' + 'ld.bfd' + d.getVar('HOST_LD_KERNEL_ARCH', False) + tc_options)
+ d.setVar('KERNEL_AR', d.getVar('CCACHE', False) + sys_multilib + '-' + 'ar' + d.getVar('HOST_AR_KERNEL_ARCH', False))
+
+ error_qa = d.getVar('ERROR_QA', True)
+ if 'arch' in error_qa:
+ d.setVar('ERROR_QA', error_qa.replace(' arch', ''))
+}
diff --git a/bsp/meta-freescale/classes/use-imx-headers.bbclass b/bsp/meta-freescale/classes/use-imx-headers.bbclass
new file mode 100644
index 00000000..9dcd864d
--- /dev/null
+++ b/bsp/meta-freescale/classes/use-imx-headers.bbclass
@@ -0,0 +1,19 @@
+# Easy use of linux-imx-headers by packages
+#
+# This allow to easy reuse of binary packages among similar SoCs. The
+# usual use for this is to share SoC specific packages among different
+# boards independently of the kernel version it is using, as far it is
+# ABI compatible with the official version it will just work.
+#
+# All recipes using this class ought to depend on linux-imx-headers
+# and by default to use MACHINE_SOCARCH.
+#
+# Please use the STAGING_INCDIR_IMX variable to refer to the installed
+# headers.
+#
+# Copyright 2018 (C) O.S. Systems Software LTDA.
+
+DEPENDS_append_imx = " linux-imx-headers"
+PACKAGE_ARCH_imx ?= "${MACHINE_SOCARCH}"
+
+STAGING_INCDIR_IMX = "${STAGING_INCDIR}/imx"