All of lore.kernel.org
 help / color / mirror / Atom feed
* use kernel build system for dtb compilation
@ 2013-07-15 16:50 Andre Draszik
  2013-07-22 14:02 ` [PATCH] linux-dtb: allow to build dtb using support from kernel André Draszik
  0 siblings, 1 reply; 4+ messages in thread
From: Andre Draszik @ 2013-07-15 16:50 UTC (permalink / raw)
  To: openembedded-core


[-- Attachment #1.1: Type: text/plain, Size: 978 bytes --]

Hi,

I have a use-case where I need to compile the dtb using the kernel build
system, and the kernel's device tree compiler:
- In dylan, dtc is outdated and can not compile our dts, as that needs
additional include files. dtc in dylan does not understand the include path
option -i, although the dtc that comes with linux-3.4.x does support it.
- Irrespective of the version of the dtc (dylan vs. master), the kernel
build system supports running dtsp files through CPP, which we also need

The attached patch changes linux-dtb.inc to support such a use-case

If KERNEL_DEVICETREE points to file(s) in arch/${ARCH}/boot/dts, instead of
full paths (relative to ${S}), kbuild is used, otherwise behaviour is
unchanged.

An alternative would be to copy what the kernel's Makefile is doing, but
that seems pointless, and still requires updating dtc to something more
recent in dylan.


What do you think about attached (incomplete) patch?


Cheers,
Andre'

[-- Attachment #1.2: Type: text/html, Size: 1124 bytes --]

[-- Attachment #2: 0001-linux-dtb-allow-to-build-dtb-using-kernel-build-syst.patch --]
[-- Type: application/octet-stream, Size: 4775 bytes --]

From 73bc3f26265dc46cba578c1da080a2d4002de195 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <andre.draszik@st.com>
Date: Mon, 15 Jul 2013 16:42:15 +0100
Subject: [PATCH] linux-dtb: allow to build dtb using kernel build system
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 from standard
directories, and it also supports the pre-processing of
source file(s) 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/

Still missing is a change to the dependency tracking python
code after which we would only add the dtc-native dependency
if the kernel build system is not used.

Signed-off-by: André Draszik <andre.draszik@st.com>
---
 meta/recipes-kernel/linux/linux-dtb.inc | 60 +++++++++++++++++++++++++++------
 1 file changed, 50 insertions(+), 10 deletions(-)

diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-kernel/linux/linux-dtb.inc
index 7747718..7eea83a 100644
--- a/meta/recipes-kernel/linux/linux-dtb.inc
+++ b/meta/recipes-kernel/linux/linux-dtb.inc
@@ -1,3 +1,5 @@
+inherit kernel-arch
+
 # Support for device tree generation
 FILES_kernel-devicetree = "/boot/devicetree*"
 KERNEL_DEVICETREE_FLAGS ?= "-R 8 -p 0x3000"
@@ -5,24 +7,49 @@ KERNEL_DEVICETREE_FLAGS ?= "-R 8 -p 0x3000"
 python __anonymous () {
     devicetree = d.getVar("KERNEL_DEVICETREE", True) or ''
     if devicetree:
+        # fixme: add dependency only if file not found
         depends = d.getVar("DEPENDS", True)
         d.setVar("DEPENDS", "%s dtc-native" % depends)
         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 +57,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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] linux-dtb: allow to build dtb using support from kernel
  2013-07-15 16:50 use kernel build system for dtb compilation Andre Draszik
@ 2013-07-22 14:02 ` André Draszik
  2013-07-22 14:52   ` Bruce Ashfield
  0 siblings, 1 reply; 4+ messages in thread
From: André Draszik @ 2013-07-22 14:02 UTC (permalink / raw)
  To: openembedded-core; +Cc: Otavio Salvador

Currently, OE is unable to use the linux kernel's built-in
support to generate a device tree blob (dtb). This is an
issue for device tree source (dts) files that need to be run
through CPP (dtsp).

The kernel build system has built-in 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 kbuild if $KERNEL_DEVICETREE points
to file(s) that are located in arch/${ARCH}/boot/dts/, e.g.
KERNEL_DEVICETREE = "<machine>.dts". In this case, no
dependency is added on dtc-native, as that is not needed any
more.

The previous way of handling dts files, i.e. compilation via
the stand-alone dtc-native, is still supported - it is triggered
by specifying the full path to the dts file, as before, e.g.
KERNEL_DEVICETREE = "arch/${ARCH}/boot/dts/<machine>.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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] linux-dtb: allow to build dtb using support from kernel
  2013-07-22 14:02 ` [PATCH] linux-dtb: allow to build dtb using support from kernel André Draszik
@ 2013-07-22 14:52   ` Bruce Ashfield
  2013-07-22 15:23     ` Otavio Salvador
  0 siblings, 1 reply; 4+ messages in thread
