最近在基于韦东山老师的imx6ul开发板学习嵌入式linux内容,在此记录一下自己的操作步骤,更多详细内容请访问百问网QEMU。
在不方便使用开发板直接调试的时候,可以使用韦东山老师提供的QEMU虚拟开发板硬件进行简单调试,非常便捷。
可以直接下载百问网提供的虚拟机镜像:
6dl2
虚拟机登陆密码:
123456
安装KVM可以加速qemu的运行,在ubuntu终端执行以下指令:
sudo apt-get update
sudo apt-get install qemu qemu-kvm libvirt-bin bridge-utils virt-manager
git clone https://e.coding.net/weidongshan/ubuntu-18.04_imx6ul_qemu_system.git
命令执行完成后,会得到ubuntu-18.04_imx6ul_qemu_system
目录,其结构如下:
进入ubuntu-18.04_imx6ul_qemu_system
目录,执行以下操作。
如果是第一次运行QEMU系统,那么需要安装SDL环境,命令如下:
./install_sdl.sh
安装过程中可能会遇到如下错误提示信息:
dpkg: dependency problems prevent configuration of libxcb-xfixes0-dev:amd64:
libxcb-xfixes0-dev:amd64 depends on libxcb-shape0-dev; however:
Package libxcb-shape0-dev is not installed.
dpkg: error processing package libxcb-xfixes0-dev:amd64 (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libxcb-present-dev:amd64:
libxcb-present-dev:amd64 depends on libxcb-xfixes0-dev; however:
Package libxcb-xfixes0-dev:amd64 is not configured yet.
dpkg: error processing package libxcb-present-dev:amd64 (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libegl1-mesa-dev:amd64:
libegl1-mesa-dev:amd64 depends on libxcb-present-dev; however:
Package libxcb-present-dev:amd64 is not configured yet.
dpkg: error processing package libegl1-mesa-dev:amd64 (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libgl1-mesa-dev:amd64:
libgl1-mesa-dev:amd64 depends on libxcb-present-dev; however:
Package libxcb-present-dev:amd64 is not configured yet.
dpkg: error processing package libgl1-mesa-dev:amd64 (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libgles2-mesa-dev:amd64:
libgles2-mesa-dev:amd64 depends on libegl1-mesa-dev; however:
Package libegl1-mesa-dev:amd64 is not configured yet.
dpkg: error processing package libgles2-mesa-dev:amd64 (--install):
dependency problems - leaving unconfigured
Setting up libglib2.0-dev-bin (2.56.4-0ubuntu0.18.04.4) ...
dpkg: dependency problems prevent configuration of libglu1-mesa-dev:amd64:
libglu1-mesa-dev:amd64 depends on libgl1-mesa-dev | libgl-dev; however:
Package libgl1-mesa-dev:amd64 is not configured yet.
Package libgl-dev is not installed.
Package libgl1-mesa-dev:amd64 which provides libgl-dev is not configured yet.
dpkg: error processing package libglu1-mesa-dev:amd64 (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
libxcb-xfixes0-dev:amd64
libxcb-present-dev:amd64
libegl1-mesa-dev:amd64
libgl1-mesa-dev:amd64
libgles2-mesa-dev:amd64
libglu1-mesa-dev:amd64
libsdl2-dev:amd64
可以通过如下指令进行修复:
sudo apt --fix-broken install
./qemu-imx6ull-gui.sh //启动后,登录名是root,不需要密码。
./qemu-imx6ull-nogui.sh //启动后,登录名是root,不需要密码。
git clone https://e.coding.net/codebug8/repo.git
mkdir -p 100ask_imx6ull-qemu && cd 100ask_imx6ull-qemu
../repo/repo init -u https://e.coding.net/weidongshan/manifests.git -b linux-sdk -m imx6ull/100ask-imx6ull_qemu_release_v1.0.xml --no-repo-verify
../repo/repo sync -j4
上述命令执行完成后,会得到100ask_imx6ull-qemu
和repo
两个目录,100ask_imx6ull-qemu
包含了linux-4.9.88
(linux内核源码目录)和ToolChain
(交叉编译工具链目录)。
由于我的ubuntu虚拟机需要用来编译不同的开发板,所以采用如下方式配置编译环境。该方式只对当前终端有效,不会影响其他终端中的开发板源码编译。
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export PATH=$PATH:/home/book/100ask/100ask_imx6ull-qemu/ToolChain/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin
PATH变量的配置需要根据你的ToolChain
所在目录进行修改。
编译过程需要lzop工具,因此需要先执行
sudo apt-get install lzop
进行安装,以免编译失败。
cd linux-4.9.88 //进入内核源码目录
make mrproper //完全清除以前的配置
make 100ask_imx6ull_qemu_defconfig //基于开发板信息配置linux内核编译选项
make zImage -jN //编译zImage内核镜像,其中N参数可以根据CPU个数,来加速编译系统。
make dtbs //编译设备树文件
编译完成后,会得到如下文件:
linux-4.9.88/arch/arm/boot/zImage //内核文件
linux-4.9.88/arch/arm/boot/dts/100ask_imx6ull_qemu.dtb //设备树文件
将编译生成的zImage
和100ask_imx6ull_qemu.dtb
替换ubuntu-18.04_imx6ul_qemu_system/imx6ull-system-image/
目录下的zImage
和100ask_imx6ull_qemu.dtb
文件后,执行4.2章节
的qemu-imx6ull-gui.sh
命令即可在QEMU环境下启动新编译的内核和设备树。