PlatformIO Community

关于启用pio debug时开关的值一直读不进变量问题

在使用platformio对nexys a7进行riscv开发时,编写了用开关控制led的程序,启动pio debug后调试到getswitch()函数时读取不到开关设置的值,无论如何一直显示0。图一显示了demo教程手册中可以看到val的值,但是我在调试时(图二)val总显示为0(开关的值是已经设置好的)image

image

I cannot read mandarin, so I used Google Translate.

When using platformio to develop riscv on nexys a7, I wrote a program to control the led with a switch. After starting pio debug and debugging to the getswitch() function, the value of the switch setting cannot be read, and 0 is always displayed anyway.
Figure 1 shows that the value of val can be seen in the demo tutorial manual, but when I debug (Figure 2) val always shows 0 (the value of the switch is already set)

  • What is the full source code and platformio.ini?
  • is it show something different with a different optimization level? Add
debug_build_flags = -O0 -ggdb3 -g3

(documentation) and retry.

1 Like

; PlatformIO Project Configuration File
;
; Build options: build flags, source filter, extra scripting
; Upload options: custom port, speed and extra flags
; Library options: dependencies, extra library storages
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html

[env:swervolf_nexys]
platform = chipsalliance
board = swervolf_nexys
framework = wd-riscv-sdk

monitor_speed = 115200

debug_tool = whisper
debug_build_flags = -O0 -ggdb3 -g3

board_build.bitstream_file = /home/minyang/RVfpga/src/rvfpga.bit

board_debug.verilator.binary = /home/minyang/RVfpga/verilatorSIM/Vrvfpgasim

我按照您的要求把debug_build_flags = -O0 -ggdb3 -g3添加到platformio.ini后仍然检测不到val的值

That is really not enough information to be able to help.

以下内容是按键点灯源码

#define GPIO_SWs    0x80001400
#define GPIO_LEDs   0x80001404
#define GPIO_INOUT  0x80001408

#define READ_GPIO(dir) (*(volatile unsigned *)dir)
#define WRITE_GPIO(dir, value) { (*(volatile unsigned *)dir) = (value); }

int main ( void )
{
    int En_Value=0xFFFF, switches_value;

    WRITE_GPIO(GPIO_INOUT, En_Value);

    while (1) { 
        switches_value = READ_GPIO(GPIO_SWs);
        switches_value = switches_value >> 16;
        WRITE_GPIO(GPIO_LEDs, switches_value);
    }

    return(0);
}

是这样的,我们把该程序build后直接upload到开发板上是可以正常运行的。但是当我连上开发板后直接点pio debug开始按钮(三角形状),在不断点击单步跳过按钮过程中,开发板上的灯并没有亮,并且开关的值(val)不能读到数据,这让我很困惑。是否是该调试器是虚拟的,点击pio debug并没有将程序下载到开发板上?但这点又与rvfpga给出的教程不一致(教程上正确显示了开关的值,并且灯是亮的)