[A20-SOM204] Modify or create new device tree

Started by dpierleo, November 21, 2019, 11:29:02 AM

Previous topic - Next topic

dpierleo

Hi,
we are working with a SoM A20-SOM204-A20 (A20-SOM204-1Ge16Gs16M-MC) mounted to an evaluation board SOM204-EVB.

We downloaded and wrote in the eMMC the latest official image from your ftp site:

Armbian_5.92.2_Olinuxino-a20_Ubuntu_bionic_next_5.2.20_desktop

We made the procedure for booting from SPI flash and then loading kernel from internal eMMC. Device tree loaded by U-Boot during booting is:

sun7i-a20-olimex-som204-evb-emmc.dtb

Everything seems to work correctly.

Our next step is to migrate to our custom board leaving the evaluation board.
In order to do that, we have to change device tree for our custom board.

Our idea is to create a new dts (based on sun7i-a20-olimex-som204-evb-emmc.dts), recompile it, put the obtained dtb in folder /boot/dtb of the system and finally modify environment fdtfile to load our new dtb during booting step.

First of all we cloned kernel with:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
and we tried to recompile original dts with following instructions:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sunxi_defconfig
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j4 dtbs

The result was a series of dtb in the folder arch/arm/boot/dts but the obtained device tree sun7i-a20-olimex-som204-evb-emmc.dtb has different size of the same file in official image Armbian_5.92.2_Olinuxino-a20_Ubuntu_bionic_next_5.2.20_desktop (27KB instead of 37KB of the original one) and does not work if loaded during boot (system hang up after a while the kernel starts).

How is this possible if we started from the same dts?

We would like to know please:
1) the right path of repository from where to clone kernel for your official image (where we can find official dts files)
2) the right defconfig file and parameters to obtain the same dtb that you have put in official image we used
3) do we have to do something else for changing or creating a new dtb? do we have to recompile also u-boot? 

LubOlimex

What you do will not result in the same image as ours.

The repo is here: https://github.com/olimex/build

Instructions for u-boot, kernel, file system building can be found here (at the bottom): https://www.olimex.com/wiki/ArmbianHowTo
Technical support and documentation manager at Olimex

dpierleo

#2
Hi LubOlimex,

thank you for your prompt answer.

I have done what you told me.
I followed your suggestions and the instructions in the page https://www.olimex.com/wiki/ArmbianHowTo (naturally I already knew that page).
I ran script ./compile and I chose configuration for a20-som204 and kernel mainline. After some time the packages were available in the output directory.

I found dtd just compiled in the folder build/cache/sources/linux-mainline/linux-4.19.y/arch/arm/boot/dts and sun7i-a20-olimex-som204-evb-emmc.dtb has now another different size (40KB).

Anyway I still have the original problem: I do not want to compile kernel and/or u-boot. I simply would like to create a new dtb (with a new name) and load this dtb at booting time. More specifically I would like to do following operations:

1) copy sun7i-a20-olimex-som204-evb-emmc.dts to new file my_board.dts
2) compile my_board.dts with dtc compiler
3) copy my_board.dtb in folder /boot/dtb of the image downloaded from your ftp site
4) change fdtfile (environment variable) fdtfile=my_board.dtb and run boot from u-boot

Is it possible?

selfbg

#3
You cannot compile sun7i-a20-olimex-som204-evb-emmc.dts outside the kernel tree. There are some imports that will not be resolved.

You could use overlay file (dtbo), which can be compiled with dtc.
Otherwise the procedure is:
  • Download correct kernel version 5.2.y
  • Copy sun7i-a20-olimex-som204-evb-emmc.dts to my-board.dts in arch/arm/boot/dts/
  • Add my-board.dts in arch/arm/boot/dts/Makefile
  • Build dts with make ARCH=arm sunxi_defconfig && make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs

Also the dtbs are different sizes, because of different kernel version.

git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Right now this is 5.4. The Armbian image is 5.2.

When using ./compile.sh make sure that you're on the olimex branch and there is .ignore_changes file present.