From 505a3f93504e12085ad7b78d12c4eb21f67cda1f Mon Sep 17 00:00:00 2001 From: Nathan Rossi Date: Thu, 1 Aug 2013 17:45:02 +1000 Subject: Refactored MACHINE_* usage * Added 'conf/machine/boards' as a default FILESEXTRAPATH (for each available layer). * Change MACHINE_* to rely only on the path being relative to 'conf/machine/boards'. * Fixed up linux-xlnx.inc and linux-machine-common.inc to use 'MACHINE_*' for default files. * Fixed KERNEL_DEVICETREE setting such that the variable is valid before the base __anonymous function of linux-dtb.inc is executed. Signed-off-by: Nathan Rossi --- conf/layer.conf | 3 - conf/machine/kc705-trd-microblazeel.conf | 6 +- conf/machine/qemumicroblaze.conf | 4 +- conf/machine/qemuzynq.conf | 2 +- conf/machine/zc702-zynq7.conf | 4 +- conf/machine/zedboard-zynq7.conf | 6 +- recipes-bsp/u-boot/u-boot-extra.inc | 15 +++-- recipes-kernel/linux/linux-machine-common.inc | 4 +- recipes-kernel/linux/linux-machine-config.inc | 85 +++++++++++++++++++-------- recipes-kernel/linux/linux-xlnx.inc | 4 +- 10 files changed, 86 insertions(+), 47 deletions(-) diff --git a/conf/layer.conf b/conf/layer.conf index ba976bad..d6f07d3d 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -8,6 +8,3 @@ BBFILES += " ${LAYERDIR}/recipes-*/*/*.bbappend" BBFILE_COLLECTIONS += "xilinx" BBFILE_PATTERN_xilinx := "^${LAYERDIR}/" BBFILE_PRIORITY_xilinx = "8" - -XILINX_LAYERDIR := "${LAYERDIR}" -XILINX_BOARDDIR := "${XILINX_LAYERDIR}/conf/machine/boards" diff --git a/conf/machine/kc705-trd-microblazeel.conf b/conf/machine/kc705-trd-microblazeel.conf index 4552824e..86315ba6 100644 --- a/conf/machine/kc705-trd-microblazeel.conf +++ b/conf/machine/kc705-trd-microblazeel.conf @@ -19,6 +19,6 @@ TUNE_FEATURES_tune-microblaze += "v8.50 little-endian barrel-shift pattern-compa SERIAL_CONSOLE = "115200 ttyS0" -MACHINE_DEVICETREE := "${XILINX_BOARDDIR}/kc705/kc705-trd-microblazeel.dts" -MACHINE_KCONFIG := "${XILINX_BOARDDIR}/kc705/kc705-trd-microblazeel.kconfig.cfg" -MACHINE_XPARAMETERS := "${XILINX_BOARDDIR}/kc705/kc705-trd-microblazeel.xparameters.h" +MACHINE_DEVICETREE := "kc705/kc705-trd-microblazeel.dts" +MACHINE_KCONFIG := "kc705/kc705-trd-microblazeel.kconfig.cfg" +MACHINE_XPARAMETERS := "kc705/kc705-trd-microblazeel.xparameters.h" diff --git a/conf/machine/qemumicroblaze.conf b/conf/machine/qemumicroblaze.conf index 67a22f3e..824dbf47 100644 --- a/conf/machine/qemumicroblaze.conf +++ b/conf/machine/qemumicroblaze.conf @@ -9,5 +9,5 @@ TUNE_FEATURES_tune-microblaze += "v8.50 little-endian barrel-shift reorder patte SERIAL_CONSOLE = "115200 ttyS0" -MACHINE_DEVICETREE := "${XILINX_BOARDDIR}/qemu/qemumicroblaze.dts" -MACHINE_KCONFIG := "${XILINX_BOARDDIR}/qemu/qemumicroblaze.cfg" +MACHINE_DEVICETREE := "qemu/qemumicroblaze.dts" +MACHINE_KCONFIG := "qemu/qemumicroblaze.cfg" diff --git a/conf/machine/qemuzynq.conf b/conf/machine/qemuzynq.conf index 7db1b0bb..a260dd32 100644 --- a/conf/machine/qemuzynq.conf +++ b/conf/machine/qemuzynq.conf @@ -8,4 +8,4 @@ require conf/machine/include/tune-zynq.inc SERIAL_CONSOLE = "115200 ttyPS0" -MACHINE_DEVICETREE := "${XILINX_BOARDDIR}/qemu/qemuzynq.dts" +MACHINE_DEVICETREE := "qemu/qemuzynq.dts" diff --git a/conf/machine/zc702-zynq7.conf b/conf/machine/zc702-zynq7.conf index 2db72377..bb7fb8d7 100644 --- a/conf/machine/zc702-zynq7.conf +++ b/conf/machine/zc702-zynq7.conf @@ -19,5 +19,5 @@ UBOOT_MACHINE = "zynq_zc70x_config" SERIAL_CONSOLE = "115200 ttyPS0" -MACHINE_DEVICETREE := "${XILINX_BOARDDIR}/zc702/zc702-zynq7.dts" -MACHINE_KCONFIG := "${XILINX_BOARDDIR}/common/rtc.cfg" +MACHINE_DEVICETREE := "zc702/zc702-zynq7.dts" +MACHINE_KCONFIG := "common/rtc.cfg" diff --git a/conf/machine/zedboard-zynq7.conf b/conf/machine/zedboard-zynq7.conf index 18223796..6dbb8f75 100644 --- a/conf/machine/zedboard-zynq7.conf +++ b/conf/machine/zedboard-zynq7.conf @@ -20,7 +20,7 @@ UBOOT_MACHINE = "zynq_zed_config" SERIAL_CONSOLE = "115200 ttyPS0" MACHINE_DEVICETREE := " \ - ${XILINX_BOARDDIR}/zedboard/zedboard-zynq7.dtsi \ - ${XILINX_BOARDDIR}/zedboard/zedboard-zynq7-mmcblk0p2.dts \ - ${XILINX_BOARDDIR}/zedboard/zedboard-zynq7-ram.dts \ + zedboard/zedboard-zynq7.dtsi \ + zedboard/zedboard-zynq7-mmcblk0p2.dts \ + zedboard/zedboard-zynq7-ram.dts \ " diff --git a/recipes-bsp/u-boot/u-boot-extra.inc b/recipes-bsp/u-boot/u-boot-extra.inc index 79808a37..e1c89d05 100644 --- a/recipes-bsp/u-boot/u-boot-extra.inc +++ b/recipes-bsp/u-boot/u-boot-extra.inc @@ -20,9 +20,16 @@ do_deploy_append() { # and generate a u-boot specific config.mk do_configure_prepend () { if [ "${SOC_FAMILY}" = "microblaze" -a ! -z "${MACHINE_XPARAMETERS}" ]; then - if [ ! -z "${MACHINE_XPARAMETERS}" -a -e "${MACHINE_XPARAMETERS}" ]; then + # Find the file based on the avaliable layers (using $BBPATH) + MACHINE_XPARAMETERS_ABSOLUTE= + for i in ${BBPATH}; do + if [ -e $i/conf/machine/boards/${MACHINE_XPARAMETERS} ]; then + MACHINE_XPARAMETERS_ABSOLUTE = $i/conf/machine/boards/${MACHINE_XPARAMETERS} + fi + done + if [ -e "${MACHINE_XPARAMETERS_ABSOLUTE}" ]; then CONFIG_MK=${S}/board/xilinx/microblaze-generic/config.mk - cp ${MACHINE_XPARAMETERS} ${S}/board/xilinx/microblaze-generic/xparameters.h + cp ${MACHINE_XPARAMETERS_ABSOLUTE} ${S}/board/xilinx/microblaze-generic/xparameters.h # Generate the config.mk from CFLAGS and XPARAMETERS file echo "# This file is generated by the meta-xilinx layer." > ${CONFIG_MK} @@ -36,8 +43,8 @@ do_configure_prepend () { echo "" >> ${CONFIG_MK} # Calculate the TEXT_BASE address at RAM_END - 4MB - RAM_START=$(grep "XILINX_RAM_START" ${MACHINE_XPARAMETERS} | grep -o "0x.*$") - RAM_SIZE=$(grep "XILINX_RAM_SIZE" ${MACHINE_XPARAMETERS} | grep -o "0x.*$") + RAM_START=$(grep "XILINX_RAM_START" ${MACHINE_XPARAMETERS_ABSOLUTE} | grep -o "0x.*$") + RAM_SIZE=$(grep "XILINX_RAM_SIZE" ${MACHINE_XPARAMETERS_ABSOLUTE} | grep -o "0x.*$") BASE_OFFSET=$(printf "0x%08x" "$[$RAM_START + $RAM_SIZE - 0x400000]") echo "TEXT_BASE = $BASE_OFFSET" >> ${CONFIG_MK} diff --git a/recipes-kernel/linux/linux-machine-common.inc b/recipes-kernel/linux/linux-machine-common.inc index 6d8cd8c5..2ef76ff9 100644 --- a/recipes-kernel/linux/linux-machine-common.inc +++ b/recipes-kernel/linux/linux-machine-common.inc @@ -5,6 +5,4 @@ require linux-machine-config.inc DEPENDS_append_microblaze += "u-boot-mkimage-native" # Common Device Tree Includes -# (put them in ${WORKDIR} to avoid using dtc with include paths) -FILESEXTRAPATHS_append := "${XILINX_LAYERDIR}/conf/machine/boards/common:" -SRC_URI_append += "file://zynq-7-base.dtsi" +MACHINE_DEVICETREE_append_zynq += "common/zynq-7-base.dtsi" diff --git a/recipes-kernel/linux/linux-machine-config.inc b/recipes-kernel/linux/linux-machine-config.inc index 184011f4..6568e4b5 100644 --- a/recipes-kernel/linux/linux-machine-config.inc +++ b/recipes-kernel/linux/linux-machine-config.inc @@ -1,34 +1,71 @@ +# +# This include file implements the MACHINE_DEVICETREE and MACHINE_KCONFIG +# variable handling for the Kernel. +# +# e.g. (set in the associated .conf) +# MACHINE_DEVICETREE := "zc702/zc702-zynq7.dts" +# MACHINE_KCONFIG := "common/rtc.cfg" +# +# This will expand out to: +# SRC_URI_append += "file://zc702/zc702-zynq7.dts file://common/rtc.cfg" +# KERNEL_DEVICETREE ?= "${WORKDIR}/devicetree/zc702-zynq7.dts" +# +# This include also adds all the 'conf/machine/boards' for all layers (that are +# available) to the FILESEXTRAPATHS. +# -# Scan all files in MACHINE_DEVICETREE and MACHINE_KCONFIG and populate SRC_URI, -# FILESEXTRAPATHS and KERNEL_DEVICETREE. -python __anonymous () { +# Returns a space seperated list of all '.dts' files which +def get_all_devicetrees(d): workdir = d.getVar("WORKDIR", True) machine_devicetree = d.getVar("MACHINE_DEVICETREE", True) or '' - machine_kconfigs = d.getVar("MACHINE_KCONFIG", True) or '' - extrapaths = set() - sources = set() if machine_devicetree: - # linux-dtb.inc gets processed before this '__anonymous' - depends = d.getVar("DEPENDS", True) - d.setVar("DEPENDS", "%s dtc-native" % depends) - packages = d.getVar("PACKAGES", True) - d.setVar("PACKAGES", "%s kernel-devicetree" % packages) - files=set() for path in machine_devicetree.split(): - sources.add("file://" + os.path.basename(path)) - extrapaths.add(os.path.dirname(path)) - if os.path.splitext(os.path.basename(path))[1] == '.dts': - files.add(os.path.join(workdir, os.path.basename(path))) - d.setVar("KERNEL_DEVICETREE", ' '.join(files)) - if machine_kconfigs: - for path in machine_kconfigs.split(): - files.add(os.path.join(workdir, os.path.basename(path))) - sources.add("file://" + os.path.basename(path)) - extrapaths.add(os.path.dirname(path)) + if os.path.splitext(path)[1] == '.dts': + files.add(os.path.join(workdir, "devicetree", os.path.basename(path))) + if len(files) != 0: + return ' '.join(files) + return '' + +# Retuns a ':' seperated list of expanded '${BBPATH}/$path' +def get_additional_bbpath_filespath(path, d): + board_extrapaths = [] + bbpath = d.getVar("BBPATH", True) or "" + for i in bbpath.split(":"): + board_extrapaths.append(os.path.join(i, path)) + if len(board_extrapaths): + return ":".join(board_extrapaths) + ":" + return "" + +# If KERNEL_DEVICETREE is not set, default to the device tree's provided by +# MACHINE_DEVICETREE +KERNEL_DEVICETREE ?= "${@get_all_devicetrees(d)}" + +# Appends the '/conf/machine/boards' path to FILESEXTRAPATHS for all +# layers (using the ${BBPATH}) +FILESEXTRAPATHS_append := "${@get_additional_bbpath_filespath('conf/machine/boards', d)}" - if len(extrapaths) != 0: - d.setVar("FILESEXTRAPATHS_append", ":".join(extrapaths) + ":") +# Using the MACHINE_DEVICETREE and MACHINE_KCONFIG vars, append them to SRC_URI +python () { + machine_devicetree = d.getVar("MACHINE_DEVICETREE", True) or '' + machine_kconfigs = d.getVar("MACHINE_KCONFIG", True) or '' + sources = set() + for path in (machine_devicetree.split() + machine_kconfigs.split()): + sources.add("file://" + path) if len(sources) != 0: d.setVar("SRC_URI_append", " %s " % " ".join(sources)) } + +# Copy all device tree's into the same directory. This is due to compatibility +# with dtc and the use of DTSI (Device Tree Includes), the version of DTC in +# Yocto does not provide include path support. +do_install_prepend() { + if test -n "${MACHINE_DEVICETREE}"; then + mkdir -p ${WORKDIR}/devicetree + for i in ${MACHINE_DEVICETREE}; do + if test -e ${WORKDIR}/$i; then + cp ${WORKDIR}/$i ${WORKDIR}/devicetree + fi + done + fi +} diff --git a/recipes-kernel/linux/linux-xlnx.inc b/recipes-kernel/linux/linux-xlnx.inc index b31d61bd..0065466d 100644 --- a/recipes-kernel/linux/linux-xlnx.inc +++ b/recipes-kernel/linux/linux-xlnx.inc @@ -18,8 +18,8 @@ COMPATIBLE_MACHINE = "qemumicroblaze|qemuzynq|microblaze|zynq" # Common kernel configuration parts # Arch specific kernel configuration parts -SRC_URI_append_zynq += "file://zynq_defconfig_${LINUX_VERSION}.cfg" -SRC_URI_append_microblaze += "file://microblaze_defconfig_${LINUX_VERSION}.cfg" +MACHINE_KCONFIG_append_zynq += "common/zynq_defconfig_${LINUX_VERSION}.cfg" +MACHINE_KCONFIG_append_microblaze += "common/microblaze_defconfig_${LINUX_VERSION}.cfg" # Add the modules directory to the 'kernel-base' files list FILES_kernel-base_append = " /lib/modules/${KERNEL_VERSION}/kernel" -- cgit v1.2.3-54-g00ecf