Skip to content

Openocd failed to get flash maps in micropython firmware (OCD-1209) #366

Open
@XIAO-Q7

Description

@XIAO-Q7

Development Kit

ESP32-S3-DevKitC-1 N32R16V

Module or chip used

ESP32-S3-WROOM-2 N32R16V

Debug Adapter

USB-JTAG

OpenOCD version

v0.12.0-esp32-20241016

Operating System

WSL-Ubuntu24.04 / WSL-Ubuntu22.04

Using an IDE ?

VSCode

OpenOCD command line

openocd -f interface/esp_usb_jtag.cfg -f target/esp32s3.cfg

JTAG Clock Speed

default

ESP-IDF version

v5.4.1

Problem Description

Openocd failed to get flash maps in micropython firmware

micropython version 1.25.0

  1. compiled the ESP32S3 MicroPython firmware based on the MicroPython project. I made the following changes to fit the ESP32 dev board.
    1. select partitions-32MiB.csv
    2. I set MICROPY_HW_ENABLE_USBDEVD, MICROPY_HW_ESP_USB_SERIAL_JTAG, and MICROPY_HW_USB_CDC to 0 to disable MicroPython operations on the USB port.
  2. I flashed the firmware to the ESP32S3 board, and MicroPython runs as expected.
  3. However, when I try to start debugging, OpenOCD throws the following errors:
Warn : 1435 12843 esp_flash.c:383 esp_algo_flash_get_mappings(): Failed to get flash maps (-9)!
Warn : 1436 12843 esp_flash.c:392 esp_algo_flash_get_mappings(): Failed to read flash size!
Warn : 1437 12843 esp_flash.c:986 esp_algo_flash_probe(): Failed to get flash mappings (-4)!
Error: 1438 12843 esp_flash.c:1022 esp_algo_flash_probe(): Failed to probe flash, size 0 KB
Error: 1439 12843 core.c:291 get_flash_bank_by_num(): auto_probe failed
Error: 1440 12843 gdb_server.c:1056 gdb_new_connection(): Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
  1. I later tried debugging the "hello world" example, and everything worked fine.
  2. To avoid this error, I started OpenOCD with -c 'set ESP_FLASH_SIZE 0', and debugging worked normally.

I'm not sure what caused this problem. I checked the partition table offset in my project and it looks fine (although I'm not absolutely sure, as I'm not very familiar with this part). Is it possible that MicroPython changes something related to this?
I would appreciate any help or advice to locate the root cause.
If you are also using MicroPython, you may be able to reproduce this problem easily.

Failed debug with MicroPyhton FW
fail_debug_openocd.log

Succeed debug with ”hello world“ example
succeed_debug_openocd.log

My sdkconfig file
sdkconfig.txt

Expected behavior

openocd throws no errors and debug normally

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions