ESP32-C6-WROOM Segger J-Link Connection

Marius28
Posts: 15
Joined: Sat Oct 28, 2023 4:23 pm

ESP32-C6-WROOM Segger J-Link Connection

Postby Marius28 » Sat Oct 28, 2023 4:33 pm

Hello all,

hopefully somebody can help me out because im struggling with the JTAG connection between my Segger J-Link and the ESP32-C6-WROOM on my pcb.

I connect the 4 JTAG GPIO 4-7 plus GND and 3V3 to my J-Link device. But if i start openocd via

Code: Select all

openocd -f board/esp32c6builtin.cfg
i get the error
Error: esp_usb_jtag: could not find or open device!
Otherwise i read that these JTAG GPIOs of the ESP32-C6 are connected to the internal built-in JTAG interface. Does it mean i can only debug via the USB GPIOs of the ESP32-C6?
Unfortunately I didn't bring these pins out to my pcb...

And otherwise i read that there (maybe) is a pre installed AT firmware onto the ESP32-C6 that can disturb the connection of JTAG is this true?

Hopefully anybody can help with these problem, otherwise i need to buy another flasher for my ESP32-C6 pcb?

ESP_Sprite
Posts: 9583
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-C6-WROOM Segger J-Link Connection

Postby ESP_Sprite » Sun Oct 29, 2023 12:28 am

The C6 by default indeed has JTAG connected to the internal USB-JTAG-serial port, but there is an eFuse you can blow to fix that. If you still have access to the programming UART and can put the ESP into download mode, espefuse.py can help you out.

Marius28
Posts: 15
Joined: Sat Oct 28, 2023 4:23 pm

Re: ESP32-C6-WROOM Segger J-Link Connection

Postby Marius28 » Sun Oct 29, 2023 12:55 pm

ESP_Sprite wrote:
Sun Oct 29, 2023 12:28 am
The C6 by default indeed has JTAG connected to the internal USB-JTAG-serial port
So i need to connect via a usb cable and the D- / D+ / GND pins of the ESP32-C6 to debug via openocd?

ESP_Sprite
Posts: 9583
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-C6-WROOM Segger J-Link Connection

Postby ESP_Sprite » Sun Oct 29, 2023 2:07 pm

That is one of the options. The other one is to put the ESP32C3 in download mode, connect via UART0, and blow the eFuse that connects the internal JTAG to the GPIO JTAG pins instead.

Marius28
Posts: 15
Joined: Sat Oct 28, 2023 4:23 pm

Re: ESP32-C6-WROOM Segger J-Link Connection

Postby Marius28 » Mon Oct 30, 2023 10:12 am

ESP_Sprite wrote:
Sun Oct 29, 2023 2:07 pm
That is one of the options. The other one is to put the ESP32C3 in download mode, connect via UART0, and blow the eFuse that connects the internal JTAG to the GPIO JTAG pins instead.
Work's fine via the internal USB / JTAG controller. You mean the eFuse 3: EFUSE_JTAG_SEL_ENABLE of the ESP32-C6 and GPIO15 = 0 to connect the internal JTAG to the JTAG GPIOs?

If i start the debug session via ESP-IDF i get the following error:

Code: Select all

Reading symbols from esp32-c6-devkitc-1/firmware.elf...
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Ignoring packet error, continuing...
gdbinit:1: Error in sourced command file:
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
(gdb)
GDB is running in another ESP-IDF instance and throws out the following error:

Code: Select all

Info : accepting 'gdb' connection on tcp/3333
Warn : No symbols for FreeRTOS!
Error: Algorithm timed out after 40009 ms.
Info : [esp32c6] Halt cause (5) - (PMP Load access fault)
Error: ra = 0x408012a2
Error: sp = 0x40804700
...
Error: mepc = 0x40800000
Error: mcause = 0x5
Error: Failed to wait algorithm (-302)!
Error: Algorithm run failed (-302)!
Error: Failed to run flasher stub (-302)!
Warn : Failed to get flash mappings (-302)!
Error: Target is already running an algorithm
Error: Failed to start algorithm (-4)!
Error: Failed to run flasher stub (-4)!
Error: Target is already running an algorithm
Error: Failed to start algorithm (-4)!
Error: Failed to run flasher stub (-4)!
Error: Failed to probe flash, size 0 KB
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
shutdown command invoked
What's wrong with my code for debugging? The upload without debug works fine.

Marius28
Posts: 15
Joined: Sat Oct 28, 2023 4:23 pm

Re: ESP32-C6-WROOM Segger J-Link Connection

Postby Marius28 » Wed Nov 01, 2023 10:18 am

Got it running after a full reinstallation of ESP-IDF plus driver...

To get the debugger working i need to add some code files to my .vscode folder. I oriented myself at the following video series https://www.youtube.com/@YuriR/videos

Here are my code files for .vscode folder.

launch.json

Code: Select all

{
    "version": "0.2.0",
    "configurations": [
        {
            "preLaunchTask": "preRun",
            "name": "ESP32-C6 OpenOCD",
            "type": "cppdbg",
            "request": "launch",
            "cwd": "${workspaceFolder}/build",
            "program": "${workspaceFolder}/build/wifi_softAP.elf",      // Change path to {project}.elf
            // For the following lines of code take a look at
            // https://docs.espressif.com/projects/esp-idf/en/latest/esp32c6/api-guides/jtag-debugging/using-debugger.html#jtag-debugging-using-debugger-command-line
            "miDebuggerPath": "C:/Espressif/tools/riscv32-esp-elf-gdb/12.1_20221002/riscv32-esp-elf-gdb/bin/riscv32-esp-elf-gdb.exe",
            "setupCommands": [
                {"text": "target remote :3333"},
                {"text": "set remote hardware-watchpoint-limit 2"},
                {"text": "mon reset halt"},
                {"text": "maintenance flush register-cache"},
                {"text": "thb app_main"}
            ]
        }
    ]
}
settings.json adding arguments to "args":

Code: Select all

            // Add the following arguments to open the ESP-IDF in VSCode Terminal
            "args": [
                "/k",
                "C:/Espressif/idf_cmd_init.bat esp-idf-320ad5a1f7f1ffa6c2d9808f7d43bb34"
            ],
tasks.json

Code: Select all

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "preRun",
            "type": "shell",
            "windows": {
                "command": "clear & start openocd -c \"set ESP_RTOS none\" -f board/esp32c6-builtin.cfg & exit"
            }
        }
    ]
}
This code files will start automatically OpenOCD and the debugger session when pressing F5 or Run -> Start Debugging in VSCode.

Who is online

Users browsing this forum: No registered users and 80 guests