semihosting Q: fwrite not working in linux env

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

semihosting Q: fwrite not working in linux env

697件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by can.finner on Fri Apr 15 01:49:24 MST 2011
Hi,
sorry to disturb.
I wrote a little semihosting program which running on LPC1769 with lpcXpresso/LPC-link/LPC1769.
the test code is like:
int main(void)
{
#define FILE_SIZE 100
  int n = 0;
  char *name = "helloworld.txt";
  char str[FILE_SIZE] = "initial value\n";
  FILE *fp;
  fp = fopen(name, "r+");
  if (!fp)
  {
      fprintf(stdout, "debug : file open error!\n");
  }
  n = fread(str, 1, FILE_SIZE, fp);
  fprintf(stdout, "debug : %d bytes read!\n", n);
  fprintf(stdout, "debug : %s\n", str);
  n = fwrite("xxxxx debug : write from semihosting", 1, 36, fp);
  fprintf(stdout, "debug : %d bytes write!\n", n);

  fclose(fp);

  return 0;
}

The program works on windows 7(32bit) with semihosting. The file helloworld.txt is modified as expected.
Unfortunately, there comes a problem when running it in linux(ubuntu 9.10 32bit). All other semihosting operations works alright except fwrite. the fwrite function does return the number of bytes written into file, but the file helloworld.txt on host system remains its original contents.

BTW,
1 , the file has rwx access right for all users;
2 , lpcXpresso version is  LPCXpresso v3.6.3 [Build 317] [08/04/2011]  for windows 7
and
LPCXpresso v3.8.3 [Build 317] [08/04/2011] for linux.

Thanks.
0 件の賞賛
返信
0 返答(返信)