MFS with internal flash on M52255

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

MFS with internal flash on M52255

2,448件の閲覧回数
ck_max
Contributor I

Hi,

 

As title, how can I read/write internal flash of M52259 with MFS?

 

I installed flashx driver, opened device and installed MFS, but I cannot format the device.

 

 

/* initialize internel flash device */pf_IntFlash=fopen("flashx:", NULL);if(pf_IntFlash==NULL)printf("Error open internal flash device!\n");else{ /* mount filesystem */ mfsStatus=_io_mfs_install(pf_IntFlash, "c:", (_file_size)0);    if(mfsStatus != MFS_NO_ERROR)printf("MFS install failed!\n"); else {  /* format if needed */  FILE_PTR pf_fd;  int_32 error_code;  /* Open the filesystem and detect, if format is required */  pf_fd = fopen("c:", NULL);  error_code = ferror(pf_fd);  if(error_code==MFS_NO_ERROR)printf("Internal flash device initialized.\n");  else if (error_code == MFS_NOT_A_DOS_DISK)   {   /* no file system, need to format */   printf("Formating internal flash drive...\n");   error_code=ioctl(pf_fd, IO_IOCTL_DEFAULT_FORMAT, NULL);   if(error_code)printf("IntFlash format error!(%X)\n", error_code);  }  else printf("Error while opening c:\\ (%s)\n", MFS_Error_text((uint_32)(uint_32)error_code));  //fclose(pf_fd); }}

 The result like following

 

Formating internal flash drive...IntFlash format error!(301D)

 The error code means MFS_WRITE_FAULT, but I don't know how to solve this...

 

Please help!

Thanks!

 

Regards,

Max.

ラベル(1)
タグ(1)
0 件の賞賛
6 返答(返信)

541件の閲覧回数
NeraPhil
Contributor I

Looking at the flashx demo application (with MQX 3.8) I guess you need to unprotect the flash (by calling ioctl(flash_file, FLASH_IOCTL_WRITE_PROTECT, &ioctl_param):smileywink: to be able to write to the internal flash.

 

Cheers

Philipp

0 件の賞賛

541件の閲覧回数
cutworth
NXP Employee
NXP Employee

I don't understand why you would format internal flash if you have code running in flash, that will erase all your code and finally you get exception, if you really need to do this, you at least have to move code to sram.

0 件の賞賛

541件の閲覧回数
bonzo
NXP Employee
NXP Employee

I have a similar situation where I want to use internal Flash to store web pages.

The 52259 has 512K which is considerable, and I'd like to use the last 64K or 128K to upload webpages.  As it is now, I have to rebuild the entire image.

Ideally, I'd like to upload webpages using ftp or tfpt or a shell command.

Any suggestions?

0 件の賞賛

541件の閲覧回数
Jeinstei
Contributor II

bonzo-- did you ever figure out a solution for this MFS on internal Flash? I'm trying to do the same thing now and getting a write protect error.

0 件の賞賛

541件の閲覧回数
jausel
Contributor II

Hello,

I have the same problem.

I want to write some files in the internal Flash using the MFS.

 

This is my code:

/*************************************************/

flash_handle = fopen("flashx:bank1", NULL);
if (flash_handle == NULL)
      _task_block();
   
param = IO_O_RDWR; // Read and Write FLASH, just in case
if (IO_OK != ioctl(flash_handle, IO_IOCTL_SET_FLAGS, (char_ptr) &param))
       _task_block();
    
// FILE SYSTEM installation over  FLASH
error_code = _io_mfs_install(flash_handle, filesystem_name, (_file_size)0);
if (error_code != MFS_NO_ERROR)
       _task_block();    
               
//Open FILE SYSTEM
filesystem_handle = fopen(filesystem_name, NULL);
error_code = ferror (filesystem_handle);
if ((error_code != MFS_NO_ERROR) && (error_code != MFS_NOT_A_DOS_DISK))
         _task_block();
                
// if not Formated, I do Format
if (error_code == MFS_NOT_A_DOS_DISK)
        ioctl(filesystem_handle, IO_IOCTL_DEFAULT_FORMAT, NULL);
         
ioctl( filesystem_handle, IO_IOCTL_FAT_CACHE_OFF, NULL);    // without CACHE
  
// Open and close a file, if it do not exist, it is created
file_0 = NULL;
file_0 = fopen(FullFileName, "a");
fclose(file_0);    
ioctl( filesystem_handle, IO_IOCTL_FLUSH_FAT, NULL); // flush file system

// Open the file
file_0 = fopen(FullFileName, "r+");
if (file_0 == NULL)
        _task_block();
memset(buffer, 0, sizeof buffer);

len = read(file_0, buffer, 32);
       
if( strcmp( buffer, "HELLO") ) {
      strcpy(buffer, "HELLO");
      fseek(file_0, -32, IO_SEEK_END);
      write(file_0, buffer, 32);    
      fflush(file_0);
}
fclose(file_0);
ioctl( filesystem_handle, IO_IOCTL_FLUSH_FAT, NULL); // Fluch file system

/********************************************************/

 

I can write the files, but when I try to access again,  I cannot find the file. I always have to create it again. I inspect the flash, and  I can see the file contents, but the file system do not see it.

I think the problem is that  IO_IOCTL_FLUSH_FAT is not working or something like that.

 

Can anyone help me?

thank you!

 

 

 

0 件の賞賛

541件の閲覧回数
ironsean
Contributor V

I am experiencing the same problem with MFS on Internal Flash on a K60 chip, using FlashX, Partition Manager, and MFS. I can install, format, check it's formatted, see no errors, appear to write the file, and then upon reading the file nothing is read, and the buffer I have allocated to take the read data is not changed.

0 件の賞賛