PlatformIO Community

QEMU Emulation of SiFive Board Does Not Update Registers

When running a C program for the e310 SiFive board the RISCV register values never appear to change. I’m trying to call a simple assembly function from C, so I need to be able to track the effect the instructions are having on the register values as I step through the code. I’m also new to Platformio, so perhaps I’m missing some configuration to achieve the desired emulation behavior. I’ve tried the Dissassembly mode “switch to assembly” and when stepping through the C code the register values are simply not updating for the debugging emulation session.

Am I missing something here to enable this use case?

Can you a screenshot of the misbehavior and the platformio.ini and code to reproduce it?

platformio.ini

[platformio]
description = A simple "Hello, World!" example to demonstrate printf and build environment.

[env:e310-emulation]
platform = sifive
framework = freedom-e-sdk
board = e310-arty
debug_tool = qemu

hello.c

#include <stdio.h>

int main() {
    printf("Hello, World!\n");
}

Something as simple as the code above will fail to update registers even when stepping through the assembly that is generated from the Disassembly option.

I see the same thing. Register values are showing up as 0 under “REGISTERS” on the left side.
However, accessing the registers from the gdb console works (info registers, p $ra, etc).
It also works to add them as watch expressions (using $ra etc).

Is there any workaround?

Please open an issue in https://github.com/platformio/platform-sifive/issues so that @valeros or @ivankravets can have a look at it

The list of registers are from toolchain or SVD file. These register names point to some memory address. So, does QEMU support this emulation? I’m not so expert here. @valeros please comment.

If it works in gdb console then it might be a problem on our side, so as @maxgerhardt correctly suggested, open an issue in https://github.com/platformio/platform-sifive/issues