idf-eclipse-plugin icon indicating copy to clipboard operation
idf-eclipse-plugin copied to clipboard

Need separate Debug & Release build output directories at the very least (IEP-791)

Open JBHunterI opened this issue 3 years ago • 3 comments

The ESP-IDF Eclipse Plugin stores what it builds into a single 'build' directory. I need to be able to build separate 'Debug' & 'Release' builds. For this, the ESP-IDF CLI allows to run idf.py with a '-B

' option but I couldn't get the plugin to do that in Eclipse until after reading this closed issue:

"Failed to create temporary file" during compile/flash process. Windows path length. (IEP-312) #168 from [alezancomelit] opened this issue on Dec 18, 2020

Hope it was closed because a fix is available since as @alezancomelit said, even with his wonderful "project [Launch] configuration -> Build Settings -> Additional CMake arguments" workaround that avoids a 'build' directory from being created after a successful build, the thing can't be programmed into the target without getting an OpenOCD error:

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 Info : only one transport option; autoselect 'jtag' Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001 Info : esp_usb_jtag: capabilities descriptor set to 0x2000 Warn : Transport "jtag" was already selected *** dir=C:/...[projectDir]/build file=flasher_args.json args=verify reset exit *** C:...[espIdfDir]\tools\openocd-esp32\v0.11.0-esp32-20220706\openocd-esp32\share/openocd/scripts/target/esp_common.cfg:209: Error: C:/...[projectDir]/build/flasher_args.json: No such file or directory in procedure 'program_esp_bins' at file "C:...[espIdfDir]\tools\openocd-esp32\v0.11.0-esp32-20220706\openocd-esp32\share/openocd/scripts/target/esp_common.cfg", line 209

So, we can see the output directory path ends in 'build' instead of the 'Debug' I had it build into. I just can't find where procedure 'program_esp_bins' is being called. Is there a patch for the ESP-IDF Eclipse Plugin release 2.60, assuming it's the one setting the output directory incorrectly? Also, if specifying a relative path is not possible, it would be great if we could use something like the ${project_loc} variable after the '-B' to specify an absolute path.

FYI, the OpenOCD page https://openocd.org/doc/doxygen/html/tasks.html#thelisttargets doesn't even list ESP32 as being supported, and the files list after https://openocd.org/doc/doxygen/html/esp32_8c.html doesn't seem to show support for the ESP32-C3.

JBHunterI avatar Nov 02 '22 00:11 JBHunterI

Hi @JBHunterI,

Thanks for reporting this, we will fix it asap. For now, you can use this workaround: edit debug configuration -> in Config options: add -c program_esp_bins <path-to-build-dir> flasher_args.json verify reset command, like here: image

Just in case, turn off Flash every time with application binaries in the Startup section, because it will duplicate this command with the build directory in the path.

sigmaaa avatar Nov 02 '22 09:11 sigmaaa

Thank you for the prompt & accurate response, @sigmaaa. I had to modify my Run Launch Mode's Main tab OpenOCD Arguments to: -c "program_esp_bins C:...[projectDir]/Debug flasher_args.json verify reset exit" to use forward-slashes instead of double back-slashes, and add the 'exit' to get it to run. Since ${openocd_path} is used earlier in the arguments, I was also hoping to replace C:...[projectDir] with ${project_loc:/[projectName]} but I guess that doesn't work because of the mandatory double-quotes after the -c switch. Finally was able to get it to run that way, though.

For the Debug Launch Mode, I followed your suggestion for the Debugger and Startup tabs, but I also had to change its C/C++ Application setting from build\[projectName] to ${resource_loc:/[projectName]/Debug/[projectName].elf}. Then, I was able to debug my code running on my target. I left the Startup tab's Enable ARM semihosting checked, although I'm not sure whether it should. Can you clarify this?

