BSP
前提:用到的开发板100ask_imx6ull
1、下载BSP
- 100ask_imx6ull 开发板的 BSP 都保存在 Git 站点上,通过 repo 命令进行统一管理。
- 配置 repo,名字可以自定义
git config --global user.email "user@100ask.com"
book@100ask:~$ git config --global user.name "100ask"
可以用git config --list查看
- 下载 BSP
git clone https://e.coding.net/codebug8/repo.git
mkdir -p 100ask_imx6ull-sdk && cd 100ask_imx6ull-sdk
../repo/repo init -u https://gitee.com/weidongshan/manifests.git -b linux-sdk -m imx6ull/100ask_imx6ull_linux4.9.88_release.xml --no-repo-verify
../repo/repo sync -j4
压缩源码,可以传到window上打开,更方便看
tar cjf Linux-4.9.88.tar.bz2 Linux-4.9.88
2、配置IMX6ULL Pro 版交叉编译工具链
-设置环境变量(临时生效)
export ARCH=arm
export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
//export PATH=$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin
export PATH=$PATH:/home/johan/share/linux_bsp/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin
注意:编译链的路径用自己的
执行以下命令测试环境变量
echo $ARCH
echo $CROSS_COMPILE
执行以下命令测试工具链
arm-buildroot-linux-gnueabihf-gcc -v
-设置环境变量(永久生效)
vim ~/.bashrc
在行尾添加或修改,加上上面几行
执行下面命令来验证是否配置成功
source ~/.bashrc
arm-buildroot-linux-gnueabihf-gcc -v
3、编译内核
进入Linux-4.9.88目录
make mrproper
make 100ask_imx6ull_defconfig
make zImage -j4
make dtbs
在 arch/arm/boot 目录下生成 zImage 内核文件, 在arch/arm/boot/dts 目录下生成设备树的二进制文件 100ask_imx6ull-14x14.dtb,把这 2 个文件复制到~/nfs_rootfs 目录下备用(nfs_rootfs 是开发板挂载的目录)
- 编译内核模块
make modules
把模块安装在 nfs 目录“~/nfs_rootfs/”下
安装好驱动后,用tree命令(没有tree就使用sudo apt install tree安装)查看~/nfs_rootfs/目录结构
4、安装内核和模块到开发板上(100ask_imx6ull)
假设:在 Ubuntu 的~/nfs_rootfs 目录下,已经有了 zImage、dtb 文件,并且有 lib/modules 子目录(里面含有各种模块)
- 挂载
mount -t nfs -o nolock,vers=3 192.168.0.11:/home/zhangjinyou/nfs_rootfs /mnt
//192.168.0.11 是被挂载目录的服务器ip(我这里用的是ubuntu)
接着执行下面的命令
cp /mnt/zImage /boot
cp /mnt/100ask_imx6ull-14x14.dtb /boot
cp /mnt/lib/modules /lib -rfd
sync
最后重启开发板,它就使用新的 zImage、dtb、模块了
5、出现的问题
5.1 /bin/sh: 1: lzop: not found
安装lzoop
sudo apt-get install lzop
再次编译,ok
6、编译脚本
#!/bin/sh
echo $1
case $1 in
mrproper | 100ask_imx6ull_defconfig | "zImage -j4" | clean | distclean | menuconfig | dtbs | modules)
#构建Linux内核
make $1
esac