【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

2年前 (2022) 程序员胖胖胖虎阿
208 0 0
  • 文章假定读者一定程度了解 linux 基础知识
  • 文章来源于《嵌入式linux完全开发手册》- IMX6ull 开发板从零移植篇
区别在于:本文描述从各个网站(官网)下载最新 ubuntu、交叉编译器、uboot、kernel、buildroot 从零开始构建,更接近实际工程环境
(可同时交叉参阅两份文章)

一、关于 ubuntu

  • 下载安装最新桌面 LTS 版本 ubuntu
  • 正常步骤安装(参考网络其它文章)
  • 几个关键的设置

    • 磁盘大小:60GB 以上
    • 网络连接:使用桥接网络(复制网络连接状态)[路由器连接开发板和电脑]

二、关于交叉工具链

1、下载

ARM开发者中心下载交叉编译工具链

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

host 为 linux 👉 `x86_64 linux`
imx6ul 为 arm_A7 架构 👉 `AArch32`
imx6ul 支持硬件浮点 👉 `hard fllat`
需支持 linux 操作系统 👉 `none-linux`

2、配置

解压缩

tiansong@tiansong:~/100ask_imx6ull_pro$ ls
arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz

tiansong@tiansong:~/100ask_imx6ull_pro$ tar -xvf arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz

tiansong@tiansong:~/100ask_imx6ull_pro$ ls
arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf  arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz

设置环境变量

tiansong@tiansong:~$ vim ~/.bashrc

# 在文件末尾追加
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabihf-
export PATH=$PATH:/home/tiansong/100ask_imx6ull_pro/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf/bin

# 使环境变量在当前终端生效
tiansong@tiansong:~/100ask_imx6ull_pro$ source ~/.bashrc

验证是否配置成功

tiansong@tiansong:~/100ask_imx6ull_pro$ arm-none-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/home/tiansong/100ask_imx6ull_pro/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf/bin/../libexec/gcc/arm-none-linux-gnueabihf/11.3.1/lto-wrapper
Target: arm-none-linux-gnueabihf
Configured with: /data/jenkins/workspace/GNU-toolchain/arm-11/src/gcc/configure --target=arm-none-linux-gnueabihf --prefix= --with-sysroot=/arm-none-linux-gnueabihf/libc --with-build-sysroot=/data/jenkins/workspace/GNU-toolchain/arm-11/build-arm-none-linux-gnueabihf/install//arm-none-linux-gnueabihf/libc --with-bugurl=https://bugs.linaro.org/ --enable-gnu-indirect-function --enable-shared --disable-libssp --disable-libmudflap --enable-checking=release --enable-languages=c,c++,fortran --with-gmp=/data/jenkins/workspace/GNU-toolchain/arm-11/build-arm-none-linux-gnueabihf/host-tools --with-mpfr=/data/jenkins/workspace/GNU-toolchain/arm-11/build-arm-none-linux-gnueabihf/host-tools --with-mpc=/data/jenkins/workspace/GNU-toolchain/arm-11/build-arm-none-linux-gnueabihf/host-tools --with-isl=/data/jenkins/workspace/GNU-toolchain/arm-11/build-arm-none-linux-gnueabihf/host-tools --with-arch=armv7-a --with-fpu=neon --with-float=hard --with-mode=thumb --with-arch=armv7-a --with-pkgversion='Arm GNU Toolchain 11.3.Rel1'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.3.1 20220712 (Arm GNU Toolchain 11.3.Rel1)

三、关于 uboot

1、下载

# 下载
tiansong@tiansong:~/100ask_imx6ull_pro$ tiansong@tiansong:~/100ask_imx6ull_pro$ git clone https://source.codeaurora.cn/external/imx/uboot-imx
tiansong@tiansong:~/100ask_imx6ull_pro$ ls
arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf  uboot-imx

# 查看仓库所有分支
tiansong@tiansong:~/100ask_imx6ull_pro$ cd uboot-imx/
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ git branch -a
...
remotes/origin/imx_v2020.04_5.4.70_2.3.0
...

# 切换到 imx 最新分支
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ git checkout remotes/origin/imx_v2020.04_5.4.70_2.3.0
Updating files: 100% (11834/11834), done.
Note: switching to 'remotes/origin/imx_v2020.04_5.4.70_2.3.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 62a81128c0 MLK-25878: imx8: scu: Increase sendmsg timeout for SCFW MU

# 确认是否却换成功
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ git log -1
commit 62a81128c07c3efc123039f796ffc43b4eacbf04 (HEAD, origin/imx_v2020.04_5.4.70_2.3.0)
Author: Nitin Garg <nitin.garg@nxp.com>
Date:   Fri Apr 29 10:54:20 2022 -0500

    MLK-25878: imx8: scu: Increase sendmsg timeout for SCFW MU

    Similar to receivemsg, sendmsg function should also
    use 1 sec timeout for MU communication with SCFW.

    Signed-off-by: Nitin Garg <nitin.garg@nxp.com>
    Reviewed-by: Ye Li <ye.li@nxp.com>

2、开发板文件适配

前置说明:有多处关联,移植尽量一口气完成

默认的配置文件