Also, now that I have Run & Debug Launcher Modes, I duplicated the latter to create one that I can use to only connect to a running target without restarting it. I followed the Startup tab's pop-up comments that appear when I hover my mouse cursor over its Initial Reset and Pre-run/Restart reset checkboxes, saying those 2 boxes should not be checked. I also disabled the Main tab's Disable auto build. However, the Console tab's "connect [projectName] [ESP-IDF GDB OpenOCD Debugging]" displays:

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 Info : only one transport option; autoselect 'jtag' Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001 Info : esp_usb_jtag: capabilities descriptor set to 0x2000 Warn : Transport "jtag" was already selected Flashing C:...[projectPath]/Debug/bootloader/bootloader.bin at 0x0 **Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED** Info : esp_usb_jtag: serial (68:B6:B3:A3:CB:B0) Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255 Info : clock speed 40000 kHz Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0) Info : datacount=2 progbufsize=16 Info : Examined RISC-V core; found 1 harts Info : hart 0: XLEN=32, misa=0x40101104 Info : starting gdb server for esp32c3 on 3333 Info : Listening on port 3333 for gdb connections Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0) **Info : Reset cause (3) - (Software core reset)** Info : [esp32c3] Found 8 triggers Info : Flash mapping 0: 0x10020 -> 0x3c020020, 32 KB Info : Flash mapping 1: 0x20020 -> 0x42000020, 86 KB Info : Auto-detected flash bank 'esp32c3.flash' size 4096 KB Info : Using flash bank 'esp32c3.flash' size 4096 KB ** Programming Started ** Info : PROF: Erased 20480 bytes in 555.993 ms Info : PROF: Data transferred in 361.504 ms @ 55.3244 KB/s Info : PROF: Wrote 20480 bytes in 885.007 ms (data transfer time included) ** Programming Finished in 2634 ms ** ** Verify Started ** Info : PROF: Flash verified in 374.906 ms ** Verify OK ** ** Flashing done for bootloader/bootloader.bin in 3014 ms ** Flashing C:...[projectPath]/Debug/[projectName].bin at 0x10000 Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0) Info : Reset cause (3) - (Software core reset) ** Programming Started ** Info : PROF: Erased 176128 bytes in 1758.02 ms Info : PROF: Data transferred in 2781.15 ms @ 61.8449 KB/s Info : PROF: Wrote 176128 bytes in 3409.9 ms (data transfer time included) ** Programming Finished in 5653 ms ** ** Verify Started ** Info : PROF: Flash verified in 423.1 ms ** Verify OK ** ** Flashing done for [projectName].bin in 6084 ms ** Flashing C:...[projectPath]/Debug/partition_table/partition-table.bin at 0x8000 Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0) Info : Reset cause (3) - (Software core reset) ** Programming Started ** Info : PROF: Erased 4096 bytes in 366 ms Info : PROF: Data transferred in 121.298 ms @ 32.9766 KB/s Info : PROF: Wrote 4096 bytes in 665.755 ms (data transfer time included) ** Programming Finished in 1519 ms ** ** Verify Started ** Info : PROF: Flash verified in 340.236 ms ** Verify OK ** ** Flashing done for partition_table/partition-table.bin in 1865 ms ** ** Total programming time 10967 ms ** ** Resetting Target ** Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0) Info : Reset cause (3) - (Software core reset) 0 Started by GNU MCU Eclipse Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : accepting 'gdb' connection on tcp/3333 Warn : No symbols for FreeRTOS! Info : Flash mapping 0: 0x10020 -> 0x3c020020, 32 KB Info : Flash mapping 1: 0x20020 -> 0x42000020, 86 KB Info : Using flash bank 'esp32c3.irom' size 88 KB Info : Flash mapping 0: 0x10020 -> 0x3c020020, 32 KB Info : Flash mapping 1: 0x20020 -> 0x42000020, 86 KB Info : Using flash bank 'esp32c3.drom' size 36 KB Warn : negative reply, retrying Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333" Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0) Info : Reset cause (3) - (Software core reset) Info : Detected FreeRTOS version: (10.4.3)

and my terminal shows:

