Basic Device Tree for the Udoo Board

Document created by alejandrolozano Employee on Jan 18, 2016Last modified by Diana Torres on Feb 2, 2016
Version 1Show Document
  • View in full screen mode
  1. INTRODUCTION
  2. REQUIREMENTS
  3. DEVICE TREE
  4. BOOTING LINUX

 

 

1. INTRODUCTION

 

    This document explains how to use the yocto images and tailor the source code for a different board. The board used in this document is the Udoo board that features an iMX6Q. In this document U-Boot Migration Example the U-boot changes are covered and it must be followed before this one. The below steps will cover the next board changes:

 

  •     Ethernet PHY
  •     SD card
  •     Debug UART

 

2. REQUIREMENTS

 

  • A functional Yocto environment (Images generated for your target, core-image-minimal). The images generated must be chosen for the imx6q, which is the one explained in this document.
  • Toolchain. The meta-toolchain is used in this document.
  • L3.14.38 is used in this document.
  • Build Kernel using meta-toolchain
  • A SD card with the core-image-minimal image.

 

NOTE:

Follow the next training that explains in detail the steps to cover the requirements.

Yocto Training - HOME

 

3. DEVICE TREE   

 

    In previous Linux versions 3.0.35 backwards, the kernel contained hardcoded structures in C language used for board and platform specific configurations. Thanks to the device tree, the same kernel image can be used for different boards and the description of the platform and board is defined in a different file. Therefore the same kernel used by the SABRE-SD or SABRE-AI board can be used for the Udoo board and only  a new Device Tree file has to be generated.

 

3.1 ADDING A NEW DEVICE TREE

After you have chosen the configuration of the corresponding board (imx_v7_defconfig), exported the needed environment variables like ARCH, CROSS_COMPILE; the new .dts file must be added.

    • In the linux source folder arch/arm/boot/dts create a file named imx6q-udoo-doc.dts. This is the .dts file that contains the hardware description.

 

$ touch imx6q-udoo-doc.dts

 

    • Add the new dts file in the Makefile found in arch/arm/boot/dts. The file must be inside the precomipler directive $(CONFIG_ARCH_MXC)

 

3.2 DEVICE TREE CONTENT

    • Using your prefered text editor, add the dts version at the top of the file

 

/dts-v1/;

 

    • There is already a dtsi file that describes  the imx6q device named imx6q.dtsi. Include this file in the new dts .
#include "imx6q.dtsi"

 

    • Add the root node, model and compatible property. The udoo,imx6q-udoo property does not exist in the DT_MACHINE structure, but fsl,imx6q does.
/ {

        model = "Udoo i.MX6 Quad Board";
        compatible = "udoo,imx6q-udoo", "fsl,imx6q";

};

    • Add the memory region.

 

memory{
          reg = <0x10000000 0x40000000>;
};

 

    • Add the pinctrl configurations for the nodes you want to add. UART2_TXD and UART2_RXD are the pins used for the serial debug console. The pin description must be placed in the iomuxc node.

 

 

 

&iomuxc{
     imx6q-udoo{
          pinctrl_uart2: uart2grp{
               fsl,pins = <
                         MX6QDL_PAD_EIM_D26__UART2_TX_DATA          0x1b0b1
                         MX6QDL_PAD_EIM_D27__UART2_RX_DATA          0x1b0b1
                          >;
               };
         };
     };

 

    • The RGMII connection and SD characteristics are the same as iMX6Q SABRE-SD .

 

 

pinctrl_usdhc3: usdhc3grp {
                        fsl,pins = <
                               MX6QDL_PAD_SD3_CMD__SD3_CMD 0x17059
                               MX6QDL_PAD_SD3_CLK__SD3_CLK 0x10059
                               MX6QDL_PAD_SD3_DAT0__SD3_DATA0 0x17059
                               MX6QDL_PAD_SD3_DAT1__SD3_DATA1 0x17059
                               MX6QDL_PAD_SD3_DAT2__SD3_DATA2 0x17059
                               MX6QDL_PAD_SD3_DAT3__SD3_DATA3 0x17059
                        >;
                };

 

 

pinctrl_enet: enetgrp {
                        fsl,pins = <                   
                               MX6QDL_PAD_RGMII_RXC__RGMII_RXC 0x1b0b0
                               MX6QDL_PAD_RGMII_RD0__RGMII_RD0 0x1b0b0
                               MX6QDL_PAD_RGMII_RD1__RGMII_RD1 0x1b0b0
                               MX6QDL_PAD_RGMII_RD2__RGMII_RD2 0x1b0b0
                               MX6QDL_PAD_RGMII_RD3__RGMII_RD3 0x1b0b0
                               MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL 0x1b0b0 
                               MX6QDL_PAD_RGMII_TXC__RGMII_TXC 0x1b0b0
                               MX6QDL_PAD_RGMII_TD0__RGMII_TD0 0x1b0b0 
                               MX6QDL_PAD_RGMII_TD1__RGMII_TD1 0x1b0b0 
                               MX6QDL_PAD_RGMII_TD2__RGMII_TD2 0x1b0b0 
                               MX6QDL_PAD_RGMII_TD3__RGMII_TD3 0x1b0b0 
                               MX6QDL_PAD_RGMII_TX_CTL__RGMII_TX_CTL 0x1b0b0
                               MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK 0x1b0b0
                               MX6QDL_PAD_ENET_MDIO__ENET_MDIO 0x1b0b0
                               MX6QDL_PAD_ENET_MDC__ENET_MDC 0x1b0b0
                               MX6QDL_PAD_GPIO_16__ENET_REF_CLK 0x4001b0a8
                        >;      
                }; 
    • The fec, uart2 and usdhc3 nodes must be added. These nodes exist already in the imx6q.dtsi but the status property, pinctrl  among others must be added.

 