From: Bruce Ashfield @ 2013-07-22 14:52 UTC (permalink / raw)
  To: André Draszik
  Cc: Otavio Salvador, Patches and discussions about the oe-core layer

On Mon, Jul 22, 2013 at 10:02 AM, André Draszik
<andre.draszik@linaro.org> wrote:
> Currently, OE is unable to use the linux kernel's built-in
> support to generate a device tree blob (dtb). This is an
> issue for device tree source (dts) files that need to be run
> through CPP (dtsp).

It's not clear to me (from the commit message), why the dtc recipe can't
provide what we need. I don't object to using the in kernel tree dtc, but
all the reasons why there are no other options need to be in the commit
message.

>
> The kernel build system has built-in 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 kbuild if $KERNEL_DEVICETREE points
> to file(s) that are located in arch/${ARCH}/boot/dts/, e.g.
> KERNEL_DEVICETREE = "<machine>.dts". In this case, no
> dependency is added on dtc-native, as that is not needed any
> more.
>

What happens with SDK builds ? i.e. if nativsdk versions of the dtc recipe are
used, we'll still have the functional gap.

> The previous way of handling dts files, i.e. compilation via
> the stand-alone dtc-native, is still supported - it is triggered
> by specifying the full path to the dts file, as before, e.g.
> KERNEL_DEVICETREE = "arch/${ARCH}/boot/dts/<machine>.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"

There really needs to be a flag or other option to override this detection.

>          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

Since install comes after compile, it would be better to test on the results of
the compile phase (i.e. is there a dtb already), and keep the checking on the
existence of the DTS in as few places as possible. In particular, since there
should still be an opt-out flag, having as few touches as possible is better.


> +                               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

This should really be testing on the dtb, not the DTS. We could also
have a single install
line, if any testing is done at the top of the routine and a single
variable set to point to
the dtb, wherever it may be.

Cheers,

Bruce

> +                               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
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core



--
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] linux-dtb: allow to build dtb using support from kernel
  2013-07-22 14:52   ` Bruce Ashfield
@ 2013-07-22 15:23     ` Otavio Salvador
  0 siblings, 0 replies; 4+ messages in thread
From: Otavio Salvador @ 2013-07-22 15:23 UTC (permalink / raw)
  To: Bruce Ashfield; +Cc: Patches and discussions about the oe-core layer

On Mon, Jul 22, 2013 at 11:52 AM, Bruce Ashfield
<bruce.ashfield@gmail.com> wrote:
> On Mon, Jul 22, 2013 at 10:02 AM, André Draszik
> <andre.draszik@linaro.org> wrote:
>> Currently, OE is unable to use the linux kernel's built-in
>> support to generate a device tree blob (dtb). This is an
>> issue for device tree source (dts) files that need to be run
>> through CPP (dtsp).
>
> It's not clear to me (from the commit message), why the dtc recipe can't
> provide what we need. I don't object to using the in kernel tree dtc, but
> all the reasons why there are no other options need to be in the commit
> message.
>
>>
>> The kernel build system has built-in 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 kbuild if $KERNEL_DEVICETREE points
>> to file(s) that are located in arch/${ARCH}/boot/dts/, e.g.
>> KERNEL_DEVICETREE = "<machine>.dts". In this case, no
>> dependency is added on dtc-native, as that is not needed any
>> more.
>>
>
> What happens with SDK builds ? i.e. if nativsdk versions of the dtc recipe are
> used, we'll still have the functional gap.
>
>> The previous way of handling dts files, i.e. compilation via
>> the stand-alone dtc-native, is still supported - it is triggered
>> by specifying the full path to the dts file, as before, e.g.
>> KERNEL_DEVICETREE = "arch/${ARCH}/boot/dts/<machine>.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"
>
> There really needs to be a flag or other option to override this detection.

Yes; I flag would be good indeed.

>>          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
>
> Since install comes after compile, it would be better to test on the results of
> the compile phase (i.e. is there a dtb already), and keep the checking on the
> existence of the DTS in as few places as possible. In particular, since there
> should still be an opt-out flag, having as few touches as possible is better.
>
>
>> +                               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
>
> This should really be testing on the dtb, not the DTS. We could also
> have a single install
> line, if any testing is done at the top of the routine and a single
> variable set to point to
> the dtb, wherever it may be.
>
> Cheers,
>
> Bruce
>
>> +                               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
>>
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>
>
>
> --
> "Thou shalt not follow the NULL pointer, for chaos and madness await
> thee at its end"



--
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-22 15:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-15 16:50 use kernel build system for dtb compilation Andre Draszik
2013-07-22 14:02 ` [PATCH] linux-dtb: allow to build dtb using support from kernel André Draszik
2013-07-22 14:52   ` Bruce Ashfield
2013-07-22 15:23     ` Otavio Salvador

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.