... I (38291) app_main: Turning the LED OFF! ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0xESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x20000828 SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd5820,len:0x16e0 load:0x403cc710,len:0x940 load:0x403ce710,len:0x2d98 entry 0x403cc710 I (33) boot: ESP-IDF dbcf640-dirty 2nd stage bootloader I (33) boot: compile time 09:47:52 I (33) boot: chip revision: V003 I (35) boot.esp32c3: SPI Speed : 80MHz I (40) boot.esp32c3: SPI Mode : DIO I (45) boot.esp32c3: SPI Flash Size : 2MB I (50) boot: Enabling RNG early entropy source... I (55) boot: Partition Table: I (59) boot: ## Label Usage Type ST Offset Length I (66) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (73) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (81) boot: 2 factory factory app 00 00 00010000 00100000 I (88) boot: End of partition table I (92) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=083e8h ( 33768) map I (106) esp_image: segment 1: paddr=00018410 vaddr=3fc8b400 size=014e8h ( 5352) load I (110) esp_image: segment 2: paddr=00019900 vaddr=40380000 size=06718h ( 26392) load I (123) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=15b98h ( 88984) map I (140) esp_image: segment 4: paddr=00035bc0 vaddr=40386718 size=04b20h ( 19232) load I (144) esp_image: segment 5: paddr=0003a6e8 vaddr=50000010 size=00010h ( 16) load I (149) boot: Loaded app from partition at offset 0x10000 I (152) boot: Disabling RNG early entropy source... I (358) cpu_start: Pro cpu up. I (366) cpu_start: Pro cpu start user code I (366) cpu_start: cpu freq: 160000000 Hz I (366) cpu_start: Application information: I (369) cpu_start: Project name: [projectName] I (375) cpu_start: App version: 1 I (379) cpu_start: Compile time: Nov 2 2022 09:47:08 I (385) cpu_start: ELF file SHA256: 0a6e1ab74277236f... I (391) cpu_start: ESP-IDF: dbcf640-dirty I (397) heap_init: Initializing. RAM available for dynamic allocation: I (404) heap_init: At 3FC8D7C0 len 0004EF50 (315 KiB): DRAM I (410) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM I (417) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM I (424) spi_flash: detected chip: generic I (424) spi_flash: flash io: dio W (424) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header. I (437) cpu_start: Starting scheduler. I (437) app_main: ADC steps/rev 205 I (437) gpio: GPIO[3]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (437) app_main: Initializing addressable LED strip for GPIO 8 I (437) gpio: GPIO[8]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (437) app_main: ADC1 Channel[3] Raw Data: 5 -> HW PCBA Rev = 1 I (437) app_main: Turning the LED OFF! I (1437) app_main: ADC1 Channel[3] Raw Data: 3 -> HW PCBA Rev = 1 I (1437) app_main: Turning the LED ON! I (2437) app_main: ADC1 Channel[3] Raw Data: 3 -> HW PCBA Rev = 1 I (2437) app_main: Turning the LED OFF! I (3437) app_main: ADC1 Channel[3] Raw Data: 5 -> HW PCBA Rev = 1 I (3437) app_main: Turning the LED ON! ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT) Saved PC:0x20000830 SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd5820,len:0x16e0 load:0x403cc710,len:0x940 load:0x403ce710,len:0x2d98 entry 0x403cc710 I (24) boot: ESP-IDF dbcf640-dirty 2nd stage bootloader I (24) boot: compile time 09:47:52 I (24) boot: chip revision: V003 I (26) boot.esp32c3: SPI Speed : 80MHz I (31) boot.esp32c3: SPI Mode : DIO I (36) boot.esp32c3: SPI Flash Size : 2MB I (41) boot: Enabling RNG early entropy source... I (46) boot: Partition Table: I (50) boot: ## Label Usage Type ST Offset Length I (57) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (64) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (72) boot: 2 factory factory app 00 00 00010000 00100000 I (79) boot: End of partition table I (83) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=083e8h ( 33768) map I (97) esp_image: segment 1: paddr=00018410 vaddr=3fc8b400 size=014e8h ( 5352) load I (101) esp_image: segment 2: paddr=00019900 vaddr=40380000 size=06718h ( 26392) load I (114) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=15b98h ( 88984) map I (131) esp_image: segment 4: paddr=00035bc0 vaddr=40386718 size=04b20h ( 19232) load I (135) esp_image: segment 5: paddr=0003a6e8 vaddr=50000010 size=00010h ( 16) load I (140) boot: Loaded app from partition at offset 0x10000 I (143) boot: Disabling RNG early entropy source... I (349) cpu_start: Pro cpu up. I (357) cpu_start: Pro cpu start user code I (357) cpu_start: cpu freq: 160000000 Hz I (357) cpu_start: Application information: I (360) cpu_start: Project name: [projectName] I (366) cpu_start: App version: 1 I (370) cpu_start: Compile time: Nov 2 2022 09:47:08 I (376) cpu_start: ELF file SHA256: 0a6e1ab74277236f... I (382) cpu_start: ESP-IDF: dbcf640-dirty I (388) heap_init: Initializing. RAM available for dynamic allocation: I (395) heap_init: At 3FC8D7C0 len 0004EF50 (315 KiB): DRAM I (401) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM I (408) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM I (415) spi_flash: detected chip: generic I (415) spi_flash: flash io: dio W (415) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header. I (428) cpu_start: Starting scheduler.

A breakpoint early in main() confirms my target is being reset. Why is my target still being restarted & re-flashed? Does it have anything to do with the Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED line early on? How do I achieve this "connect to" Launch Mode?

JBHunterI avatar Nov 02 '22 18:11 JBHunterI

Any idea why I get the Info : Reset cause (3) - (Software core reset) msg at line 10 followed by **Programming Started ** Info : PROF: Erased 20480 bytes in 555.993 ms at line 13 in my Console tab's "connect [projectName] [ESP-IDF GDB OpenOCD Debugging]" display above when I only want to connect to my target? Will this still occur with the upcoming updates of ESP-IDF & its Eclipse Plugin?

JBHunterI avatar Nov 04 '22 17:11 JBHunterI