Hello! In the last article as a part of the Getting Started series, we discussed the bash, bashrc and Path variable. Moving forward, now we will be seeing the tools involved in SHAKTI. In this article, Questions like how to use vim editor? What is spike? What are OpenOCD and RISCV-GDB? How OpenOCD and RISCV-GDB work together to establish a connection between our PC and the Microprocessor? are answered .

vi/vim editor:

When you first opened your vi/vim editor, Probably you would have struggled to even save and quit the screen. You never actually need to learn your text editor, Unless you use vim.

Firstly, let’s take a look at the brief history of vi to get a better understanding of its design. Vi editor was created with a motto “Type less, do more” as there was no graphical interface or a mouse at that time. So they had to do everything with only the keyboard. Thus the difficulty.

vi improved is vim. In other words, vim is 200x vi.

Basic commands of vim

iinvokes the insert mode, You can start editing the file in this mode.
Escape keyInvokes command mode where you execute all the commands like save, quit.
h-j-k-lActs as Arrow keys
:wqIn the command mode, saves and quits the terminal
:q!When in the command mode, trashes all the changes and quits the terminal.
/word In the command mode, searches for the specified word
u or UWhen in command mode, use u to undo and U to undo the entire last line
ctrl + rIn command mode, redo the last command.

Vim even has features like auto-complete, find & replace. The learning curve for this editor is steep, Yes! But it has the strongest customization mechanism. With its high flexibility, if you have the heart, You can even build your own personalized editor.


Spike is a RISC-V instruction set simulator. When you don’t have the physical device, you can use spike to do application development. Therefore the code can be easily migrated to real hardware later. Spike simulates the processor development environment.



RISC-V GDB is the GNU debugger for RISC-V platforms. A debugger lets you pause a program, examine various memory addresses, change variables, and step through the code. In this way, you can find the exact location and cause of the problem. While debugging, the GDB controls the Target hardware. You can pass instructions through gdb to control the target device

Debug adapter:

An additional hardware device is required to allow the Host Computer to communicate and introspect the target hardware. These devices are often referred to as Debugger devices or Debug adapters. The compiled program is transferred to the target hardware using the Debugger device.


The Open On-Chip Debugger (OpenOCD) is a piece of software that provides an interface for the RISCV-GDB, to connect to the target device. It allows the RISC-V GDB (gdbserver) to connect to the target microcontroller through a debug adapter.

Debugging with OpenOCD and RISC-V GDB:

Debugging happens as part of both software and hardware development. In hardware development, we initialize the peripherals, the memory, registers, and instantiate a platform for application development. Software debugging is easier as the OS takes care of logs and memory dumps. However, the hardware debugging is challenging because it has to be done over bare metal with limited memory and specific capabilities.

The Debug adapter usually has a set of hardware pins (called Test Access Points aka TAPs) which can be used to see what is going on in different types of memories (registers, flash, sram, etc.).

Now we need to connect the TAPs on the microcontroller to the computer using USB (or a parallel port). To convert in between the TAPs (which usually support a standard called JTAG) and the USB data formats, we need an intermediate like a dongle. OpenOCD supports such dongles. 

How OpenOCD and RISC-GDB works in SHAKTI?

  1. The hardware you have connected is an FPGA board that can use many kinds of serial interfaces like SPI or JTAG or GPIO.
  2. Firstly, Connect the FPGA Board (Arty7 35t or 100t) your PC using a USB cable.
  3. Then run OpenOCD on your PC which supports remote GDB protocol.
  4. OpenOCD listens for GDB connections on the default port 3333. In RISV-GDB, connect to OpenOCD by typing target remote localhost:3333. 
  5. This would cause RISC-V GDB to connect to the gdbserver on the local PC using port 3333. Now RISC-V GDB just sends the commands it knows and receives data it understands.

Thus RISC-V GDB and OpenOCD works together for us to interact with the device and perform any operation. Do you want to learn more about SHAKTI? Click here!

Leave a Reply