Issue
I am trying to attach GDB to QEMU for my bare-metal project on RISC-V. However, it is unable to connect. My host is a Ubuntu by WSL on a Windows machine. I am using the firmware supplied by openSBI to launch my custom "bootloader" (boot.bin).
I run QEMU (in Ubuntu WSL):
qemu-system-riscv64.exe --machine virt -m 256 -bios ./opensbi/build/platform/generic/firmware/fw_jump.bin -kernel ./boot.bin --nographic -s -S
Then I open a new command line (new Ubuntu WSL window) and start GDB:
riscv-gnu/bin/riscv64-unknown-elf-gdb
and specify a target:
target remote localhost:1234
After a few seconds this gives me the error: localhost:1234: Connection timed out.
Has anyone else had this issue, would be greatful for your help!
Solution
Usually WSL has an IP address in a different network so if you want to make a connection between WSL and Windows you need to provide correct IP and not just localhost.
Check ipconfig under Windows and in gdb provide IP of the correct network.
In my case Windows has a local address of 192.168.1.24 and WSL has 172.190.0.1. So to connect gdb from WSL to qemu running on Windows I need to type target remote 192.168.1.24.
Answered By - Paweł Łukasik

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.