Renode now supports .NET 6
Topics: Open source tools, Open hardware, Open ISA
The latest version of Antmicro’s open source simulation framework, Renode 1.13 was released some months ago, bringing a variety of improvements all across the board. Since then, there have been even more updates in the form of 1.13.1 and 1.13.2, reflecting the rapid development of the framework. One of the most significant changes for the long term development of Renode, but perhaps less prominently discussed so far while the work was underway, is introducing support for the .NET 6 runtime, alongside the original Mono framework that Renode was built around.
With this development, Renode is now open to introducing all of the newest C# language features, gets a new, simplified build process and allows users to utilize all the latest official tools introduced in this version of the .NET environment.
This note will explain the background, implementation and implications of the change, and how moving forward .NET 6 provides exciting new future opportunities for Renode.
A dive into Renode’s history and implementation
Renode is a complex tool built using several programming languages, with the most prevalent by far being C#; some features and extensions however use Python (e.g. metrics_analyzer) or C++ (e.g. Verilator Integration Library), while C is used for implementation of the CPU instruction translation libraries. But the core of Renode and most of its peripherals are written in C#, which is a high-level object-oriented language.
Originally an internal development tool that was subsequently open sourced, Renode has been in development for over a decade. Dating back to when most people didn’t yet own a smartphone, what eventually became the open source Renode framework remembers a time (not so very long ago!) when .NET (the VM-like runtime needed to execute C# code) was strictly tied to the Windows ecosystem. But reflecting the diversified user base and ambitious goals of the project (and Antmicro’s own affinity to Linux and open source), the simulation framework needed to run on all the major development platforms: Windows, Linux, and Mac.
Back then, the only way to get access to the advanced features of C# as a programming language while maintaining cross-platform compatibility was Mono, an alternative implementation of the .NET Framework that originated as a community-driven project spearheaded by Xamarin, eventually acquired by Microsoft.
Renode, since its first version, has been using Mono on Linux/Mac and the .NET Framework on Windows, and while this setup has served Renode well all these years, the success of Linux which brought about Microsoft’s expansion of .NET to natively cover non-Windows OSs presents us with other options. Although Mono still works and is a great solution in many cases, it does have certain limitations, primarily the fact that it is not fully compatible with new language features. The critical mass of the ecosystem lies with the main .NET runtime, and version 6 offers vast improvements to the developer experience thanks to improved integration with various popular tools, which Renode can take advantage of.
Changes to internal implementation
From the user’s perspective, supporting .NET 6 in Renode will be a seamless transition as changes are focused mainly around the build system (most users will typically take advantage of pre-built versions of Renode). This migration necessitated modifications to the API to move them from Mono-specific code to a platform-independent form (available in .NET).
The most important change is related to exception handling. Renode, mostly implemented in C#, uses many components that are compiled to native machine code - notably the core simulation layer is written in C. The application flow often jumps from C# to C and vice versa. Both .NET Framework and Mono supported these transitions very well, but the .NET 6 implementation on Linux lacks support for one important feature we used very often - the ability to pass exceptions through the managed - native boundary. To address this issue we have designed a new infrastructure for exception handling when crossing from native code to managed code. It is now used for all framework versions.
Another significant change for Linux/macOS users is the transition of the UI from GTK 2 to GTK 3, which is conditionally loaded when using the .NET 6 version:
var assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var assembly = Assembly.LoadFrom(Path.Combine(assemblyLocation, "Xwt.Gtk3.dll"));
This of course does not affect core emulation logic in any way, so everything will work perfectly fine for developers using a version other than .NET 6.
We provide separate project files for both the Mono/.NET Framework and the modern .NET build systems, making them more readable and allowing for better support by tools, e.g., IDEs, linters, profilers, etc. Some dependencies have been updated, and build/run scripts now have the option to select the target framework.
Reasoning behind Renode’s migration to .NET 6
Migration of this magnitude poses significant challenges, so the decision to make the leap is never easy. The primary advantage was that Renode can now use a common runtime on all supported platforms to give both users and developers a more unified experience and more flexibility. Using the official .NET framework provides better access to many bug fixes, security patches, and new language features. On top of that, .NET comes with many better diagnostic, debug, and developer tools (e.g. support in VSCode and access to extensions like OmniSharp). The recent decision by Microsoft to phase out the .NET Framework also meant continuing to use it opened up the risk of problems in the future due to a lack of official support.
Thanks to a better compiler and runtime environment, you will be able to observe improved performance in all of your simulations, and native NuGet support will make dependency management easier.
.NET 6 is now supported in Renode
All features of Renode are available on .NET 6 version, and it is ready to be used for both interactive and testing scenarios. When building or running Renode, you can choose to use the .NET 6 version, but for now, to make sure the transition for our current user base is as smooth as possible, the Mono/.NET Framework version remains a default target.
Until .NET 6 becomes the default, to use the .NET 6 version of Renode, you will need to use the
--net flag when building Renode to get this variant:
Similarly, to select .NET 6 when running Renode:
To run tests using the .NET 6 version, use:
./renode-test --runner dotnet [test.robot | tests.yaml]
Those flags will eventually be removed when Renode defaults to .NET 6 in future revisions.
.NET also comes with some additional profiling capabilities, which is useful both in Antmicro’s work on improving the performance of Renode in various scenarios, but also in profiling your own use cases.
You can generate execution traces yourself with:
dotnet-trace collect --format Speedscope --providers Microsoft-DotNETCore-SampleProfiler -- output/bin/Release/net6.0/Renode
In the near future, building packages will be done automatically, and after a sufficient testing period, the .NET target will become the default option. Moreover, the changes introduced in .NET 6 should make building “portable” versions of the packages possible on all systems. These packages will be a significant improvement from the user’s convenience point of view, as the previous solution worked only on Linux, and its implementation required some clever - but fragile - engineering.
Accelerate your projects with Renode
Antmicro provides a broad spectrum of engineering services that can help take your development environment for sensors, robotics, smart industrial devices, consumer electronics and other devices (or even ASICs) to the next level using Renode. Antmicro’s Renode, software and hardware engineering teams can help you introduce newest technologies to your development workflow and combine them with an open source approach to fast-track your next project. We’re always happy to learn about your ideas and needs, so do not hesitate to reach out to us at email@example.com.