Device tree modification in Yocto for Colibri i.MX7 emmc

Hi all,
Today I managed to create my first BSP 5.7 image with Yocto and I now want to modify the device tree (I already know what to change since I did this with TorizonCore, which I have to abandon since it doesn’t support RPMSG).

In the local.conf file, I did specify MACHINE ?= "colibri-imx7-emmc" and this seems to work since the resulting image is in a directory called deploy/images/colibri-imx7-emmc and under deploy/images/colibri-imx7-emmc/devicetree there are imx7 related files.

However, now that I want to add a new device tree file (by following the device tree part of these instructions), I was looking for the name of the original “top” device tree file (since I have to replace it with a command in the file recipes-bsp/u-boot/u-boot-toradex_%.bbappend as explained in the instructions).
But looking for *.dts files in the layers directory, I only found these ones:

find . -name "*dts" -print
./meta-freescale-3rdparty/recipes-kernel/linux/linux-fslc/imx6q-var-som-vsc.dts
./meta-freescale-3rdparty/recipes-kernel/linux/linux-fslc-lts-4.19/imx6q-var-som-vsc.dts

I.e. only device tree files for the imx6q !! So I am probably missing something.
=> Can anybody tell me where the actual device tree files are located ?

Even doing the search in oe-core (the top directory), I only get these two matches…

Any help is very much appreciated !
Jeroen

Hi @ompie ,

I will ping @hfranco.tx here just for the record.

As far as I can see you’re doing everything right.
The sources you are looking for can not be found in the layers directory.

One place you can find them is in your work directory, something like this:
/build/tmp/work-shared/colibri-imx7/kernel-source/arch/arm/boot/dts

Alternatively, you can check the sources directly in the kernel, for example here:

https://git.toradex.com/cgit/linux-toradex.git/tree/arch/arm/boot/dts?h=toradex_5.4.y

I hope this helps.

Let us know if there are more questions.

Best Regards
Kevin

Hello @kevin.tx,

Thanks for you reply. I do indeed have all the DT files in the directory you suggested. So everything looks OK, as was confirmed by the fact that the generated image did run on my module.
If you look at my initial post, I want to introduce some modifications in the device tree. I do have the correct DT files since I already tested them via TorizonBuilder while using TorizonCore (I just switched to BSP 5.7 since I need a downstream version of Linux in order to be able to use RPMSG (see here)).

