Create text file in Emmc read & write data to the text file in ATSAMA5D36

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Requirement:

 

  • I interfaced my ATSAMA5D36 development board with a GUI and i need to open a  .txt file in EMMC . 
  • To write the data which the user enters from the GUI to the text file and read it when ever requires.
  •  I added the .c file which contain code (below) in source folder and .h in lib folder.

 

ISSUE:

  •  In this application i'm unable to open a .txt file.
  •  The code snippet i'm using is given below please check.
  • The code is making without showing errors or warnings.
  • In runtime the code is stopping before the call f_open.

Code snippet:
 

nt DeviceInfo(uint8_t* msg) { 
AckMsg_t msg_h; 
char dev_name[20]; 
FILE *fp; 
uint8_t file_name[50]="DeviceInfo.txt"; 
const TCHAR drive_path[] = { '0' + 0, ':', '\0' }; 
TCHAR file_path[sizeof(drive_path) + sizeof(file_name)]; 
strcpy(file_path, drive_path); 
strcat(file_path, file_name); 
res=f_open(&f_header.file,file_path,FA_OPEN_EXISTING | FA_WRITE | FA__WRITTEN | 
                                                                                                                                                                                                                   FA_READ | FA_CREATE_NEW); 
if(res != FR_OK){ 
printf("\nFailed to open \"%s\", error %d\n\r", file_path, res); 
if(res == FR_EXIST) 
{ 
res = f_open(&f_header.file, file_path, FA_WRITE | FA__WRITTEN | FA_READ ); 
printf("\nres value after f open %d\n\r",res); 
if (res != FR_OK) { 
printf("123456\n\r");} 
return false; }} 
return (SUCCESS); 
} 

 

Structure:



struct padded_fil { 
uint8_t padding[28]; 
FIL file; 
}; 
static struct padded_fil f_header; 

*Why i'm failing to open the text file here? This same file operation calls are working on other applications.

If anyone have a solution please help me.