Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot start a GDB session in VS code for Zephyr build (OCD-1039) #346

Closed
StefanHri opened this issue Nov 7, 2024 · 3 comments
Closed

Comments

@StefanHri
Copy link

Development Kit

nanoESP32-C6 v1.0 https://github.com/wuxx/nanoESP32-C6/blob/master/README_en.md

Module or chip used

ESP32-C6-WROOM-1

Debug Adapter

On-board JTAG (no additional addapter)

OpenOCD version

Open On-Chip Debugger v0.12.0-esp32-20241016 (2024-10-16-14:17)

Operating System

Ubuntu 24.10

Using an IDE ?

vs code

OpenOCD command line

/opt/openocd-esp32/bin/openocd -l openocd_log.txt -d3 -f /opt/openocd-esp32/share/openocd/scripts/board/esp32c6-builtin.cfg

JTAG Clock Speed

clock speed 24000 kHz

ESP-IDF version

No ESP-IDF used. Instead Zephyr OS v3.7.0

Problem Description

  1. Install Zephyr OS v 3.7.0.
  2. Build the hello world sample with west build -b esp32c6_devkitc -- -DOPENOCD=/opt/openocd-esp32/bin/openocd -DOPENOCD_DEFAULT_PATH=/opt/openocd-esp32/share/openocd/scripts
  3. In VS Code set up a launch.json with
{
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
                {
                        "preLaunchTask": "openocd",
                        "name": "esp32c6",
                        "type": "cppdbg",
                        "request": "launch",
                        "cwd": "${workspaceFolder}",
                        "program": "${workspaceFolder}/build/zephyr/zephyr.elf",
                        "miDebuggerPath": "/home/stefan/Programs/esp/esp-idf/tools/tools/riscv32-esp-elf-gdb/14.2_20240403/riscv32-esp-elf-gdb/bin/riscv32-esp-elf-gdb",
                        "setupCommands": [
                                {
                                        "text": "target remote 127.0.0.1:3333"
                                },
                                {
                                        "text": "set remote hardware-watchpoint-limit 4"
                                },
                                {
                                        "text": "mon reset halt"
                                },
                                {
                                        "text": "thb main"
                                },
                                {
                                        "text": "flushregs"
                                },
                                {
                                        "text": "mon program_esp ${workspaceFolder}/build/zephyr/zephyr.bin 0x0 verify"
                                },
                                {
                                        "text": "mon reset halt"
                                },
                                {
                                        "text": "maintenance flush register-cache"
                                },
                                {
                                        "text": "thb main"
                                },
                        ],
                },
        ]
}

and task.json

{
        "version": "2.0.0",
        "tasks": [
                { //more information: https://higaski.at/vscode-esp32-debugging/
                        "label": "openocd",
                        "type": "shell",
                        "isBackground": true,
                        "options": {
                                "cwd": "/opt/openocd-esp32"
                        },
                        "command": "bin/openocd -f share/openocd/scripts/board/esp32c6-builtin.cfg -c \"set ESP_RTOS none\"",
                        
                }
        ]
}

start the debug session.

Logs:
openocd_log.txt
gdb_log.txt

Debug Logs

I tried to reproduce the behavior on the command line with the flowing commands:
1. start openocd: `stefan@p14s:~$ /opt/openocd-esp32/bin/openocd -l openocd_log.txt -d3 -f /opt/openocd-esp32/share/openocd/scripts/board/esp32c6-builtin.cfg
`
2. start GDB: `/home/stefan/Programs/esp/esp-idf/tools/tools/riscv32-esp-elf-gdb/14.2_20240403/riscv32-esp-elf-gdb/bin/riscv32-esp-elf-gdb -ex "set remotelogfile gdb_log.txt" -x gdbinit build/zephyr/zephyr.elf `

Logs are attached to the section "Problem Description"

Expected behavior

The problem is that openOCD starts normally, the program execution starts as well but it is not stopped at break point at main.

Screenshots

No response

@github-actions github-actions bot changed the title Cannot start a GDB session in VS code for Zephyr build Cannot start a GDB session in VS code for Zephyr build (OCD-1039) Nov 7, 2024
@sobuch
Copy link
Collaborator

sobuch commented Nov 8, 2024

Hi @StefanHri, could you please try replacing "setupCommands" with "postRemoteConnectCommands"?

@erhankur
Copy link
Collaborator

@StefanHri Is there any update on your side?

@StefanHri
Copy link
Author

Works for me. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants