进行中 - 从零搭建 100ask_imx6ull_pro 开发板运行环境

区别在于:本文描述从各个网站(官网)下载最新 ubuntu、交叉编译器、uboot、kernel、buildroot 从零开始构建,更接近实际工程环境
(可同时交叉参阅两份文章)

一、关于 ubuntu

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

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

二、关于交叉工具链

1、下载

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

进行中 - 从零搭建 100ask_imx6ull_pro 开发板运行环境_第1张图片

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 

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 
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 
    Reviewed-by: Ye Li 

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$ cp mx6ullevk.c 100ask_imx6ull_pro_emmc.c 
修改 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 
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

3、增加图像化支持

修改 /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"

4、配置及编译

安装环境依赖

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

image.png

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

image.png

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

进行中 - 从零搭建 100ask_imx6ull_pro 开发板运行环境_第2张图片

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

进行中 - 从零搭建 100ask_imx6ull_pro 开发板运行环境_第3张图片

网卡支持
  • 目录项 Device Drivers/Network device support

image.png
image.png

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

进行中 - 从零搭建 100ask_imx6ull_pro 开发板运行环境_第4张图片

编译

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

初次烧写测试

网卡移植

屏幕移植

提交修改到本地仓库

你可能感兴趣的:(linux)