Data is logged in debug mode but not in released and flashed mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Data is logged in debug mode but not in released and flashed mode

Jump to solution
906 Views
jmueckl
Contributor IV

I am using MCUXpresso to develop C++ firmware on an LPC54018 (OM40003UL) development board.  

Can anyone tell me why the basic code I have written below is able to successfully open and create a log file in a specified directory when I run it in debug mode, but does not create the log when I build and run the released version after flashing it using the GUI Flash Tool?  Perhaps I need a configuration change?

fp = fopen("TempData.txt","w+");

fprintf(fp, "%8lu  %10f\n", g_DataNum, tempAve);

if (g_DataNum == LOG_TIME_IN_MIN * 60)  fclose(fp);

Labels (1)
0 Kudos
1 Solution
901 Views
frank_m
Senior Contributor III

I think, check the setup of both the debug and release version.

Where are the fopen/fprintf/fclose functions routed to, the onboard SD interface or semihosting (PC) ?

Semihosting is usually only enabled for the debug build, for good reasons.

View solution in original post

0 Kudos
5 Replies
895 Views
converse
Senior Contributor V

This article will help you understand how semihosting works

https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/What-is-Semihosting/m-p/475390

This should help you understand why it is not a good idea to use printf in release code.

0 Kudos
888 Views
jmueckl
Contributor IV

I am using fprintf's to print temperature data to a log file that can be evaluated after running a released version of the firmware.  I've worked with other firmware that did this.  Please advise.

0 Kudos
883 Views
jmueckl
Contributor IV

I found some SDK examples for an SD card I can use with my development board.  I can get what I need from them.  Thank you for directing me guys.

0 Kudos
875 Views
frank_m
Senior Contributor III

Yes, that would be the suggested way.

For a non-semihosting solution, you would need a permanent storage (SD card) and a file system (usually FatFS).

FatFS usually comes with it's own versions of file io functions.

0 Kudos
902 Views
frank_m
Senior Contributor III

I think, check the setup of both the debug and release version.

Where are the fopen/fprintf/fclose functions routed to, the onboard SD interface or semihosting (PC) ?

Semihosting is usually only enabled for the debug build, for good reasons.

0 Kudos