复制公板提供的默认配置文件

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ cd configs/

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/configs$ ls *mx6ull_14x14_evk* -l
-rw-rw-r-- 1 tiansong tiansong 1988  8月 26 10:36 mx6ull_14x14_evk_defconfig             # imx6ullevk公板默认的配置文件,默认只支持 SD 卡启动
-rw-rw-r-- 1 tiansong tiansong 1963  8月 26 10:36 mx6ull_14x14_evk_emmc_defconfig        # imx6ull 支持 emmc 启动方式启动的配置文件
-rw-rw-r-- 1 tiansong tiansong 2095  8月 26 10:36 mx6ull_14x14_evk_nand_defconfig        # imx6ull 支持 nand 启动方式启动的配置文件
-rw-rw-r-- 1 tiansong tiansong 2007  8月 26 10:36 mx6ull_14x14_evk_optee_defconfig        # imx6ull 支持 optee 系统的配置文件
-rw-rw-r-- 1 tiansong tiansong 1958  8月 26 10:36 mx6ull_14x14_evk_plugin_defconfig        # imx6ull 支持扩展功能的配置文件,主要是烧写功能
-rw-rw-r-- 1 tiansong tiansong 2057  8月 26 10:36 mx6ull_14x14_evk_qspi1_defconfig        # imx6ull 支持扩展功能的配置文件,主要是烧写功能

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/configs$ cp mx6ull_14x14_evk_emmc_defconfig 100ask_imx6ull_pro_emmc_defconfig

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/configs$ ls 100ask_imx6ull_pro_emmc_defconfig -l
-rw-rw-r-- 1 tiansong tiansong 1982  8月 26 10:54 100ask_imx6ull_pro_emmc_defconfig

修改复制的配置文件 (三处)

CONFIG_TARGET_MX6ULL_14X14_EVK=y
👉
CONFIG_TARGET_100ASK_IMX6ULL_PRO_EMMC=y


CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6ullevk/imximage.cfg"
👉
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/100ask/100ask_imx6ull_pro_emmc/imximage.cfg"


CONFIG_DEFAULT_DEVICE_TREE="imx6ull-14x14-evk-emmc"
👉
CONFIG_DEFAULT_DEVICE_TREE="100ask_imx6ull_pro_emmc"

板件级支持

头文件

复制公板提供的.h文件

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ cd include/configs/

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ cd include/configs/

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/include/configs$ cp mx6ullevk.h 100ask_imx6ull_pro_emmc.h

修改复制的.h文件 (两处)

#ifndef __MX6ULLEVK_CONFIG_H
#define __MX6ULLEVK_CONFIG_H
👉
#ifndef __100ASK_IMX6ULL_PRO_EMMC_CONFIG_H
#define __100ASK_IMX6ULL_PRO_EMMC_CONFIG_H
文件夹

复制公板提供的文件夹

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ cd board/

# 创建二级目录,100ask族和100ask_imx6ull_pro_emmc族
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/board$ mkdir 100ask
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/board$ mkdir 100ask/100ask_imx6ull_pro_emmc

# 复制 common 文件夹
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/board$ cp freescale/common 100ask/

