GreenWaves-Technologies / gap_sdk

SDK for Greenwaves Technologies' GAP8 IoT Application Processor
https://greenwaves-technologies.com/en/gap8-the-internet-of-things-iot-application-processor/
Apache License 2.0
137 stars 75 forks source link

How to debug GAP8 with OpenOCD? #315

Open aleksandar-rzero opened 2 years ago

aleksandar-rzero commented 2 years ago

I try to debug the simple example of /gap_sdk/examples/pmsis/periph/uart/uart_helloworld using VSCode as described in the VSCode Integration sectoin of the manual. However, there seem to be no configuration for GAP8 when I generate the VSCode files for it. So I edit the generated fines accordingly to the command that is issued to run the example (which works ok). From:

{
    "label": "openocd",
    "type": "shell",
    "command": "<OCD install path>/openocd.exe -f <OCD install path>/scripts/tcl/interface/ftdi/olimex-arm-usb-ocd-h.cfg -f <SDK install path>/utils/openocd_tools/tcl/gap9revb.tcl",
    "presentation": {
        "reveal": "always",
        "panel": "new"
    }
}

to:

{
    "label": "openocd",
    "type": "shell",
    "command": "/workspace/tools/gap_sdk/install/workstation/gap8-openocd/bin/gap8-openocd -d2 -f interface/jlink.cfg -f target/gap8revb.tcl -f tcl/jtag_boot_entry.tcl",
    "presentation": {
        "reveal": "always",
        "panel": "new"
    }
}

Executing the task in VSCode runs well

Open On-Chip Debugger 0.10.0+dev-gb84d97ec4 (2022-02-28-10:56)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

DEPRECATED! use 'adapter speed' not 'adapter_khz'
DEPRECATED! use 'adapter driver' not 'interface'
Warn : Interface already configured, ignoring
TARGET create
Info : core 0 selected
0
Info : gap8_adv_debug_itf tap selected
Info : adv_dbg_unit debug unit selected
Info : Option 7 is passed to adv_dbg_unit debug unit
GAP8 INIT TARGET
Info : J-Link V11 compiled Dec  9 2021 14:14:49
Info : Hardware version: 11.00
Info : VTarget = 1.812 V
Info : clock speed 1500 kHz
Info : JTAG tap: gap8.cpu tap/device found: 0x149511c3 (mfg: 0x0e1 (Wintec Industries), part: 0x4951, ver: 0x1)
GAP8 examine target
Init jtag
Initialising GAP8 JTAG TAP
Info : adv debug unit is configured with option BOOT MODE JTAG
Info : adv debug unit is configured with option ADBG_USE_HISPEED
Info : starting gdb server for gap8.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections

I also edited the launch.json as suggested:

    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/workspace/tools/gap_sdk/examples/pmsis/periph/uart/uart_helloworld/BUILD/GAP8_V3/GCC_RISCV_PULPOS/test",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "console": "externalTerminal",
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "miDebuggerPath": "/workspace/tools/gap_riscv_toolchain/bin/riscv32-unknown-elf-gdb",
            "setupCommands": [
                {
                    "description": "Set Architecture",
                    "text": "set arch riscv:rv32",
                    "ignoreFailures": false
                },
                {
                    "description": "Connection to Openocd",
                    "text": "target extended-remote localhost:3333",
                    "ignoreFailures": false
                },
                {
                    "description": "set program to run",
                    "text": "file /workspace/tools/gap_sdk/examples/pmsis/periph/uart/uart_helloworld/BUILD/GAP8_V3/GCC_RISCV_PULPOS/test",
                    "ignoreFailures": false
                },
                {
                    "description": "Load Program to run",
                    "text": "load",
                    "ignoreFailures": false
                },
                {
                    "description": "Run Program",
                    "text": "exec-continue",
                    "ignoreFailures": true
                }
            ]

But VSCode fails at the very begging: vscode_debug_error

Can you point me to what is wrong here? Is there official support for GAP8 currently?

hustc12 commented 1 year ago

A following up question: could we debug our application that would be run under the GVSOC simulator? If yes, how could we do that? I tried similar steps but it doesn't work.