Patchwork Handle of kernels which need dtc_cpp use

login
register
mail settings
Submitter André Draszik
Date July 22, 2013, 12:39 p.m.
Message ID <1374496759.6719.88.camel@bril0118.bri.st.com>
Download mbox | patch
Permalink /patch/54175/
State New
Headers show

Comments

André Draszik - July 22, 2013, 12:39 p.m.
Attached, but untested, as I'm not in a position to test master at the
moment.

Cheers,
Andre'

On Mon, 2013-07-22 at 09:34 -0300, Otavio Salvador wrote:
> On Mon, Jul 22, 2013 at 9:29 AM, André Draszik <andre.draszik@linaro.org> wrote:
> > Hi,
> >
> > I am using the attached.
> >
> > To use DTC+CPP, instead of giving the full path
> > arch/${ARCH}/boot/dts/<filename>, you only have to specify <filename> in
> > KERNEL_DEVICETREE.
> >
> > This was done to stay compatible with existing build rules, but I don't
> > know if this would work for the case ${ARCH} != arm
> 
> I tried to apply this on master and it failed. Can you please rebase
> this? This does look like the way to go.
> 
> --
> Otavio Salvador                             O.S. Systems
> http://www.ossystems.com.br        http://projetos.ossystems.com.br
> Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
Otavio Salvador - July 22, 2013, 1:44 p.m.
On Mon, Jul 22, 2013 at 9:39 AM, André Draszik <andre.draszik@linaro.org> wrote:
> Attached, but untested, as I'm not in a position to test master at the
> moment.

If I change the machine to have the filename.dtb, without the
fullpath, it works fine.

Can you send this for review? I think it'd be good to have more
feedback on this.

--
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://projetos.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750

Patch

From 3e55b7c4cea9fca3b7fc8b93c40f76dc8aec7610 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <andre.draszik@linaro.org>
Date: Fri, 19 Jul 2013 09:15:42 +0100
Subject: [PATCH] linux-dtb: allow to build dtb using support from kernel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The kernel build system has native support for device tree
source files that /include/ additional files and it also
supports the source file to be pre-processed using CPP.

This commits lets OE use the kbuild system if
$KERNEL_DEVICETREE points to file(s) that are located in
arch/${ARCH}/boot/dts/

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 meta/recipes-kernel/linux/linux-dtb.inc | 75 +++++++++++++++++++++++++++------
 1 file changed, 63 insertions(+), 12 deletions(-)

diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-kernel/linux/linux-dtb.inc
index 7747718..75b8b76 100644
--- a/meta/recipes-kernel/linux/linux-dtb.inc
+++ b/meta/recipes-kernel/linux/linux-dtb.inc
@@ -1,28 +1,66 @@ 
+inherit kernel-arch
+
 # Support for device tree generation
 FILES_kernel-devicetree = "/boot/devicetree*"
 KERNEL_DEVICETREE_FLAGS ?= "-R 8 -p 0x3000"
 
 python __anonymous () {
+    from os import path
+
     devicetree = d.getVar("KERNEL_DEVICETREE", True) or ''
     if devicetree:
-        depends = d.getVar("DEPENDS", True)
-        d.setVar("DEPENDS", "%s dtc-native" % depends)
+        S = d.getVar("S", True)
+        for DTS_FILE in devicetree.split():
+            DTS_FILE = S + "/" + DTS_FILE
+            if os.path.exists(DTS_FILE):
+                # full path given, use dtc-native
+                print "old style KERNEL_DEVICETREE, adding depend on dtc-native"
+                depends = d.getVar("DEPENDS", True)
+                d.setVar("DEPENDS", "%s dtc-native" % depends)
+            else:
+                # new style - it's just a file name, under arch/${ARCH}/boot/dts
+                # we don't need dtc-native, as we use the kernel's compiler
+                print "new style KERNEL_DEVICETREE"
         packages = d.getVar("PACKAGES", True)
         d.setVar("PACKAGES", "%s kernel-devicetree" % packages)
 }
 