# 复制 freescale/mx6ullevk/* 下所有公板文件
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/board$ cp freescale/mx6ullevk/* 100ask/100ask_imx6ull_pro_emmc/

# 查看文件数,确认是否操作成功
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/board$ cd 100ask/
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/board/100ask$ tree
.
├── 100ask_imx6ull_pro_emmc  # 注重修改 !!
│   ├── 100ask_imx6ull_pro_emmc.c
│   ├── built-in.o
│   ├── imximage.cfg
│   ├── imximage_lpddr2.cfg
│   ├── Kconfig
│   ├── MAINTAINERS
│   ├── Makefile
│   ├── plugin.S
│   └── README
└── common
    ├── arm_sleep.c
    ├── built-in.o
    ├── cadmus.c
    ├── cadmus.h
    ├── cds_pci_ft.c
    ├── cds_via.c
    ...
    ...

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/board/100ask$ cd 100ask_imx6ull_pro_emmc/

重命名 mx6ullevk.c

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/board/freescale/mx6ullevk$ mv mx6ullevk.c 100ask_imx6ull_pro_emmc.c 

修改 100ask_imx6ull_pro_emmc.c

int checkboard(void)
{
    else
        puts("Board: MX6ULL 14x14 EVK\n");
        👉
        puts("Board: 100ASK_IMX6ULL_PRO_EMMC\n");
    return 0;
}

修改 Makefile

obj-y  := 100ask_imx6ull_pro_emmc.o

修改 Kconfig

if TARGET_100ASK_IMX6ULL_PRO_EMMC         # 注意与 100ask_imx6ull_pro_emmc_defconfig 中 CONFIG_TARGET_100ASK_IMX6ULL_PRO_EMMC=y 对应 

config SYS_BOARD
        default "100ask_imx6ull_pro_emmc" # 100ask_imx6ull_pro_emmc 注意与后续多处对应

config SYS_VENDOR
        default "100ask"

config SYS_CONFIG_NAME
        default "100ask_imx6ull_pro_emmc"

config SYS_TEXT_BASE
        default 0x87800000
endif

修改 MAINTAINERS 【注意路径填写正确】

MX6ULLEVK BOARD
M:      Peng Fan <peng.fan@nxp.com>
S:      Maintained
F:      board/100ask/100ask_imx6ull_pro_emmc/
F:      include/configs/100ask_imx6ull_pro.h
F:      configs/100ask_imx6ull_pro_emmc_defconfig

修改 imximage.cfg

PLUGIN  board/freescale/mx6ullevk/plugin.bin 0x00907000
👉
PLUGIN  board/100ask/100ask_imx6ull_pro_emmc/plugin.bin 0x00907000

修改 imximage_lpddr2.cfg

PLUGIN  board/freescale/mx6ullevk/plugin.bin 0x00907000
👉
PLUGIN  board/100ask/100ask_imx6ull_pro_emmc/plugin.bin 0x00907000

增加图像化支持

修改 /home/tiansong/100ask_imx6ull_pro/uboot-imx/arch/arm/mach-imx/mx6/Kconfig【注意路径】

config TARGET_MX6ULL_14X14_EVK
        bool "Support mx6ull_14x14_evk"
        select BOARD_LATE_INIT
        select DM
        select DM_THERMAL
        select MX6ULL
        imply CMD_DM

# 在 TARGET_MX6ULL_14X14_EVK 之下添加,注意与 100ask_imx6ull_pro_emmc_defconfig 中 CONFIG_TARGET_100ASK_IMX6ULL_PRO_EMMC=y 对应 
config TARGET_100ASK_IMX6ULL_PRO_EMMC
        bool "Support 100ask_imx6ull_pro_emmc"
        select BOARD_LATE_INIT
        select DM
        select DM_THERMAL
        select MX6ULL
        imply CMD_DM

# 文件末尾添加,注意路径
source "board/100ask/100ask_imx6ull_pro_emmc/Kconfig"

默认的设备树

复制公板设备树文件 imx6ull-14x14-evk-emmc.dts

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/arch/arm/dts$ pwd
/home/tiansong/100ask_imx6ull_pro/uboot-imx/arch/arm/dts

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/arch/arm/dts$ ls imx6ull-14x14-evk* -l
-rw-rw-r-- 1 tiansong tiansong   407  8月 26 10:36 imx6ull-14x14-evk.dts
-rw-rw-r-- 1 tiansong tiansong   570  8月 26 10:36 imx6ull-14x14-evk-emmc.dts
-rw-rw-r-- 1 tiansong tiansong  1184  8月 26 10:36 imx6ull-14x14-evk-gpmi-weim.dts

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/arch/arm/dts$ cp imx6ull-14x14-evk-emmc.dts 100ask_imx6ull_pro_emmc.dts

编辑设备树文件 100ask_imx6ull_pro_emmc.dts

# 观察 100ask_imx6ull_pro_emmc.dts 文件内容,依赖于 imx6ull-14x14-evk.dts
#include "imx6ull-14x14-evk.dts"

# 观察 imx6ull-14x14-evk.dts, 依赖于多个文件 
#include "imx6ull.dtsi"
#include "imx6ul-14x14-evk.dtsi"
#include "imx6ul-14x14-evk-u-boot.dtsi"
  • 融合 100ask_imx6ull_pro_emmc.dtsimx6ull-14x14-evk.dtsimx6ul-14x14-evk.dtsi100ask_imx6ull_pro_emmc.dts
  • 修改 lcd 和 phy 设备树参数
  • 以下为修改好的设备树:
/*
 * Copyright 2019 NXP
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 */

/dts-v1/;

#include "imx6ull.dtsi"

/ {
        model = "i.MX6 ULL 100ASK PRO EMMC Board";  // 修改
        compatible = "fsl,imx6ull-14x14-evk", "fsl,imx6ull";

    aliases {
        spi5 = &{/spi4};
    };

    chosen {
        stdout-path = &uart1;
    };

    memory@80000000 {
        device_type = "memory";
        reg = <0x80000000 0x20000000>;
    };

    reg_sd1_vmmc: regulator-sd1-vmmc {
        compatible = "regulator-fixed";
        regulator-name = "VSD_3V3";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        gpio = <&gpio1 9 GPIO_ACTIVE_HIGH>;
        off-on-delay-us = <20000>;
        enable-active-high;
    };

    reg_can_3v3: regulator-can-3v3 {
        compatible = "regulator-fixed";
        regulator-name = "can-3v3";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        gpios = <&gpio_spi 3 GPIO_ACTIVE_LOW>;
    };

    spi4 {
        compatible = "spi-gpio";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_spi4>;
        status = "okay";
        pinctrl-assert-gpios = <&gpio5 8 GPIO_ACTIVE_LOW>;
        gpio-sck = <&gpio5 11 0>;
        gpio-mosi = <&gpio5 10 0>;
        cs-gpios = <&gpio5 7 0>;
        num-chipselects = <1>;
        #address-cells = <1>;
        #size-cells = <0>;

        gpio_spi: gpio@0 {
            compatible = "fairchild,74hc595";
            gpio-controller;
            #gpio-cells = <2>;
            reg = <0>;
            registers-number = <1>;
            registers-default = /bits/ 8 <0x57>;
            spi-max-frequency = <100000>;
        };
    };
    
    // 新增背光控制节点
    backlight {
            compatible = "pwm-backlight";
            pwms = <&pwm1 0 1000>;
            brightness-levels = <0 1 2 3 4 5 6 8 10>;
            default-brightness-level = <8>;
            status = "okay";
        };
};

&clks {
    assigned-clocks = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>;
    assigned-clock-rates = <786432000>;
};

&i2c2 {
    clock-frequency = <100000>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c2>;
    status = "okay";

    codec: wm8960@1a {
        #sound-dai-cells = <0>;
        compatible = "wlf,wm8960";
        reg = <0x1a>;
        wlf,shared-lrclk;
    };
};

