-
Notifications
You must be signed in to change notification settings - Fork 6
OpenOCD for sc_riscv32
You will need to install several packages to compile and run OpenOCD. Open a terminal window and type:
sudo apt-get install make libtool autoconf texinfo libusb-dev doxygen
Clone any available repository to working directory
git clone -b syntacore_riscv32i --recursive https://github.com/syntacore/openocd.gitSee http://elinux.org/Compiling_OpenOCD
./bootstrap./configure --enable-maintainer-mode --disable-werror --enable-ftdiFor other configuration options see
./configure --helpAlso check configuration of jimtcl, especially list of --with-ext="".
Most of extensions are disabled in commit 56d163c (jimtcl: update to 0.77, the current version, enable only specific modules).
Try to re-configure by default:
cd jimtcl && ./configure && cd ..touch src/openocd.c && time nice make -jCall of touch src/openocd.c updates openocd banner by git-based version and build timestamp:
$ src/openocd --version
Open On-Chip Debugger 0.10.0+dev-00920-g98813c7 (2017-08-22-18:02)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
If build is successful, you can install OpenOCD and headers
sudo make installTo deinstall library and headers
sudo make uninstallRun OpenOCD as TCP server with selected configuration files (even without install).
Use sudo if policy for your USB device is not configured.
For example ./tcl folder contains set of configuration files, using olimex-arm-usb-ocd interface for syntacore_riscv32i 2 TAPs target:
sudo src/openocd -f tcl/interface/ftdi/olimex-arm-usb-ocd.cfg -f tcl/target/syntacore_riscv32i_2tap.cfg |& tee ocd.logAfter initialization OpenOCD waiting for command from the network.
Run telnet application in other console:
telnet localhost 4444Print help to show list of commands.
For example:
# show targets (usually last configured target is current core)
targets
# set core #0 as current core (usually for multicore configuration all but #0 cores are in parking state)
targets sc_rv32i0.cpu
# halt core (debug mode state)
halt
# load some elf image to memory
load_image /home/tools32i/test/scr5-baremetal-example/build/scr-test.elf
# resume execution from elf start address
resume 0x200
# halt core (if you need to examine registers or memory)
halt
# shutdown openocd server
shutdownRun riscv32 gdb:
$ riscv32-unknown-elf-gdbGNU gdb (GDB) 7.11.50.20160212-git
Copyright (C) 2016 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=riscv32-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".
Connect gdb with openocd:
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
Note: openocd target should be in halt state before target remote command. gdb try to read general purpose register by G (gdb serial protocol) instruction during connection. openocd return the error "Target is not halted" if target is in running state.
openocd terminates telnet connection if gdb connection established.
Following gdb debug session can use both gdb and openocd commands.
Use monitor gdb command to send openocd command.
0xffff6af8 in ?? ()
(gdb) x/i $pc
0xffff6af8: andi a5,a5,1
(gdb) monitor shutdown
shutdown command invoked
(gdb) q
A debugging session is active.
Inferior 1 [Remote target] will be detached.
Quit anyway? (y or n) y
Detaching from program: , Remote target
Remote connection closed