自动构建文件系统和内核的工具但是编译速度感人可能要两个小时以上,中途尽量不要断网,
断网会爆很多奇怪的问题。
下载
wget http://buildroot.uclibc.org/downloads/snapshots/buildroot-snapshot.tar.bz2
tar -jxvf buildroot-snapshot.tar.bz2
cd buildroot
配置
sudo apt-get install libncurses-dev patch
make clean
make list-defconfigs #挑选自己需要的架构
make qemu_mips32r2el_malta_defconfig #我需要编译mipsel的
make menuconfig#这里需要配置一下,需要下载两个工具,
#Target packages ---> Networking applications --->bridge-utils,openssh
make
启动
buildroot给的sh启动文件没有tap服务需要自己改一下
#!/bin/sh
BINARIES_DIR="${0%/*}/"
# shellcheck disable=SC2164
cd "${BINARIES_DIR}"
mode_serial=false
mode_sys_qemu=false
while [ "$1" ]; do
case "$1" in
--serial-only|serial-only) mode_serial=true; shift;;
--use-system-qemu) mode_sys_qemu=true; shift;;
--) shift; break;;
*) echo "unknown option: $1" >&2; exit 1;;
esac
done
if ${mode_serial}; then
EXTRA_ARGS='-nographic'
else
EXTRA_ARGS='-serial stdio'
fi
if ! ${mode_sys_qemu}; then
export PATH="/home/iot/Desktop/buboxy/buildroot/output/host/bin:${PATH}"
fi
exec sudo qemu-system-mipsel -M malta -kernel vmlinux -drive file=rootfs.ext2,format=raw -append "rootwait root=/dev/sda" -net nic,model=pcnet -net tap,ifname=tap0,script=no,downscript=no ${EXTRA_ARGS} "$@"
宿主机
sudo ip link add br0 type bridge
sudo ip addr add 192.168.1.1/24 dev br0
sudo ip link set br0 up
sudo ip tuntap add dev tap0 mode tap
sudo ip link set tap0 master br0
sudo ip link set tap0 up
qemu虚拟机
ifconfig eth0 192.168.1.2 netmask 255.255.255.0 up
route add default gw 192.168.1.1
记得要修改qemu的root密码,如果scp传输不了,就重启一下qemu。
坑
如果qemu内存太小就
Filesystem images --->
] ext2/3/4 root filesystem │ │
│ │ ext2/3/4 variant (ext2 (rev1)) ---> │ │
│ │(rootfs) filesystem label │ │
│ │(60M) exact size │ │
│ │(0) exact number of inodes (leave at 0 for auto calculation) │ │
│ │(256) inode size │ │
│ │(5) reserved blocks percentage │ │
│ │(-O ^64bit) additional mke2fs options │ │
│ │Compression method (no compression) ---> │ │
│ │[ ] f2fs root filesystem
修改exact size 的大小就行
scp无法传输
vi /etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication yes
sshd
#!/bin/sh
cleanup() {
# 清理 TAP 接口
sudo ip link set tap0 down
sudo ip tuntap del dev tap0 mode tap
}
trap cleanup EXIT
BINARIES_DIR="${0%/*}/"
cd "${BINARIES_DIR}"
mode_serial=false
mode_sys_qemu=false
while [ "$1" ]; do
case "$1" in
--serial-only|serial-only) mode_serial=true; shift;;
--use-system-qemu) mode_sys_qemu=true; shift;;
--) shift; break;;
*) echo "unknown option: $1" >&2; exit 1;;
esac
done
if ${mode_serial}; then
EXTRA_ARGS='-nographic'
else
EXTRA_ARGS='-serial stdio'
fi
if ! ${mode_sys_qemu}; then
export PATH="/home/giant/Desktop/IOT/buildroot-2024.02/output/host/bin:${PATH}"
fi
# 创建 TAP 接口
sudo ip tuntap add dev tap0 mode tap user $(whoami)
sudo ip link set tap0 up
sudo ip link set tap0 master br0
# 启动 QEMU
sudo qemu-system-arm -M versatilepb -kernel zImage -dtb versatile-pb.dtb -drive file=rootfs.ext2,if=scsi,format=raw -append "rootwait root=/dev/sda console=ttyAMA0,115200" -net nic,model=rtl8139 -net tap,ifname=tap0,script=no,downscript=no ${EXTRA_ARGS} "$@"
sudo brctl addbr br0
sudo ifconfig br0 192.168.1.1 netmask 255.255.255.0 up
sudo ip tuntap add dev tap0 mode tap
sudo ifconfig tap0 up
sudo brctl addif br0 tap0
标签:buildroot,tap0,ip,sudo,mode,serial,qemu
From: https://www.cnblogs.com/blonet/p/18322825