cancel
Showing results for 
Search instead for 
Did you mean: 

How do we check code coverage on STM32?

SBhon.1
Associate II

I am using STM32L4 for my application and I want to do code coverage on my controller to see how it performs. How can I do that? Is there any tool or is there any in-built feature in STM32CubeIDE which I can use?

10 REPLIES 10
Pavel A.
Evangelist III

IAR EWARM has good instrumentation for coverage.

Yes. But I am running linux so only STM32CubeIDE is working for me. IAR, Keil dont have support for linux. So is there any option?

GLASS
Senior

If board is equiped wih a large package, maybe ETM can be accessible through debug/trace connector. In this case Ozone debugger from Segger with j-trace probe are very good. Not affordable for hobbyst but helpfull for professional targeting good quality software.

With it you can code coverage in real time! A must have​. Caution: With j link probe you can't code coverage. Only with j trace and if you can connect to ETM.

I use it under Windows but it is also under Linux​.

Thanks. Will try that and revert back for any queires.

ITM also has some capability for profiling (PC sampling). Of course, ETM is better, but ITM is cheaper for coarse profiling. CubeIDE has a limited support for this, see the fine manual.

What is code coverage?

JW

GLASS
Senior

Hi Jan. Code coverage is a metrics on source code based on runtime analysis. With ETM it can be done in real time with not noticable impact on timing.

Doing so can highlight for example instruction that are not executed during a non regression test​. Generally tools give also statistic so you can target very qickly witch part of code need to be rewrite for optimisation purpose.

As stated by @Pavel A.​ ITM can only sample PC to give a statistic. Sampling approche is not so accurate due to insuffisant sampling on very small part of code as like ISR for example...

Have a look to video example using J-TRACE not j link!!!

https://www.segger.com/products/development-tools/ozone-j-link-debugger/technology/code-coverage/

Thanks.

JW

I dont have J-Trace. Currently I have JLink Mini. Using that I cant do code coverage?