Debug esp32-cam CJMCU-232H

Hi there, I’m having an issue while attempting to debug an esp32-cam module
with an CJMCU-232H (FT232H Single channel) module (No dual channel FT2232H) as JTAG interface with Arduino framework.
It’s just basically hitting the same line over and over in the asm and never moves to my C code, no matter if I hit play/next/step in/step out

I’m on PlatformIO, version 4.3.2a1 (dev channel)

this is my platformio.ini

[env:esp32cam]
platform = espressif32
board = esp32cam
framework = arduino
monitor_port = COM9
monitor_speed = 115200
upload_port = COM9
upload_speed = 1500000
debug_init_break = tbreak setup
debug_tool = custom
upload_protocol = custom
debug_server =
  $PLATFORMIO_HOME_DIR/packages/tool-openocd-esp32/bin/openocd
  -s
  $PLATFORMIO_HOME_DIR/packages/tool-openocd-esp32/share/openocd/scripts/
  -f
  $PLATFORMIO_HOME_DIR/packages/tool-openocd-esp32/share/openocd/scripts/interface/ftdi/esp32_devkitj_v1.cfg
  -f
  $PLATFORMIO_HOME_DIR/packages/tool-openocd-esp32/share/openocd/scripts/board/esp-wroom-32.cfg
  -c 'ftdi_vid_pid 0x0403 0x6014'

I wired it according to the last section named “Adapter 3: Generic FT232H board” in the following post: https://medium.com/@manuel.bl/low-cost-esp32-in-circuit-debugging-dbbee39e508b
Only difference is I didn’t edit the esp32_devkitj_v1.cfg file since passing params as custom debug options seemed a cleaner solution which should survive future upgrades

This is what my vscode and zadig looks like:

and the following is the output

Processing esp32cam (platform: espressif32; board: esp32cam; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32cam.html
PLATFORM: Espressif 32 1.12.0 > AI Thinker ESP32-CAM
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (custom) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.200129 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - tool-openocd-esp32 1.1000.20190708 (10.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 27 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <WiFi> 1.0
Building in debug mode
Retrieving maximum program size .pio\build\esp32cam\firmware.elf
Checking size .pio\build\esp32cam\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  11.8% (used 38568 bytes from 327680 bytes)
Flash: [==        ]  22.9% (used 721930 bytes from 3145728 bytes)
========================= [SUCCESS] Took 2.73 seconds =========================
Reading symbols from d:\Development\electronic\[projects]\ping\.pio\build\esp32cam\firmware.elf...
done.
PlatformIO Unified Debugger -> http://bit.ly/pio-debug
PlatformIO: debug_tool = custom
PlatformIO: Initializing remote target...
Open On-Chip Debugger  v0.10.0-esp32-20190708 (2019-07-08-11:04)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
none separate
adapter speed: 20000 kHz
Info : Configured 2 cores
esp32 interrupt mask on
Info : tcl server disabled
Info : telnet server disabled
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 20000 kHz
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 : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Detected debug stubs @ 3ffc359c on core0 of target 'esp32'
Info : accepting 'gdb' connection from pipe
Info : Target halted. PRO_CPU: PC=0x4000C472 (active)    APP_CPU: PC=0x4019557E
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x4019557E
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 309 KB
Info : Flash mapping 1: 0x60018 -> 0x400d0018, 802 KB
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x4019557E
Info : Auto-detected flash size 4096 KB
Info : Using flash size 4096 KB
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x4019557E
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 309 KB
Info : Flash mapping 1: 0x60018 -> 0x400d0018, 802 KB
Info : Using flash size 804 KB
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x4019557E
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 309 KB
Info : Flash mapping 1: 0x60018 -> 0x400d0018, 802 KB
Info : Using flash size 312 KB
0x4000c472 in ?? ()
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)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000
Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400
** Programming Started **
** Programming Started **
auto erase enabled
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
wrote 16384 bytes from file C:/Users/Jacopo/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin in 0.876431s (18.256 KiB/s)
wrote 16384 bytes from file C:/Users/Jacopo/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin in 0.876431s (18.256 KiB/s)
** Programming Finished **
** Programming Finished **
** Verify Started **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
read 15872 bytes from file C:/Users/Jacopo/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin and flash bank 0 at offset 0x00001000 in 0.333050s (46.540 KiB/s)
contents match
read 15872 bytes from file C:/Users/Jacopo/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin and flash bank 0 at offset 0x00001000 in 0.333050s (46.540 KiB/s)
contents match
** Verified OK **
** Verified OK **
invalid command name "projects"
invalid command name "projects"
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)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000
Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400
** Programming Started **
** Programming Started **
auto erase enabled
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
wrote 8192 bytes from file C:/Users/Jacopo/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin in 0.799714s (10.004 KiB/s)
wrote 8192 bytes from file C:/Users/Jacopo/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin in 0.799714s (10.004 KiB/s)
** Programming Finished **
** Programming Finished **
** Verify Started **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x400916EE (active)    APP_CPU: PC=0x40000400
read 8192 bytes from file C:/Users/Jacopo/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin and flash bank 0 at offset 0x0000e000 in 0.393853s (20.312 KiB/s)
contents match
read 8192 bytes from file C:/Users/Jacopo/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin and flash bank 0 at offset 0x0000e000 in 0.393853s (20.312 KiB/s)
contents match
** Verified OK **
** Verified OK **
invalid command name "projects"
invalid command name "projects"
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)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000
Target halted. PRO_CPU: PC=0x5000004B (active)    APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400
Target halted. PRO_CPU: PC=0x40000400 (active)    APP_CPU: PC=0x40000400
Temporary breakpoint 1 at 0x400d1054: file src\main.cpp, line 74.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = tbreak setup`
PlatformIO: More configuration options -> http://bit.ly/pio-debug
Note: automatically using hardware breakpoints for read-only addresses.
Info : Detected debug stubs @ 3ffc359c on core0 of target 'esp32'
Detected debug stubs @ 3ffc359c on core0 of target 'esp32'
Info : Target halted. PRO_CPU: PC=0x4019557E             APP_CPU: PC=0x4000C595 (active)
Target halted. PRO_CPU: PC=0x4019557E             APP_CPU: PC=0x4000C595 (active)

Program received signal
SIGTRAP, Trace/breakpoint trap.
0x4000c595 in ?? ()

I tried also the simple following code:

#include <Arduino.h>

int LED_BUILTIN = 2;

void setup()
{
    // initialize digital pin LED_BUILTIN as an output.
    pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop()
{
    digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
    delay(1000);                     // wait for a second
    digitalWrite(LED_BUILTIN, LOW);  // turn the LED off by making the voltage LOW
    delay(1000);                     // wait for a second
}

but I had to add “build_flags = -g -Og -fno-inline” because of xtensa-esp32-elf-gdb crash (IDFGH-353) · Issue #2343 · espressif/esp-idf · GitHub

also I get stuck many times on “Info : Flash mapping XYZ:…” and I have to just restart the board and the debugging process

I tried

platform = https://github.com/platformio/platform-espressif32.git#v2.0.0

and

platform_packages =
    framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#idf-release/v3.3

and several other permutations and versions of these two with similar unsuccessful results

Any help would be very much appreciated.

Thanks,
Jacopo

Ok, best answers are the ones you get to yourself after 5 minutes you posted asking for help after banging your head on the problem for 2 days.

I was re reading my freshly posted question above and it hit me:

invalid command name "projects"

my project was in a folder named

D:\Development\electronic\[projects]\ping

I removed brackets from path and debugging started to work like a charm.

triple-facepalm-facepalm-know-your-meme-52308008

Thank you everyone

1 Like