Build custom device tree

Hi,

I am truing to build modified device tree for Apalis iMX6Q.
The modification I need, is to setup SPI1 to work without MOSI wire.
MOSI shall be configured as GPIO and used as data strobe due to hardware requirements.
I’ve used GPIO1 from Ixora board to test my software and everything works fine, but I prefer to set MOSI to GPIO in the final version. This will allow me to use the full SPI if hardware is updated one day.

So I found SPI1 pinout configuration is placed in imx6qdl-apalis.dtsi.

Here is the content of original file:

pinctrl_ecspi1: ecspi1grp {
	fsl,pins = <
		MX6QDL_PAD_CSI0_DAT6__ECSPI1_MISO 0x100b1
		MX6QDL_PAD_CSI0_DAT5__ECSPI1_MOSI 0x100b1
		MX6QDL_PAD_CSI0_DAT4__ECSPI1_SCLK 0x100b1
		/* SPI1 cs */
		MX6QDL_PAD_CSI0_DAT7__GPIO5_IO25 0x000b1
	>;
};

Here is my modification:

pinctrl_ecspi1: ecspi1grp {
	fsl,pins = <
		MX6QDL_PAD_CSI0_DAT6__ECSPI1_MISO 0x100b1

		/* Set SPI1 MOSI as GPIO */
		MX6QDL_PAD_CSI0_DAT5_GPIO5_IO23 0x000b1

		MX6QDL_PAD_CSI0_DAT4__ECSPI1_SCLK 0x100b1
		/* SPI1 cs */
		MX6QDL_PAD_CSI0_DAT7__GPIO5_IO25 0x000b1
	>;
};

Unfortunately I was not able to build the dtb.
I am using Ubuntu 18.04LTS build stations with cross compiler for iMX6. All applications for Apalis module were build via QT creator and they works fine.

Here is the result, when I try to build dtb:
~/2.8b_LXDE/linux-toradex/arch/arm/boot/dts$ make imx6q-apalis-eval.dtb
make: *** No rule to make target ‘imx6q-apalis-eval.dtb’. Stop.

The result is the same if I try to build dtbs.

Could you please support me in this task. It’s my first attempt to build dtb.

PS:
Initially kernel was build using bitbake.

Dear @Ivan_Gorchev

Welcome to the Toradex Community!

Commands for compilation with make have to be done in the root directory of the repository, means you have to go back to ~/2.8b_LXDE/linux-toradex/ and execute make imx6q-apalis-eval.dtb there. Don’t forget: ARCH and CROSS_COMPILE must be set and the kernel must be configured before device tree binaries can be compiled.
We also have an article about device tree customization in our developer center.

Best regards
Diego

Dear Diego,

Thank you very much for your reply!
I’ve tried to execute make in root directory, but seems there is an issue with my configuration.
I will check the configuration for ARCH and CROSS_COMPILE.

Could you please let me know how to configure the kernel?

Best regards,
Ivan Gorchev

Dear Diego,

Thank you very much for your advices and support!
I was able to build the device tree binary following your instructions.

Thank you so much!
Best regards,
Ivan Gorchev

Hi @Ivan_Gorchev

Please have a look at this article about how to build U-boot and Linux Kernel from Source Code. You basically have to download the toolchain and export it the following way (described here):

export ARCH=arm
export PATH=<path-to-toolchain>/bin/:$PATH
export CROSS_COMPILE=arm-linux-gnueabihf-

After that you also have to configure the kernel before you can build the device tree. You can use the default configuration provided by Toradex:

cd <path-to-the-local-toradex-linux-repository>
make apalis_imx6_defconfig

And after that, you will be able to build the device tree binary:

make imx6q-apalis-eval.dtb

Best regards
Diego

Hi @Ivan_Gorchev

Perfect that it works. Thanks for your feedback.