&fec1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_enet1>;
    phy-mode = "rmii";
    phy-handle = <&ethphy0>;
    status = "disabled";  // 网口 1 未使用,状态禁用
};

&fec2 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_enet2>;
    phy-mode = "rmii";
    phy-handle = <&ethphy1>;
    phy-reset-gpios = <&gpio5 6 GPIO_ACTIVE_LOW>;  // 增加复位
    phy-reset-duration = <25>;                     // 复位持续时间
    status = "okay";

    mdio {
        #address-cells = <1>;
        #size-cells = <0>;

        ethphy0: ethernet-phy@2 {
            reg = <0>;
            smsc,led-mode = <1>;
            clocks = <&clks IMX6UL_CLK_ENET_REF>;
            clock-names = "rmii-ref";
        };

        ethphy1: ethernet-phy@1 {
            reg = <1>;  // phy 地址
            smsc,led-mode = <1>;
            clocks = <&clks IMX6UL_CLK_ENET2_REF>;
            clock-names = "rmii-ref";
        };
    };
};

&can1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_flexcan1>;
    xceiver-supply = <&reg_can_3v3>;
    status = "okay";
};

&can2 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_flexcan2>;
    xceiver-supply = <&reg_can_3v3>;
    status = "okay";
};

&i2c1 {
    clock-frequency = <100000>;
    pinctrl-names = "default", "gpio";
    pinctrl-0 = <&pinctrl_i2c1>;
    pinctrl-1 = <&pinctrl_i2c1_gpio>;
    scl-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
    sda-gpios = <&gpio1 29 GPIO_ACTIVE_HIGH>;
    status = "okay";

    mag3110@e {
        compatible = "fsl,mag3110";
        reg = <0x0e>;
    };
};

&lcdif {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_lcdif_dat
                     &pinctrl_lcdif_ctrl>;

        display = <&display0>;
        status = "okay";
        reset-gpios = <&gpio3 4 GPIO_ACTIVE_LOW>;  // 增加复位

        display0: display@0 {
                bits-per-pixel = <24>;
                bus-width = <24>;

                display-timings {  // 时许调整
                        native-mode = <&timing0>;
                        timing0: timing0 {
                                clock-frequency = <50000000>;
                                hactive = <1024>;
                                vactive = <600>;
                                hfront-porch = <160>;
                                hback-porch = <140>;
                                hsync-len = <20>;
                                vback-porch = <20>;
                                vfront-porch = <12>;
                                vsync-len = <3>;

                                hsync-active = <0>;
                                vsync-active = <0>;
                                de-active = <1>;
                                pixelclk-active = <0>;
                        };
                };
        };
};

&pwm1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_pwm1>;
    status = "okay";
};

&qspi {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_qspi>;
    status = "okay";

    flash0: n25q256a@0 {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "micron,n25q256a", "jedec,spi-nor";
        spi-max-frequency = <29000000>;
        reg = <0>;
    };
};

&sai2 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_sai2>;
    assigned-clocks = <&clks IMX6UL_CLK_SAI2_SEL>,
              <&clks IMX6UL_CLK_SAI2>;
    assigned-clock-parents = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>;
    assigned-clock-rates = <0>, <12288000>;
    fsl,sai-mclk-direction-output;
    status = "okay";
};

&snvs_poweroff {
    status = "okay";
};

&tsc {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_tsc>;
    xnur-gpio = <&gpio1 3 GPIO_ACTIVE_LOW>;
    measure-delay-time = <0xffff>;
    pre-charge-time = <0xfff>;
    status = "okay";
};

&uart1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_uart1>;
    status = "okay";
};

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

&usbotg1 {
    dr_mode = "otg";
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_usb_otg1>;
    status = "okay";
};

&usbotg2 {
    dr_mode = "host";
    disable-over-current;
    status = "okay";
};

&usbphy1 {
    fsl,tx-d-cal = <106>;
};

&usbphy2 {
    fsl,tx-d-cal = <106>;
};

&usdhc1 {
    pinctrl-names = "default", "state_100mhz", "state_200mhz";
    pinctrl-0 = <&pinctrl_usdhc1>;
    pinctrl-1 = <&pinctrl_usdhc1_100mhz>;
    pinctrl-2 = <&pinctrl_usdhc1_200mhz>;
    cd-gpios = <&gpio1 19 GPIO_ACTIVE_LOW>;
    keep-power-in-suspend;
    wakeup-source;
    vmmc-supply = <&reg_sd1_vmmc>;
    status = "okay";
};

&usdhc2 {
    pinctrl-names = "default", "state_100mhz", "state_200mhz";
    pinctrl-0 = <&pinctrl_usdhc2_8bit>;
    pinctrl-1 = <&pinctrl_usdhc2_8bit_100mhz>;
    pinctrl-2 = <&pinctrl_usdhc2_8bit_200mhz>;
    bus-width = <8>;
    non-removable;
    status = "okay";
};

&wdog1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_wdog>;
    fsl,ext-reset-output;
};

