espressif / openocd-esp32

OpenOCD branch with ESP32 JTAG support
Other
348 stars 128 forks source link

Failed To init Debug adapter (Failed to get flash maps, failed to get flash size) (OCD-789) #295

Closed 5ami closed 7 months ago

5ami commented 1 year ago

Development Kit

Customs Board

Module or chip used

ESP32s3 Chip

Debug Adapter

esp32s3 on-chip JTAG

OpenOCD version

v0.11.0-esp32-20220706

Operating System

Windows

Using an IDE ?

VScode with ESP-IDF extension

OpenOCD command line

openocd -f board/esp32s3-builtin.cfg

JTAG Clock Speed

40000 kHz

ESP-IDF version

v5.0

Problem Description

I have a costume board with esp32s3 chip (not a wroom). I could flash software for it using the USB/JTAG, however I cant get the Debuger connected to it. I get Failed To init Debug adapter (Failed to get flash maps, failed to get flash size).

With the same menuconfig settings, same environment and same software uploaded, the debugger works with other esspressif boards.

The only difference is that My costume board has a 512KB flash. and the log from openOCD says: [OpenOCD] ❌ Error: Failed to get flash maps (4294967295)! Warn : Failed to get flash mappings (-4)!

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

[OpenOCD] ❌ Error: Failed to get flash size!

[OpenOCD] Info : [esp32s3.cpu0] Target halted, PC=0x403B2482, debu [OpenOCD] g_reason=00000001

[OpenOCD] ❌ Error: Failed to get flash size! Error: Failed to probe flash, size 0 KB [OpenOCD] ❌

Debug Logs

Here is the full Log:

[OpenOCD]
Open On-Chip Debugger  v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html

[OpenOCD]
debug_level: 2

[OpenOCD]
Info : only one transport option; autoselec
C:\Users\U405172\.espressif\tools\openocd-esp32\v0.11.0-esp32-20220706\openocd-esp32\bin\openocd.exe

[OpenOCD]
t 'jtag'

[OpenOCD]
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000

[OpenOCD]
M
[OpenOCD]
emory protection is enabled. Reset targe
[OpenOCD]
t to disable it...

[OpenOCD]
Info : Listening on port 6666 for tcl co
[OpenOCD]
nnections
Info : Listening on port 4444 for telnet connections

[OpenOCD]
❌ Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED

[OpenOCD]
Info : esp_usb_jtag: serial (7C:DF:A1:F7:43:50)
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 40000 kHz

[OpenOCD]
Info : JTAG tap: esp32s3.cpu0 tap/d
[OpenOCD]
evice 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] Debug controller was reset.

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

[OpenOCD]
Info : esp32s3.cpu0: Detecte
[OpenOCD]
d debug stubs @ 3fc96154

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

[OpenOCD]
Info : starting gdb server for esp32s3.cpu0 on 3333

[OpenOCD]
Info : Listening on port 3333 for gdb connections

[Debug Adapter]
2023-08-21 12:03:51,747 - Debug Adapter (main) - DEBUG - START_TIME_2023_08_21_12-03-51

[Debug Adapter]
2023-08-21 12:03:51,747 - Debug Adapter (main) - DEBUG - Init errors:None
2023-08-21 12:03:51,747 - Debug Adapter (main) - INFO - Working directory: C:\Users\U405172\AppData\Local\Programs\Microsoft VS Code

[Debug Adapter]
2023-08-21 12:03:51,748 - Debug Adapter (main) - INFO - Arguments: 
{   'app_flash_off': 65536,
    'board_type': None,
    'cmdfile': None,
    'core_file': (),
    'debug': 5,
    'developer_mode': 'none',
    'device_name': 'esp32s3',
    'elfpath': ('c:\\Users\\U405172\\eplanet_test\\build\\eplanet_test.elf',),
    'log_file': 'c:\\Users\\U405172\\eplanet_test\\debug.log',
    'log_mult_files': None,
    'log_no_debug_console': None,
    'oocd': 'openocd',
    'oocd_args': None,
    'oocd_ip': 'localhost',
    'oocd_mode': 'connect_to_instance',
    'oocd_scripts': None,
    'port': 43474,
    'postmortem': False,
    'tmo_scale_factor': 1,
    'toolchain_prefix': 'xtensa-esp32s3-elf-'}
