Hello,
Greetings for the day...
Below are the point-wise details to your query:
- IDE: MCUXpresso 24.12.148
- SDK: 24.12.00
- Gcov is enabled using the instructions provided at the aforesaid user manual in IDE. Below are the detailed steps which were followed.
- Opened example program from the installed SDK. I opened Hello World program.
- Build it and started debug session when semi-hosting is enabled. It worked without any implementation of gcov enabled for it.Now, enabled gcov functionality by setting-up the flags "-fprofile-arcs -ftest-coverage" as provided in the manual. The respective flags were set by selecting the relevant project under the Project Explorer tab. Then navigated to Project from menu bar > Properties > C/ C++ Build > Settings > Tool Settings > MCU C-Compiler >
- Optimization: Removed the optimization of "Merge Identical Constants" as per the comment in Gcov user guide of IDE for removing the compiler optimizations
- Debugging: Enabled gcov by checking the box to "Generate gcov information
- Miscellaneous: Enabled Verbose (-v) for details of execution.
- Miscellaneous: Added flags "-fprofile-arcs -ftest-coverage" at the column of "Other flags" as recommended in the IDE manual for gcov functionality.
- Miscellaneous: Using Library headers "NewlibNano (Auto).
- Then navigated to Project from menu bar > Properties > C/ C++ Build > Settings > Tool Settings > MCU Linker >
- Miscellaneous: Added "-fprofile-arcs -ftest-coverage" in Linker Flags row. Applied and saved the project configurations. a pop-up came to re-build index owing to changes in the flags. allowed it to re-build and then clicked on "Apply and close".
- Now, I did a right click on my project title in Project Explorer tab. Clicked on "Clean Project".
- Again, I did a right-click on the same Hello World project. Clicked on Debug As > MCU Xpresso IDE Link Server probes. It successfully compiled and deployed then resulted in "hard-fault". The program stopped at semihost_hardfault.c
- Even after attempts to resume the run it kept stopping at the same point. While all this, it is noted that so far there is no .gcno files as well. Therefore, stopped the debug session.
- Now, I updated the flags in project settings > C/ C++ build > Settings > Tool Settings >
(a) Miscellaneous: Moved the gcov flags "-fprofile-arcs -ftest-coverage" from 'Other flags' to 'Other flags (excluded from discovery). - Started the debug session again. Now it is noted that I am getting the .gcno files in my Debug folder. This is expected success here. It reveals that my settings are now updated for gcov functionality and running fine with the toolchain.
- However, the debug session is still landing into the hard fault handler block of code.
Below is the hard fault result with status registers description for providing you with the insight on firmware level.

Let me know if it is expected to go to hard fault. Even the hello world SDK example program when used with gcov functionality.
I hope that I have provided all feasible details here. Feel free to ask if anything else could help me to catch the issues in configuration/ settings or even the set-up.
Have a nice day...
MCX-W71X MCUXpresso-IDE MCUXpresso-SDK
Best Regards,
Kishan Mishra