Closed szekelyisz closed 6 months ago
@szekelyisz how did you run appimage_offset command? Can you send verbose(-d3) OpenOCD logs from the beginning?
Also please send your partition table or application console output to check the new offsets.
I see from the env variables, openocd script location doesn't show the current OpenOCD version you run. I don't say related to this issue but always better to use correct script set.
@erhankur Thanks for looking into this issue.
@szekelyisz how did you run appimage_offset command?
I add -c "init; halt; esp appimage_offset 0xa000"
to OpenOCD command line as described here
Can you send verbose(-d3) OpenOCD logs from the beginning?
Also please send your partition table
Using the default builtin partition table CONFIG_PARTITION_TABLE_SINGLE_APP=y
with CONFIG_PARTITION_TABLE_OFFSET=0xa000
.
or application console output to check the new offsets.
I can flash and run the image through UART, partition offsets seem correct, here goes the logs:
I (31) boot: ESP-IDF v5.2.1-182-g08299f5f9b 2nd stage bootloader
I (31) boot: compile time Mar 16 2024 03:50:51
I (32) boot: Multicore bootloader
I (36) boot: chip revision: v1.0
I (40) boot.esp32: SPI Speed : 40MHz
I (45) boot.esp32: SPI Mode : DIO
I (49) boot.esp32: SPI Flash Size : 2MB
I (54) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (63) boot: ## Label Usage Type ST Offset Length
I (70) boot: 0 nvs WiFi data 01 02 0000b000 00006000
I (78) boot: 1 phy_init RF data 01 01 00011000 00001000
I (85) boot: 2 factory factory app 00 00 00020000 00100000
I (93) boot: End of partition table
I (97) esp_image: segment 0: paddr=00020020 vaddr=3f400020 size=17670h ( 95856) map
I (138) esp_image: segment 1: paddr=00037698 vaddr=3ffb0000 size=0231ch ( 8988) load
I (142) esp_image: segment 2: paddr=000399bc vaddr=40080000 size=0665ch ( 26204) load
I (154) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=3eecch (257740) map
I (243) esp_image: segment 4: paddr=0007eef4 vaddr=4008665c size=07248h ( 29256) load
I (261) boot: Loaded app from partition at offset 0x20000
I (261) boot: Disabling RNG early entropy source...
I (273) cpu_start: Multicore app
I (282) cpu_start: Pro cpu start user code
I (282) cpu_start: cpu freq: 160000000 Hz
I (282) cpu_start: Application information:
I (285) cpu_start: Project name: simple
I (290) cpu_start: App version: 1
I (294) cpu_start: Compile time: Mar 19 2024 17:13:22
I (300) cpu_start: ELF file SHA256: 4658ff184...
I (305) cpu_start: ESP-IDF: v5.2.1-182-g08299f5f9b
I (312) cpu_start: Min chip rev: v0.0
I (316) cpu_start: Max chip rev: v3.99
I (321) cpu_start: Chip rev: v1.0
I (326) heap_init: Initializing. RAM available for dynamic allocation:
I (333) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (339) heap_init: At 3FFB3620 len 0002C9E0 (178 KiB): DRAM
I (345) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (352) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (358) heap_init: At 4008D8A4 len 0001275C (73 KiB): IRAM
I (366) spi_flash: detected chip: generic
I (369) spi_flash: flash io: dio
W (373) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (387) main_task: Started on CPU0
I (397) main_task: Calling app_main()
I (457) esp_eth.netif.netif_glue: 84:0d:8e:d3:66:27
I (457) esp_eth.netif.netif_glue: ethernet attached to netif
I (2157) ethernet_connect: Waiting for IP(s).
I (6157) esp_netif_handlers: example_netif_eth ip: 192.168.17.116, mask: 255.255.255.0, gw: 192.168.17.1
I (6157) ethernet_connect: Got IPv4 event: Interface "example_netif_eth" address: 192.168.17.116
I (6157) example_common: Connected to example_netif_eth
I (6167) example_common: - IPv4 address: 192.168.17.116,
I (6177) example: Starting server on port: '80'
I (6187) example: Registering URI handlers
I see from the env variables, openocd script location doesn't show the current OpenOCD version you run. I don't say related to this issue but always better to use correct script set.
Not sure I know what you mean. I'm running OpenOCD from Eclipse, my startup script is set to ${openocd_path}/share/openocd/scripts -f board/esp32-ethernet-kit-3.3v.cfg
. openocd_path
has the value /home/szabi/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32
which is in line with my OPENOCD_SCRIPTS
environment variable.
@szekelyisz When you don't set the appimage offset manually, OpenOCD will try to get that offset from the default partition table. (0x8000)
If you change the partition table offset you have to set your new appimage location. In this case, it is 0x20000 not 0xA000.
Because if the appimage offset is set, OpenOCD will not check the partition table anymore. It will try to read the specified address directly.
Please try;
-c "init; halt; esp appimage_offset 0x20000"
@szekelyisz When you don't set the appimage offset manually, OpenOCD will try to get that offset from the default partition table. (0x8000)
If you change the partition table offset you have to set your new appimage location. In this case, it is 0x20000 not 0xA000.
Ah OK thanks, that was not obvious from the documentation.
Because if the appimage offset is set, OpenOCD will not check the partition table anymore. It will try to read the specified address directly.
Please try;
-c "init; halt; esp appimage_offset 0x20000"
That's better. Here's my OpenOCD startup now:
# /home/szabi/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin/openocd -s /home/szabi/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/share/openocd/scripts -f board/esp32-ethernet-kit-3.3v.cfg -c "init; halt; esp appimage_offset 0x20000"
Open On-Chip Debugger v0.12.0-esp32-20230921 (2023-09-21-13:41)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
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 : starting gdb server for esp32.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Info : [esp32.cpu1] Target halted, PC=0x400850EA, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14) - (CPU1 reset by CPU0)
Info : Set GDB target to 'esp32.cpu1'
Info : [esp32.cpu0] Target halted, PC=0x400850EA, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (1) - (Power on reset)
Info : [esp32.cpu0] Target halted, PC=0x400BE636, debug_reason=00000001
Info : Flash mapping 0: 0x20020 -> 0x3f400020, 93 KB
Info : Flash mapping 1: 0x40020 -> 0x400d0020, 251 KB
Info : Using flash bank 'esp32.cpu0.irom' size 252 KB
Info : [esp32.cpu0] Target halted, PC=0x400BE636, debug_reason=00000001
Info : Flash mapping 0: 0x20020 -> 0x3f400020, 93 KB
Info : Flash mapping 1: 0x40020 -> 0x400d0020, 251 KB
Info : Using flash bank 'esp32.cpu0.drom' size 96 KB
Info : [esp32.cpu0] Target halted, PC=0x400BE636, debug_reason=00000001
Info : Flash mapping 0: 0x20020 -> 0x3f400020, 93 KB
Info : Flash mapping 1: 0x40020 -> 0x400d0020, 251 KB
Info : Using flash bank 'esp32.cpu1.irom' size 252 KB
Info : [esp32.cpu0] Target halted, PC=0x400BE636, debug_reason=00000001
Info : Flash mapping 0: 0x20020 -> 0x3f400020, 93 KB
Info : Flash mapping 1: 0x40020 -> 0x400d0020, 251 KB
Info : Using flash bank 'esp32.cpu1.drom' size 96 KB
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
But now when I start GDB something is still not right:
# /home/szabi/.espressif/tools/xtensa-esp-elf-gdb/12.1_20231023/xtensa-esp-elf-gdb/bin/xtensa-esp32-elf-gdb
GNU gdb (esp-gdb) 12.1_20231023
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=xtensa-esp-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) set mem inaccessible-by-default off
(gdb) set remotetimeout 20
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
Remote communication error. Target disconnected.: Connection reset by peer.
(gdb)
At the same time on the OpenOCD console I see:
Info : accepting 'gdb' connection on tcp/3333
Warn : No symbols for FreeRTOS!
Error: timed out while waiting for target halted
Info : [esp32.cpu0] Target halted, PC=0x4000C341, debug_reason=00000000
Error: xtensa_wait_algorithm: not halted 0, pc 0x4000c341, ps 0x60025
Error: Failed to wait algorithm (-302)!
Error: Algorithm run failed (-302)!
Error: Failed to run flasher stub (-302)!
Warn : Failed to get flash mappings (-302)!
Error: Target is already running an algorithm
Error: Failed to start algorithm (-4)!
Error: Failed to run flasher stub (-4)!
Error: Target is already running an algorithm
Error: Failed to start algorithm (-4)!
Error: Failed to run flasher stub (-4)!
Error: Failed to probe flash, size 0 KB
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
I switched to full manual startup as I'm not sure if the IDF Eclipse plugin is doing the right thing behind the scenes. For example, it seems to ignore the -c "init; halt; esp appimage_offset 0x20000"
option. Because of this I might have missed some steps, be advised.
If I reset the partition table offset to the default value 0x8000, the same startup flow works without a problem (removing -c "init; halt; esp appimage_offset 0x20000"
from the command line of course). A difference is though that this way OpenOCD stops sooner:
# /home/szabi/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin/openocd -s /home/szabi/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/share/openocd/scripts -f board/esp32-ethernet-kit-3.3v.cfg
Open On-Chip Debugger v0.12.0-esp32-20230921 (2023-09-21-13:41)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
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 : starting gdb server for esp32.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Info : [esp32.cpu0] Target halted, PC=0x400850EA, debug_reason=00000001
Info : [esp32.cpu0] Reset cause (1) - (Power on reset)
Info : Set GDB target to 'esp32.cpu0'
Info : [esp32.cpu1] Target halted, PC=0x400850EA, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14) - (CPU1 reset by CPU0)
And only continues after I connect from GDB.
@szekelyisz I have shared the issue with the IDE team. We will get back when we have a clear understanding.
@szekelyisz I made a fix that can solve your issue. Can you test again with the master branch? You can find the Linux built here
@szekelyisz can you confirm if the fix in the master branch works for you?
@szekelyisz can you confirm if the fix in the master branch works for you?
Thanks for the fix. I'll be able to test it in a couple of days.
@erhankur Your fix seems to work. At least debugging starts up properly and breakpoints are hit with the partition table offset set to 0xa000
and -c "init; halt; esp appimage_offset 0x20000"
added to OpenOCD command line.
Answers checklist.
General issue report
Changing
PARTITION_TABLE_OFFSET
insdkconfig
makes debugger startup fail, even withesp appimage_offset <offset>
.Using ESP32 Ethernet Kit.
OpenOCD log
GNU gdb (esp-gdb) 12.1_20231023Environment information
Executing /usr/bin/python3 /home/szabi/esp/esp-idf/tools/idf_tools.py list * xtensa-esp-elf-gdb: GDB for Xtensa - 12.1_20231023 (recommended, installed) * riscv32-esp-elf-gdb: GDB for RISC-V - 12.1_20231023 (recommended, installed) * xtensa-esp-elf: Toolchain for 32-bit Xtensa based on GCC - esp-13.2.0_20230928 (recommended, installed) * esp-clang: Toolchain for all Espressif chips based on clang (optional) - 16.0.1-fe4f10a809 (recommended, installed) * riscv32-esp-elf: Toolchain for 32-bit RISC-V based on GCC - esp-13.2.0_20230928 (recommended, installed) * esp32ulp-elf: Toolchain for ESP32 ULP coprocessor - 2.35_20220830 (recommended, installed) * cmake: CMake build system (optional) - 3.24.0 (recommended, installed) - 3.16.3 (supported) * openocd-esp32: OpenOCD for ESP32 - v0.12.0-esp32-20230921 (recommended, installed) * ninja: Ninja build system (optional) - 1.11.1 (recommended, installed) * esp-rom-elfs: ESP ROM ELFs - 20230320 (recommended, installed) * qemu-xtensa: QEMU for Xtensa (optional) - esp_develop_8.1.3_20231206 (recommended, installed) * qemu-riscv32: QEMU for RISC-V (optional) - esp_develop_8.1.3_20231206 (recommended, installed) OK CDT Build environment variables PATH: /home/szabi/.espressif/tools/xtensa-esp-elf-gdb/12.1_20231023/xtensa-esp-elf-gdb/bin:/home/szabi/.espressif/tools/riscv32-esp-elf-gdb/12.1_20231023/riscv32-esp-elf-gdb/bin:/home/szabi/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/szabi/.espressif/tools/esp-clang/16.0.1-fe4f10a809/esp-clang/bin:/home/szabi/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin:/home/szabi/.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/home/szabi/.espressif/tools/cmake/3.24.0/bin:/home/szabi/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin:/home/szabi/.espressif/tools/ninja/1.11.1/:/home/szabi/.espressif/tools/qemu-xtensa/esp_develop_8.1.3_20231206/qemu/bin:/home/szabi/.espressif/tools/qemu-riscv32/esp_develop_8.1.3_20231206/qemu/bin:/home/szabi/.espressif/python_env/idf5.2_py3.11_env/bin:/home/szabi/esp/esp-idf/tools:/home/szabi/.local/bin:/home/szabi/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin XAUTHORITY: /run/user/1000/xauth_lKPGTt INVOCATION_ID: 4e792d174ce54153b29305ffc98198e8 XMODIFIERS: @im=ibus XDG_DATA_DIRS: /home/szabi/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop LC_TIME: en_150.UTF-8 PLASMA_USE_QT_SCALING: 1 GTK_IM_MODULE: ibus DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1000/bus ESP_IDF_VERSION: 5.2 XDG_ACTIVATION_TOKEN: kwin-99 XDG_CURRENT_DESKTOP: KDE OPENOCD_SCRIPTS: /home/szabi/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/share/openocd/scripts QT_AUTO_SCREEN_SCALE_FACTOR: 0 JOURNAL_STREAM: 8:23113 IDF_DEACTIVATE_FILE_PATH: /tmp/tmp73u5yc3aidf_369349 SESSION_MANAGER: local/neo:@/tmp/.ICE-unix/4429,unix/neo:/tmp/.ICE-unix/4429 LOGNAME: szabi MANAGERPID: 4246 PWD: /home/szabi PAM_KWALLET5_LOGIN: /run/user/1000/kwallet5.socket IM_CONFIG_PHASE: 1 XCURSOR_THEME: breeze_cursors QT_WAYLAND_FORCE_DPI: 96 LANGUAGE: en_US:en KDE_SESSION_VERSION: 5 XKB_DEFAULT_MODEL: pc105 SHELL: /bin/bash KDE_FULL_SESSION: true IDF_COMPONENT_MANAGER: 1 GTK_MODULES: gail:atk-bridge CLUTTER_IM_MODULE: ibus XDG_SESSION_PATH: /org/freedesktop/DisplayManager/Session1 SYSTEMD_EXEC_PID: 4851 XDG_SESSION_DESKTOP: KDE SSH_AGENT_LAUNCHER: openssh KDE_APPLICATIONS_AS_SCOPE: 1 OXYGEN_DISABLE_INNER_SHADOWS_HACK: 1 QT_IM_MODULE: ibus KDE_SESSION_UID: 1000 XDG_CONFIG_DIRS: /home/szabi/.config/kdedefaults:/etc/xdg:/usr/share/desktop-base/kf5-settings LANG: en_CA.UTF-8 XDG_SEAT_PATH: /org/freedesktop/DisplayManager/Seat0 XDG_SESSION_ID: 3 XDG_SESSION_TYPE: wayland DISPLAY: :1 WAYLAND_DISPLAY: wayland-0 GTK_RC_FILES: /etc/gtk/gtkrc:/home/szabi/.gtkrc:/home/szabi/.config/gtkrc XKB_DEFAULT_LAYOUT: us XDG_SESSION_CLASS: user XCURSOR_SIZE: 24 GDK_BACKEND: x11 QTWEBENGINE_DICTIONARIES_PATH: /usr/share/hunspell-bdic/ LIBOVERLAY_SCROLLBAR: 0 IDF_PATH: /home/szabi/esp/esp-idf GDK_CORE_DEVICE_EVENTS: 1 DESKTOP_SESSION: plasmawayland USER: szabi GTK2_RC_FILES: /etc/gtk-2.0/gtkrc:/home/szabi/.gtkrc-2.0:/home/szabi/.config/gtkrc-2.0 QT_ACCESSIBILITY: 1 SSH_AUTH_SOCK: /run/user/1000/openssh_agent XDG_SEAT: seat0 STM32CubeMX_PATH: /home/szabi/apps/STM32CubeMX IDF_MAINTAINER: 1 XDG_RUNTIME_DIR: /run/user/1000 XDG_VTNR: 1 IDF_PYTHON_ENV_PATH: /home/szabi/.espressif/python_env/idf5.2_py3.11_env HOME: /home/szabi ESP_ROM_ELF_DIR: /home/szabi/.espressif/tools/esp-rom-elfs/20230320/ Operating System: linux Java Runtime Version: 17.0.10+7-Debian-1deb12u1 Eclipse Version: 4.31.100.v20240229-0520 Eclipse CDT Version: 11.5.0.202312062348 IDF Eclipse Plugin Version: 2.12.1.202402231119 ESP-IDF v5.2.1-182-g08299f5f9b Python set for IDF_PYTHON_ENV: Python 3.11.2