The question I have is how to introduce these files (I added two new ones ‘myboard.dts’ and ‘myboard.dtsi’ and I also modified some of the existing files like `imx7d-colibri-emmc.dtsi’).
I created a new meta layer for the device tree and a recipe.
Concerning my initial question, is it OK to specify a top level device in the replacement command that is in a tmp directory ?

Best regards,
Jeroen

Hi @ompie ,

Glad that you found the files.

That’s already good.

I would say that its probably not good practice to do these things in the tmp directory. In the link you sent with the instructions it also explains on how to add your custom device tree to the kernel.

I am not sure if I understand what you mean by “top level device in the replacement command”. Could you elaborate, just so I understand fully what you mean?

Best Regards
Kevin

Hi @kevin.tx,

Just above here, it is explained that U-boot must be told as well to use the new .dtb file and the contents of the newly created file recipes-bsp/u-boot/u-boot-toradex_%.bbappend looks like this:

do_configure_append() {
    sed -i 's/#define FDT_FILE.*/#define FDT_FILE "my-custom-devicetree-file.dtb"/' ${S}/include/configs/colibri_imx6.h
}

I didn’t correctly read the sed command and thought that colibri_imx6.h was part of the replacement search, indicating the ancient “top level device tree file”.
If I interpret it correctly (I’m used to vi, so the sed syntax is familiar) ‘sed’ is used to replace the original FDT_FILE definition with one that that includes our new .dtb and the ${S}/include/configs/colibri_imx6.h part is probably just inserted after the replacement.

So my question should be rephrased to "what shall I specify instead of colibri-imx6.h ?
I’m using a Colibri i.MX7D emmc…

Meanwhile, I’m going to try myself and see whether I get bitbake make a new image…

EDIT: bitbake gave an error when using colibri-imx7-emmc.h and the error message allowed me to look in the ${s}/include/configs directory. There is only .h that will match, and it is colibri_imx7.h so the question above has been answered.
However, it now complains about not knowing how to make the .dtb file that I specified in layers/meta-customer/recipes-bsp/u-boot/u-boot-toradex_%.bbappend.
I’ll try to do some research. If I don’t find the solution, I’ll post again.

Jeroen

Hi @kevin.tx and @hfranco.tx,

Running bitbake, I get the following error:

| make[2]: *** No rule to make target 'arch/arm/boot/dts/imx7d-colibri-emmc-interferometer.dtb'.  Stop.
| make[1]: *** [/home/jeroen/tmp/work-shared/colibri-imx7-emmc/kernel-source/Makefile:1270: imx7d-colibri-emmc-interferometer.dtb] Error 2
| make: *** [/home/jeroen/tmp/work-shared/colibri-imx7-emmc/kernel-source/Makefile:179: sub-make] Error 2
| ERROR: oe_runmake failed
| WARNING: exit code 1 from a shell command.
| ERROR: Execution of '/home/jeroen/tmp/work/colibri_imx7_emmc-tdx-linux-gnueabi/linux-toradex/5.4.193+gitAUTOINC+f782992971-r0/temp/run.do_compile.2941665' failed with exit code 1
ERROR: Task (/home/jeroen/Interferometer/yocto/oe-core/build/../layers/meta-toradex-nxp/recipes-kernel/linux/linux-toradex_5.4-2.3.x.bb:do_compile) failed with exit code '1'

Apperently, bitbake doesn’t know how to compile the .dts files into a binary device tree. I was already wondering how this was going to work when I copied the files from the examples in the article: in meta-customer/in recipes-kernel/linux/linux-toradex_%.bb_append, I have specified a .dts file which will be copied to ${S}/arch/arm/boot/dts:


FILESEXTRAPATHS_prepend := "${THISDIR}/linux-toradex:"

# Prevent the use of in-tree defconfig
unset KBUILD_DEFCONFIG

CUSTOM_DEVICETREE = "imx7d-colibri-emmc-interferometer.dts"

SRC_URI += "\
    file://${CUSTOM_DEVICETREE} \
#    file://custom-display.patch \
#    file://defconfig \
    "

do_configure_append() {
    # For arm32 bit devices
    cp ${WORKDIR}/${CUSTOM_DEVICETREE} ${S}/arch/arm/boot/dts
}

But in `meta-customer/conf/machine/imx7d-colibri-emmc-interferometer.conf’, we’re talking about an.dtb (the compiled device tree):

KERNEL_DEVICETREE_append = " imx7d-colibri-emmc-interferometer.dtb"

(this .conf file is included in meta-customer/layer.conf, and that seems to work, otherwise I would not have the error)

So I am clearly missing something here, any idea what is going on ?
At the beginning of the kernel customization instructions, it is recommended to change the kernel outside of yocto but is it really necessary ? I know my DT modifications are working so there is no need to first build the kernel elsewhere, right ?

Another thing that is not yet clear for me is the defconfig file that is specified in the linux-toradex_%.bb_append file above (copied from the example in the article).
I commented it but is this OK ?
Uncommenting it does not change the .dtb error but maybe it will cause errors later on ?
Do I have to make one ?

EDIT: I forgot to mention that I’m running bitbake on Ubuntu 22.04 and I get a warning at the start of bitbake:

WARNING: Host distribution "ubuntu-22.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.

Hopefully this is not a showstopper (since I already managed to make a reference image, I don’t thinks so)

I’m sure you guys can help me ! Thanks in advance,
Jeroen

Hi @ompie ,

Glad that you found this. That was exactly the file you were looking for.

Following the other information you posted I noticed the possible reason for the error that you see.

That is absolutely correct. You don’t need to first build the kernel elsewhere. :+1:

I guess the reason is:

The file ending should not be .bb_append but rather .bbappend. Maybe there was a typo that happened somewhen during creation.

It should not, I was using Yocto on Ubuntu 22.04 myself. Just be aware that you walk on untested or unverified territory. As the warning states it is possible to have unexpected behaviour. Since you managed to build the reference image I assume it is working as intended.

Have a great day.

Best Regards
Kevin

Hello @kevin.tx,

Correcting the file name did greatly improve things since I now got error messages on that particular file. At least I know it is taken into account now :slight_smile: .

As you can see in my previous post, I commented out the line with file://defconfig \ and I asked you whether this was OK. Now I know it isn’t since bitbake complains about it:

ERROR: linux-toradex-5.4.193+gitAUTOINC+f782992971-r0 do_kernel_metadata: Could not locate BSP definition for colibri-imx7-emmc/standard and no defconfig was provided

So I un-commented the line but this leads to a new error:

ERROR: linux-toradex-5.4.193+gitAUTOINC+f782992971-r0 do_fetch: Fetcher failure: Unable to find file file://defconfig anywhere. The paths that were searched were:
    /home/jeroen/Interferometer/yocto/oe-core/build/../layers/meta-customer/recipes-kernel/linux/linux-toradex/tdx
    /home/jeroen/Interferometer/yocto/oe-core/build/../layers/meta-toradex-nxp/recipes-kernel/linux/linux-toradex-5.4-2.3.x/tdx
    /home/jeroen/Interferometer/yocto/oe-core/build/../layers/meta-toradex-nxp/recipes-kernel/linux/linux-toradex-5.4.193+gitAUTOINC+f782992971/tdx
...
...

The defconf file is not found so I suppose I have to provide the defconf file somewhere.
Where can I find the default version for the Colibri i.MX7 emmc?

Best regards,
Jeroen

Hi @ompie,

I hope you had a good weekend.

Great, glad to hear that! :slight_smile:

I must have overlooked that one sorry. In general, this is correct.

Yes as the error states, the file could not be found. Yocto checks specific paths for the defconfig file and drops this error if the file can not be found in these locations. Are you trying to use a custom kernel configuration? If not, then you can start with the Toradex defconfig.

Here you can find the file colibri_imx7_defconfig:
https://git.toradex.com/cgit/linux-toradex.git/tree/arch/arm/configs?h=toradex_5.4-2.3.x-imx

Usually, you would create a .config file like this

After that you can perform make menuconfig where you can change all the settings of your kernel. Following that you can make savedefconfig which will result in a new defconfig with your custom settings. This file you can then copy into the location where Yocto is looking for it. In your case for example in /home/jeroen/Interferometer/yocto/oe-core/build/../layers/meta-customer/recipes-kernel/linux/linux-toradex/tdx.

Hope this helps.

Best Regards
Kevin

Hi @kevin.tx,

Thanks, I actually got a good holiday. And that’s the reason I did not reply earlier on :slight_smile: .

OK that worked. The bitbake terminates successfully. I did nit have time to download the new image and test it but I’ll give feedback ASAP

Regards,
Jeroen

Hi @ompie ,

Even better. I also had vacation last week. :wink:

All right. Let me know when you need assistance.

Best Regards
Kevin

Hi @kevin.tx,

After installing the image on the module, Linux starts up as expected. However, the modifications I made in my device tree did not show up: I disabled UART2 but it still shows up as /dev/ttymxc1

&uart2 {
        status = "disabled";     // overrides the "okay" status
};

I’m sure that my .dts file is read by bitbake because when I introduce a syntax error (e.g. removing the semicolon after ‘}’), bitbake reports it.
I followed the instructions for kernel customization (except for the display patch), adding both recipes for the kernel and bsp without success.
One strange thing is that when I fill in a wrong name in meta-customer/recipes-bsp/u-boot/u-boot-toradex_%.bbappend, bit bake does NOT complain about it !! (as you can see below, I added “ERROR_” in front of the file name)