DEBUG_ADAPTER_STARTED
2023-08-21 12:03:51,749 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_STARTED

[Debug Adapter]
2023-08-21 12:03:51,752 - Debug Adapter (main) - INFO - Starting. Cmd: c:\Users\U405172\.vscode\extensions\espressif.esp-idf-extension-1.6.4\esp_debug_adapter\debug_adapter_main.py -d 5 -e c:\Users\U405172\eplanet_test\build\eplanet_test.elf -l c:\Users\U405172\eplanet_test\debug.log -p 43474 -dn esp32s3 -a 0x10000 -t xtensa-esp32s3-elf-

[Debug Adapter]
2023-08-21 12:03:51,761 - Debug Adapter (main) - INFO - Listening on port 43474
DEBUG_ADAPTER_READY2CONNECT
2023-08-21 12:03:51,761 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_READY2CONNECT

[Debug Adapter]
2023-08-21 12:03:51,765 - Debug Adapter (main) - DEBUG - Got connection

[Debug Adapter]
2023-08-21 12:03:51,772 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Debug adapter -> Extension: DEBUG_ADAPTER_STARTED\n", "source": {}}, "seq": 0}

[Debug Adapter]
2023-08-21 12:03:51,773 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Starting. Cmd: c:\\Users\\U405172\\.vscode\\extensions\\espressif.esp-idf-extension-1.6.4\\esp_debug_adapter\\debug_adapter_main.py -d 5 -e c:\\Users\\U405172\\eplanet_test\\build\\eplanet_test.elf -l c:\\Users\\U405172\\eplanet_test\\debug.log -p 43474 -dn esp32s3 -a 0x10000 -t xtensa-esp32s3-elf-\n\n", "source": {}}, "seq": 1}

2023-08-21 12:03:51,773 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Listening on port 43474\n", "source": {}}, "seq": 2}

2023-08-21 12:03:51,773 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Debug adapter -> Extension: DEBUG_ADAPTER_READY2CONNECT\n", "source": {}}, "seq": 3}

2023-08-21 12:03:51,773 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Got connection\n", "source": {}}, "seq": 4}

[Debug Adapter]
2023-08-21 12:03:51,811 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'Content-Length: 514\\r\\n'<<

[Debug Adapter]
2023-08-21 12:03:51,811 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'\\r\\n'<<

2023-08-21 12:03:51,811 - Debug Adapter(Command Processor) - DEBUG - Got json: {
    "arguments": {
        "adapterID": "espidf",
        "clientID": "vscode",
        "clientName": "Visual Studio Code",
        "columnsStartAt1": true,
        "linesStartAt1": true,
        "locale": "en",
        "pathFormat": "path",
        "supportsArgsCanBeInterpretedByShell": true,
        "supportsInvalidatedEvent": true,
        "supportsMemoryEvent": true,
        "supportsMemoryReferences": true,
        "supportsProgressReporting": true,
        "supportsRunInTerminalRequest": true,
        "supportsStartDebuggingRequest": true,
        "supportsVariablePaging": true,
        "supportsVariableType": true
    },
    "command": "initialize",
    "seq": 1,
    "type": "request"
}

[Debug Adapter]
2023-08-21 12:03:51,812 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Got json: {\n    \"arguments\": {\n        \"adapterID\": \"espidf\",\n        \"clientID\": \"vscode\",\n        \"clientName\": \"Visual Studio Code\",\n        \"columnsStartAt1\": true,\n        \"linesStartAt1\": true,\n        \"locale\": \"en\",\n        \"pathFormat\": \"path\",\n        \"supportsArgsCanBeInterpretedByShell\": true,\n        \"supportsInvalidatedEvent\": true,\n        \"supportsMemoryEvent\": true,\n        \"supportsMemoryReferences\": true,\n        \"supportsProgressReporting\": true,\n        \"supportsRunInTerminalRequest\": true,\n        \"supportsStartDebuggingRequest\": true,\n        \"supportsVariablePaging\": true,\n        \"supportsVariableType\": true\n    },\n    \"command\": \"initialize\",\n    \"seq\": 1,\n    \"type\": \"request\"\n}\n", "source": {}}, "seq": 5}

