通过buildroot+qemu搭建ARM-Linux虚拟开发环境

 

1. 配置工作环境

sudo apt-get install build-essential pkg-config zlib1g-dev libglib2.0-0 libglib2.0-dev  libsdl1.2-dev libpixman-1-dev libfdt-dev autoconf automake libtool librbd-dev libaio-dev flex bison -y

安装qemu工具: 


wget https://download.qemu.org/qemu-4.2.0.tar.xz
tar xJvf qemu-4.2.0.tar.xz

cd qemu-4.2.0 

./configure --prefix=/usr/local/qemu --target-list=arm-softmmu --audio-drv-list=

sudo make -j 8 && sudo make install

sudo ln -s /usr/local/qemu/bin/* /usr/local/bin/

# --target-list:选择目标机器的架构。默认是将所有的架构都编译,但为了更快的完成编译,指定需要的架构即可。
# 或者执行./configure --prefix=/usr/local/qemu --audio-drv-list=

# 测试
qemu-img -V

 

安装gdb-multiarch

sudo apt-get install gdb-multiarch

 

2. 下载buildroot

到buildroot.org官网下载相应的压缩包:buildroot-2017.05.2.tar.gz

然后解压tar -zxvf buildroot-2017.05.2.tar.gz。

或者通过gi他下载指定branch。

git clone https://github.com/arnoldlu/buildroot.git -b arnoldlu_2017_05_2

 

然后新建分支,上传git push origin your_branch。

 

3. 配置编译buildroot

 

#选择虚拟qemu配置
make qemu_arm_vexpress_defconfig

#下载并且编译包
make

 

结果在output/images下生成zImage、vexpress-v2p-ca9.dtb、rootfs.ext2三个文件,分别是内核、DeviceTree文件和文件系统。

 

cd /output/images

sudo qemu-system-arm -M vexpress-a9 -smp 4 -m 1024M -kernel zImage -append "root=/dev/mmcblk0 console=ttyAMA0 loglevel=8" -dtb vexpress-v2p-ca9.dtb -sd rootfs.ext2 -nographic #带tap网络 桥接 sudo qemu-system-arm -M vexpress-a9 -smp 4 -m 1024M -kernel zImage -append "root=/dev/mmcblk0 console=ttyAMA0 loglevel=8" -dtb vexpress-v2p-ca9.dtb -sd rootfs.ext2 -nographic -nic tap

 

 

按Ctrl + a 后按 x  退出 QEMU

然后就进入console,输入root 登陆

 

 

配置网络  (/etc/resolv.conf 、/etc/hosts)

ifconfig eth0 10.10.12.187 netmask 255.255.255.0 broadcast 10.10.12.255
route
route add default gw 10.10.12.254

#查看DNS配置文件
cat /etc/resolv.conf

echo 'nameserver 8.8.8.8' >> /etc/resolv.conf

 

https://www.cnblogs.com/arnoldlu/p/9689585.html

https://blog.csdn.net/qq_24188351/article/details/77921653

 

posted @ 2020-03-28 12:11  sinferwu  阅读(857)  评论(0编辑  收藏  举报