Skip to contentSkip to conversation

kernel-devicetree: Corrected normalize_dtb

PATCH In review Paulo Neves 3 participants 4 messages Jul 2, 2018 – Jul 4, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel-devicetree: Corrected normalize_dtb

The normalize_dtb function was buggy because it only converted from .dts suffix to .dtb suffix if the user passed a full source path to KERNEL_DEVICETREE containing the /dts/ path. The problem is that if the user did that there would be a warning.

On the othet hand if user just set the variable KERNEL_DEVICETREE="file.dts" the bbclass translation to the respective .dtb target did not occur and make would fail saying it has no rule to make target file.dts

This patch decouples the logic of having /dts/ in the path from the target translation.

---
 meta/classes/kernel-devicetree.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel-devicetree.bbclass +1 -1
index 4f80cc62eb..9866d844ab 100644
@@ -13,8 +13,8 @@ normalize_dtb () {
 	DTB="$1"
 	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=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
 	echo "${DTB}"
 }
 
Signature · 1 line
2.14.1
#1 lore raw
Quoted 7 lines · Paulo Neves

The normalize_dtb function was buggy because it only converted from .dts suffix to .dtb suffix if the user passed a full source path to KERNEL_DEVICETREE containing the /dts/ path. The problem is that if the user did that there would be a warning.

Quoted 9 lines

On the othet hand if user just set the variable KERNEL_DEVICETREE="file.dts" the bbclass translation to the respective .dtb target did not occur and make would fail saying it has no rule to make target file.dts

This patch decouples the logic of having /dts/ in the path from the target translation.

This breaks a case where relative paths are used e.g. for rpi kernel we use DTB=overlay/xxx.dtbo and DTB=xxx.dtb and so on with this change its going to strip leading directory name and break that assumption.

See
http://git.yoctoproject.org/cgit/cgit.cgi/meta-raspberrypi/tree/conf/machine/include/rpi-base.inc#n17

Quoted 20 lines
---
  meta/classes/kernel-devicetree.bbclass | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel-devicetree.bbclass +1 -1
index 4f80cc62eb..9866d844ab 100644
@@ -13,8 +13,8 @@ normalize_dtb () {
  	DTB="$1"
  	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=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
  	echo "${DTB}"
  }
 
#2 lore raw

Confirmed.

I was seeing the same today when testing my rebased changes for kernel*bbclasses.

Quoted 57 lines · Khem Raj
Quoted 7 lines · Paulo Neves

The normalize_dtb function was buggy because it only converted from .dts suffix to .dtb suffix if the user passed a full source path to KERNEL_DEVICETREE containing the /dts/ path. The problem is that if the user did that there would be a warning.

Quoted 9 lines

On the othet hand if user just set the variable KERNEL_DEVICETREE="file.dts" the bbclass translation to the respective .dtb target did not occur and make would fail saying it has no rule to make target file.dts

This patch decouples the logic of having /dts/ in the path from the target translation.

This breaks a case where relative paths are used e.g. for rpi kernel we use DTB=overlay/xxx.dtbo and DTB=xxx.dtb and so on with this change its going to strip leading directory name and break that assumption.

See

http://git.yoctoproject.org/cgit/cgit.cgi/meta-raspberrypi/tree/conf/machine/include/rpi-base.inc#n17

Review

Quoted 6 lines
---
  meta/classes/kernel-devicetree.bbclass | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/classes/kernel-devicetree.bbclass

meta/classes/kernel-devicetree.bbclass normalize_dtb () { · line 15

Quoted 7 lines

index 4f80cc62eb..9866d844ab 100644

meta/classes/kernel-devicetree.bbclass +0 -0
@@ -13,8 +13,8 @@ normalize_dtb () {
      DTB="$1"
      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."

meta/classes/kernel-devicetree.bbclass normalize_dtb () { · line 20

Quoted 7 lines
meta/classes/kernel-devicetree.bbclass +1 -1
-             DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
      fi
+     DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
      echo "${DTB}"
  }
 

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#3 lore raw
In reply to Paulo Neves
Quoted 7 lines · Paulo Neves

The normalize_dtb function was buggy because it only converted from .dts suffix to .dtb suffix if the user passed a full source path to KERNEL_DEVICETREE containing the /dts/ path. The problem is that if the user did that there would be a warning.

Quoted 9 lines

On the othet hand if user just set the variable KERNEL_DEVICETREE="file.dts" the bbclass translation to the respective .dtb target did not occur and make would fail saying it has no rule to make target file.dts

This patch decouples the logic of having /dts/ in the path from the target translation.

Looking a bit more into the problem you are trying to solve, I think adding another check for files ending with .dts and then applying the dts-2-dtb tranform is better approach. Which will let us keep building dtb overlays as well as fix the case you have pointed out.

Quoted 20 lines
---
  meta/classes/kernel-devicetree.bbclass | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel-devicetree.bbclass +1 -1
index 4f80cc62eb..9866d844ab 100644
@@ -13,8 +13,8 @@ normalize_dtb () {
  	DTB="$1"
  	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=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
  	echo "${DTB}"
  }