semihosting fopen path

cancel
Showing results for 
Search instead for 
Did you mean: 

semihosting fopen path

Jump to solution
292 Views
billchadwick
Contributor III

I am using the semihosting library with file support and a JLink debugger for an iMXRT1064 project.

I can fopen a file for write just fine if I use an absolute path e.g. "C:\\MyProject\\my_log.csv".

As I am working with others, it would be nice to use a project working directory relative path.

If I use a path with just a filename in fopen e.g.  "my_log.csv", the file appears to open and fprintf looks to work. However the file can't be found in any obvious location on my PC. Where would such a file be written to by default? Is there perhaps a project setting for the default working folder that I have missed?

Thanks,

Bill

 

0 Kudos
1 Solution
247 Views
ErichS
Senior Contributor IV

Yes, the IDE folder is really not ideal, and the process might not have write permission.

View solution in original post

0 Kudos
4 Replies
268 Views
ErichS
Senior Contributor IV

This is what I have in my gcov library (see https://mcuoneclipse.com/2014/12/26/code-coverage-for-embedded-target-with-eclipse-gcc-and-gcov/

  /*
   * Creating a file without absolute path.
   * With J-Link and MCUXpresso IDE 11.4.1, this file gets created in the IDE installation directory (C:\NXP\MCUXpressoIDE_11.4.1_6260\ide).
   * Where the file gets created (current directory of the semihosting process on the host) really depends on the probe firmware and is non-standard.
   * See as well:
   * https://developer.arm.com/documentation/dui0058/d/semihosting/semihosting-swis/sys-open--0x01-?lang=en
   */
  file = fopen ("gcov_text.txt", "w");
  fputs("hello world with file I/O\r\n", file);
  fclose(file);

 

I hope this helps

Erich

0 Kudos
250 Views
billchadwick
Contributor III

Thanks for that Erich.

I have had some success using __FILE__  and popping up a few directories.

I doubt my co-developers would expect/want log files going to the IDE folder.

Bill

 

0 Kudos
248 Views
ErichS
Senior Contributor IV

Yes, the IDE folder is really not ideal, and the process might not have write permission.

View solution in original post

0 Kudos
290 Views
billchadwick
Contributor III

MCUXpresso IDE v11.3.1 [Build 5262] [2021-04-02]

0 Kudos