ESP32-S3-DevKit-C / ESP32-S3-WROOM-1-N16R8 - How To Debug With Built-in JTAG? (solved)

sutabi
Posts: 1
Joined: Fri Dec 01, 2023 8:09 pm

ESP32-S3-DevKit-C / ESP32-S3-WROOM-1-N16R8 - How To Debug With Built-in JTAG? (solved)

Postby sutabi » Fri Dec 01, 2023 9:01 pm

While writing this figured it out, might still be helpful for others... Basically the hello world example provided by ESP-IDF resets each time its done and the debugger gives up from the reset. Had to wrap everything in a while loop.

I am having issues stepping through hello world example code for the ESP-IDF / OpenOCD. I have a video going over this: https://www.youtube.com/watch?v=gnra_owX4Yg however here is what I have so far.

System: Windows 11 Pro
ESP Device: ESP32-S3-DevKit-C / ESP32-S3-WROOM-1-N16R8 - 2022-v1.3
Image
Image

Even though I installed the drivers (I cant remember which forum post this was from) it wasn't being picked up and ended up using "UsbDriverTool"
Image

I also followed this, but I am assuming I don't need to mess with any pins?
https://docs.espressif.com/projects/esp ... -jtag.html

USB Hardware IDs:
USB\VID_303A&PID_1001&REV_0101&MI_00
USB\VID_303A&PID_1001&MI_00

Registry:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_303A&PID_1001&MI_00\7&f95a91f&0&0000]
"DeviceDesc"="@usbser.inf,%usbserial.devicedesc%;USB Serial Device"
"LocationInformation"="0000.0014.0000.009.001.000.000.000.000"
"Capabilities"=dword:00000080
"Address"=dword:00000001
"ContainerID"="{c3483517-b93c-51c8-9bb1-befb7303197c}"
"HardwareID"=hex(7):55,00,53,00,42,00,5c,00,56,00,49,00,44,00,5f,00,33,00,30,\
00,33,00,41,00,26,00,50,00,49,00,44,00,5f,00,31,00,30,00,30,00,31,00,26,00,\
52,00,45,00,56,00,5f,00,30,00,31,00,30,00,31,00,26,00,4d,00,49,00,5f,00,30,\
00,30,00,00,00,55,00,53,00,42,00,5c,00,56,00,49,00,44,00,5f,00,33,00,30,00,\
33,00,41,00,26,00,50,00,49,00,44,00,5f,00,31,00,30,00,30,00,31,00,26,00,4d,\
00,49,00,5f,00,30,00,30,00,00,00,00,00
"CompatibleIDs"=hex(7):55,00,53,00,42,00,5c,00,43,00,4f,00,4d,00,50,00,41,00,\
54,00,5f,00,56,00,49,00,44,00,5f,00,33,00,30,00,33,00,61,00,26,00,43,00,6c,\
00,61,00,73,00,73,00,5f,00,30,00,32,00,26,00,53,00,75,00,62,00,43,00,6c,00,\
61,00,73,00,73,00,5f,00,30,00,32,00,26,00,50,00,72,00,6f,00,74,00,5f,00,30,\
00,30,00,00,00,55,00,53,00,42,00,5c,00,43,00,4f,00,4d,00,50,00,41,00,54,00,\
5f,00,56,00,49,00,44,00,5f,00,33,00,30,00,33,00,61,00,26,00,43,00,6c,00,61,\
00,73,00,73,00,5f,00,30,00,32,00,26,00,53,00,75,00,62,00,43,00,6c,00,61,00,\
73,00,73,00,5f,00,30,00,32,00,00,00,55,00,53,00,42,00,5c,00,43,00,4f,00,4d,\
00,50,00,41,00,54,00,5f,00,56,00,49,00,44,00,5f,00,33,00,30,00,33,00,61,00,\
26,00,43,00,6c,00,61,00,73,00,73,00,5f,00,30,00,32,00,00,00,55,00,53,00,42,\
00,5c,00,43,00,6c,00,61,00,73,00,73,00,5f,00,30,00,32,00,26,00,53,00,75,00,\
62,00,43,00,6c,00,61,00,73,00,73,00,5f,00,30,00,32,00,26,00,50,00,72,00,6f,\
00,74,00,5f,00,30,00,30,00,00,00,55,00,53,00,42,00,5c,00,43,00,6c,00,61,00,\
73,00,73,00,5f,00,30,00,32,00,26,00,53,00,75,00,62,00,43,00,6c,00,61,00,73,\
00,73,00,5f,00,30,00,32,00,00,00,55,00,53,00,42,00,5c,00,43,00,6c,00,61,00,\
73,00,73,00,5f,00,30,00,32,00,00,00,00,00
"ConfigFlags"=dword:00000000
"ClassGUID"="{4d36e978-e325-11ce-bfc1-08002be10318}"
"Driver"="{4d36e978-e325-11ce-bfc1-08002be10318}\\0004"
"Mfg"="@usbser.inf,%msft%;Microsoft"
"Service"="usbser"
"FriendlyName"="USB Serial Device (COM6)"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_303A&PID_1001&MI_00\7&f95a91f&0&0000\Device Parameters]
"VendorRevision"=dword:00000000
"RevisionId"=dword:00000101
"ExtPropDescSemaphore"=dword:00000001
"PortName"="COM6"
"PollingPeriod"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_303A&PID_1001&MI_00\7&f95a91f&0&0000\Device Parameters\e5b3b5ac-9725-4f78-963f-03dfb1d828c7]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_303A&PID_1001&MI_00\7&f95a91f&0&0000\Device Parameters\WDF]

