Change DeviceTree

I want to use the timer on the M4 but I recognized, that I have to change the device tree to use it.
I have already created my own device tree, but now I do not know how to change it in the boot loader.

Linux kernel and Device Tree blob located at emmc partition 1. You can list them by U_boot command ls mmc 0:1 or by ls /media/mmcblk0p1/ at Linux.
You can have multiple device tree blobs here. Which exactly device tree will be loaded defined by U_boot environment variable:

bootcmd=run emmcboot ; echo ; echo emmcboot failed ; setenv fdtfile ${soc}-colibri-emmc-${fdt_board}.dtb && run distro_bootcmd;

You can either replace ${soc}-colibri-emmc-${fdt_board}.dtb by your device tree name or name your device tree as imx7d-colibri-emmc-mytree.dtb and change fdt_board environment variable to mytree

Could you give an Example on how to load the device tree to the emmc partition 1? And maybe you could give me a working device tree to test if its working properly, for error elimination purpose?

Thanks in advance.

Under Linux:

cp <your device tree file> /media/mmcblk0p1

There are 4 device tree already present there:


You can choose any one

After a little struggle I found my problem:
After I copied the device tree in the /media/mmcblk0p1 I restarted the board with a simple press on the Carrier board. The Problem is with that method is that the iMX7 doesnt save the device tree and uses the old one.
Solution: I had to restart the board by clicking on the shutdown button in the OS.

Thanks for update. You can also use a sync command.

“By default, the Linux kernel writes data to disk asynchronously. Writes are buffered (cached) in memory, and written to the storage device at the optimal time. The sync command forces an immediate write of all cached data to disk.”

Hi @PG03 ,

Which timer are you going to use on M4, FTM or GPT?
FTM could be used on Linux for additional PWM’s, but it seems FTM1 and FTM2 are not used in device tree, so they should be usable on M4 out of the box.
There are 4 GPT timers in iMX7D. Gpt3 and gpt4 according to device tree and FreeRTOS files seem being dedicated to M4, so you can use them in M4 and not bother with device tree. In FreeRTOS for GPT3 is called GPTA. See various defines in board.h like BOARD_GPTA_BASEADDR, BORAD_GPTA_CCM_ROOT etc.


We are using the GPT 4 timer. Problem is: that we use ccmRootmuxGptSysPllPfd0 mux value. I saw in an other post that I could use a different Timer mux value but than my interrupts didnt work.

/* Select GPTB clock derived from PLL PFD0 */
CCM_UpdateRoot(CCM, BOARD_GPTB_CCM_ROOT, ccmRootmuxGptSysPllPfd0, 0, 0);

So I figured that I change the device tree, so I dont have to change any code on the M4.

Which comes to my next question:
I made the device tree with just one change on the model name, that I can see if the device tree compilation works alright. After I copied the device tree in the Partition 0 I restarted the board and it got stuck after “Starting Kernel …”
How can I figure out what went wrong?

I uploaded my dts and dtb file mybe it helps to give me an answer.

Thx in advance.

link text

Thanks for that Info!

iMX7D GPT is specified to work up to 100MHz (see iMX7D RM, table 5-11. Clock Root Table). I think you have more than that from SysPllPfd0.
As well there’s another not very clear statement in RM, see chapter 12.1.3:

The CCM is expected to provide this clock after synchronizing it to the System Bus Clock (ahb_clk)

I don’t see suggestion how it is supposed to be synchronized. Do they mean just frequency below the ahb_clk or as well clock edges matching ahb_clk edges?

Anyway you don’t have to change anything in device tree to use GPT3/4 in M4. Did you try to check your M4 code is working with Linux not booted? Just start your M4 code using bootaux command and check M4 is working without booting to Linux.

Regarding your modification. If you just changed board name in dts and Linux doesn’t boot, then most likely you use dts for different and incompatible SOM or board.

I am using GPT4 in combination with GPIO pins. It works fine with just the M4 running, so I figured it has to be something in the device tree, since there are some questions regarding this specific topic.

The strange thing is, that this question is saying, that the gpio is the problem. But I tested the GPIO in combination with RPMsg to set a LED on and of, and it worked.

Therefore I want to change the device tree. Probably disabling GPIO Bank 4 and hope for the best.

But there is still the problem with the device tree not working correctly.
So I use the Colibri iMX7D 1GB V1.1A the standard device tree is called imx7d-colibri-emmc-eval-v3.dtb.

So i executed this commands:
make colibri_imx7_defconfig
and after that
make imx7d-colibri-emmc-eval-v3.dtb
Everything worked as planed and I think I choose the right make commands. Maybe you have some other problem suggestions that i could check if they are right.

1 Like
  1. if you make etc setup to crosscompile for ARM? If not, then perhaps that was the problem. Provided you have gcc-arm-gnueabihf installed, try something like this:

make imx7d-colibri-emmc-eval-v3.dtb ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

The same args should be using making kernel and modules.

  1. You meant timers initially. Well, reading / settings pins without removing Linux access to whole GPIO bank may work by locking/unlocking Linux access to gpio executing on M4 RDC_SEMAPHORE_Lock(rdcPdapGpio4) and RDC_SEMAPHORE_Unlock(rdcPdapGpio4).
    But if you need interrupts, then most likely you will need to disable whole GPIO4 bank for Linux. But first search in device tree folder for imx7* files containing gpio4. Some pins are used for other SOM functions…

You are welcome.