Flashx write errors

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

Flashx write errors

Jump to solution
1,046 Views
derekkrouze
Contributor II

Hello,

Recently I made the switch to MQX 3.8.1 from 3.7, for better DDR performance, and have been noticing that the flashx driver does not seem to function the same as it used to. The project is being developed on a K61 with 1MB of flash space and both the user_config.h and linker file allow the entire flash space to be used. The current configuration is using the DDR region as ram and using the SRAM as the uncached data zone. I also do not currently use PE components.

This is a bootloader project that reads an SREC line and writes it to flash, about 76 bytes at a time. I have noticed errors on consective flash writes. The first flash write will go through but trying to write the next chunk of data always returns the FTFE_ERR_MGSTAT0 error. I have tried to read entires sectors, modify and write them back and the data that gets put back into flash has arbitrary chunks of 0xFFFFFFFF scattered about. Putting the old MQX 3.7 flash code produced similar results until disabling the icache ( _ICACHE_DISABLE()) during writes. It is unclear to me if I need to set up the flash or system cache differently than I currently have it. Disabling the flash cache using the FMC_PFBxx registers didn't seem to make a difference either.

Everything besides the DDR ran fine in 3.7 so any help would be appreciated.

-Thanks,

Derek

Tags (4)
0 Kudos
1 Solution
445 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Derek,

The MQX 4.0 seems to include some fixes for the flash driver. From the release notes:

-Kinetis FlashX driver updated. Fixed incorrect functionality in case number of sectors was not divisible by 8. Fixed chip erase IOCTL command. Corrected problem in io_flashx_find_correct_sectors() in case a flashx_file spreads over more than one flashx_block.

-Changed size of FLASH memory from 512kB to 1MB in linker command files for TWR-K60F120M board. Changed initialization struct for FlashX driver from 2 banks to 4 banks.

Have you tried this release?

Best Regards,

-Garabo

View solution in original post

0 Kudos
3 Replies
446 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Derek,

The MQX 4.0 seems to include some fixes for the flash driver. From the release notes:

-Kinetis FlashX driver updated. Fixed incorrect functionality in case number of sectors was not divisible by 8. Fixed chip erase IOCTL command. Corrected problem in io_flashx_find_correct_sectors() in case a flashx_file spreads over more than one flashx_block.

-Changed size of FLASH memory from 512kB to 1MB in linker command files for TWR-K60F120M board. Changed initialization struct for FlashX driver from 2 banks to 4 banks.

Have you tried this release?

Best Regards,

-Garabo

0 Kudos
445 Views
derekkrouze
Contributor II

Garabo,

I did try the 4.0 flash driver previously and it still showed the same behavior. I have modified the driver in 3.8.1 and I seem to have one that works now. The consecutive flash write errors seemed to be caused by the _io_flash_check_free_space() function. It did not check to see if there was data wrote to the flash region prior to the source pointer. So that would say that the flash area was not used, but then in the sector program command it writes to the address with mod 8 correction, which could possibly try to write to data that has not been previously erased. My work around was to make another function that checked the mod 8 correction area to make sure data was not being wrote twice. If this doesn't make sense I can try to explain it again or if I am missing something in the flashx driver please feel free to comment.

In MQX 3.7 if the sector cache was enabled it would always cache the data and not check free space, which is why the code worked then and not now. As for the arbitrary chunks of 0xFFFFFFFF being wrote, I still have not figured out why it is happening but using the _ICACHE_DISABLE() still seems to work.

Thanks,

-Derek

0 Kudos
445 Views
David_Wu
Contributor III

Hi Derek,

I have a similar Flash write error on K60 using MQX4.0. Do not know if it has issues with MQX3.8.

In my case I did not enable sector cache (ioctl with FLASH_IOCTL_DISABLE_SECTOR_CACHE) and always erased all sectors then called write().  I have tried to write totally 4k Bytes - 8 bytes per write(), I saw arbitrary chunks of 0xFFFFFFFF- 16 bytes, or 32 bytes, etc - the write() returned correct return code but without really writing to Flash. If I read back after write I see some location were written correctly, some were 0xff - but if I wait some time - say 1 second - then read back, the same location would be written correctly (previously were failed with 0xff). But there still are arbitrary chunks of 0xFFFFFFFF left unwritten.

Other tests I did is to write 512bytes each time (totally ~300kB) to upper half of the Flash and had similar issue - (160Bytes, or maybe 280Bytes of 0xffs without written correct data)

I have tried to call _ICACHE_DISABLE() and it seemed worked for me. No failure so far.

David

0 Kudos