1 Star 0 Fork 0

unicornx/ilovelinux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
run.sh 1.98 KB
一键复制 编辑 原始数据 按行查看 历史
unicornx 提交于 2024-08-28 16:20 . use buildroot
#!/bin/bash
source ./envsetup
usage() {
echo "Usage:"
echo " ./run.sh -h | [-t <type>] [-d] [-g]"
echo " -h: display usage"
echo " -t <type>: noinitrd | initrd (default)"
echo " -d: load hard disk image, only effective when type is initramfs"
echo " -g: launch gdb"
}
A_TYPE=initrd
while getopts ":t:dhg" opt
do
case $opt in
h)
O_HELP=y
;;
t)
A_TYPE=$OPTARG
;;
d)
O_DISK=y
;;
g)
O_GDB=y
;;
?)
echo "there is unrecognized parameter."
usage
exit 1
;;
esac
done
if [ $O_HELP -a $O_HELP = y ]; then
usage
exit 0;
fi
PARAMS_QEMU="-M virt -m 256M -nographic \
-kernel $PATH_KERNEL_IMAGE"
if [ $A_TYPE = initrd ]; then
PARAMS_QEMU+=" -initrd $PATH_INITRAMFS_IMAGE \
-append \"nokaslr console=ttyS0\""
elif [ $A_TYPE = noinitrd ]; then
PARAMS_QEMU+=" -drive file=$PATH_ROOTFS_IMAGE,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-append \"nokaslr root=/dev/vda rw console=ttyS0\""
else
echo "\"-t $A_TYPE\" is not supported"
usage
exit 1;
fi
if [ $O_DISK -a $O_DISK = y ]; then
if [ ! $A_TYPE = initrd ]; then
echo "-d only valid when type is initramfs"
usage
exit 1;
fi
PARAMS_QEMU+=" -drive file=$PATH_DISK_IMAGE,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0"
fi
PARAMS_QEMU+=" -netdev user,id=net0 -device virtio-net-device,netdev=net0"
if [ $O_GDB -a $O_GDB = y ]; then
PARAMS_QEMU+=" -s -S &"
fi
#set -v
COMMAND="${QEMU} ${PARAMS_QEMU}"
eval $COMMAND
if [ $O_GDB -a $O_GDB = y ]; then
COMMAND="$GDB $PATH_VMLINUX -q -x $PATH_GDBINIT"
eval $COMMAND
fi
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/unicornx/ilovelinux.git
[email protected]:unicornx/ilovelinux.git
unicornx
ilovelinux
ilovelinux
master

搜索帮助