代码拉取完成,页面将自动刷新
同步操作将从 xt/runninglinuxkernel_5.0 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
LROOT=$PWD
JOBCOUNT=${JOBCOUNT=$(nproc)}
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
export INSTALL_PATH=$LROOT/rootfs_debian_arm64/boot/
export INSTALL_MOD_PATH=$LROOT/rootfs_debian_arm64/
export INSTALL_HDR_PATH=$LROOT/rootfs_debian_arm64/usr/
kernel_build=$PWD/rootfs_debian_arm64/usr/src/linux/
rootfs_path=$PWD/rootfs_debian_arm64
rootfs_image=$PWD/rootfs_debian_arm64.ext4
rootfs_size=4096
SMP="-smp 4"
if [ $# -lt 1 ]; then
echo "Usage: $0 [arg]"
echo "build_kernel: build the kernel image."
echo "build_rootfs: build the rootfs image, need root privilege"
echo "update_rootfs: update kernel modules for rootfs image, need root privilege."
echo "run: run debian system."
echo "run debug: enable gdb debug server."
fi
if [ $# -eq 2 ] && [ $2 == "debug" ]; then
echo "Enable qemu debug server"
DBG="-s -S"
SMP=""
fi
make_kernel_image(){
echo "start build kernel image..."
make debian_defconfig
make -j $JOBCOUNT
}
prepare_rootfs(){
if [ ! -d $rootfs_path ]; then
echo "decompressing rootfs..."
# split -d -b 80m rootfs_debian_arm64.tar.xz -- rootfs_debian_arm64.part
cat rootfs_debian_arm64.part0* > rootfs_debian_arm64.tar.xz
tar -Jxf rootfs_debian_arm64.tar.xz
fi
}
build_kernel_devel(){
kernver="$(make -s kernelrelease)"
echo "kernel version: $kernver"
mkdir -p $kernel_build
rm rootfs_debian_arm64/lib/modules/$kernver/build
cp -a include $kernel_build
cp Makefile .config Module.symvers System.map vmlinux $kernel_build
mkdir -p $kernel_build/arch/arm64/
mkdir -p $kernel_build/arch/arm64/kernel/
cp -a arch/arm64/include $kernel_build/arch/arm64/
cp -a arch/arm64/Makefile $kernel_build/arch/arm64/
cp arch/arm64/kernel/module.lds $kernel_build/arch/arm64/kernel/
ln -s /usr/src/linux rootfs_debian_arm64/lib/modules/$kernver/build
# ln to debian linux-5.0/scripts
ln -s /usr/src/linux-kbuild/scripts rootfs_debian_arm64/usr/src/linux/scripts
#ln -s /usr/src/linux-kbuild/tools rootfs_debian_arm64/usr/src/linux/tools
}
check_root(){
if [ "$(id -u)" != "0" ];then
echo "superuser privileges are required to run"
echo "sudo ./run_debian_arm64.sh build_rootfs"
exit 1
fi
}
update_rootfs(){
if [ ! -f $rootfs_image ]; then
echo "rootfs image is not present..., pls run build_rootfs"
else
echo "update rootfs ..."
mkdir -p $rootfs_path
echo "mount ext4 image into rootfs_debian_arm64"
mount -t ext4 $rootfs_image $rootfs_path -o loop
make install
make modules_install -j $JOBCOUNT
#make headers_install
build_kernel_devel
umount $rootfs_path
chmod 777 $rootfs_image
rm -rf $rootfs_path
fi
}
build_rootfs(){
if [ ! -f $rootfs_image ]; then
make install
make modules_install -j $JOBCOUNT
make headers_install
build_kernel_devel
echo "making image..."
dd if=/dev/zero of=$rootfs_image bs=1M count=$rootfs_size
mkfs.ext4 $rootfs_image
mkdir -p tmpfs
echo "copy data into rootfs..."
mount -t ext4 $rootfs_image tmpfs/ -o loop
cp -af $rootfs_path/* tmpfs/
umount tmpfs
chmod 777 $rootfs_image
rm -rf $rootfs_path
fi
}
run_qemu_debian(){
qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt,gic-version=3,its=on,iommu=smmuv3\
-nographic $SMP -kernel arch/arm64/boot/Image \
-append "noinintrd sched_debug root=/dev/vda rootfstype=ext4 rw crashkernel=256M loglevel=8" \
-drive if=none,file=$rootfs_image,id=hd0 \
-device virtio-blk-device,drive=hd0 \
--fsdev local,id=kmod_dev,path=./kmodules,security_model=none \
-device virtio-9p-pci,fsdev=kmod_dev,mount_tag=kmod_mount\
$DBG
}
case $1 in
build_kernel)
make_kernel_image
#prepare_rootfs
#build_rootfs
;;
build_rootfs)
#make_kernel_image
check_root
prepare_rootfs
build_rootfs
;;
update_rootfs)
update_rootfs
;;
run)
if [ ! -f $LROOT/arch/arm64/boot/Image ]; then
echo "canot find kernel image, pls run build_kernel command firstly!!"
exit 1
fi
if [ ! -f $rootfs_image ]; then
echo "canot find rootfs image, pls run build_rootfs command firstly!!"
exit 1
fi
#prepare_rootfs
#build_rootfs
run_qemu_debian
;;
esac
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。