夜雨聆风学习资料网

ARTICLE · 1526090

使用qemu调试arm内核

使用qemu调试arm内核

参考书籍《奔跑吧Linux内核》–笨叔 下载Linux-5.0源码

https://benshushu.coding.net/public/runninglinuxkernel_5.0/runninglinuxkernel_5.0/git/files

或者直接git源码

git clone https://e.coding.net/benshushu/runninglinuxkernel_5.0/runninglinuxkernel_5.0.git

安装必要的包

sudo apt-get install qemu libncurses5-dev gcc-aarch64-linux-gnu build-essential bison flex libssl-dev qemu-system-arm

切换到rlk_5.0分支

git checkout rlk_5.0

编译内核

~/kernel/runninglinuxkernel_5.0 sudo ./run_debian_arm64.sh build_rootfs

使用qemu运行Debian系统

/kernel/runninglinuxkernel_5.0 cp test.txt runninglinuxkernel_5.0/kmodules/benshushu:~# ls /mnt/README  arm64_virt.dts  rlk_lab  test.txtbenshushu:~# vi /mnt/test.txt退出qemuCtrl +a  x或者之间结束qemups -e | grep qemu kill -9 48977使用GDB调试安装支持不同处理器架构的gdb sudo apt install gdb-multiarch运行脚本启动qemu和GDB:~/kernel/runninglinuxkernel_5.0 gdb-multiarch --tui  vmlinux设置 aarch64架构(gdb)set architecture aarch64通过1234端口远程连接到qemu虚拟机。(gdb)target remote localhost:1234在内核的start_kernel 处设置断点(gdb)b start_kernel运行测试(gdb)c 将跳转到断点 start_kernelchu退出 GDB(gdb)q/quit方法二:图形化界面调试工具安装 Eclipse-CDT插件下载Eclipse-CDT插件https://projects.eclipse.org/projects/tools.cdtDownload Packageshttps://projects.eclipse.org/projects/iot.embed-cdt下载x86_64 Linux安装包DownloadLinux x86_64 | AArch64https://www.eclipse.org/downloads/download.php?file=/oomph/epp/2023-09/R/eclipse-inst-jre-linux64.tar.gz安装java运行环境。sudo apt-get install openjdk-13-jre安装hudahua@VirtualBox:~/workspace/tools ./eclipse-inst安装 Eclipse IDE for C/C++ Developer图形界面下载和调试较慢,后期不使用了。

回首页,搜索你想要的文档

在首页搜索框输入关键词,快速定位资料

文库首页搜索指引 立即搜索

相关学习资料