一、关于 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
编译
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
在 调试过程中,会不断的修改、编译,之后再将 zImage
和 dtb
传输到开发板执行。为了方便这一过程,开发板的 uboot
使用 tftp
下载 ubuntu 中的 zImage
和 dtb
启动。
安装
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
tftp 下载
dtb
内核启动
网卡工作正常
lcd 观察 (🐧)
注意:下图提示未能正确挂载根文件系统(是正常现象,根文件系统在
buildroot
部分制作)
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 <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: arch/arm/boot/dts/Makefile
Untracked files:
(use "git add <file>..." 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 <1508539502@qq.com>
Date: Tue Aug 30 20:45:12 2022 +0800
适配 100ask_imx6ull_pro 开发板
二、关于 buildroot
1、下载
最新长期支持版 : https://buildroot.org/downloa...
tiansong@tiansong:~/100ask_imx6ull_pro$ tar -xvf buildroot-2022.02.4.tar.xz
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4$ ls
arch boot Config.in configs DEVELOPERS fs Makefile package support toolchain
board CHANGES Config.in.legacy COPYING docs linux Makefile.legacy README system utils
2、安装依赖
安装必要依赖
参考
buildroot
官方手册Chapter 2
: https://buildroot.org/downloa...
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4$ sudo apt install -y sed make binutils build-essential gcc g++ patch gzip bzip2 perl tar cpio \
unzip rsync file bc wget
安装可选依赖
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4$ sudo apt install -y wget python3 libncurses5 bzr cvs git mercurial rsync subversion
3、开发板文件适配
复制公版提供的默认配置文件
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4$ ls configs/*6ull* -l
-rw-rw-r-- 1 tiansong tiansong 974 7月 29 17:39 configs/freescale_imx6ullevk_defconfig
-rw-rw-r-- 1 tiansong tiansong 1013 7月 29 17:39 configs/imx6ullevk_defconfig
生成 .config 文件
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4$ cd configs/
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4$ cp imx6ullevk_defconfig 100ask_imx6ull_pro_emmc_defconfig
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4/configs$ cd ..
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4$ make 100ask_imx6ull_pro_emmc_defconfig
4、图形化配置工具链
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4$ make menuconfig
注意红框标记的内容
关于
Toolchain/Tool path
tiansong@tiansong:~/100ask_imx6ull_pro/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf$ whereis arm-none-linux-gnueabihf-gcc
arm-none-linux-gnueabihf-gcc: /home/tiansong/100ask_imx6ull_pro/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gcc
关于
Toolchain/prefix
关于
Toolchain/External toolchain gcc version
tiansong@tiansong:~/100ask_imx6ull_pro/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf$ 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)
关于
Toolchain/External toolchain kernel header series
暂时选定 4.20 如果不匹配,编译时会报错提示版本信息,再依据提示进行修改
5、编译根文件系统
确认
buildroot
中未选中Linux kernel
确认
buildroot
中未选中Bootloader/uboot
编译
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4$ pwd
/home/tiansong/100ask_imx6ull_pro/buildroot-2022.02.4
tiansong@tiansong:~/100ask_imx6ull_pro/buildroot-2022.02.4$ make
注意,在编译过程中
buildroot
会在网络下载依赖包,下载失败\慢时可中终止编译【CTRL+C】,使用 迅雷 下载上传到/home/tiansong/100ask_imx6ull_pro/buildroot-2022.02.4/dl
,之后再重新开始编译
编译结束,错误提示不能生成
zImage
是正常的,因为还未设置kernel
可以看到根文件系统已经生成
/home/tiansong/100ask_imx6ull_pro/buildroot-2022.02.4/output/target
6、 安装 nfs 服务
目的在于开发板使用 nfs 挂载网络文件系统,检查
kernel
是否还存在问题
sudo apt-get install nfs-kernel-server
添加配置信息
sudo vim /etc/exports
# 文件末尾添加
/home/tiansong *(rw,nohide,insecure,no_subtree_check,async,no_root_squash)
重启
nfs
服务
sudo /etc/init.d/nfs-kernel-server restart
7、开发板 nfs 挂载根文件系统
uboot
命令行依次输入
=> setenv nfsroot /home/tiansong/100ask_imx6ull_pro/buildroot-2022.02.4/output/target
=> setenv fdt_file 100ask_imx6ull_pro_emmc.dtb
=> setenv serverip 172.16.10.228
=> run netboot
查看串口终端输出, 网络文件系统正常挂载
8、移植触摸驱动
转载请注明:【从零搭建 100ask_imx6ull_pro 开发板运行环境】2_kernel & buildroot | 胖虎的工具箱-编程导航