[Debug Adapter]
2023-08-21 12:03:51,837 - Gdb - DEBUG - MI->: -gdb-set mi-async on

[Debug Adapter]
2023-08-21 12:03:52,496 - Gdb - DEBUG - MI<-:
[{'message': 'thread-group-added',
  'payload': {'id': 'i1'},
  'stream': 'stdout',
  'token': None,
  'type': 'notify'},
 {'message': 'done',
  'payload': None,
  'stream': 'stdout',
  'token': None,
  'type': 'result'}]

[Debug Adapter]
2023-08-21 12:03:52,496 - Gdb - INFO - NOTIFY: thread-group-added {'id': 'i1'}
2023-08-21 12:03:52,496 - Gdb - DEBUG - RESULT: done None
2023-08-21 12:03:52,497 - Gdb - DEBUG - MI->: -gdb-set logging file C:\Users\U405172\AppData\Local\Temp\gdb_proc.log

[Debug Adapter]
2023-08-21 12:03:52,510 - Gdb - DEBUG - MI<-:
[{'message': 'done',
  'payload': None,
  'stream': 'stdout',
  'token': None,
  'type': 'result'}]
2023-08-21 12:03:52,510 - Gdb - DEBUG - RESULT: done None
2023-08-21 12:03:52,510 - Gdb - DEBUG - MI->: -gdb-set logging on

[Debug Adapter]
2023-08-21 12:03:52,524 - Gdb - DEBUG - MI<-:
[{'message': 'done',
  'payload': None,
  'stream': 'stdout',
  'token': None,
  'type': 'result'}]

[Debug Adapter]
2023-08-21 12:03:52,525 - Gdb - DEBUG - RESULT: done None
2023-08-21 12:03:52,525 - Debug Adapter (main) - DEBUG - Created gdb object of type: GdbEspXtensa
2023-08-21 12:03:52,525 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Created gdb object of type: GdbEspXtensa\n", "source": {}}, "seq": 6}

2023-08-21 12:03:52,525 - Gdb - DEBUG - MI->: -file-exec-and-symbols c:/Users/U405172/eplanet_test/build/eplanet_test.elf

[Debug Adapter]
2023-08-21 12:03:57,526 - Gdb - DEBUG - MI<-:
[]

[Debug Adapter]
2023-08-21 12:03:57,527 - Debug Adapter (main) - ERROR - Failed to wait for completion of command "-file-exec-and-symbols c:/Users/U405172/eplanet_test/build/eplanet_test.elf" / 5!
Traceback (most recent call last):
  File "c:\Users\U405172\.vscode\extensions\espressif.esp-idf-extension-1.6.4\esp_debug_adapter\debug_adapter\command_processor.py", line 52, in __call__
    on_request(protocol_message)
  File "c:\Users\U405172\.vscode\extensions\espressif.esp-idf-extension-1.6.4\esp_debug_adapter\debug_adapter\command_processor.py", line 75, in on_initialize_request
    raise e
  File "c:\Users\U405172\.vscode\extensions\espressif.esp-idf-extension-1.6.4\esp_debug_adapter\debug_adapter\command_processor.py", line 70, in on_initialize_request
    self.da.adapter_init()
  File "c:\Users\U405172\.vscode\extensions\espressif.esp-idf-extension-1.6.4\esp_debug_adapter\debug_adapter\debug_adapter.py", line 329, in adapter_init
    raise e
  File "c:\Users\U405172\.vscode\extensions\espressif.esp-idf-extension-1.6.4\esp_debug_adapter\debug_adapter\debug_adapter.py", line 325, in adapter_init
    self.start_gdb()
  File "c:\Users\U405172\.vscode\extensions\espressif.esp-idf-extension-1.6.4\esp_debug_adapter\debug_adapter\debug_adapter.py", line 678, in start_gdb
    raise e
  File "c:\Users\U405172\.vscode\extensions\espressif.esp-idf-extension-1.6.4\esp_debug_adapter\debug_adapter\debug_adapter.py", line 666, in start_gdb
    self._gdb.exec_file_set(elf)
  File "C:\Users\U405172\.espressif\python_env\idf5.0_py3.8_env\lib\site-packages\esp_debug_backend\gdb.py", line 283, in exec_file_set
    res, _ = self._mi_cmd_run('-file-exec-and-symbols %s' % local_file_path)
  File "C:\Users\U405172\.espressif\python_env\idf5.0_py3.8_env\lib\site-packages\esp_debug_backend\gdb.py", line 206, in _mi_cmd_run
    raise DebuggerTargetStateTimeoutError(
esp_debug_backend.defs.DebuggerTargetStateTimeoutError: Failed to wait for completion of command "-file-exec-and-symbols c:/Users/U405172/eplanet_test/build/eplanet_test.elf" / 5!

[Debug Adapter]
2023-08-21 12:03:57,527 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "response", "request_seq": 1, "success": false, "command": "initialize", "seq": 7, "message": "Failed to init Debug Adapter!", "body": {}}

