How do you rebuild dts files to make dtb

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do you rebuild dts files to make dtb

Jump to solution
15,088 Views
wdunkley
Contributor III

I've made a few changes to my imx8mm-evk.dts located in <build>/tmp/work-shared/imx8mmevk/kernel-source/arch/arm64/boot/dts/freescale. Now I need to compile imx8mm-evk.dts it to a dtb file and move it over to <build>/tmp/deploy/images/imx8mmevk so that I can use it in my Yocto image. 

I've tried to bitbake my image again and that didn't work. I read someone said they ran bitbake -c menuconfig linux-imx to recompile the dts file but that opens up another window "Linux/arm64 5.4.47 Kernel Configuration" that I have no idea what to do with.

I tried using DTC

dtc -I dts -O dtb -o imx8mm-evk.dtb imx8mm-evk.dts

and got this error.

Error: imx8mm-evk.dts:8.1-9 syntax error
FATAL ERROR: Unable to parse input tree

I read that DTC didn't like the "#" in my dts file so I changed it to "/include" and I got the same error.

I tried to run the make file in the freescale folder from above and got this error 

make -f Makefile
make: *** No targets. Stop.

How do you make changes to the dts file and then implement them into your project? 
Thanks

Labels (1)
0 Kudos
1 Solution
15,045 Views
JohnKlug
Senior Contributor I

I found a way to do this, assuming you are using yocto.

 

First do:

bitbake -f -c compile linux-imx (if build directory does not exist yet for the kernel)

bitbake -c devshell linux-imx  (or whatever your linux recipe is)

 

Then go to the build directory in the new devshell window (build/tmp/work/[machine]*/[kernel recipe]/version/build):

cd  ~/imx6-yocto-bsp/build/tmp/work/imx6ull14x14evk-poky-linux-gnueabi/linux-imx/5.4-r0/build

make mtcap3.dtb (name of a dtb file that is created by your kernel build).

 

Obviously your path to the kernel build will differ.  You need to do "bitbake -c compile linux-imx" to create the build directory in the first place.  Or build the whole thing if you device tree does not compile.

View solution in original post

11 Replies
15,078 Views
wdunkley
Contributor III

I am using #include, however, I tried changing it because people said that was what was causing the error when trying to compile with dtc.

0 Kudos
15,074 Views
JohnKlug
Senior Contributor I

You could try to comment out sections to find out where the error is.  Or use a macro:

 

#ifdef NEVER

Code you wish to remove temporarily.

#endif //NEVER

 

I have found that dtc does not produce very good error message.

 

/include is invalid.

0 Kudos
15,067 Views
wdunkley
Contributor III

How are the dtb files initially created? I have been trying for the last two days to compile any dts file and I can't get any of them to compile. I found one post that said I needed to preprocess the dts files with this command

cpp -nostdinc -I include -I arch  -undef -x assembler-with-cpp  arch/arm64/boot/dts/freescale/imx8mm-evk.dts imx8mm-evk.dts.preprocessed

dtc -I dts -O dtb -p 0x1000 imx8mm-evk.dts.preprocessed -o imx8mm-evk.dtb

This created the .preprocessed file but then the second command failed.  

0 Kudos
15,046 Views
JohnKlug
Senior Contributor I

I found a way to do this, assuming you are using yocto.

 

First do:

bitbake -f -c compile linux-imx (if build directory does not exist yet for the kernel)

bitbake -c devshell linux-imx  (or whatever your linux recipe is)

 

Then go to the build directory in the new devshell window (build/tmp/work/[machine]*/[kernel recipe]/version/build):

cd  ~/imx6-yocto-bsp/build/tmp/work/imx6ull14x14evk-poky-linux-gnueabi/linux-imx/5.4-r0/build

make mtcap3.dtb (name of a dtb file that is created by your kernel build).

 

Obviously your path to the kernel build will differ.  You need to do "bitbake -c compile linux-imx" to create the build directory in the first place.  Or build the whole thing if you device tree does not compile.

