cnrv / fpga-rocket-chip

Wrapper for Rocket-Chip on FPGAs
Other
124 stars 26 forks source link

JTAG debug pull request #20

Closed thomascp closed 2 years ago

thomascp commented 2 years ago

Hi, This repo is briliant! Especially for me as a beginner. I worked on it, and added a JTAG debug codes. There are two ways to connect the JTAG, one is over PMOD, the other one is through BSCAN. Both works on my Nexys A7 board. Are you guys interested in this? If so, I plan to make a pull request for it. BR, Peng

thomascp commented 2 years ago

@wsong83 @NeutrinoLiu

NeutrinoLiu commented 2 years ago

thx for your passion of contributing to this project. Yet the project is out of maintenance for a while and honestly it has a bad file organization as well as a messy makefile. It might take some efforts to reorganize the project. Here I suggest you simply fork it and in the readme I could top a url linking to your repo. If this sounds good for you, plz provide me with a one line intro of what specific problem your fork has solved. If you still want to pull request to this repo. Make sure you append sufficient instructions in readme and make sure codes are backward compatible.

thomascp commented 2 years ago

Thanks for your quick reply! OK, I got your idea. I can fork it to my repo, and add the commits there. After it is done, I will let you know the URL, and it is mainly about some codes and introduction about how to add and use a JTAG component based on this project. Though this project is out of maintanace as you said, I still think it is a good project and especially for the beginners who wants to build a FPGA Soc like me.

wsong83 commented 2 years ago

Oops, OK, this repo is indeed old but in rare conditions I may still maintain it, the same as many of my other long out of sync repos. If I would accept a PR, I need to see some clear benefits why others may like it. I think Neutrino's idea is good. After you finishing the addition on your branch, let me know and I will definitely spear some time to have a look. Many thanks for the willingness to contribution.

thomascp commented 2 years ago

@NeutrinoLiu @wsong83 I committed some codes and documents here, https://github.com/thomascp/fpga-rocket-chip/tree/nexys-jtag Please have a look, any comments are welcome!

wsong83 commented 2 years ago

This look fantasic actually! I do not have a PMOD board at hand but I can definitly try the BSCAN one. Would you mind provide some demo test programs along with the commits? Can I use GDB to debug a bare-metal program, a program running on a Linux kernel, or both? Do I need to set any special command in GDB to make it work?

thomascp commented 2 years ago

We can use GDB to debug bare-metal or Linux kernel, just need target remote to connect to the openocd server.

$ riscv64-unknown-elf-gdb
GNU gdb (GDB) 10.1
Copyright (C) 2020 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=x86_64-pc-linux-gnu --target=riscv64-unknown-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
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".
(gdb) target remote 172.31.208.1:3333
Remote debugging using 172.31.208.1:3333
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0xffffffe00009b49c in ?? ()
(gdb) symbol-file /home/peng/job/rocket-chip/riscv-linux/vmlinux
Reading symbols from /home/peng/job/rocket-chip/riscv-linux/vmlinux...
(gdb) c
wsong83 commented 2 years ago

OK, I will spend some time try it myself and come back here. I could be slow due to limited spare time.

wsong83 commented 2 years ago

@thomascp Many thanks Peng!

With some further debug, I have successfully reproduce your simplest gdb session on my computer. Your JTAG support is now merged by #23