do_configure_append() {
    sed -i 's/#define FDT_FILE.*/#define FDT_FILE "ERROR_imx7d-colibri-emmc-interferometer.dtb"/' ${S}/include/configs/colibri_imx7.h
}

So I’m stuck again :frowning:

I made a zip file with the contents of the …/oe-core/layers/meta-customer directory :
meta-customer.zip (25.7 KB)
And also from the …/oe-core/build/conf directory :
conf.zip (32.3 KB)

Maybe you can have a look at them and immediately see the thing I forgot…
As you may remember, I’m using BSP 5.7

Thanks in advance !
Jeroen

@kevin.tx , @hfranco.tx, any one please ?

Best regards,

Jeroen

Hi @kevin.tx and @hfranco.tx,

There is something else that makes me suspect that my kernel recipe is not really used for configuration.
The defconfig file I specified in linux-toradex%.bbappend (under meta-customer/recipes-kernel/linux/) is copied from here.
In this file, RPMSG is NOT enabled. There is simply no line that contains “rpmsg” (I did a cas insensitive search). So how do I end up with an image in which RPMSG is enabled ?

>> cat .config | grep -i rpmsg
CONFIG_HAVE_IMX_RPMSG=y
# CONFIG_GPIO_IMX_RPMSG is not set
# CONFIG_REGULATOR_PF1550_RPMSG is not set
# CONFIG_SND_SOC_FSL_RPMSG_I2S is not set
# CONFIG_SND_SOC_IMX_RPMSG is not set
# CONFIG_SND_SOC_RPMSG_WM8960 is not set
# CONFIG_SND_SOC_RPMSG_WM8960_I2C is not set
# CONFIG_RTC_DRV_IMX_RPMSG is not set
# Rpmsg drivers
CONFIG_RPMSG=y
# CONFIG_RPMSG_CHAR is not set
# CONFIG_RPMSG_QCOM_GLINK_RPM is not set
CONFIG_RPMSG_VIRTIO=y
CONFIG_IMX_RPMSG_PINGPONG=m
CONFIG_IMX_RPMSG_TTY=m
# end of Rpmsg drivers

