- The article assumes that the reader has a certain level of understanding of the basics of linux
- Supplementary information "Embedded Linux Complete Development Manual" - IMX6ull development board from scratch
本文描述从各个网站(官网)下载最新 ubuntu、交叉编译器、uboot、kernel、buildroot 从零开始构建,更接近实际工程环境
(可同时交叉参阅两份文章)
1. About ubuntu
- Download and install the latest desktop LTS version ubuntu
- Normal steps to install (refer to other articles on the network)
a few key settings
- Disk size: 60GB or more
- Network connection: use bridged network (copy network connection status) [router connects development board and computer]
2. About the cross tool chain
1. Download
ARM Developer Center Download Cross Compilation Toolchain
host 为 linux 👉 `x86_64 linux`
imx6ul 为 arm_A7 架构 👉 `AArch32`
imx6ul 支持硬件浮点 👉 `hard fllat`
需支持 linux 操作系统 👉 `none-linux`
2. Configuration
unzip
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
Set environment variables
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
Verify that the configuration is successful
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)
3. About uboot
1. Download
# 下载
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. Development board file adaptation
Prerequisites: There are many connections, and the transplantation should be completed in one breath as much as possible.
default configuration file
Copy the default configuration file provided by the public board
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
Modify the copied configuration file (three places)
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"
Board level support
head File
Copy the .h
file provided by the public board
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
Modify the copied .h
file (two places)
#ifndef __MX6ULLEVK_CONFIG_H
#define __MX6ULLEVK_CONFIG_H
👉
#ifndef __100ASK_IMX6ULL_PRO_EMMC_CONFIG_H
#define __100ASK_IMX6ULL_PRO_EMMC_CONFIG_H
folder
Copy the folder provided by the public board
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/
Rename mx6ullevk.c
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/board/freescale/mx6ullevk$ mv mx6ullevk.c 100ask_imx6ull_pro_emmc.c
Modified 100ask_imx6ull_pro_emmc.c
int checkboard(void)
{
else
puts("Board: MX6ULL 14x14 EVK\n");
👉
puts("Board: 100ASK_IMX6ULL_PRO_EMMC\n");
return 0;
}
Modified Makefile
obj-y := 100ask_imx6ull_pro_emmc.o
Modified 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
Modify MAINTAINERS
[Note that the path is filled in correctly]
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
Modified imximage.cfg
PLUGIN board/freescale/mx6ullevk/plugin.bin 0x00907000
👉
PLUGIN board/100ask/100ask_imx6ull_pro_emmc/plugin.bin 0x00907000
Modified imximage_lpddr2.cfg
PLUGIN board/freescale/mx6ullevk/plugin.bin 0x00907000
👉
PLUGIN board/100ask/100ask_imx6ull_pro_emmc/plugin.bin 0x00907000
Add image support
Modification /home/tiansong/100ask_imx6ull_pro/uboot-imx/arch/arm/mach-imx/mx6/Kconfig
[Note the path]
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"
default device tree
Copy the device tree file corresponding to the public version
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$ cp imx6ull-14x14-evk-emmc.dts 100ask_imx6ull_pro_emmc.dts
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/arch/arm/dts$ cp imx6ull-14x14-evk.dts 100ask_imx6ull_pro.dts
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/arch/arm/dts$ cp imx6ull-14x14-evk.dtsi 100ask_imx6ull_pro.dtsi
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx/arch/arm/dts$ cp imx6ull-u-boot.dtsi 100ask_imx6ull_pro_u_boot.dtsi
Modified 100ask_imx6ull_pro_emmc.dts
#include "imx6ull-14x14-evk.dts"
👉
#include "100ask_imx6ull_pro.dts"
Modified 100ask_imx6ull_pro.dts
#include "imx6ull.dtsi"
#include "imx6ul-14x14-evk.dtsi"
#include "imx6ul-14x14-evk-u-boot.dtsi"
model = "i.MX6 ULL 14x14 EVK Board";
👉
#include "imx6ull.dtsi"
#include "100ask_imx6ull_pro.dtsi"
#include "100ask_imx6ull_pro_u_boot.dtsi"
model = "100ASK IMX6ULL PRO Board";
Modified 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 0x79 // 增加复位引脚
>;
};
# 3.修改 lcd 节点
&lcdif {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lcdif_dat
&pinctrl_lcdif_ctrl>;
reset-gpios = <&gpio3 4 GPIO_ACTIVE_LOW>;
display = <&display0>;
status = "okay";
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 // 增加复位引脚
>;
};
Modified /home/tiansong/100ask_imx6ull_pro/uboot-imx/arch/arm/dts/Makefile
dtb-$(CONFIG_MX6ULL) += \
...
imx6ull-14x14-evk.dtb \
100ask_imx6ull_pro.dtb \ # 新增
imx6ull-14x14-evk-emmc.dtb \
100ask_imx6ull_pro_emmc.dtb \ # 新增
...
Modified /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. Configuration and compilation
installation environment dependencies
sudo apt install make
sudo apt install bison flex
Generate .config
file
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ pwd
/home/tiansong/100ask_imx6ull_pro/uboot-imx
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ make distclean
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ make 100ask_imx6ull_pro_emmc_defconfig
Graphical configuration
tiansong@tiansong:~/100ask_imx6ull_pro/uboot-imx$ make menuconfig
Confirm board level support, directory entry ARM architecture
Confirm the default device tree, directory entryBoot media
-->Device Tree Control
enableSD/EMMC
start, directory entryBoot media
Enable randomMAC
Address generation, directory entryNetworking support
NIC support
- Directory Item
Device Drivers/Network device support
- Directory Entry
Device Drivers/Ethernet PHY(physical media interface) support
compile
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, programming test
Use 100ASK IMX6ULL Flashing Tool
to write (for the programming method, please refer to "Embedded Linux Complete Development Manual")
View the debug serial port output of the development board
- startup log
-
version
View
-
dhcp
NIC test
-
mmcinfo
test
- lcd observation
5. File and code management
Default profile update
# 根据当前配置生成默认配置文件
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
local git repository commit
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 开发板
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。