Testing and debugging embedded systems in simulation with Renode VS Code extension

Published:

Topics: Open source tools, Open simulation

Renode is typically used to test and debug complex hardware-software systems, where having a tight interactive debugging feedback loop and a visual overview of the state of the system and registers are key. Renode’s superpower is making embedded systems more like working with regular software by representing your entire system within a single deterministic simulation environment that can be more easily integrated with typical continuous integration based workflows.

To this end, we have always provided our customers with configurations for running Renode with VS Code - given that many of them use the editor. Now, to enable even easier integration of testing and debugging with Renode simulation into IDEs (similarly as in the case of the Microchip SoftConsole integration), we created a VS Code extension that enables spawning and connecting to an instance of the simulator, setting up a desired simulation and controlling it via commands generated by the IDE, all in a graphical environment. This extension can be used either with VS Code running natively as a desktop application or with a web instance of VS Code or Theia embedded in a website with additional back end providing simulation - either on a local machine or on a remote server.

In the article below, we will show how to set up the VS Code Renode extension in desktop and web scenarios, present a demo use case with Antmicro’s System Designer and go over future development plans.

Introducing the Renode VS Code extension

Local VS Code setup

To run the extension locally, you need Renode and GDB installed in your system:

wget https://builds.renode.io/renode-latest.linux-portable-dotnet.tar.gz
tar xf renode-latest.linux-portable-dotnet.tar.gz
sudo apt install gdb-multiarch

Additionally, the extension uses renode-ws-proxy - a session manager and a proxy that enables remote communication with Renode.

To get started, install the renode-ws-proxy package:

pip3 install --upgrade --user git+https://github.com/antmicro/renode-ws-proxy.git

Now, build the extension using pnpm (pnpm installation instructions):

pnpm i && pnpm run v:pack

This will produce a renode*.vsix file you can install in your IDE by going to the extensions menu and choosing the Install from VSIX… option from the Views and More Actions(...) menu.

Here is a sample configuration you can place in .vscode/launch.json or .theia/launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "renodegdb",
      "request": "launch",
      "name": "Debug in Renode",
      "elf": "${workspaceFolder}/path/to/your/binary.elf"

      "resc": "${workspaceFolder}/your.resc",

      "cwd": "${workspaceFolder}"
    }
  ]
}

Running and debugging on simulated devices

To use Renode for simulating boards or entire systems represented in our System Designer, follow the instructions in the section above and start renode-ws-proxy on the default (21234) port, providing the path to the Renode portable package and a desired execution directory:

renode-ws-proxy renode_{version}-dotnet_portable/renode .

With the setup ready, you can go to System Designer, select a device you would like to start debugging in Renode simulation and launch the web IDE that uses an instance of Renode running locally on your machine. Below you can see a video presenting a sample flow:

Future development plans

There is an ongoing effort at Antmicro to provide the extension as a one-click solution, where the session management and proxy functionalities currently handled by renode-ws-proxy are integrated into the extension itself.

In the future, we are also planning to expose more information from the simulation itself, e.g. the state of peripherals, analyzers, a peripherals tree, the IRQ status, the ability to add hooks and more. All this information will be available from the VS Code interface to enable development and debugging in even more detailed simulation scenarios.

Integrate Renode into your workflows for a seamless simulation debugging environment

The introduction of the VS Code / Theia Renode extension is a valuable milestone for the ease of integration of the open source simulation framework into our customers’ (as well as our own) workflows and toolkits. This way, we can implement unified SW/HW development environments with simulation either handled by instances of Renode running locally on developers’ machines or in cloud-based setups.

If you are interested in simplifying your debugging and development pipelines and reducing turnaround time by enabling deterministic simulation right there in your IDE, do not hesitate to contact us at contact@antmicro.com and describe your needs. You can also read about Renode’s functionalities and the versatile engineering services we provide on our interactive offering page.

See Also: