All of lore.kernel.org
 help / color / mirror / Atom feed
* How to define and build device tree in Yocto?
@ 2019-05-05 12:03 JH
  2019-05-06  6:17 ` Gabriele Zampieri
  2019-05-06 14:35 ` Bas Mevissen
  0 siblings, 2 replies; 8+ messages in thread
From: JH @ 2019-05-05 12:03 UTC (permalink / raw)
  To: Yocto discussion list

Hi,

I think the device tree blob is build from device tree source, but I
could not find any dts files in recipe source directory, there are
many dts files in build directory and there are dtb in build
directory.

If I have a device tree source, where I should put it and how to
define the recipe to built it?

Thank you.

Kind regards,

- jupiter


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

* Re: How to define and build device tree in Yocto?
  2019-05-05 12:03 How to define and build device tree in Yocto? JH
@ 2019-05-06  6:17 ` Gabriele Zampieri
  2019-05-06  7:36   ` JH
  2019-05-06 14:35 ` Bas Mevissen
  1 sibling, 1 reply; 8+ messages in thread
From: Gabriele Zampieri @ 2019-05-06  6:17 UTC (permalink / raw)
  To: JH; +Cc: Yocto discussion list

[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]

Hi,

The easiest way is to add them via patches. You can write a recipe that
patch the Linux tree and put it in your meta layer (usually in
meta-xxx/recipes-kernel/linux). Then you need to tell Yocto to export the
dtb via KERNEL_DEVICETREE variable (
https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#var-KERNEL_DEVICETREE).
I usually put this variable in my machine configuration.

Gabriele

Il giorno dom 5 mag 2019 alle ore 14:04 JH <jupiter.hce@gmail.com> ha
scritto:

> Hi,
>
> I think the device tree blob is build from device tree source, but I
> could not find any dts files in recipe source directory, there are
> many dts files in build directory and there are dtb in build
> directory.
>
> If I have a device tree source, where I should put it and how to
> define the recipe to built it?
>
> Thank you.
>
> Kind regards,
>
> - jupiter
> --
> _______________________________________________
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>

[-- Attachment #2: Type: text/html, Size: 1729 bytes --]

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

* Re: How to define and build device tree in Yocto?
  2019-05-06  6:17 ` Gabriele Zampieri
@ 2019-05-06  7:36   ` JH
  2019-05-06 11:27     ` Gabriele Zampieri
  0 siblings, 1 reply; 8+ messages in thread
From: JH @ 2019-05-06  7:36 UTC (permalink / raw)
  To: Gabriele Zampieri; +Cc: Yocto discussion list

Thanks Gabriele,

Yes, I have already added KERNEL_DEVICETREE =  "imx6ull-14x14-evk.dtb"
to generate an image running on imx6 EVK. What I don't understand is
how that imx6ull-14x14-evk.dtb was compiled? I thought all dtb are
compiled from dts files, but there is no imx6ull-14x14-evk.dts, the
imx6ullevk.conf defined the EVK but there is no detail in that file.

My second question is my new hardware based on imx6ull MCU now has a
dts file, since I could not see any samples how is the dtb compiled
from a dts file, I have no idea where to put the dts file, how to link
that dts file to generate a dtb file in recipe. Appreciate more
clarification.

Thank you.

- jh

