Hi, everyone!
I use Spike ISA Simulator with Eclipse. I did not found information about this anywhere, so I want to tell how I use it. Might be it will useful for somebody.
To use Spike with Eclipse it's need to connect Spike with OpenOCD and GDB.
1. Create new RISC-V project in Eclipse and set path to the toolchain.
2. File -> Properties -> C/C++ Build -> Settings -> GNU RISCV Cross C++ Linker -> General -> Script files (-T) :
Set path to your ld-script.
3. File -> Properties -> C/C++ Build -> Settings -> GNU RISCV Cross C++ Linker -> General :
Turn on checkbox "-nostartfiles";
Turn off "Remove unused section (-Xlinker --cg-sections)".
4. File -> Properties -> C/C++ Build -> Settings -> GNU RISCV Cross C++ Linker -> Librares -> Library Search Path :
Set path to .../lib/rv64imafdc/lp64d (for example /home/riscv/opt/7.1.1-1-20170702-0625/riscv64-unknown-elf/lib/rv64imafdc/lp64d).
5. Build the project.
-f /path/to/spike.cfg
7. Run -> Debug Configurations -> Run -> Debug Configuration -> GDB OpenOCD Debugging -> Startup -> Runtime Options :
Turn on checkbox "Debug in RAM".
8. Initialization the stack pointer. Run -> Debug Configurations -> Run -> Debug Configuration -> GDB OpenOCD Debugging -> Startup -> Run/Restart Commands :
set $sp = 0x10002000
9. Start the Spike:
And it works! It is possible to go by C-code, stop at breakpoints and watch registerts and disassembly.
Conclusion
To use Spike with Eclipse it's important to:
- Build with -nostartfiles;
- Set the sp with GDB command "set $sp = 0x10002000";
- Select the entry point ENTRY(main).
It was tested on:
- spike-isa-sim (commit: 3a4e89322a8c8dac94185812a238f13789ab392f)
- GNU MCU Eclipse (from Liviu Ionescu): version v4.1.1-201707111115 and version 4.3.1-201801092051
- OpenOCD: 0.10.0-3-20170826-1813-dev
- Toolchain: 7.1.1-1-20170702-0625
- FreedomStudio (from SiFive)
TODO: It will be great to add to Eclipse buttom for start and restart Spike.