-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
stm32/profiler.c: Add gprof-compatible profiling for STM32. #5926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This allows you to profile code from py/*.c with GCC's `-pg` flag, and analyse the results using gprof.
Very cool! How much here is actually ARM-specific? Could profile.c be placed in a port-independent place so it can be reused? |
Technically, just the |
Everything else should raise NotImplementedError. First step in micropython#5926
Services and characteristics still won't work. Progress on micropython#5926
This allows you to connect to GATT services on the other device. It also adds connection initiation (GAP central). More progress on micropython#5926
This allows you to connect to GATT services on the other device. It also adds connection initiation (GAP central). More progress on micropython#5926
This is an automated heads-up that we've just merged a Pull Request See #13763 A search suggests this PR might apply the STATIC macro to some C code. If it Although this is an automated message, feel free to @-reply to me directly if |
Enable BLE where we can. Switch 4MB, non-USB board default partitioning over to a single 2MB firmware bank. Old boards override this setting to keep the same behavior. This also adds alpha support for the ESP32-C2 (aka ESP8684). Fixes micropython#5926 and micropython#7170
Enable BLE where we can. Switch 4MB, non-USB board default partitioning over to a single 2MB firmware bank. Old boards override this setting to keep the same behavior. This also adds alpha support for the ESP32-C2 (aka ESP8684). Fixes micropython#5926 and fixes micropython#7170
Possibly useful idea from experiments during a long weekend in lockdown... tidyed up into PR form.
This allows you to instrument code for profiling with GCC's
-pg
flag, and analyse the results using gprof. This gives you periodic (1kHz) instruction sampling, and call count and call graph data.This implements the very minimum to collect call arc data and the sampling histogram and save it to a file in flash. Tested on F4.
Obviously this is very easy to do on Unix, but the results are so noisy it can be hard to really understand. And optimising for x86 can be very different to optimising for ARM, so getting the "truth" from the real device is useful.
The main limitation is to avoid using too much RAM, the instruction sampling is a bit coarse, so occasionally will report the wrong function. (This only applies to caller and time, not to callee count which is accurate).
Credit and many thanks to @ErichStyger for this excellent post that explains much of the background required to implement this https://mcuoneclipse.com/2015/08/23/tutorial-using-gnu-profiling-gprof-with-arm-cortex-m/
Then
pyboard --device /dev/ttyACM1 -f cp :gmon.out . gprof build-BOARD/firmware.elf gmon.out
gprof output (of a program that does a lot of string creation and hits the O(n) QSTR pool lookup)