&iomuxc {
    pinctrl-names = "default";

    pinctrl_csi1: csi1grp {
        fsl,pins = <
            MX6UL_PAD_CSI_MCLK__CSI_MCLK        0x1b088
            MX6UL_PAD_CSI_PIXCLK__CSI_PIXCLK    0x1b088
            MX6UL_PAD_CSI_VSYNC__CSI_VSYNC        0x1b088
            MX6UL_PAD_CSI_HSYNC__CSI_HSYNC        0x1b088
            MX6UL_PAD_CSI_DATA00__CSI_DATA02    0x1b088
            MX6UL_PAD_CSI_DATA01__CSI_DATA03    0x1b088
            MX6UL_PAD_CSI_DATA02__CSI_DATA04    0x1b088
            MX6UL_PAD_CSI_DATA03__CSI_DATA05    0x1b088
            MX6UL_PAD_CSI_DATA04__CSI_DATA06    0x1b088
            MX6UL_PAD_CSI_DATA05__CSI_DATA07    0x1b088
            MX6UL_PAD_CSI_DATA06__CSI_DATA08    0x1b088
            MX6UL_PAD_CSI_DATA07__CSI_DATA09    0x1b088
        >;
    };

    pinctrl_enet1: enet1grp {
        fsl,pins = <
            MX6UL_PAD_ENET1_RX_EN__ENET1_RX_EN    0x1b0b0
            MX6UL_PAD_ENET1_RX_ER__ENET1_RX_ER    0x1b0b0
            MX6UL_PAD_ENET1_RX_DATA0__ENET1_RDATA00    0x1b0b0
            MX6UL_PAD_ENET1_RX_DATA1__ENET1_RDATA01    0x1b0b0
            MX6UL_PAD_ENET1_TX_EN__ENET1_TX_EN    0x1b0b0
            MX6UL_PAD_ENET1_TX_DATA0__ENET1_TDATA00    0x1b0b0
            MX6UL_PAD_ENET1_TX_DATA1__ENET1_TDATA01    0x1b0b0
            MX6UL_PAD_ENET1_TX_CLK__ENET1_REF_CLK1    0x4001b031
        >;
    };

    pinctrl_enet2: enet2grp {
        fsl,pins = <
            MX6UL_PAD_GPIO1_IO07__ENET2_MDC        0x1b0b0
            MX6UL_PAD_GPIO1_IO06__ENET2_MDIO    0x1b0b0
            MX6UL_PAD_ENET2_RX_EN__ENET2_RX_EN    0x1b0b0
            MX6UL_PAD_ENET2_RX_ER__ENET2_RX_ER    0x1b0b0
            MX6UL_PAD_ENET2_RX_DATA0__ENET2_RDATA00    0x1b0b0
            MX6UL_PAD_ENET2_RX_DATA1__ENET2_RDATA01    0x1b0b0
            MX6UL_PAD_ENET2_TX_EN__ENET2_TX_EN    0x1b0b0
            MX6UL_PAD_ENET2_TX_DATA0__ENET2_TDATA00    0x1b0b0
            MX6UL_PAD_ENET2_TX_DATA1__ENET2_TDATA01    0x1b0b0
            MX6UL_PAD_ENET2_TX_CLK__ENET2_REF_CLK2    0x4001b031
            /* used for pht reset */
            MX6ULL_PAD_SNVS_TAMPER6__GPIO5_IO06 0x79
        >;
    };

    pinctrl_flexcan1: flexcan1grp{
        fsl,pins = <
            MX6UL_PAD_UART3_RTS_B__FLEXCAN1_RX    0x1b020
            MX6UL_PAD_UART3_CTS_B__FLEXCAN1_TX    0x1b020
        >;
    };

    pinctrl_flexcan2: flexcan2grp{
        fsl,pins = <
            MX6UL_PAD_UART2_RTS_B__FLEXCAN2_RX    0x1b020
            MX6UL_PAD_UART2_CTS_B__FLEXCAN2_TX    0x1b020
        >;
    };

    pinctrl_i2c1: i2c1grp {
        fsl,pins = <
            MX6UL_PAD_UART4_TX_DATA__I2C1_SCL 0x4001b8b0
            MX6UL_PAD_UART4_RX_DATA__I2C1_SDA 0x4001b8b0
        >;
    };

    pinctrl_i2c1_gpio: i2c1grp_gpio {
        fsl,pins = <
            MX6UL_PAD_UART4_TX_DATA__GPIO1_IO28 0x1b8b0
            MX6UL_PAD_UART4_RX_DATA__GPIO1_IO29 0x1b8b0
        >;
    };

    pinctrl_i2c2: i2c2grp {
        fsl,pins = <
            MX6UL_PAD_UART5_TX_DATA__I2C2_SCL 0x4001b8b0
            MX6UL_PAD_UART5_RX_DATA__I2C2_SDA 0x4001b8b0
        >;
    };

    pinctrl_lcdif_dat: lcdifdatgrp {
        fsl,pins = <
            MX6UL_PAD_LCD_DATA00__LCDIF_DATA00  0x79
            MX6UL_PAD_LCD_DATA01__LCDIF_DATA01  0x79
            MX6UL_PAD_LCD_DATA02__LCDIF_DATA02  0x79
            MX6UL_PAD_LCD_DATA03__LCDIF_DATA03  0x79
            MX6UL_PAD_LCD_DATA04__LCDIF_DATA04  0x79
            MX6UL_PAD_LCD_DATA05__LCDIF_DATA05  0x79
            MX6UL_PAD_LCD_DATA06__LCDIF_DATA06  0x79
            MX6UL_PAD_LCD_DATA07__LCDIF_DATA07  0x79
            MX6UL_PAD_LCD_DATA08__LCDIF_DATA08  0x79
            MX6UL_PAD_LCD_DATA09__LCDIF_DATA09  0x79
            MX6UL_PAD_LCD_DATA10__LCDIF_DATA10  0x79
            MX6UL_PAD_LCD_DATA11__LCDIF_DATA11  0x79
            MX6UL_PAD_LCD_DATA12__LCDIF_DATA12  0x79
            MX6UL_PAD_LCD_DATA13__LCDIF_DATA13  0x79
            MX6UL_PAD_LCD_DATA14__LCDIF_DATA14  0x79
            MX6UL_PAD_LCD_DATA15__LCDIF_DATA15  0x79
            MX6UL_PAD_LCD_DATA16__LCDIF_DATA16  0x79
            MX6UL_PAD_LCD_DATA17__LCDIF_DATA17  0x79
            MX6UL_PAD_LCD_DATA18__LCDIF_DATA18  0x79
            MX6UL_PAD_LCD_DATA19__LCDIF_DATA19  0x79
            MX6UL_PAD_LCD_DATA20__LCDIF_DATA20  0x79
            MX6UL_PAD_LCD_DATA21__LCDIF_DATA21  0x79
            MX6UL_PAD_LCD_DATA22__LCDIF_DATA22  0x79
            MX6UL_PAD_LCD_DATA23__LCDIF_DATA23  0x79
        >;
    };

    pinctrl_lcdif_ctrl: lcdifctrlgrp {
        fsl,pins = <
            MX6UL_PAD_LCD_CLK__LCDIF_CLK        0x79
            MX6UL_PAD_LCD_ENABLE__LCDIF_ENABLE  0x79
            MX6UL_PAD_LCD_HSYNC__LCDIF_HSYNC    0x79
            MX6UL_PAD_LCD_VSYNC__LCDIF_VSYNC    0x79
            /* used for lcd reset */
            MX6UL_PAD_LCD_RESET__GPIO3_IO04     0x1b0b0
        >;
    };

    pinctrl_qspi: qspigrp {
        fsl,pins = <
            MX6UL_PAD_NAND_WP_B__QSPI_A_SCLK    0x70a1
            MX6UL_PAD_NAND_READY_B__QSPI_A_DATA00    0x70a1
            MX6UL_PAD_NAND_CE0_B__QSPI_A_DATA01    0x70a1
            MX6UL_PAD_NAND_CE1_B__QSPI_A_DATA02    0x70a1
            MX6UL_PAD_NAND_CLE__QSPI_A_DATA03    0x70a1
            MX6UL_PAD_NAND_DQS__QSPI_A_SS0_B    0x70a1
        >;
    };

    pinctrl_sai2: sai2grp {
        fsl,pins = <
            MX6UL_PAD_JTAG_TDI__SAI2_TX_BCLK    0x17088
            MX6UL_PAD_JTAG_TDO__SAI2_TX_SYNC    0x17088
            MX6UL_PAD_JTAG_TRST_B__SAI2_TX_DATA    0x11088
            MX6UL_PAD_JTAG_TCK__SAI2_RX_DATA    0x11088
            MX6UL_PAD_JTAG_TMS__SAI2_MCLK        0x17088
            MX6UL_PAD_SNVS_TAMPER4__GPIO5_IO04    0x17059
        >;
    };

    pinctrl_pwm1: pwm1grp {
        fsl,pins = <
            MX6UL_PAD_GPIO1_IO08__PWM1_OUT   0x110b0
        >;
    };

    pinctrl_sim2: sim2grp {
        fsl,pins = <
            MX6UL_PAD_CSI_DATA03__SIM2_PORT1_PD        0xb808
            MX6UL_PAD_CSI_DATA04__SIM2_PORT1_CLK        0x31
            MX6UL_PAD_CSI_DATA05__SIM2_PORT1_RST_B        0xb808
            MX6UL_PAD_CSI_DATA06__SIM2_PORT1_SVEN        0xb808
            MX6UL_PAD_CSI_DATA07__SIM2_PORT1_TRXD        0xb809
            MX6UL_PAD_CSI_DATA02__GPIO4_IO23        0x3008
        >;
    };

    pinctrl_spi4: spi4grp {
        fsl,pins = <
            MX6UL_PAD_BOOT_MODE0__GPIO5_IO10    0x70a1
            MX6UL_PAD_BOOT_MODE1__GPIO5_IO11    0x70a1
            MX6UL_PAD_SNVS_TAMPER7__GPIO5_IO07    0x70a1
            MX6UL_PAD_SNVS_TAMPER8__GPIO5_IO08    0x80000000
        >;
    };

    pinctrl_tsc: tscgrp {
        fsl,pins = <
            MX6UL_PAD_GPIO1_IO01__GPIO1_IO01        0xb0
            MX6UL_PAD_GPIO1_IO02__GPIO1_IO02        0xb0
            MX6UL_PAD_GPIO1_IO03__GPIO1_IO03        0xb0
            MX6UL_PAD_GPIO1_IO04__GPIO1_IO04        0xb0
        >;
    };

    pinctrl_uart1: uart1grp {
        fsl,pins = <
            MX6UL_PAD_UART1_TX_DATA__UART1_DCE_TX 0x1b0b1
            MX6UL_PAD_UART1_RX_DATA__UART1_DCE_RX 0x1b0b1
        >;
    };

    pinctrl_uart2: uart2grp {
        fsl,pins = <
            MX6UL_PAD_UART2_TX_DATA__UART2_DCE_TX    0x1b0b1
            MX6UL_PAD_UART2_RX_DATA__UART2_DCE_RX    0x1b0b1
            MX6UL_PAD_UART3_RX_DATA__UART2_DCE_RTS    0x1b0b1
            MX6UL_PAD_UART3_TX_DATA__UART2_DCE_CTS    0x1b0b1
        >;
    };

    pinctrl_usb_otg1: usbotg1grp {
        fsl,pins = <
            MX6UL_PAD_GPIO1_IO00__ANATOP_OTG1_ID    0x17059
        >;
    };

    pinctrl_usdhc1: usdhc1grp {
        fsl,pins = <
            MX6UL_PAD_SD1_CMD__USDHC1_CMD         0x17059
            MX6UL_PAD_SD1_CLK__USDHC1_CLK        0x10071
            MX6UL_PAD_SD1_DATA0__USDHC1_DATA0     0x17059
            MX6UL_PAD_SD1_DATA1__USDHC1_DATA1     0x17059
            MX6UL_PAD_SD1_DATA2__USDHC1_DATA2     0x17059
            MX6UL_PAD_SD1_DATA3__USDHC1_DATA3     0x17059
            MX6UL_PAD_UART1_RTS_B__GPIO1_IO19       0x17059 /* SD1 CD */
            MX6UL_PAD_GPIO1_IO05__USDHC1_VSELECT    0x17059 /* SD1 VSELECT */
            MX6UL_PAD_GPIO1_IO09__GPIO1_IO09        0x17059 /* SD1 RESET */
        >;
    };

    pinctrl_usdhc1_100mhz: usdhc1grp100mhz {
        fsl,pins = <
            MX6UL_PAD_SD1_CMD__USDHC1_CMD     0x170b9
            MX6UL_PAD_SD1_CLK__USDHC1_CLK     0x100b9
            MX6UL_PAD_SD1_DATA0__USDHC1_DATA0 0x170b9
            MX6UL_PAD_SD1_DATA1__USDHC1_DATA1 0x170b9
            MX6UL_PAD_SD1_DATA2__USDHC1_DATA2 0x170b9
            MX6UL_PAD_SD1_DATA3__USDHC1_DATA3 0x170b9

        >;
    };

    pinctrl_usdhc1_200mhz: usdhc1grp200mhz {
        fsl,pins = <
            MX6UL_PAD_SD1_CMD__USDHC1_CMD     0x170f9
            MX6UL_PAD_SD1_CLK__USDHC1_CLK     0x100f9
            MX6UL_PAD_SD1_DATA0__USDHC1_DATA0 0x170f9
            MX6UL_PAD_SD1_DATA1__USDHC1_DATA1 0x170f9
            MX6UL_PAD_SD1_DATA2__USDHC1_DATA2 0x170f9
            MX6UL_PAD_SD1_DATA3__USDHC1_DATA3 0x170f9
        >;
    };

    pinctrl_usdhc2: usdhc2grp {
        fsl,pins = <
            MX6UL_PAD_NAND_RE_B__USDHC2_CLK     0x17059
            MX6UL_PAD_NAND_WE_B__USDHC2_CMD     0x17059
            MX6UL_PAD_NAND_DATA00__USDHC2_DATA0 0x17059
            MX6UL_PAD_NAND_DATA01__USDHC2_DATA1 0x17059
            MX6UL_PAD_NAND_DATA02__USDHC2_DATA2 0x17059
            MX6UL_PAD_NAND_DATA03__USDHC2_DATA3 0x17059
        >;
    };

    pinctrl_usdhc2_8bit: usdhc2grp_8bit {
        fsl,pins = <
            MX6UL_PAD_NAND_RE_B__USDHC2_CLK     0x10069
            MX6UL_PAD_NAND_WE_B__USDHC2_CMD     0x17059
            MX6UL_PAD_NAND_DATA00__USDHC2_DATA0 0x17059
            MX6UL_PAD_NAND_DATA01__USDHC2_DATA1 0x17059
            MX6UL_PAD_NAND_DATA02__USDHC2_DATA2 0x17059
            MX6UL_PAD_NAND_DATA03__USDHC2_DATA3 0x17059
            MX6UL_PAD_NAND_DATA04__USDHC2_DATA4 0x17059
            MX6UL_PAD_NAND_DATA05__USDHC2_DATA5 0x17059
            MX6UL_PAD_NAND_DATA06__USDHC2_DATA6 0x17059
            MX6UL_PAD_NAND_DATA07__USDHC2_DATA7 0x17059
        >;
    };

    pinctrl_usdhc2_8bit_100mhz: usdhc2grp_8bit_100mhz {
        fsl,pins = <
            MX6UL_PAD_NAND_RE_B__USDHC2_CLK     0x100b9
            MX6UL_PAD_NAND_WE_B__USDHC2_CMD     0x170b9
            MX6UL_PAD_NAND_DATA00__USDHC2_DATA0 0x170b9
            MX6UL_PAD_NAND_DATA01__USDHC2_DATA1 0x170b9
            MX6UL_PAD_NAND_DATA02__USDHC2_DATA2 0x170b9
            MX6UL_PAD_NAND_DATA03__USDHC2_DATA3 0x170b9
            MX6UL_PAD_NAND_DATA04__USDHC2_DATA4 0x170b9
            MX6UL_PAD_NAND_DATA05__USDHC2_DATA5 0x170b9
            MX6UL_PAD_NAND_DATA06__USDHC2_DATA6 0x170b9
            MX6UL_PAD_NAND_DATA07__USDHC2_DATA7 0x170b9
        >;
    };

    pinctrl_usdhc2_8bit_200mhz: usdhc2grp_8bit_200mhz {
        fsl,pins = <
            MX6UL_PAD_NAND_RE_B__USDHC2_CLK     0x100f9
            MX6UL_PAD_NAND_WE_B__USDHC2_CMD     0x170f9
            MX6UL_PAD_NAND_DATA00__USDHC2_DATA0 0x170f9
            MX6UL_PAD_NAND_DATA01__USDHC2_DATA1 0x170f9
            MX6UL_PAD_NAND_DATA02__USDHC2_DATA2 0x170f9
            MX6UL_PAD_NAND_DATA03__USDHC2_DATA3 0x170f9
            MX6UL_PAD_NAND_DATA04__USDHC2_DATA4 0x170f9
            MX6UL_PAD_NAND_DATA05__USDHC2_DATA5 0x170f9
            MX6UL_PAD_NAND_DATA06__USDHC2_DATA6 0x170f9
            MX6UL_PAD_NAND_DATA07__USDHC2_DATA7 0x170f9
        >;
    };

    pinctrl_wdog: wdoggrp {
        fsl,pins = <
            MX6UL_PAD_LCD_RESET__WDOG1_WDOG_ANY    0x30b0
        >;
    };
};
  • 注意 backlight 为新增加节点,用于 lcd 背光控制
  • 注意 fec1 节点,修改为禁用
  • 注意 fec2 节点,增加复位支持,SMSC 支持
  • 注意lcdif 节点,修改复位支持,修改屏幕控制器时许
  • 注意 usdhc2 节点,来自于 imx6ull-14x14-evk-emmc.dts
  • 注意 pinctrl_enet2 节点,MX6ULL_PAD_SNVS_TAMPER6__GPIO5_IO06 0x79
  • 注意 pinctrl_lcdif_ctrl节点,MX6UL_PAD_LCD_RESET__GPIO3_IO04 0x1b0b0

