Customized device tree / possible modify some kernel source

Hi,

Let me first start with that I know this kind of question is often asked. I have searched all over the main Toradex website, Toradex community and the Internet in general to get my answer, but I could not succeed with it in real life. This could be due to the fact that I’m just starting to dive into the heart of what Linux is and how to mold it to my needs with missing some crucial commands / information to optimize my search for the answers/solution.

The first thing I want to accomplish is to alter the device tree to my own carrier board design. In my search I found that this could be done in two ways? (I’m not sure about this):

  1. Add your own .dts to linux-toradex (latest from git). And make the dtbs, like described here. I just create a copy of the default Apalis evaluation board, but change the description inside to show a difference. I also renamed the file. I have succeeded in making the .dtb of my own version. Only from this point on I don’t know how I could link it to the OpenEmbedded bitbake system so that in the end a correct image file with my custom device can be installed on the module.
    I have also tried to manually set my carrier device tree inside the boot menu, like partially described here. But this also wouldn’t succeed, it just booted with the default device tree.
  2. Apply a patch to the kernel inside the oe-core meta layers. I have tried different configuration with the aid of a video of yours and some community posts (like this). But also here I can’t seem to get it to work.

So at the moment I’m just thinking that I’m the problem because of just the basics I know. And before you ask, I’m able to build the default image (without me tampering with something) and let it run on the module.

So at this point I still don’t have a Linux version running with my custom device tree. And I’m not even sure which one of the two is the better option. One post calls out for option one and another post for option 2. In the end I want to have a nice flow in operation without all to much hassle.

With this post I try to get an understanding how I can accomplish this. Examples would be very helpful but a good book (or some sorts) is also welcome. In addition advise in the best method is preferred so that I don’t switch between them all the time in trying somethings out.

The seconds thing, this is only an assumption at the moment, is that we maybe need to alter some code in the kernel with regards to V4L2 (adding support for maybe different cameras). Does this change to whole vision I have created above, or would this just be absurd to even try?

Thanks in advance and any help is appreciated. Also if I let out some crucial information please ask. I tried to keep it simple so that others can follow my mindset, at the moment, so they know how to explain it to me :).

Kind regards,

Remco

Partially answering to your question

In order to yocto export the desired dtb, you should change the machine configuration in meta-toradex-nxp and include your customised dtb.
Additionally, change update.sh to do the exact same.

With this, the .tar.bz2 output will also include your customised dtb in your image.
Then you just change the fdt_file environmental variable in u-boot and it should load your .dtb

You probably checked my question regarding this matter but i’ll leave the link anyway. Best of luck.

Link for my dtb question

Let me first start with that I know this kind of question is often asked. I have searched all over the main Toradex website, Toradex community and the Internet in general to get my answer, but I could not succeed with it in real life. This could be due to the fact that I’m just starting to dive into the heart of what Linux is and how to mold it to my needs with missing some crucial commands / information to optimize my search for the answers/solution.

The first thing I want to accomplish is to alter the device tree to my own carrier board design. In my search I found that this could be done in two ways? (I’m not sure about this):

Let me first start with a quick mentioning that one of the biggest pros but also cons of Linux is that often times there are a multitude of possibilities leading to more or less equal goals. Only nuances in your requirements and often times just rather philosophical reasoning may favour one before the other.

  1. Add your own .dts to linux-toradex (latest from git). And make the dtbs, like described here.

That article on our developer website really only talks about the device tree part and does not really cover the later integration thereof into the BSP at all.

I just create a copy of the default Apalis evaluation board, but change the description inside to show a difference. I also renamed the file. I have succeeded in making the .dtb of my own version.

Yes, that is really the recommended and most future prove way of going at it.

Only from this point on I don’t know how I could link it to the OpenEmbedded bitbake system so that in the end a correct image file with my custom device can be installed on the module.

@Joao was right that this is basically about the machine configuration. Of course also here the best approach is to create your own machine as e.g. explained in the following blog post of my senior engineer @max.tx.

I have also tried to manually set my carrier device tree inside the boot menu,

By boot menu I assume you are talking about U-Boot, right?

like partially described here. But this also wouldn’t succeed, it just booted with the default device tree.

You basically would extend U-Boot as well with your machine specific configuration picking up the desired device tree blob. One thing to remember is that one may have to default to resp. U-Boot environment as well (e.g. doing env default -a; saveenv during legacy initial flashing of your custom firmware or even better using the new Toradex Easy Installer instead).

  1. Apply a patch to the kernel inside the oe-core meta layers. I have tried different configuration with the aid of a video of yours and some community posts (like this). But also here I can’t seem to get it to work.

Using a custom patch should work just fine but just patching the default device tree is not recommended as it is neither very flexible nor much future prove.

So at the moment I’m just thinking that I’m the problem because of just the basics I know. And before you ask, I’m able to build the default image (without me tampering with something) and let it run on the module.

No, I think you are on the right track and probably just missing some minor detail(s).

So at this point I still don’t have a Linux version running with my custom device tree. And I’m not even sure which one of the two is the better option. One post calls out for option one and another post for option 2. In the end I want to have a nice flow in operation without all to much hassle.

Unfortunately as initially mentioned there often times isn’t just a one size fits all solution.

With this post I try to get an understanding how I can accomplish this. Examples would be very helpful but a good book (of some sorts) is also welcome. In addition advise in the best method is preferred so that I don’t switch between them all the time in trying somethings out.

Max’ blog post mentions some good book as well. Plus we do have some webinar videos talking about customisation as well.

The seconds thing, this is only an assumption at the moment, is that we maybe need to alter some code in the kernel with regards to V4L2 (adding support for maybe different cameras). Does this change to whole vision I have created above, or would this just be absurd to even try?

No, that sounds like a rather common thing to do. Maybe ask a separate question including some more details about what exactly you are planing so we may give you some suggestions.

Thanks in advance and any help is appreciated.

You are very welcome.

Also if I let out some crucial information please ask. I tried to keep it simple so that others can follow my mindset, at the moment, so they know how to explain it to me :).

I believe there is nothing wrong in your approach. Just go step by step and ask clear concise questions just like you did above and you will succeed in no time. Good luck!

@joao I indeed read you post earlier on but didn’t succeeded. But the additional information (that little missing piece) you mentioned here helped. Thus I could successfully start Linux with my .dtb file. Thanks.

@marcel.tx Thank you for you elaborated answer and additional information. Now I know that I’m on the right track with extra material to read. The next step has a high chance of succeeding now.

You are very welcome. Just let us know should you have any further questions or concerns.