-do_install_append() {
+do_compile_append() {
 	if test -n "${KERNEL_DEVICETREE}"; then
 		for DTS_FILE in ${KERNEL_DEVICETREE}; do
 			if [ ! -f ${DTS_FILE} ]; then
-				echo "Warning: ${DTS_FILE} is not available!"
-				continue
+				if [ ! -f arch/${ARCH}/boot/dts/${DTS_FILE} ]; then
+					echo "Warning: ${DTS_FILE} is not available!"
+					continue
+				fi
+
+				# standard build using kbuild
+				echo "Info: standard kbuild for device tree blob"
+				DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
+
+				unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
+				oe_runmake ${DTS_BASE_NAME}.dtb CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS}
 			fi
+		done
+	fi
+}
+
+do_install_append() {
+	if test -n "${KERNEL_DEVICETREE}"; then
+		for DTS_FILE in ${KERNEL_DEVICETREE}; do
 			DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
-			DTB_NAME=`echo ${KERNEL_IMAGE_BASE_NAME} | sed "s/${MACHINE}/${DTS_BASE_NAME}/g"`
 			DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTS_BASE_NAME}/g"`
-			dtc -I dts -O dtb ${KERNEL_DEVICETREE_FLAGS} -o ${DTS_BASE_NAME} ${DTS_FILE}
-			install -m 0644 ${DTS_BASE_NAME} ${D}/boot/devicetree-${DTB_SYMLINK_NAME}.dtb
+			if [ ! -f ${DTS_FILE} ]; then
+				if [ ! -f arch/${ARCH}/boot/dts/${DTS_FILE} ]; then
+					echo "Warning: ${DTS_FILE} is not available!"
+					continue
+				fi
+
+				install -m 0644 arch/${ARCH}/boot/${DTS_BASE_NAME}.dtb ${D}/boot/devicetree-${DTB_SYMLINK_NAME}.dtb
+				continue
+			fi
+			dtc -I dts -O dtb ${KERNEL_DEVICETREE_FLAGS} -o ${DTS_BASE_NAME}.dtb ${DTS_FILE}
+			install -m 0644 ${DTS_BASE_NAME}.dtb ${D}/boot/devicetree-${DTB_SYMLINK_NAME}.dtb
 		done
 	fi
 }
@@ -30,15 +68,28 @@  do_install_append() {
 do_deploy_append() {
 	if test -n "${KERNEL_DEVICETREE}"; then
 		for DTS_FILE in ${KERNEL_DEVICETREE}; do
+			DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
 			if [ ! -f ${DTS_FILE} ]; then
-				echo "Warning: ${DTS_FILE} is not available!"
-				continue
+				if [ ! -f arch/${ARCH}/boot/dts/${DTS_FILE} ]; then
+					echo "Warning: ${DTS_FILE} is not available!"
+					continue
+				fi
+
+				# standard build using kbuild
+				echo "Info: standard kbuild for device tree blob"
 			fi
-			DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
+
 			DTB_NAME=`echo ${KERNEL_IMAGE_BASE_NAME} | sed "s/${MACHINE}/${DTS_BASE_NAME}/g"`
 			DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTS_BASE_NAME}/g"`
+
 			install -d ${DEPLOYDIR}
-			install -m 0644 ${B}/${DTS_BASE_NAME} ${DEPLOYDIR}/${DTB_NAME}.dtb
+
+			if [ -f arch/${ARCH}/boot/dts/${DTS_FILE} ]; then
+				install -m 0644 ${B}/arch/${ARCH}/boot/${DTS_BASE_NAME}.dtb ${DEPLOYDIR}/${DTB_NAME}.dtb
+			else
+				install -m 0644 ${B}/${DTS_BASE_NAME}.dtb ${DEPLOYDIR}/${DTB_NAME}.dtb
+			fi
+
 			cd ${DEPLOYDIR}
 			ln -sf ${DTB_NAME}.dtb ${DTB_SYMLINK_NAME}.dtb
 			cd -
-- 
1.8.2