Could there be a relation between this and the other problem of not being able to update the device tree ???

Best regards,
Jeroen

Hi @ompie,

Sorry for the delay.

Are you sure this ttymxc1 is the uart2 from the device tree? Can you confirm that?

You can check the following command:

$ bitbake-layers show-recipes | grep linux-toradex
$ bitbake-layers show-appends | grep linux-toradex

With those commands, you can check if bitbake is finding your files. In general, if you added your layer to the bblayers.conf file and also have a bbappend inside of it, it will be applied.

Isn’t that enabled by default? Can you explain better what happened here?

Best Regards,
Hiago.

Hi @hfranco.tx,

Yes. By default there are three /dev/ttymxc* devices on the Colibri (0, 1, and 2). When I used Torizon, I was able to let ttymxc1 “disappear” by disabling uart2 in the device tree.

This is the output of the two commands:

bitbake-layers show-recipes | grep linux-toradex
  meta                 unknown (skipped: PREFERRED_PROVIDER_virtual/kernel set to linux-toradex, not linux-dummy)
  meta-freescale       5.4 (skipped: PREFERRED_PROVIDER_virtual/kernel set to linux-toradex, not linux-fslc-imx)
  meta-freescale       5.4 (skipped: PREFERRED_PROVIDER_virtual/kernel set to linux-toradex, not linux-imx)
linux-toradex:
linux-toradex-mainline:
  meta-toradex-bsp-common 5.4 (skipped: PREFERRED_PROVIDER_virtual/kernel set to linux-toradex, not linux-toradex-mainline)
bitbake-layers show-appends | grep linux-toradex
linux-toradex_4.14-2.0.x.bb:
  /home/jeroen/Interferometer/yocto/oe-core/build/../layers/meta-customer/recipes-kernel/linux/linux-toradex_%.bbappend