On 5/6/19, Gabriele Zampieri <gabbla.malist@gmail.com> wrote:
> Hi,
>
> The easiest way is to add them via patches. You can write a recipe that
> patch the Linux tree and put it in your meta layer (usually in
> meta-xxx/recipes-kernel/linux). Then you need to tell Yocto to export the
> dtb via KERNEL_DEVICETREE variable (
> https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#var-KERNEL_DEVICETREE).
> I usually put this variable in my machine configuration.
>
> Gabriele
>
> Il giorno dom 5 mag 2019 alle ore 14:04 JH <jupiter.hce@gmail.com> ha
> scritto:
>
>> Hi,
>>
>> I think the device tree blob is build from device tree source, but I
>> could not find any dts files in recipe source directory, there are
>> many dts files in build directory and there are dtb in build
>> directory.
>>
>> If I have a device tree source, where I should put it and how to
>> define the recipe to built it?
>>
>> Thank you.
>>
>> Kind regards,
>>
>> - jupiter
>> --
>> _______________________________________________
>> yocto mailing list
>> yocto@yoctoproject.org
>> https://lists.yoctoproject.org/listinfo/yocto
>>
>


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

* Re: How to define and build device tree in Yocto?
  2019-05-06  7:36   ` JH
@ 2019-05-06 11:27     ` Gabriele Zampieri
  0 siblings, 0 replies; 8+ messages in thread
From: Gabriele Zampieri @ 2019-05-06 11:27 UTC (permalink / raw)
  To: JH; +Cc: Yocto discussion list

[-- Attachment #1: Type: text/plain, Size: 3515 bytes --]

Hi,

> but there is no imx6ull-14x14-evk.dts

it is located in arch/arm/boot/dts/imx6ull-14x14-evk.dts and it is compiled
(among others dts) while building virtual/kernel task.

Setting KERNEL_DEVICETREE =  "imx6ull-14x14-evk.dtb" simply tells to
bitbake to put a copy of imx6ull-14x14-evk.dtb inside your image deploy
directory. You can dig through meta/classes/kernel-devicetree.bbclass to
see how KERNEL_DEVICETREE is used.

If you do not need to modify the dts, you will find all the image related
stuff in poky/build/tmp/deploy/images/<MACHINE>/<IMAGE>.

If you need to patch the dts (or any other kernel related file):

- Clone you kernel source tree locally
- Checkout the correct branch
- Do your edits, then commit
- Get a patch with the customization through git format-patch (or any other
way)

Now, in your meta layer:
- create recipes-kernel/linux/<your-kernel-provider>.bbappend file
- create recipes-kernel/linux/files/<MACHINE>/ directory

Then:
- Copy your patch in recipes-kernel/linux/files/<MACHINE>
- Edit the bbappend file with:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:" # Add files to the search
paths
SRC_URI_append_<MACHINE> = " file://0001-your-commit-message.patch"

bitbake will apply the patch after the kernel unpack automatically, then
build the tree with the patch(es) applied.

You can also add a completely new dts via patch, then add it to
KERNEL_DEVICETREE.

Best regards,
Gabriele

Il giorno lun 6 mag 2019 alle ore 09:36 JH <jupiter.hce@gmail.com> ha
scritto:

> Thanks Gabriele,
>
> Yes, I have already added KERNEL_DEVICETREE =  "imx6ull-14x14-evk.dtb"
> to generate an image running on imx6 EVK. What I don't understand is
> how that imx6ull-14x14-evk.dtb was compiled? I thought all dtb are
> compiled from dts files, but there is no imx6ull-14x14-evk.dts, the
> imx6ullevk.conf defined the EVK but there is no detail in that file.
>
> My second question is my new hardware based on imx6ull MCU now has a
> dts file, since I could not see any samples how is the dtb compiled
> from a dts file, I have no idea where to put the dts file, how to link
> that dts file to generate a dtb file in recipe. Appreciate more
> clarification.
>
> Thank you.
>
> - jh
>
> On 5/6/19, Gabriele Zampieri <gabbla.malist@gmail.com> wrote:
> > Hi,
> >
> > The easiest way is to add them via patches. You can write a recipe that
> > patch the Linux tree and put it in your meta layer (usually in
> > meta-xxx/recipes-kernel/linux). Then you need to tell Yocto to export the
> > dtb via KERNEL_DEVICETREE variable (
> >
> https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#var-KERNEL_DEVICETREE
> ).
> > I usually put this variable in my machine configuration.
> >
> > Gabriele
> >
> > Il giorno dom 5 mag 2019 alle ore 14:04 JH <jupiter.hce@gmail.com> ha
> > scritto:
> >
> >> Hi,
> >>
> >> I think the device tree blob is build from device tree source, but I
> >> could not find any dts files in recipe source directory, there are
> >> many dts files in build directory and there are dtb in build
> >> directory.
> >>
> >> If I have a device tree source, where I should put it and how to
> >> define the recipe to built it?
> >>
> >> Thank you.
> >>
> >> Kind regards,
> >>
> >> - jupiter
> >> --
> >> _______________________________________________
> >> yocto mailing list
> >> yocto@yoctoproject.org
> >> https://lists.yoctoproject.org/listinfo/yocto
> >>
> >
>

[-- Attachment #2: Type: text/html, Size: 5084 bytes --]

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

* Re: How to define and build device tree in Yocto?
  2019-05-05 12:03 How to define and build device tree in Yocto? JH
  2019-05-06  6:17 ` Gabriele Zampieri
@ 2019-05-06 14:35 ` Bas Mevissen
  2019-05-07  0:13   ` JH
  1 sibling, 1 reply; 8+ messages in thread
From: Bas Mevissen @ 2019-05-06 14:35 UTC (permalink / raw)
  To: yocto, JH

On 5/5/19 2:03 PM, JH wrote:
> Hi,
> 

Hi JH,

> I think the device tree blob is build from device tree source, but I
> could not find any dts files in recipe source directory, there are
> many dts files in build directory and there are dtb in build
> directory.
> 

Already answered by Gabriele.

> If I have a device tree source, where I should put it and how to
> define the recipe to built it?
> 

My usual way of doing it is as follows:

I usually don't need to make large modifications to the kernel source, 
so I don't need to clone the kernel, but use the default kernel for the 
SoC with some patches.

I use a platform support layer and add a .bbappend file for the (arm) 
kernel to add a custom dts and .config files, together with some small 
patches:

*** File meta-<platform>/recipes-kernel/linux/linux-<version>_%.bbappend:

THISAPPENDFILESDIR := "${THISDIR}/files"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

require linux-set-custom-defconfig.inc
require linux-add-custom-dts.inc

# The first patch simply appends my custom DTS to the list of DTD files 
in the Makefile
SRC_URI += \
         "file://add-custom-dts.patch \
          file://some_other.patch \
          file://another_driver_patch.patch \
         "

*** File meta-<platform>/recipes-kernel/linux/linux-add-custom-dts.inc

do_add_platform_dts() {
	cp -f "${THISAPPENDFILESDIR}/custom.dts" \
             "${WORKDIR}/git/arch/arm/boot/dts"
}

addtask add_platform_dts before do_preconfigure after do_patch

*** File meta-<platform>/recipes-kernel/linux/linux-set-custom-defconfig.inc

do_set_custom_defconfig() {
         cp -f "${THISAPPENDFILESDIR}/defconfig" "${WORKDIR}/defconfig"
}

addtask set_custom_defconfig before do_preconfigure after do_patch


It is maybe a bit complex, but it saves cloning the kernel for the sake 
of just adding a single DTS with defconfig and a few patches.

Hope this helps,

Bas.


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

* Re: How to define and build device tree in Yocto?
  2019-05-06 14:35 ` Bas Mevissen
@ 2019-05-07  0:13   ` JH
  2019-05-07  6:41     ` Gabriele Zampieri
  0 siblings, 1 reply; 8+ messages in thread
From: JH @ 2019-05-07  0:13 UTC (permalink / raw)
  To: Bas Mevissen; +Cc: yocto

Hi Bas and Gabriele,

Thank you so much for you advice.

> My usual way of doing it is as follows:
>
> I usually don't need to make large modifications to the kernel source,
> so I don't need to clone the kernel, but use the default kernel for the
> SoC with some patches.

So do I.

> I use a platform support layer and add a .bbappend file for the (arm)
> kernel to add a custom dts and .config files, together with some small
> patches:
>
> *** File meta-<platform>/recipes-kernel/linux/linux-<version>_%.bbappend:
>
> THISAPPENDFILESDIR := "${THISDIR}/files"
> FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
>
> require linux-set-custom-defconfig.inc
> require linux-add-custom-dts.inc
>
> # The first patch simply appends my custom DTS to the list of DTD files
> in the Makefile
> SRC_URI += \
>          "file://add-custom-dts.patch \
>           file://some_other.patch \
>           file://another_driver_patch.patch \
>          "
>
> *** File meta-<platform>/recipes-kernel/linux/linux-add-custom-dts.inc
>
> do_add_platform_dts() {
> 	cp -f "${THISAPPENDFILESDIR}/custom.dts" \
>              "${WORKDIR}/git/arch/arm/boot/dts"
> }

That is exactly I am looking for the proper location of the dts files,
thank you so much.

> addtask add_platform_dts before do_preconfigure after do_patch
>
> *** File
> meta-<platform>/recipes-kernel/linux/linux-set-custom-defconfig.inc
>
> do_set_custom_defconfig() {
>          cp -f "${THISAPPENDFILESDIR}/defconfig" "${WORKDIR}/defconfig"
> }
>
> addtask set_custom_defconfig before do_preconfigure after do_patch

Good advice, I missed that one, how did you do the defconfig usually?
Compile it in kernel source like using following command?

make ARCH=arm imx_v6_v7_defconfig

> It is maybe a bit complex, but it saves cloning the kernel for the sake
> of just adding a single DTS with defconfig and a few patches.

That is procedure I was looking for.

> Hope this helps,

Great helps, thank you so much.

- jupiter

> Bas.
>


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

* Re: How to define and build device tree in Yocto?
  2019-05-07  0:13   ` JH
@ 2019-05-07  6:41     ` Gabriele Zampieri
  2019-05-07  9:36       ` Bas Mevissen
  0 siblings, 1 reply; 8+ messages in thread
From: Gabriele Zampieri @ 2019-05-07  6:41 UTC (permalink / raw)
  To: JH; +Cc: Yocto discussion list

[-- Attachment #1: Type: text/plain, Size: 3441 bytes --]

Hi all,

Bas' defconfig trick (do_set_custom_defconfig) is already implemented by
Yocto itself: just add a file called defconfig to SRC_URI and the system
will apply it for you  (you can read kernel_do_configure in kernel.bbclass)
. For more information check
https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#changing-the-configuration

> how did you do the defconfig usually?

The link I put above asks this question too.

>> # The first patch simply appends my custom DTS to the list of DTD files
in the Makefile

and

>> I usually don't need to make large modifications to the kernel source,
>> so I don't need to clone the kernel, but use the default kernel for the
>> SoC with some patches.

How do you generate that patches?

I know that the kernel repo is huge, but having a local kernel tree can be
very useful and allows you to do all the patchworks easily. It also speeds
up the test if you are planning to upgrade some part of it.

Best regards,
Gabriele

Il giorno mar 7 mag 2019 alle ore 02:14 JH <jupiter.hce@gmail.com> ha
scritto:

> Hi Bas and Gabriele,
>
> Thank you so much for you advice.
>
> > My usual way of doing it is as follows:
> >
> > I usually don't need to make large modifications to the kernel source,
> > so I don't need to clone the kernel, but use the default kernel for the
> > SoC with some patches.
>
> So do I.
>
> > I use a platform support layer and add a .bbappend file for the (arm)
> > kernel to add a custom dts and .config files, together with some small
> > patches:
> >
> > *** File meta-<platform>/recipes-kernel/linux/linux-<version>_%.bbappend:
> >
> > THISAPPENDFILESDIR := "${THISDIR}/files"
> > FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
> >
> > require linux-set-custom-defconfig.inc
> > require linux-add-custom-dts.inc
> >
> > # The first patch simply appends my custom DTS to the list of DTD files
> > in the Makefile
> > SRC_URI += \
> >          "file://add-custom-dts.patch \
> >           file://some_other.patch \
> >           file://another_driver_patch.patch \
> >          "
> >
> > *** File meta-<platform>/recipes-kernel/linux/linux-add-custom-dts.inc
> >
> > do_add_platform_dts() {
> >       cp -f "${THISAPPENDFILESDIR}/custom.dts" \
> >              "${WORKDIR}/git/arch/arm/boot/dts"
> > }
>
> That is exactly I am looking for the proper location of the dts files,
> thank you so much.
>
> > addtask add_platform_dts before do_preconfigure after do_patch
> >
> > *** File
> > meta-<platform>/recipes-kernel/linux/linux-set-custom-defconfig.inc
> >
> > do_set_custom_defconfig() {
> >          cp -f "${THISAPPENDFILESDIR}/defconfig" "${WORKDIR}/defconfig"
> > }
> >
> > addtask set_custom_defconfig before do_preconfigure after do_patch
>
> Good advice, I missed that one, how did you do the defconfig usually?
> Compile it in kernel source like using following command?
>
> make ARCH=arm imx_v6_v7_defconfig
>
> > It is maybe a bit complex, but it saves cloning the kernel for the sake
> > of just adding a single DTS with defconfig and a few patches.
>
> That is procedure I was looking for.
>
> > Hope this helps,
>
> Great helps, thank you so much.
>
> - jupiter
>
> > Bas.
> >
> --
> _______________________________________________
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>

[-- Attachment #2: Type: text/html, Size: 5759 bytes --]

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

* Re: How to define and build device tree in Yocto?
  2019-05-07  6:41     ` Gabriele Zampieri
@ 2019-05-07  9:36       ` Bas Mevissen
  0 siblings, 0 replies; 8+ messages in thread
From: Bas Mevissen @ 2019-05-07  9:36 UTC (permalink / raw)
  To: Gabriele Zampieri; +Cc: Yocto discussion list

On 2019-05-07 08:41, Gabriele Zampieri wrote:

> Hi all,
> 
> Bas' defconfig trick (do_set_custom_defconfig) is already implemented 
> by Yocto itself: just add a file called defconfig to SRC_URI and the 
> system will apply it for you  (you can read kernel_do_configure in 
> kernel.bbclass) . For more information check 
> https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#changing-the-configuration
> 

Yes, that is the better solution. Not sure why I did not use it. I 
created the "do_set_custom_defconfig" years ago. Maybe to be able in the 
future to select one of different defconfigs based upon a local.conf 
setting. There can only be one in the kernel bbclass. I would prefer to 
be able to add multiple files ending on e.g. _defconfig and be able to 
set a variable to select the one to use.

Maybe we can define something similar for the device tree file source 
file in the bbclass. It would obviously only be valid for architectures 
supporting device trees.

>> how did you do the defconfig usually?
> 
> The link I put above asks this question too.
> 
>>> # The first patch simply appends my custom DTS to the list of DTD 
>>> files in the Makefile
> 
> and
> 
>>> I usually don't need to make large modifications to the kernel 
>>> source,
>>> so I don't need to clone the kernel, but use the default kernel for 
>>> the
>>> SoC with some patches.
> 
> How do you generate that patches?
> 
> I know that the kernel repo is huge, but having a local kernel tree can 
> be very useful and allows you to do all the patchworks easily. It also 
> speeds up the test if you are planning to upgrade some part of it.
> 

I use custom BSP development environment that contains a small build 
environment for building the device tree from source, u-boot 
development, kernel tree (shallow) clone, extended mfgtools ramdisk with 
some utilities and a customized version of mfgtools that loads the 
before-mentioned parts in RAM and starts them. This allows me to do very 
quick cycles.

The kernel patches are created using git against a (shallow) clone of 
the kernel I want to use. Mostly it is nothing more than a few small 
fixes.
U-boot is a full clone as I setup a new board definition for the custom 
board (mostly derived from an existing dev board, both hw and sw wise).

-- Bas.

> Best regards,
> 
> Gabriele
> 
> Il giorno mar 7 mag 2019 alle ore 02:14 JH <jupiter.hce@gmail.com> ha 
> scritto:
> 
>> Hi Bas and Gabriele,
>> 
>> Thank you so much for you advice.
>> 
>>> My usual way of doing it is as follows:
>>> 
>>> I usually don't need to make large modifications to the kernel 
>>> source,
>>> so I don't need to clone the kernel, but use the default kernel for 
>>> the
>>> SoC with some patches.
>> 
>> So do I.
>> 
>>> I use a platform support layer and add a .bbappend file for the (arm)
>>> kernel to add a custom dts and .config files, together with some 
>>> small
>>> patches:
>>> 
>>> *** File 
>>> meta-<platform>/recipes-kernel/linux/linux-<version>_%.bbappend:
>>> 
>>> THISAPPENDFILESDIR := "${THISDIR}/files"
>>> FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
>>> 
>>> require linux-set-custom-defconfig.inc
>>> require linux-add-custom-dts.inc
>>> 
>>> # The first patch simply appends my custom DTS to the list of DTD 
>>> files
>>> in the Makefile
>>> SRC_URI += \
>>> "file://add-custom-dts.patch \
>>> file://some_other.patch \
>>> file://another_driver_patch.patch \
>>> "
>>> 
>>> *** File 
>>> meta-<platform>/recipes-kernel/linux/linux-add-custom-dts.inc
>>> 
>>> do_add_platform_dts() {
>>> cp -f "${THISAPPENDFILESDIR}/custom.dts" \
>>> "${WORKDIR}/git/arch/arm/boot/dts"
>>> }
>> 
>> That is exactly I am looking for the proper location of the dts files,
>> thank you so much.
>> 
>>> addtask add_platform_dts before do_preconfigure after do_patch
>>> 
>>> *** File
>>> meta-<platform>/recipes-kernel/linux/linux-set-custom-defconfig.inc
>>> 
>>> do_set_custom_defconfig() {
>>> cp -f "${THISAPPENDFILESDIR}/defconfig" "${WORKDIR}/defconfig"
>>> }
>>> 
>>> addtask set_custom_defconfig before do_preconfigure after do_patch
>> 
>> Good advice, I missed that one, how did you do the defconfig usually?
>> Compile it in kernel source like using following command?
>> 
>> make ARCH=arm imx_v6_v7_defconfig
>> 
>>> It is maybe a bit complex, but it saves cloning the kernel for the 
>>> sake
>>> of just adding a single DTS with defconfig and a few patches.
>> 
>> That is procedure I was looking for.
>> 
>>> Hope this helps,
>> 
>> Great helps, thank you so much.
>> 
>> - jupiter
>> 
>>> Bas.
>>> 
>> --
>> _______________________________________________
>> yocto mailing list
>> yocto@yoctoproject.org
>> https://lists.yoctoproject.org/listinfo/yocto


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

end of thread, other threads:[~2019-05-07  9:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-05 12:03 How to define and build device tree in Yocto? JH
2019-05-06  6:17 ` Gabriele Zampieri
2019-05-06  7:36   ` JH
2019-05-06 11:27     ` Gabriele Zampieri
2019-05-06 14:35 ` Bas Mevissen
2019-05-07  0:13   ` JH
2019-05-07  6:41     ` Gabriele Zampieri
2019-05-07  9:36       ` Bas Mevissen

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.