ESP32 Debugging failed with Visual Studio due to FLASH programming

Sysprogs forums Forums VisualGDB ESP32 Debugging failed with Visual Studio due to FLASH programming

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #33825

    I had a problem starting debug ESP32 with Visual studio: FLASH programming failed.
    Until yesterday it was functioning…

    Debug Settings are:

    Debug using: OpenOCD
    JTAG/SWD programmer: ESP32 Devkit
    Set JTAG/SWD frequency to 3000
    Debugging devie: ESP32
    Program FLASH memory: always
    Program FLASH using OpenOCD(via JTAG)

    TEST debug is OK.
    Logs from TEST DEBUG are:

    VisualGDB_OpenOCD_Ready
    Info : Listening on port 6666 for tcl connections
    Info : Listening on port 54906 for telnet connections
    Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
    Info : clock speed 3000 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.cpu0: Debug controller was reset.
    Info : esp32.cpu0: Core was reset.
    Info : esp32.cpu1: Debug controller was reset.
    Info : esp32.cpu1: Core was reset.
    Info : starting gdb server for esp32.cpu0 on 54908
    Info : Listening on port 54908 for gdb connections
    Info : accepting ‘gdb’ connection on tcp/54908
    Info : esp32.cpu0: Target halted, PC=0x401EA6AE, debug_reason=00000000
    Info : Set GDB target to ‘esp32.cpu0’
    Info : esp32.cpu1: Target halted, PC=0x401EA6AE, debug_reason=00000000
    Warn : No symbols for FreeRTOS!
    Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
    Error: Failed to get flash maps (4294967290)!
    Warn : Failed to get flash mappings (-4)!
    Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
    Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
    Info : Auto-detected flash bank ‘esp32.cpu0.flash’ size 16384 KB
    Info : Using flash bank ‘esp32.cpu0.flash’ size 16384 KB
    Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
    Error: Failed to get flash maps (4294967290)!
    Warn : Failed to get flash mappings (-4)!
    Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
    Info : Using flash bank ‘esp32.cpu0.irom’ size 0 KB
    Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
    Error: Failed to get flash maps (4294967290)!
    Warn : Failed to get flash mappings (-4)!
    Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
    Info : Using flash bank ‘esp32.cpu0.drom’ size 0 KB
    Info : New GDB Connection: 1, Target esp32.cpu0, state: halted
    Info : dropped ‘gdb’ connection
    shutdown command invoked

     

    Logs from Visual Studio  are:

    @”JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n”
    @”JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n”
    @”esp32.cpu0: Target halted, PC=0x400803C0, debug_reason=00000001\n”
    @”esp32.cpu0: Core was reset.\n”
    @”esp32.cpu0: Target halted, PC=0x40000400, debug_reason=00000000\n”
    @”esp32.cpu1: Core was reset.\n”
    @”esp32.cpu1: Target halted, PC=0x40000400, debug_reason=00000000\n”
    ^done
    mon program_esp “C:/Progetti_FW/FAAC_IOT_GIT/build/VisualGDB/Debug/bootloader/bootloader.bin” 0x1000
    &”mon program_esp \”C:/Progetti_FW/FAAC_IOT_GIT/build/VisualGDB/Debug/bootloader/bootloader.bin\” 0x1000\n”
    @”JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n”
    @”JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n”
    @”esp32.cpu0: Debug controller was reset.\n”
    @”esp32.cpu0: Core was reset.\n”
    @”esp32.cpu0: Target halted, PC=0x500000CF, debug_reason=00000000\n”
    @”esp32.cpu0: Core was reset.\n”
    @”esp32.cpu0: Target halted, PC=0x40000400, debug_reason=00000000\n”
    @”esp32.cpu1: Debug controller was reset.\n”
    @”esp32.cpu1: Core was reset.\n”
    @”esp32.cpu1: Target halted, PC=0x40000400, debug_reason=00000000\n”
    @”timed out while waiting for target halted\n”
    @”esp32.cpu0: Target halted, PC=0x4000C2DD, debug_reason=00000000\n”
    @”xtensa_wait_algorithm: not halted 0, pc 0x4000c2dd, ps 0x60025\n”
    @”Failed to wait algorithm (-302)!\n”
    @”Algorithm run failed (-302)!\n”
    @”Too many flash mappings 11072892! Must be 2.\n”
    @”Failed to get flash mappings (-4)!\n”
    @”Target is already running an algorithm\n”
    @”Failed to start algorithm (-4)!\n”
    @”Failed to get flash size!\n”
    @”Target is already running an algorithm\n”
    @”Failed to start algorithm (-4)!\n”
    @”Failed to get flash size!\n”
    @”Failed to probe flash, size 0 KB\n”
    @”auto_probe failed\n”
    @”Failed to find bank ‘esp32.cpu1.flash’!\n”
    @”\n”
    ^done
    -target-disconnect
    =thread-group-exited,id=”i1″
    ^done
    -gdb-exit
    ^exit

     

     

     

    #33829
    support
    Keymaster

    Hi,

    This looks like a known issue of the ESP32 OpenOCD. Please see this thread for details.

    In order to flash the application via USB as the thread suggests, you can use the “Program FLASH Memory” command in the context menu in Solution Explorer (you would need the make sure the virtual COM port used for programming has the correct drivers installed).

    #33830

    Sorry,  but I continue to have the problem also after to have programmed by USB – COM  bootloader and partition table..

    The problem was born after to have updated last Open OCD proposed on VisualStudio ….then I  removed that Open OCD but the problem remained ..

     

    #33831
    support
    Keymaster

    Hi,

    It could be a bug in a particular OpenOCD version then. You can always revert to the previous version as shown here: https://visualgdb.com/support/oldpackages/

    Restoring the previous OpenOCD and doing a full FLASH erase via esptool.py should completely reverse any changes done by the newer OpenOCD.

    #33832

    I restored the previus openOCD but I have the same problem 🙁

    Is it possible to understand something from Error log below?

    &”mon program_esp \”C:/Progetti_FW/FAAC_IOT_GIT/build/VisualGDB/Debug/bootloader/bootloader.bin\” 0x1000\n”
    @”JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n”
    @”JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n”
    @”esp32.cpu0: Debug controller was reset.\n”
    @”esp32.cpu0: Core was reset.\n”
    @”esp32.cpu0: Target halted, PC=0x500000CF, debug_reason=00000000\n”
    @”esp32.cpu0: Core was reset.\n”
    @”esp32.cpu0: Target halted, PC=0x40000400, debug_reason=00000000\n”
    @”esp32.cpu1: Debug controller was reset.\n”
    @”esp32.cpu1: Core was reset.\n”
    @”esp32.cpu1: Target halted, PC=0x40000400, debug_reason=00000000\n”
    @”timed out while waiting for target halted\n”
    @”esp32.cpu0: Target halted, PC=0x4000C2DD, debug_reason=00000000\n”
    @”xtensa_wait_algorithm: not halted 0, pc 0x4000c2dd, ps 0x60025\n”
    @”Failed to wait algorithm (-302)!\n”
    @”Algorithm run failed (-302)!\n”
    @”Too many flash mappings 11072892! Must be 2.\n”
    @”Failed to get flash mappings (-4)!\n”
    @”Target is already running an algorithm\n”
    @”Failed to start algorithm (-4)!\n”
    @”Failed to get flash size!\n”
    @”Target is already running an algorithm\n”
    @”Failed to start algorithm (-4)!\n”
    @”Failed to get flash size!\n”
    @”Failed to probe flash, size 0 KB\n”
    @”auto_probe failed\n”
    @”Failed to find bank ‘esp32.cpu1.flash’!\n”
    @”\n”
    ^done
    -target-disconnect
    =thread-group-exited,id=”i1″
    ^done
    -gdb-exit
    ^exit

    #33842
    support
    Keymaster

    Hi,

    The log comes from the OpenOCD tool, that is maintained by Espressif, so we do not have much insights into it. You can try downloading OpenOCD from Espressif directly, running it manually per their instructions, and checking if it works. If it fails with the same error, please consider posting on the Espressif’s forum, perhaps they have a better idea of what’s going on.

    If OpenOCD works when running it manually, but doesn’t work with VisualGDB, please let us know and we will walk you through getting it to work with VisualGDB as well.

    #33846

    Espressif forum told me that OpenOCD looses offset of my application that is necessary to give this information to OpenOCD with:

    -c “init; halt; esp appimage_offset 0x20000”

    But where and how  in VisulStudio can I give to OpenOCD this information?

    In the past this operation wasn’t necessary….

     

    #33847
    support
    Keymaster

    Hi,

    It should normally not be necessary – in our tests OpenOCD managed to find everything automatically. Either way, please follow the steps below to resolve it:

    1. Try starting a debug session. Take a note of the OpenOCD command line at the beginning of the Debug->Windows->VisualGDB Output window.
    2. Try adding -c “esp appimage_offset 0x20000” at the end of the Command Line setting under VisualGDB Project Properties -> Debug Settings -> Advanced Settings (bottom of the page). You should not normally need the “init; halt” part.
    3. Try starting another debug session. Take a note of the updated command line in the VisualGDB Output window.
    4. If this does not resolve the problem, please try adding the “init; halt” part as well.

    If the problem is resolved, please share the full command line so that we could look further into it and make sure VisualGDB handles it automatically.

     

    #33855

    This is my initial OpenOCD start command:

    C:\Users\bope02\AppData\Local\VisualGDB\EmbeddedDebugPackages\com.sysprogs.esp32.core\bin\openocd.exe -c “gdb_port 54033” -c “telnet_port 54031” -f interface/ftdi/esp32_devkitj_v1.cfg -c “adapter_khz 3000” -f target/esp32.cfg -c “echo VisualGDB_OpenOCD_Ready”
    Open On-Chip Debugger 0.10.0 (2022-05-03)

     

    I’m sorry but after added the command line as you indicated  (see attached file VisualGDB_Debug.jpg) when I start DEBUG  immediately I always  have an error “Target not halted”.
    Even If I disconnect and then riconnect USB I continue to have this error.
    In this case logs are:

    C:\Users\bope02\AppData\Local\VisualGDB\EmbeddedDebugPackages\com.sysprogs.esp32.core\bin\openocd.exe -c “gdb_port 54450” -c “telnet_port 54448” -f interface/ftdi/esp32_devkitj_v1.cfg -c “adapter_khz 3000” -f target/esp32.cfg -c “esp appimage_offset 0x20000” -c “echo VisualGDB_OpenOCD_Ready”
    Open On-Chip Debugger 0.10.0 (2022-05-03)
    Licensed under GNU GPL v2
    libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
    For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
    adapter speed: 20000 kHz

    DEPRECATED! use ‘adapter speed’ not ‘adapter_khz’
    adapter speed: 3000 kHz

    Error: Target not halted

    Then I tryed to add “init; halt” but without any result but with a different error message:

    C:\Users\bope02\AppData\Local\VisualGDB\EmbeddedDebugPackages\com.sysprogs.esp32.core\bin\openocd.exe -c “gdb_port 54502” -c “telnet_port 54500” -f interface/ftdi/esp32_devkitj_v1.cfg -c “adapter_khz 3000” -f target/esp32.cfg “init; halt” -c “esp appimage_offset 0x20000” -c “echo VisualGDB_OpenOCD_Ready”
    Open On-Chip Debugger 0.10.0 (2022-05-03)
    Licensed under GNU GPL v2
    libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
    For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
    Unexpected command line argument: “init;

     

     

     

     

     

    #33856
    support
    Keymaster

    Hi,

    Sorry for the confusion. The correct command line should be:

    C:\Users\bope02\AppData\Local\VisualGDB\EmbeddedDebugPackages\com.sysprogs.esp32.core\bin\openocd.exe -c “gdb_port 54502” -c “telnet_port 54500” -f interface/ftdi/esp32_devkitj_v1.cfg -c “adapter_khz 3000” -f target/esp32.cfg -c “init; halt;esp appimage_offset 0x20000” -c “echo VisualGDB_OpenOCD_Ready”

    You can also do this:

    -c init -c halt -c "esp appimage_offset 0x20000"

     

    #33857

    ON your previous message I see different gdb_port and telnet_port  from mine….Have I to  change ? Where I can change them?

     

    #33858
    support
    Keymaster

    If you are changing the command line in VisualGDB project properties, rather than running VisualGDB manually, you do not need to specify the gdb port. Simply use -c “init; halt; esp appimage_offset 0x20000” instead of init; halt” -c “esp appimage_offset 0x20000” that you tried before. Please also make sure there is a space before -c.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.