SpinalHDL / openocd_riscv

Spen's Official OpenOCD Mirror
Other
48 stars 34 forks source link

Fix CSR access, and add "etherbone server address" argument #5

Closed xobs closed 5 years ago

xobs commented 5 years ago

This patch fixes two separate issues I've experienced:

Dolu1990 commented 5 years ago

Great, Thanks :)

Dolu1990 commented 5 years ago

@xobs I got some issue with a recent eclipse with this pull request code :

eclipse : https://github.com/gnu-mcu-eclipse/org.eclipse.epp.packages/releases

Error in final launch sequence
Failed to execute MI command:
-target-select remote localhost:3333
Error message from debugger back end:
bfd requires xlen 8, but target has xlen 4
Failed to execute MI command:
-target-select remote localhost:3333
Error message from debugger back end:
bfd requires xlen 8, but target has xlen 4
bfd requires xlen 8, but target has xlen 4

Does that tell you something ?

Dolu1990 commented 5 years ago

Note, if i use raw GDB command lines to run and debug software, that's fine.

xobs commented 5 years ago

That sounds like the host is expecting a 64-bit part, but openocd is feeding it 32-bit values.

Maybe we need to add an address_bits function to https://github.com/xobs/openocd_riscv/blob/368b9e0dab99b8379d626a922cbf7b23d7424d9c/src/target/vexriscv.c#L1791 similar to https://repo.or.cz/openocd.git/blob/HEAD:/src/target/riscv/riscv.c#l1958 that just returns 32?

Dolu1990 commented 5 years ago

hmm, address_bits do not existe in the openocd version used in the vexriscv branch, that's something quite recent :)

I reverted the feature/group changes (untill the fix is discovered)

xobs commented 5 years ago

Are you accessing ELF files, or something else? How can I replicate this issue? I think the gdb function that's causing issues is at https://github.com/riscv/riscv-binutils-gdb/blob/riscv-binutils-2.32/gdb/riscv-tdep.c#L2876 but I don't yet know how those structures are getting set.

Dolu1990 commented 5 years ago

I was using gnu-mcu-eclipse (i just docuemented how to use it there) :

With MuraxSim

And openocd as :

With that demo :

Builded with the SiFive GNU Embedded Toolchain :

Let's me know if one info is missing :)

I should try with a more recent RISC-V toolchain, probably the one i'm using is quite outdated, so maybe the issue is on my side.

xobs commented 5 years ago

address_bits probably isn't the answer. That seems to be more for deciding the address space size.

I'm trying to get eclipse working, but any time I try to build it just says:

04:10:30 **** Build of configuration Default for project murax ****
 all 
"all" terminated with exit code 127. Build might be incomplete.

04:10:31 Build Finished. 0 errors, 0 warnings. (took 1s.706ms)
xobs commented 5 years ago

I still don't have Eclipse working, but it does seem to be an issue when you attempt to connect to openocd before you've setup GDB:

xobs@Cuboid:~/Code/Fomu/foboot/sw$ riscv64-unknown-elf-gdb
GNU gdb (GDB) 8.2.90.20190228-git
Copyright (C) 2019 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-linux-gnu --target=riscv64-unknown-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://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 localhost:3333
Remote debugging using localhost:3333
bfd requires xlen 8, but target has xlen 4
(gdb) set arch riscv:rv32
The target architecture is assumed to be riscv:rv32
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0x00001a94 in ?? ()
(gdb)

That's something to look into, at least. Why is it different with the patch? Hmm...

xobs commented 5 years ago

Curiously, if I remove that patch and try the same thing, it works, but you can tell by the address that it's using the wrong ABI:

xobs@Cuboid:~/Code/Fomu/foboot/sw$ riscv64-unknown-elf-gdb
GNU gdb (GDB) 8.2.90.20190228-git
Copyright (C) 2019 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-linux-gnu --target=riscv64-unknown-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://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 localhost:3333
Remote debugging using localhost:3333
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0x00007fff00000000 in ?? ()
(gdb) 

@Dolu1990 What happens if you move the set arch riscv:rv32 to GDB Client Setup instead of Initialization Commands?

Dolu1990 commented 5 years ago

Ahhh nice catch :) I will try :D

Dolu1990 commented 5 years ago

That's it, moving

set arch riscv:rv32

From the startup initialisation commands to debugger gdb client setup fixed it :)

Thanks and sorry for the false positive !

Dolu1990 commented 5 years ago

I'm trying to get eclipse working, but any time I try to build it just says:

Which folder did you imported as a makefile project ?

xobs commented 5 years ago

I'm trying to get eclipse working, but any time I try to build it just says:

Which folder did you imported as a makefile project ?

I did "New -> Makefile Project with Existing Code", then pointed it to /mnt/d/Code/Fomu/VexRiscvSocSoftware/projects/murax/demo/ on my filesystem.

I can build it in the terminal by running make -f makefile, so I know my toolchain is set up properly.

Dolu1990 commented 5 years ago

Hmm normaly that should be fine, i will try, currently i was importing the repository root folder.

Dolu1990 commented 5 years ago

Got it, did you selected RISC-V Cross GCC when importing the project ? (instead of Cross GCC) ?

Because RISC-V Cross GCC give me the same error than you ^^