编译qemu
官方版本暂时只支持ls2e,ls2f,ls3a 这里使用龙芯维护的版本。此时调试的目标是Loongson 2K。
先安装编译qemu 需要的依赖包
apt install pkg-config
apt install zlib1g-dev
apt install libglib2.0-dev
apt install libpixman-1-dev
$ git clone https://gitee.com/loongsonlab/qemu.git
$ cd qemu
$ mkdir build
$ cd build
$ ../configure --target-list=mipsel-softmmu,mips64el-softmmu --disable-werror --prefix=./_install
$ make && make install
#注意qemu-system-mipsel和qemu-system-mips64el分别安装到了mipsel-softmmu和mips64el-softmmu目录下。
$ cp mipsel-softmmu/_install/bin/* _install/bin
$ cp mips64el-softmmu/_install/bin/* _install/bin
直接运行
注意:运行时只能使用elf
文件
$ ./qemu-system-mips64el -M ls2k -kernel ./rtthread.elf -serial stdio
memory_offset = 0x78;cpu_offset = 0xc88; system_offset = 0xce8; irq_offset = 0x3068; interface_offset = 0x30c8;
param len=35328
ram=0x55a70a94f0f0
oobsize = 64
Current SR: 0x10008c80
\ | /
- RT - Thread Operating System
/ | \ 4.0.3 build Aug 19 2020
2006 - 2020 Copyright by rt-thread team
Hi, this is RT-Thread!!
msh />
调试模式运行
qemu
自带有gdb server
,在终端通过qemu
运行rthread.elf
$ cd qemu/build/install/bin
$ ./qemu-system-mips64el -M ls2k -kernel ./rtthread.elf -serial stdio -gdb tcp::1234 -S
在另一个终端运行mips-elf-gdb
进行远程调试
$ cd rt-thread/bsp/ls2kdev
$ /opt/mips-2015.05/bin/mips-sde-elf-gdb ./rtthread.elf GNU gdb (Sourcery CodeBench Lite 2015.05-19) 7.7.50.20140217-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=mips-sde-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://sourcery.mentor.com/GNUToolchain/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./rtthread.elf...done.
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0xffffffffbfc00000 in ?? ()
(gdb) symbol-file ./rtthread.elf
Load new symbol table from "./rtthread.elf"? (y or n) y
Reading symbols from ./rtthread.elf...done.
(gdb) b rtthread_startup
Breakpoint 1 at 0xffffffff8020f590: file /home/vm/disk/git_code/rt-thread/src/components.c, line 218.
(gdb) c
Continuing.
Breakpoint 1, rtthread_startup () at /home/vm/disk/git_code/rt-thread/src/components.c:218
218 rt_hw_interrupt_disable();
(gdb) n
223 rt_hw_board_init();
(gdb)
参考链接:
https://blog.csdn.net/caogos/article/details/78051111