【从零搭建 100ask_imx6ull_pro 开发板运行环境】2_kernel & buildroot

一、关于 kernel

1、下载

tiansong@tiansong:~$ pwd
/home/tiansong

# 下载
tiansong@tiansong:~/100ask_imx6ull_pro$ git clone http://source.codeaurora.cn/external/imx/linux-imx

# 切换分支
tiansong@tiansong:~/100ask_imx6ull_pro$ cd linux-imx/
## 查看所有分支
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ git branch -a
## 切换到 imx 最新分支
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ git checkout remotes/origin/imx_5.4.70_2.3.0
## 确认是否切换成功
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ git log -1

2、 开发板文件适配

默认的配置文件

复制公版提供的默认配置文件
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx/arch/arm/configs$ pwd
/home/tiansong/100ask_imx6ull_pro/linux-imx/arch/arm/configs
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx/arch/arm/configs$ cp imx_v7_defconfig 100ask_imx6ull_pro_emmc_defconfig
复制公版提供设备树
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx/arch/arm/boot/dts$ pwd
/home/tiansong/100ask_imx6ull_pro/linux-imx/arch/arm/boot/dts

tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx/arch/arm/boot/dts$ cp imx6ull-14x14-evk-emmc.dts 100ask_imx6ull_pro_emmc.dts
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx/arch/arm/boot/dts$ cp imx6ull-14x14-evk.dts 100ask_imx6ull_pro.dts
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx/arch/arm/boot/dts$ cp imx6ul-14x14-evk.dtsi 100ask_imx6ull_pro.dtsi
修改 100ask_imx6ull_pro_emmc.dts
#include "imx6ull-14x14-evk.dts"

#include "100ask_imx6ull_pro.dts
修改 100ask_imx6ull_pro.dts
#include "imx6ull.dtsi"
#include "imx6ul-14x14-evk.dtsi"

model = "Freescale i.MX6 ULL 14x14 EVK Board";

#include "100ask_imx6ull_pro.dtsi"

model = "100ASK IMX6ULL PRO EMMC Board";
修改 100ask_imx6ull_pro.dtsi
# 1.修改 backlight_display 节点
backlight_display: backlight-display {
        compatible = "pwm-backlight";
        pwms = <&pwm1 0 1000>;  // 默认设备树中频率过高,背光控制芯片 滋滋滋 ~
        brightness-levels = <0 4 8 16 32 64 128 255>;
        default-brightness-level = <6>;
        status = "okay";
};

# 2.修改网口节点
&fec1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_enet1>;
        phy-mode = "rmii";
        phy-handle = <ðphy0>;
        status = "disabled";  // 修改
};

&fec2 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_enet2>;
        phy-mode = "rmii";
        phy-handle = <ðphy1>;
        phy-reset-gpios = <&gpio5 6 GPIO_ACTIVE_LOW>;  // 新增
        phy-reset-duration = <50>;                     // 新增
        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>;
                        smsc,led-mode = <1>;
                        clocks = <&clks IMX6UL_CLK_ENET2_REF>;
                        clock-names = "rmii-ref";
                };
        };
};

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 phy reset */
                MX6ULL_PAD_SNVS_TAMPER6__GPIO5_IO06     0x1b0b0  // 增加复位引脚
        >;
};

# 3.修改 lcd 节点
&lcdif {
        assigned-clocks = <&clks IMX6UL_CLK_LCDIF_PRE_SEL>;
        assigned-clock-parents = <&clks IMX6UL_CLK_PLL5_VIDEO_DIV>;
        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>;
                        };
                };
        };
};

 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  // 增加复位引脚
                >;
        };
修改 /home/tiansong/100ask_imx6ull_pro/linux-imx/arch/arm/boot/dts/Makefile
dtb-$(CONFIG_SOC_IMX6UL) += \
...
imx6ull-14x14-evk.dtb \
100ask_imx6ull_pro.dtb \         # 新增
imx6ull-14x14-evk-emmc.dtb \
100ask_imx6ull_pro_emmc.dtb \    # 新增
...

