Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 1.05 KB

README.md

File metadata and controls

39 lines (27 loc) · 1.05 KB

PC sampling profiler for Cortex-M MCUs

This script uses a telnet connection to a running openocd server to sample the program counter. The PC sampling is fully non-intrusive and does not disturb the CPU while running. It works also for the simpler Cortex-M models without SWO.

A table of statistics is displayed that shows how often the CPU is executing inside each function.

screenshot

The script detects if the ELF symbol file is modified and resets itself, which is useful if you leave the profiler running while developing.

More detail

Functions can be split up in sections for further detail by the use of this GCC macro, which generates a FUNC symbol of size 0:

#define FUNC_SYMB(l) asm(".thumb_func\\n" l "$uid%=:" :::)

Which can then be used like this:

void foo(void) {
    FUNC_SYMB("a");
    // code here
    FUNC_SYMB("b");
    // more code here
    // etc..
}

Installation

$ pip3 install git+https://github.com/lijon/cortex-profiler

Or download this repo and run pip3 install . in the directory.