Page 2 of 3

Re: Profiling on Espressif MCUs woes

Posted: Fri Aug 02, 2024 4:23 pm
by Bryght-Richard
I found Espressif's gprof. Changing the default is easy, but combining multiple text sections is more complicated, but should be doable by merging the symbol sets using BFD.

Re: Profiling on Espressif MCUs woes

Posted: Tue Aug 13, 2024 3:24 pm
by Bryght-Richard
Cleaned up patches for upstream OpenOCD available here, could use reviewers and testers for ESP32 and ESP32-S2.

Re: Profiling on Espressif MCUs woes

Posted: Mon Dec 02, 2024 2:23 am
by realfast
Can you provide a prebuilt windows binary? I delved into the mingw stuff for openocd and it just started opening other cans of worms. Id be happy to test if there was a prebuilt executable.

Re: Profiling on Espressif MCUs woes

Posted: Fri Dec 06, 2024 4:39 pm
by Bryght-Richard
Sorry @realfast, I messed up my ESP-CMD install once installing mingw, so I'm not going to build from source on this machine. I've been using Debian on an old ThinkPad to record my profiles.

Also, there's also some ongoing work in this commit stack to improve OpenOCD's profile writing capabilities to support sparse memory map systems like the ESP32 family. Without that, the files written are too granular to tell what's going on. A temporary workaround is to set max_buckets to 256*1024*1024 in src/target/target.c .

Re: Profiling on Espressif MCUs woes

Posted: Mon Jan 06, 2025 11:21 pm
by Decryptor
As far as I know, all Xtensa-based ESP32 chips should; the RiscV based ones probably have something similar somewhere. I'll point the tools team to your branch; it could be worth integrating into our official openocd branch.


What's the chance this gets pushed to mainline, especially bundled OCD? I am very interested in the orders of magnitude better performance.

Re: Profiling on Espressif MCUs woes

Posted: Mon Jan 20, 2025 5:10 pm
by Bryght-Richard
As far as I know, all Xtensa-based ESP32 chips should; the RiscV based ones probably have something similar somewhere. I'll point the tools team to your branch; it could be worth integrating into our official openocd branch.
What's the chance this gets pushed to mainline, especially bundled OCD? I am very interested in the orders of magnitude better performance.
First half(fast PC sampler) is merged to upstream OpenOCD. Second half is uploaded but unreviewed - feel free to review upstream :)

Re: Profiling on Espressif MCUs woes

Posted: Sat Jan 25, 2025 2:48 am
by windows_air
Can you provide a prebuilt windows binary? I delved into the mingw stuff for openocd and it just started opening other cans of worms. Id be happy to test if there was a prebuilt executable.
You can use github action to build openocd online.

Here's a pre-built image if anyone needs it.
https://github.com/windowsair/openocd-e ... 2946189634

Re: Profiling on Espressif MCUs woes

Posted: Thu Feb 06, 2025 3:53 am
by rsaxvc
I've got a new update that handles profiling with sparse memory maps by emitting multiple histograms - the sampling is now full resolution(instruction-accurate) with only 100-200KB typical filesize.

Re: Profiling on Espressif MCUs woes

Posted: Thu Feb 06, 2025 11:07 am
by DrMickeyLauer
That sounds pretty amazing. Will test asap.

Re: Profiling on Espressif MCUs woes

Posted: Thu Feb 06, 2025 10:10 pm
by Bryght-Richard
Here's the latest zomgsofast OpenOcd.exe: https://github.com/rsaxvc/openocd-esp32 ... 6763071220 , click "Upload Artifact", then "Artifact download URL: https://github.com/rsaxvc/openocd-esp32 ... 2545220858"

Steps:

[*] unzip OpenOCD, I put mine in c:\Espressif\tools\openocd-esp32\rsaxvc-zomgsofast
[*] Open ESP-IDF CMD and "set OPENOCD_SCRIPTS=c:\Espressif\tools\openocd-esp32\rsaxvc-zomgsofast\openocd-esp32\share\openocd\scripts"
[*] Run OpenOCD, I used "c:\Espressif\tools\openocd-esp32\rsaxvc-zomgsofast\openocd-esp32\bin\openocd.exe -f board\esp32s3-builtin.cfg"
[*] Connect to OpenOCD with Putty/Telnet
[*] Optionally in OpenOCD, select CPU0/CPU1 to profile.
[*] In OpenOCD, run "profile 5 gmon.out" - should take 80-120k samples with builtin-JTAG.
[*] Select the elf section for analysis. From my project folder, I copied the ELF while renaming with: 'xtensa-esp32s3-elf-objcopy.exe --rename-section .flash.text=.text build\blitz_app.elf blitz_app.elf'. TBH This step needs improvement, but the work probably would be best done in gprof either by processing sections according to PROGBITS+EXEC flags or allowing section names on the command line. By default gprof only searches the ELF for ".text", which ESP-IDF does not emit(instead it has things like .flash.text, .iram.text, .rom.text, ... which should all be loadable if GPROF knew to do it.
[*] Produce the report with 'xtensa-esp32s3-elf-gprof.exe blitz_app.elf gmon.out'