µTasker Forum

µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: frank on November 17, 2009, 05:14:57 PM

Title: Re-format SPI flash
Post by: frank on November 17, 2009, 05:14:57 PM
I have a MCF52232 based custom board which has ST M25P20 flash. For some reason, the filesystem got corrupted. Is there any way I can purge or reformat the SPI flash ?.
Title: Re: Re-format SPI flash
Post by: mark on November 17, 2009, 07:38:44 PM
Hi Frank

as you know, the uFileSystem expects that the SPI FLASH be in a deleted state when starting. If corruption takes place you can however use the "DEL *.*" command via FTP to completely delete the uFileSystem area - usually this is the easiest method. It also performs the delete by commanding a low level erase of all sections of the SPI FLASH defined to be within the file system and not be deleting any file found. This ensures that a corrupted memory doesn't cause delete difficulties.

A further method is to activate the define TEST_SPI_FLASH in application.c. This then performs a test of a sector in FLASH to ensure that it can be correctly written to, read and deleted. By modify in the delete part to include the whole file system size or the complete chip:
fnEraseFlashSector(TEST_DEVICE, 0);  becomes fnEraseFlashSector(TEST_DEVICE, FILE_SYSTEM_SIZE); or similar, you can also cause a full delete to take place (after which the define needs to be removed again!)

In some cases it may also be of benefit when the integrity of the FLASH is checked on start up (eg. check for files which have an impossible size) and delete automatically if obviously invalid. Generally new FLASH chips will be pre-erased but this is not guarantied!!

Regards

Mark