linux-toradex_5.4-2.3.x.bb:
  /home/jeroen/Interferometer/yocto/oe-core/build/../layers/meta-customer/recipes-kernel/linux/linux-toradex_%.bbappend
linux-toradex_4.4.bb (skipped):
  /home/jeroen/Interferometer/yocto/oe-core/build/../layers/meta-customer/recipes-kernel/linux/linux-toradex_%.bbappend

I’m not sure how to interpret the result but concerning the layers, I would have expected to see something referring to my custom recipe under .../yocto/oe-core/layers/meta-customer.
I sent the contents in zip files a few replies above, but this is how the directory looks:

$ tree -L 3
.
├── conf
│   ├── layer.conf
│   └── machine
│       └── imx7d-colibri-emmc-interferometer.conf
├── COPYING.MIT
├── README
├── recipes-bsp
│   └── u-boot
│       └── u-boot-toradex_%.bbappend
└── recipes-kernel
    └── linux
        ├── linux-toradex
        └── linux-toradex_%.bbappend

7 directories, 6 files

**

**
Yes, it appears that RPMSG is indeed enabled by default. In my last reply, I showed the results of cat .config | grep -i rpmsg on the module and RPMSG apppears in the list.
But what is bothering me, is that in the defconfig file I include in my recipe, there is no mention at all of RPMSG and it still turns up on the module… (see prevous reply).
Can you explain that?

Best regards,
Jeroen

Hi @ompie,

Did you use the same overlay from TorizonCore? Can you share the code with us, please?
Also, did you compile the overlay that you were using with TorizonCore with the BSP 5 now?

I checked the default .config and, as you said, the RPMSG is enabled:

>> cat .config | grep -i rpmsg
CONFIG_HAVE_IMX_RPMSG=y
# CONFIG_GPIO_IMX_RPMSG is not set
# CONFIG_REGULATOR_PF1550_RPMSG is not set
# CONFIG_SND_SOC_FSL_RPMSG_I2S is not set
# CONFIG_SND_SOC_IMX_RPMSG is not set
# CONFIG_SND_SOC_RPMSG_WM8960 is not set
# CONFIG_SND_SOC_RPMSG_WM8960_I2C is not set
# CONFIG_RTC_DRV_IMX_RPMSG is not set
# Rpmsg drivers
CONFIG_RPMSG=y
# CONFIG_RPMSG_CHAR is not set
# CONFIG_RPMSG_QCOM_GLINK_RPM is not set
CONFIG_RPMSG_VIRTIO=y
CONFIG_IMX_RPMSG_PINGPONG=m
CONFIG_IMX_RPMSG_TTY=m
# end of Rpmsg drivers

If your .config is based on the default one, the rpmsg will still be enabled. Also, if you’re passing to yocto a piece of the configuration instead of the whole configuration, then RPMSG will be enabled. Can you confirm this is not enabled in your configuration anywhere? You can also run

$ bitbake virtual/kernel -c menuconfig

to access the kernel configs and search for RPMSG to check what’s going on.

Best Regards,
Hiago.

Hi @hfranco.tx ,

No, I did not use the same overlays for two reasons. First of all, the overlays are for a custom board and I first wanted to experiment with my Aster board. Second, I first wanted to check whether the process was working, hence only the simple modification for uart2 only.
I already did share the sources, a few posts earlier on ( meta-customer.zip) (and also conf.zip). so you can have a look at that.

See the config in the shared files above. The defconfig (my file is called colibri_imx7_defconfig) is a copy of the same file in the git repository (sorry, I can’t find the exact site address).

bitbake virtual/kernel -c menuconfig gave this screen, which is similar to the listing from the module itself:

Just to summarize the problems I have after all those posts:

  • my devicetree in which I disabled uart2 seems to be ignore
  • although I have nothing specified for RPMSG, it still shows up in the image

These two points makes me believe that my recipes are not taken into account.
You have the files used in the yocto environment, so I hope it will give you a clue…