修改 /home/tiansong/100ask_imx6ull_pro/uboot-imx/drivers/net/phy/phy.c

int genphy_config_aneg(struct phy_device *phydev)
{
        int result;

        phy_reset(phydev);  // 新增

        if (phydev->autoneg != AUTONEG_ENABLE)
                return genphy_setup_forced(phydev);

        result = genphy_config_advert(phydev);

        // ...
}

3、配置及编译

安装环境依赖

sudo apt install make
sudo apt install bison flex

生成 .config 文件

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ pwd
/home/tiansong/100ask_imx6ull_pro/uboot-imx

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ make 100ask_imx6ull_pro_emmc_defconfig

图形化配置

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ make menuconfig

确认板级支持, 目录项 ARM architecture

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

确认默认的设备树,目录项 Boot media --> Device Tree Control

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

使能 SD/EMMC 启动,目录项 Boot media

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

使能随机 MAC 地址生成,目录项 Networking support

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

网卡支持

  • 目录项 Device Drivers/Network device support

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot
【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

  • 目录项 Device Drivers/Ethernet PHY(physical media interface) support

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

编译

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ make -j12

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ ls u-boot-dtb.imx
u-boot-dtb.imx

4、烧写测试

使用 100ASK IMX6ULL Flashing Tool 烧写 (烧写方式可参考 《嵌入式Linux完全开发手册》 )

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

