1. Download openocd branch for esp32 from Espressif's Github repo: https://github.com/espressif/openocd-esp32
2. Configure openocd-esp32 as:
Code: Select all
$ ./configure --prefix=/usr/local/openocd-esp32/ --enable-usb-blaster
Code: Select all
#define BUILD_USB_BLASTER 1
Code: Select all
static struct drvs_map lowlevel_drivers_map[] = {
#if BUILD_USB_BLASTER
{ .name = "ftdi", .drv_register = ublast_register_ftdi },
#endif
#if BUILD_USB_BLASTER_2
{ .name = "ublast2", .drv_register = ublast2_register_libusb },
#endif
{ NULL, NULL },
};
Therefore, I applied the following quick patches so the compiler errors disappear:
Code: Select all
diff --git a/src/flash/nor/xmc4xxx.c b/src/flash/nor/xmc4xxx.c
index 78ed2258..d47fea3d 100644
--- a/src/flash/nor/xmc4xxx.c
+++ b/src/flash/nor/xmc4xxx.c
@@ -931,7 +931,7 @@ static int xmc4xxx_get_info_command(struct flash_bank *bank, char *buf, int buf_
/* If OTP Write protection is enabled (User 2), list each
* sector that has it enabled */
- char otp_str[14];
+ char otp_str[28];
if (otp_enabled) {
strcat(prot_str, "\nOTP Protection is enabled for sectors:\n");
for (int i = 0; i < bank->num_sectors; i++) {
Code: Select all
diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index 828610bb..634004c0 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -1123,7 +1123,7 @@ static int dap_rom_display(struct command_context *cmd_ctx,
int retval;
uint64_t pid;
uint32_t cid;
- char tabs[16] = "";
+ char tabs[32] = "";
if (depth > 16) {
command_print(cmd_ctx, "\tTables too deep");
Code: Select all
--- a/tcl/board/esp-wroom-32.cfg
+++ b/tcl/board/esp-wroom-32.cfg
@@ -34,7 +34,7 @@ transport select jtag
#
# On DevKit-J, this can go as high as 20MHz if CPU frequency is 80MHz, or 26MHz
# if CPU frequency is 160MHz or 240MHz.
-adapter_khz 20000
+#adapter_khz 20000
Debugging:
I used to following pinout:
Code: Select all
$ /usr/local/openocd-esp32/bin/openocd -s share/openocd/scripts -f interface/altera-usb-blaster.cfg -f board/esp-wroom-32.cfg -c "init; reset halt"
Code: Select all
$ esp32-openocd -s share/openocd/scripts -f interface/altera-usb-blaster.cfg -f board/esp-wroom-32.cfg -c "init; reset halt"
Open On-Chip Debugger v0.10.0-esp32-20190313-dirty (2019-03-27-15:43)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Warn : Adapter driver 'usb_blaster' did not declare which transports it allows; assuming legacy JTAG-only
Info : only one transport option; autoselect 'jtag'
Warn : Transport "jtag" was already selected
Info : Configured 2 cores
esp32 interrupt mask on
Info : usb blaster interface using libftdi
Error: unable to get latency timer
Info : This adapter doesn't support configurable speed
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
Info : Listening on port 3333 for gdb connections
Code: Select all
$ xtensa-esp32-elf-gdb build/Handheld.elf --tui
Code: Select all
(gdb) set remotetimeout 10000
Code: Select all
(gdb) target localhost:3333
Code: Select all
Remote debugging using localhost:3333
0x40000400 in ?? ()
Code: Select all
(gdb) break app_main
(gdb) continue
Debugging works fine: I can step, set breakpoints, watch variables... However, speed really sucks. For example, a single "step" operation takes around 30 seconds. Tracebacking via "tb" works relatively fast (around 2 seconds). Flashing a ~170 KiB image takes up to 2 minutes.
How can we improve speed so debugging experience is a bit less painful?
Thanks for reading,
Xavi