When I try build, flash, monitor in Visual Studio Code I get this:
[Codebox][OpenOCD]
** Verify Started **

[OpenOCD]
Info : [esp32s3.cpu0] Target halted, PC=0x4038E3B6, debug_reason
[OpenOCD]
=00000001

[OpenOCD]
Info : PROF: Flash verified in 115.39
[OpenOCD]
1 ms

[OpenOCD]
** Verify OK **

[OpenOCD]
** Flashing done for partition_table/partition-table.bin in 836 ms **
** Total programming time 6159 ms **
** Resetting Target **

[OpenOCD]
Info : JTAG tap: esp32s3.cpu0 tap/devic
[OpenOCD]
e found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)

[OpenOCD]
Info : [esp32s3.cpu0] requesting target halt and executing a soft reset

[OpenOCD]
Info : [esp32s3.cpu0] Debug controller was reset.

[OpenOCD]
Info : [esp32s3.cpu0] Core was reset.

[OpenOCD]
Info : [esp32s3.cpu0] Target halted, PC=0x500000EF, debug_reason=
[OpenOCD]
00000000

[OpenOCD]
Info : [esp32s3.cpu0] Reset cause (3) - (Software core reset)

[OpenOCD]
Info : [esp32s3.cpu1] requesting ta
[OpenOCD]
rget halt and executing a soft reset

[OpenOCD]
Info : [esp32s3.cpu0] Core was reset.

[OpenOCD]
Info : [esp32s3.cpu1] Debug controller was reset
[OpenOCD]
.
Info : [esp32s3.cpu1] Core was reset.

[OpenOCD]
0

\[Flash\]
⚡️ Flashed Successfully (JTag)
[OpenOCD]
Info : [esp32s3.cpu0] Target halted, PC=0x4004883B, debug_reason=00000000

[OpenOCD]
Info : [esp32s3.cpu0] Reset cause (3) - (Soft
[OpenOCD]
ware core reset)

[OpenOCD]
Info : [esp32s3.cpu1] Target halted, PC=0x40043A40, debug_reason=00000000

[OpenOCD]
Info : [esp32s3.cpu1] Reset cause (3)
[OpenOCD]
- (Software core reset)

[OpenOCD]
Info : [esp32s3.cpu0] Debug controller was reset.

[OpenOCD]
Info : [esp32s3.cpu0] Core was reset.

[OpenOCD]
Info : [esp32s3.cpu1] Debug controller was reset.
[OpenOCD]

Info : [esp32s3.cpu1] Core was reset.

[OpenOCD]
Info : [esp32s3.cpu0] Target halted, PC=0x40048C26, debug_reason=00000000

[OpenOCD]
Info : [esp32s3.cpu0] Reset
[OpenOCD]
cause (12) - (Software CPU0 reset)

[OpenOCD]
Info : [esp32s3.cpu1] Target halted, PC=0x40043A40, debug_reason=00000000

[OpenOCD]
Info : [esp32s3.cpu1] Reset cause (1
[OpenOCD]
2) - (Software CPU1 reset)[/Codebox]

This is what I have in for my GDB settings, but also found this (https://github.com/espressif/vscode-esp ... ug-adapter):
[Codebox] {
"type": "cppdbg",
"name": "ESP32 OpenOCD",
"request": "launch",
"cwd": "${workspaceFolder}/build",
"program": "${workspaceRoot}/build/hello_world.elf",
"miDebuggerPath": "C:/Users/xingo/.espressif/tools/xtensa-esp-elf-gdb/12.1_20221002/xtensa-esp-elf-gdb/bin/xtensa-esp32s3-elf-gdb.exe",
"setupCommands": [
{"text": "target extended-remote 127.0.0.1:3333"},
{"text": "set remote hardware-watchpoint-limit 2"},
{"text": "monitor reset halt"},
{"text": "flushregs"}
]
}[/Codebox]

Update after writing this... I ended up wrapping this into a while loop and now debugging with breakpoints works :roll:
[Codebox]void app_main(void)
{
while (1)
{
printf("Hello world!\n");

/* Print chip information */
esp_chip_info_t chip_info;
uint32_t flash_size;
esp_chip_info(&chip_info);
printf("This is %s chip with %d CPU core(s), %s%s%s%s, ",
CONFIG_IDF_TARGET,
chip_info.cores,
(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
(chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : "");

unsigned major_rev = chip_info.revision / 100;
unsigned minor_rev = chip_info.revision % 100;
printf("silicon revision v%d.%d, ", major_rev, minor_rev);
if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
printf("Get flash size failed");
return;
}

printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024),
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");

printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());

for (int i = 10; i >= 0; i--) {
printf("Restarting in %d seconds...\n", i);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
printf("Restarting now.\n");
fflush(stdout);

}
// esp_restart();
}[/Codebox]

So I assume since the bugger is only started after the application is running, it gives up before I can start debugging?

Who is online

Users browsing this forum: Bing [Bot] and 92 guests