查看开发板调试串口输出

  • 启动日志

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

  • version 查看

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

  • dhcp 网卡测试

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

  • mmcinfo 测试

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

  • lcd 观察

【从零搭建 100ask_imx6ull_pro 开发板运行环境】1_ubuntu & 交叉工具链 & uboot

5、文件及代码管理

默认配置文件更新

# 根据当前配置生成默认配置文件
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ make savedefconfig
scripts/kconfig/conf  --savedefconfig=defconfig Kconfig

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ ls defconfig -l
-rw-rw-r-- 1 tiansong tiansong 1748  8月 26 21:34 defconfig

# 覆盖更新 100ask_imx6ull_pro_emmc_defconfig
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ cp defconfig ./configs/100ask_imx6ull_pro_emmc_defconfig

本地 git 仓库提交

tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ git status
HEAD detached at origin/imx_v2020.04_5.4.70_2.3.0
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   arch/arm/dts/Makefile
        modified:   arch/arm/mach-imx/mx6/Kconfig
        modified:   drivers/net/phy/phy.c

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        arch/arm/dts/100ask_imx6ull_pro_emmc.dts
        board/100ask/
        configs/100ask_imx6ull_pro_emmc_defconfig
        include/configs/100ask_imx6ull_pro_emmc.h

no changes added to commit (use "git add" and/or "git commit -a")
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ git add -A
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ git commit -m "适配 100ask_imx6ull_pro 开发板"
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ git log -1
commit 9f96361312aeeba348bf8b563a22479d6d2f6c23 (HEAD)
Author: TianSong <1508539502@qq.com>
Date:   Fri Aug 26 21:38:36 2022 +0800

    适配 100ask_imx6ull_pro 开发板

相关文章

暂无评论

暂无评论...