Thanks as always,
Jeroen

Hi @ompie,

I apologize for the delay.

The config you refer to will not enable the RPMSG itself, but instead the CHAR device. If you press “?” on this config, you can check the information about it:

CONFIG_RPMSG_CHAR:                                                                                                                                                                 │   
  │                                                                                                                                                                                    │   
  │ Say Y here to export rpmsg endpoints as device files, usually found                                                                                                                │   
  │ in /dev. They make it possible for user-space programs to send and                                                                                                                 │   
  │ receive rpmsg packets.                                                                                                                                                             │   
  │                                                                                                                                                                                    │   
  │ Symbol: RPMSG_CHAR [=n]                                                                                                                                                            │   
  │ Type  : tristate                                                                                                                                                                   │   
  │ Prompt: RPMSG device interface                                                                                                                                                     │   
  │   Location:                                                                                                                                                                        │   
  │     -> Device Drivers                                                                                                                                                              │   
  │       -> Rpmsg drivers                                                                                                                                                             │   
  │   Defined at drivers/rpmsg/Kconfig:9                                                                                                                                               │   
  │   Depends on: RPMSG [=y] && NET [=y]  

However, if we check the RPMSG, it’s enabled, but instead of a CHAR device, probably it’s using a BLOCK device.

Here is the default configuration (make colibri_imx7_defconfig):

>> cat .config | grep -i RPMSG
CONFIG_HAVE_IMX_RPMSG=y
# CONFIG_GPIO_IMX_RPMSG is not set
# CONFIG_REGULATOR_PF1550_RPMSG is not set
# CONFIG_SND_SOC_FSL_RPMSG_I2S is not set
# CONFIG_SND_SOC_IMX_RPMSG is not set
# CONFIG_SND_SOC_RPMSG_WM8960 is not set
# CONFIG_SND_SOC_RPMSG_WM8960_I2C is not set
# CONFIG_RTC_DRV_IMX_RPMSG is not set
# Rpmsg drivers
CONFIG_RPMSG=y
# CONFIG_RPMSG_CHAR is not set
# CONFIG_RPMSG_QCOM_GLINK_RPM is not set
CONFIG_RPMSG_VIRTIO=y
CONFIG_IMX_RPMSG_PINGPONG=m
CONFIG_IMX_RPMSG_TTY=m
# end of Rpmsg drivers

The CONFIG_RPMSG=y and CONFIG_HAVE_IMX_RPMSG=y will enable the driver for you.

Best Regards,
Hiago.

I finally found the problem concerning the device tree which did not change anything on the target machine.
Since I am using BSP5.7, I followed the instructions on this page.
Concerning the contents of recipes-bsp/u-boot/u-boot-toradex_%.bbappend, it shows:

do_configure_append() {    
  sed -i 's/#define FDT_FILE.*/#define FDT_FILE "my-custom-devicetree-file.dtb"/' ${S}/include/configs/colibri_imx6.h
}

Today, I opened the 6.0 variant of the page (by accident…) in order to re-follow all steps for the n-th time. Arriving at the contents for recipes-bsp/u-boot/u-boot-toradex_%.bbappend, it shows:

do_configure:append() {    
  # Remove exisiting fdtfile, if there is one    
  sed -i '/"fdtfile=.*\\0" \\/d' ${S}/include/configs/verdin-imx8mp.h    
  # Add new fdtfile, "my-custom-devicetree.dtb" should be replaced with your device tree binary file    
  sed -i 's/\("fdt_board=.*\\0" \\\)/\0\n      "fdtfile=my-custom-devicetree.dtb\\0" \\/' ${S}/include/configs/verdin-imx8mp.h
}

Which is quite different from the “5 LTS” version!
By adapting this format to my device tree, I managed to see the changes I made on the target module.

So I think I would be useful for others to correct the “5 LTS” page…
In the meanwhile, I close this thread. For the other subject addressed here (RPMSG), I started a new thread.

Best regards,
Jeroen