2023-08-21 12:03:57,529 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Failed to wait for completion of command \"-file-exec-and-symbols c:/Users/U405172/eplanet_test/build/eplanet_test.elf\" / 5!\n", "source": {}}, "seq": 8}

2023-08-21 12:03:57,529 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Failed to wait for completion of command \"-file-exec-and-symbols c:/Users/U405172/eplanet_test/build/eplanet_test.elf\" / 5!\n", "source": {}}, "seq": 9}

[Debug Adapter]
2023-08-21 12:03:57,537 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'Content-Length: 79\\r\\n'<<

[Debug Adapter]
2023-08-21 12:03:57,537 - Debug Adapter (ReaderThread) - DEBUG - read line: >>b'\\r\\n'<<

2023-08-21 12:03:57,538 - Debug Adapter(Command Processor) - DEBUG - Got json: {
    "arguments": {
        "restart": false
    },
    "command": "disconnect",
    "seq": 2,
    "type": "request"
}
2023-08-21 12:03:57,538 - Debug Adapter (main) - DEBUG - Adapter is Stopping...
2023-08-21 12:03:57,538 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Got json: {\n    \"arguments\": {\n        \"restart\": false\n    },\n    \"command\": \"disconnect\",\n    \"seq\": 2,\n    \"type\": \"request\"\n}\n", "source": {}}, "seq": 10}

[Debug Adapter]
2023-08-21 12:03:57,538 - Debug Adapter (main) - DEBUG - Stopping target poller
2023-08-21 12:03:57,538 - Debug Adapter (main) - DEBUG - Closing the GDB process
2023-08-21 12:03:57,538 - Debug Adapter (main) - DEBUG - Closing the Socket
2023-08-21 12:03:57,539 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Debug Adapter stopped\n", "source": {}}, "seq": 11}

[Debug Adapter]
2023-08-21 12:03:57,539 - Debug Adapter (main) - DEBUG - Stopping of the Writer thread
2023-08-21 12:03:57,539 - Debug Adapter (WriterThread) - DEBUG - Writing: {"type": "event", "event": "output", "body": {"output": "Adapter is Stopping...\n", "source": {}}, "seq": 12}

2023-08-21 12:03:57,539 - Debug Adapter (main) - DEBUG - Stopping of the Reader thread
2023-08-21 12:03:57,539 - Debug Adapter (main) - DEBUG - Adapter is Stopped

[Debug Adapter]
DEBUG_ADAPTER_STOPPED
2023-08-21 12:03:57,539 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_STOPPED
2023-08-21 12:03:57,540 - Debug Adapter(Command Processor) - DEBUG - Processed command: disconnect

[Stopped] : ESP-IDF Debug Adapter

Expected behavior

The debugger should connect.

Screenshots

No response

5ami commented 1 year ago

Extra note: I have a costume partition table in csv format. image

erhankur commented 1 year ago

@5ami Before getting into detail, can you update your OpenOCD to the latest release and share the verbose logs with -d3 option? Also, it might be useful to see your idf application boot logs.

erhankur commented 7 months ago

@5ami do you still have an issue?

erhankur commented 7 months ago

Thanks for reporting. Feel free to re-open if you still have an issue.