3、配置及编译

安装环境依赖

sudo apt-get install libssl-dev

生成 .config 文件

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

tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ make distclean

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

图形化配置

使能 SMSC PHY 支持, 目录项:Device Drivers --> Network device support --> PHY Device support and infrasttructure

image.png

编译

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

tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ ls arch/arm/boot/zImage -l
-rwxrwxr-x 1 tiansong tiansong 8998576  8月 30 19:16 arch/arm/boot/zImage

tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ ls arch/arm/boot/dts/100ask_imx6ull_pro_emmc.dtb -l
-rw-rw-r-- 1 tiansong tiansong 35808  8月 30 19:54 arch/arm/boot/dts/100ask_imx6ull_pro_emmc.dtb

4、安装 tftp 服务

目的:kernel 在 调试过程中,会不断的修改、编译,之后再将 zImagedtb 传输到开发板执行。为了方便这一过程,开发板的 uboot 使用 tftp 下载 ubuntu 中的 zImagedtb 启动。

安装 tftp 服务
sudo apt-get install tftp-hpa tftpd-hpa
创建 tftp 工作目录
mkdir -p /home/tiansong/tftpboot
sudo chmod 777 /home/tiansong/tftpboot/
添加配置信息
sudo vim /etc/default/tftpd-hpa

# 文件末尾添加
TFTP_DIRECTORY="/home/tiansong/tftpboot"
TFTP_OPTIONS="-l -c -s"
重启 tftp 服务
 sudo service tftpd-hpa restart

5、开发板 tftp 启动 & kernel 验证

uboot 命令行依次输入 【172.16.10.228 为 ubuntu 地址】
=> setenv fdt_file 100ask_imx6ull_pro_emmc.dtb
=> setenv serverip 172.16.10.228
=> run netboot
tftp 下载 zImage

【从零搭建 100ask_imx6ull_pro 开发板运行环境】2_kernel & buildroot_第1张图片

tftp 下载 dtb

【从零搭建 100ask_imx6ull_pro 开发板运行环境】2_kernel & buildroot_第2张图片

内核启动

image.png

网卡工作正常

image.png

lcd 观察 ()

【从零搭建 100ask_imx6ull_pro 开发板运行环境】2_kernel & buildroot_第3张图片

注意:下图提示未能正确挂载根文件系统(是正常现象,根文件系统在 buildroot 部分制作)

image.png

6、文件及代码管理

默认配置文件更新
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ make savedefconfig
scripts/kconfig/conf  --savedefconfig=defconfig Kconfig

tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ ls defconfig -l
-rw-rw-r-- 1 tiansong tiansong 13756  8月 30 20:42 defconfig

tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ cp defconfig ./arch/arm/configs/100ask_imx6ull_pro_emmc_defconfig
本地 git 仓库提交
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ git status
HEAD detached at origin/imx_5.4.70_2.3.0
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git restore ..." to discard changes in working directory)
        modified:   arch/arm/boot/dts/Makefile

Untracked files:
  (use "git add ..." to include in what will be committed)
        arch/arm/boot/dts/100ask_imx6ull_pro.dts
        arch/arm/boot/dts/100ask_imx6ull_pro.dtsi
        arch/arm/boot/dts/100ask_imx6ull_pro_emmc.dts
        arch/arm/configs/100ask_imx6ull_pro_emmc_defconfig
        defconfig

no changes added to commit (use "git add" and/or "git commit -a")
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ git add -A
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ git commit -m "适配 100ask_imx6ull_pro 开发板"
tiansong@tiansong:~/100ask_imx6ull_pro/linux-imx$ git log -1
commit 9ab576476820f1e5a8f4a79cbd16414f84692987 (HEAD)
Author: TianSong <[email protected]>
Date:   Tue Aug 30 20:45:12 2022 +0800

    适配 100ask_imx6ull_pro 开发板

二、关于 buildroot

你可能感兴趣的:(linuxbootloader)