4,793 Views
AlekseyM
Contributor III

I got this error after command devshell

I use WSL and yocto in docker by IMX. 
Should I use full VM linux? Or can I compile dtb files in another way?


ERROR: linux-imx-6.1.y+gitAUTOINC+29549c7073-r0 do_devshell: No valid terminal found, unable to open devshell.
Tried the following commands:
tmux split-window -c "{cwd}" "do_terminal"
tmux new-window -c "{cwd}" -n "OpenEmbedded Developer Shell" "do_terminal"
xfce4-terminal -T "OpenEmbedded Developer Shell" -e "do_terminal"
terminology -T="OpenEmbedded Developer Shell" -e do_terminal
mate-terminal --disable-factory -t "OpenEmbedded Developer Shell" -x do_terminal
konsole --separate --workdir . -p tabtitle="OpenEmbedded Developer Shell" -e do_terminal
gnome-terminal -t "OpenEmbedded Developer Shell" -- do_terminal
xterm -T "OpenEmbedded Developer Shell" -e do_terminal
rxvt -T "OpenEmbedded Developer Shell" -e do_terminal
tmux new -c "{cwd}" -d -s devshell -n devshell "do_terminal"
screen -D -m -t "OpenEmbedded Developer Shell" -S devshell do_terminal
ERROR: Logfile of failure stored in: /opt/yocto/imx-yocto-bsp/imx8mm-ddr4-evk/tmp/work/imx8mm_ddr4_evk-poky-linux/linux-imx/6.1.y+gitAUTOINC+29549c7073-r0/temp/log.do_devshell.21896
ERROR: Task (/opt/yocto/imx-yocto-bsp/sources/meta-imx/meta-bsp/recipes-kernel/linux/linux-imx_6.1.bb:do_devshell) failed with exit code '1'
NOTE: Tasks Summary: Attempted 445 tasks of which 444 didn't need to be rerun and 1 failed.

 

 

Tags (1)
0 Kudos
4,766 Views
JohnKlug
Senior Contributor I
I am using WSL2 in Windows 10. I tried both Windows Terminal and Powershell. This works for me. A window pops up from devshell. I am using Ubuntu 20.04 that is one of the choices that wsl --list --online presents.
0 Kudos
4,775 Views
wdunkley
Contributor III

There is supposed to be a way to compile them in Windows. I never had any luck in Windows, so I used a VM with Linux. It has now been a few years since I've had to do it so I don't really remember much about it. 

0 Kudos
15,006 Views
wdunkley
Contributor III

Thank you so much, this way worked perfectly. It was looking for the .dts files in

 imx-yocto-bsp/(My Build)/tmp/work-shared/imx8mmevk/kernel-source/arch/arm64/boot/dts

however they were in that same path but one folder deeper in "freescale" I fixed that issue and now I am able to compile my DTS file into a .dtb file which shows up in

 imx-yocto-bsp/(My Build)/tmp/work/imx8mmevk-poky-linux/linux-imx/5.4-r0/build/arch/arm64/boot/dts 

0 Kudos
15,057 Views
JohnKlug
Senior Contributor I

I have always used the kernel build when compiling kernel dts files.  To get this to work, you need to be able to find all the include files.  You do not need to use cpp, but you do need to somehow get all of the include directories found during the compile.

0 Kudos
15,052 Views
wdunkley
Contributor III

I'm very new to Linux and am still learning about everything. If I run bitbake virtual/kernel -f -c deploy the dtb files timestamp update but when I uncompile the dtb files back to dts files none of my changes are in there. I even deleted the dts files in /home/will/imx-yocto-bsp/wills11/tmp/work-shared/imx8mmevk/kernel-source/arch/arm64/boot/dts/freescale but the dtb file still updates the time stamp. Am I wrong to think that the imx8mm-evk.dts file I'm supposed to be editing is in the freescale folder?

0 Kudos
15,085 Views
JohnKlug
Senior Contributor I

You should use #include, not /include.

0 Kudos