zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.74k stars 6.56k forks source link

ESP32 SOCs can't be fully debugged using openocd #79623

Open Szewcson opened 2 weeks ago

Szewcson commented 2 weeks ago

Describe the bug When building appimage for esp32 soc's, it is lacking partition table by default. Openocd using partition table to determine where it should store software breakpoints. When there is no partition table, only 2 hardware breakpoints are available. There is an option to pass appimage_offset to openocd as a workaround, but default build is not using an offset as I understand. There is also an option to pass the binary partition table to a runner, but I can't find info on how to generate one for zephyr. In that case, I think the partition table should be built and included by default, or docs should be updated to allow inexperienced users debugging without too much digging in expert level esp-idf and zephyr documentation.

To Reproduce Steps to reproduce the behavior:

  1. west build -p always -b esp32c6_devkitc/esp32c6 zephyr/samples/subsys/console/echo -- -DOPENOCD= -DOPENOCD_DEFAULT_PATH=
  2. west flash
  3. west debug
  4. See warnings in the openocd logs and experience only two breakpoints

Expected behavior You can just debug

Impact I can't find a bug in a project since debugging is limited.

Logs and console output

Warn : Failed to get flash maps (-6)!
Warn : Application image is invalid! Check configured binary flash offset 'appimage_offset'.
Warn : Failed to get flash mappings (-4)!
Info : Auto-detected flash bank 'esp32c6.flash' size 8192 KB
Info : Using flash bank 'esp32c6.flash' size 8192 KB
Warn : Failed to get flash maps (-6)!
Warn : Application image is invalid! Check configured binary flash offset 'appimage_offset'.
Warn : Failed to get flash mappings (-4)!
Info : Using flash bank 'esp32c6.irom' size 0 KB
Warn : Failed to get flash maps (-6)!
Warn : Application image is invalid! Check configured binary flash offset 'appimage_offset'.
Warn : Failed to get flash mappings (-4)!
Info : Using flash bank 'esp32c6.drom' size 0 KB

Environment (please complete the following information):

github-actions[bot] commented 2 weeks ago

Hi @Szewcson! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

Szewcson commented 1 week ago

I tried to set appimage_offset in openocd to values that are printed during boot bout with no luck. `ESP-ROM:esp32c6-20220919 Build:Sep 19 2022 rst:0x1 (POWERON),boot:0x2c (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:2 load:0x40800000,len:0x83dc load:0x408083f0,len:0x16b4 SHA-256 comparison failed: Calculated: f3a2dcd05a5e41fe8422a54a06e1f61c91cbb52c04b8a90b1ccec59b0f50d780 Expected: 0000000030650000000000000000000000000000000000000000000000000000 Attempting to boot anyway... entry 0x40801782 I (46) boot: ESP Simple boot I (46) boot: compile time Oct 12 2024 15:28:08 I (46) spi_flash: detected chip: gd I (47) spi_flash: flash io: dio W (48) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header. I (60) boot: chip revision: v0.0 I (63) boot.esp32c6: SPI Speed : 80MHz I (66) boot.esp32c6: SPI Mode : DIO I (70) boot.esp32c6: SPI Flash Size : 8MB I (74) boot: Enabling RNG early entropy source... I (79) boot: DRAM: lma 0x00000020 vma 0x40800000 len 0x83dc (33756) I (85) boot: DRAM: lma 0x00008404 vma 0x408083f0 len 0x16b4 (5812) I (91) boot: padd: lma 0x00009ac8 vma 0x00000000 len 0x6530 (25904) I (97) boot: IMAP: lma 0x00010000 vma 0x42010000 len 0xa74 (2676) I (103) boot: padd: lma 0x00010a7c vma 0x00000000 len 0xf57c (62844) I (109) boot: IMAP: lma 0x00020000 vma 0x42000000 len 0x3aac (15020) I (115) boot: Image with 6 segments I (119) boot: DROM segment: paddr=00010000h, vaddr=42010000h, size=00A80h ( 2688) map I (126) boot: IROM segment: paddr=00020000h, vaddr=42000000h, size=03AACh ( 15020) map

I (169) heap: ESP runtime heap init at 0x4080c350 size 448 kB.

Booting Zephyr OS build v3.7.0-4288-g4793e00ae803 You should see another line with instructions below. If not, the (interrupt-driven) console device doesn't work as expected: Start typing characters to see them echoed back`

both 0x00020000 and 0x00010000 produced the same warnings.

and, yes W (48) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header. - but it is some issue with esp32c6 and esp-idf and without zephyr I have that one but no warnings about partition table. I also tried changing - --esp-app-address in runners.yaml but also with no luck.