&fec {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_enet>;
        phy-mode = "rgmii";     
        status = "okay";        
};                              
                        
&uart2 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_uart2>;
        status = "okay";        
};                              
                                        
                                        
                                
&usdhc3 {                                
        pinctrl-names = "default";       
        pinctrl-0 = <&pinctrl_usdhc3>;
        non-removable;          
        status = "okay";
};

    • Below is the simple dts file resulting from the above points.

 

/dts-v1/;
#include "imx6q.dtsi"

/ {
        model = "Udoo i.MX6 Quad Board";
        compatible = "udoo,imx6q-udo", "fsl,imx6q";

        memory {
                reg = <0x10000000 0x80000000>;
        };

};

&fec {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_enet>;
        phy-mode = "rgmii";
        status = "okay";
};

&uart2 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_uart2>;
        status = "okay";
};



&usdhc3 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_usdhc3>;
        non-removable;
        status = "okay";
};


&iomuxc {
        imx6q-udoo {
                pinctrl_enet: enetgrp {
                        fsl,pins = <
                                MX6QDL_PAD_RGMII_RXC__RGMII_RXC         0x1b0b0
                                MX6QDL_PAD_RGMII_RD0__RGMII_RD0         0x1b0b0
                                MX6QDL_PAD_RGMII_RD1__RGMII_RD1         0x1b0b0
                                MX6QDL_PAD_RGMII_RD2__RGMII_RD2         0x1b0b0
                                MX6QDL_PAD_RGMII_RD3__RGMII_RD3         0x1b0b0
                                MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL   0x1b0b0
                                MX6QDL_PAD_RGMII_TXC__RGMII_TXC         0x1b0b0
                                MX6QDL_PAD_RGMII_TD0__RGMII_TD0         0x1b0b0
                                MX6QDL_PAD_RGMII_TD1__RGMII_TD1         0x1b0b0
                                MX6QDL_PAD_RGMII_TD2__RGMII_TD2         0x1b0b0
                                MX6QDL_PAD_RGMII_TD3__RGMII_TD3         0x1b0b0
                                MX6QDL_PAD_RGMII_TX_CTL__RGMII_TX_CTL   0x1b0b0
                                MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK    0x1b0b0
                                MX6QDL_PAD_ENET_MDIO__ENET_MDIO         0x1b0b0
                                MX6QDL_PAD_ENET_MDC__ENET_MDC           0x1b0b0
                                MX6QDL_PAD_GPIO_16__ENET_REF_CLK        0x4001b0a8
                        >;
                };

                pinctrl_uart2: uart2grp {
                        fsl,pins = <
                                MX6QDL_PAD_EIM_D26__UART2_TX_DATA       0x1b0b1
                                MX6QDL_PAD_EIM_D27__UART2_RX_DATA       0x1b0b1
                        >;
                };

                pinctrl_usdhc3: usdhc3grp {
                        fsl,pins = <
                                MX6QDL_PAD_SD3_CMD__SD3_CMD             0x17059
                                MX6QDL_PAD_SD3_CLK__SD3_CLK             0x10059
                                MX6QDL_PAD_SD3_DAT0__SD3_DATA0          0x17059
                                MX6QDL_PAD_SD3_DAT1__SD3_DATA1          0x17059
                                MX6QDL_PAD_SD3_DAT2__SD3_DATA2          0x17059
                                MX6QDL_PAD_SD3_DAT3__SD3_DATA3          0x17059
                        >;
                };


        };
};

 

3.3 COMPILING DEVICE TREE

 

Compiling the .dts will generate a .dtb file that is the binary file the kernel needs.

 

make ARCH=arm dtbs

 

A file named imx6q-udoo-doc.dtb is the file used by our board. It is found in  arch/arm/boot/dts folder. If you have a SD with a working image, place this file in the FAT partition. You may need to change the file name first, in this case for imx6q-udoo.dtb.

 

 

4. BOOTING THE IMAGE

After this you should have a simple and functional linux system. Just plug-in your SD card and power-up the board. 

You should get an output in the serial console like the one below:

 

 

I hope you find this basic document helpful.

8 people found this helpful

Attachments

    Outcomes