Using gcc -finstrumental-functions for profiling on cortex-m1

Hello, i have a project for cortex-m1 with FreeRTOS and i’m trying to find out hard faults reasons. Because of that i want to use -finstrumental-functions of GCC compiler. Unfortunatelly this option cause new Hard Fault somethere at the beginning of execution. Did someone try to use this option on ARM arch? Thich FreeRTOS function should be marked with attribute((noinstrumentfunction))? Or maybe i need to use some other tricks? Thanks in advance

Using gcc -finstrumental-functions for profiling on cortex-m1

Hi Oleg, yes, I have used that function both for M0+ and M4, but not for M1 (which is available only for FPGA’s?). See https://mcuoneclipse.com/2015/04/04/poor-mans-trace-free-of-charge-function-entryexit-trace-with-gnu-tools/ But I think you won’t find easier your problem with that option: what you need is a hard fault handler (have you used one? See https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/). I hope this helps, Erich

Using gcc -finstrumental-functions for profiling on cortex-m1

~~~ But I think you won’t find easier your problem with that option: what you need is a hard fault handler (have you used one? ~~~ Thanks. I have Hard Fault handler, but unfortunatelly it’s not easy to understand that’s wrong with code.For example stacked_pc points to code like add r3,#8 Why it could cause Fault?

Using gcc -finstrumental-functions for profiling on cortex-m1

keep in mind that the PC usually is after the instruction who caused the problem. And you need to check the stacked LR as well.

Using gcc -finstrumental-functions for profiling on cortex-m1

Okay. Thanks a lot. I’ll describe my problem more deeper. I’ve got an application with a several tasks. Couple of these tasks is using for external interface communication (CAN and 1553B) and one of the tasks is using to compute some math. If we are enable this task sooner or later app will end in Hard Fault. Usualy it’s crashes at the same place, and it’s looks like some unaligment access. I dont understand how function may be executed for a thousands times without any problem and then suddenly crash with unaligment memory access. Can you suggest something to check?

Using gcc -finstrumental-functions for profiling on cortex-m1

Are you indeed running on an FPGA model? I suggest to run your code on a real M0+ as it could be that your syntesized model has an issue? Is that unaligned access on the stack (so maybe a stack problem)?

Using gcc -finstrumental-functions for profiling on cortex-m1

Are you indeed running on an FPGA model?
No, i’m using Russian SoC 1986VE1T which is real SoC.
Is that unaligned access on the stack (so maybe a stack problem)?
I think the same, because of that i want to trace execution to see which functions called just before hard fault, i hope this will help me to find a problem.