Ok Mark , i checked a lot of things, and this are my conclusion:
first i need to claryfi that i need to clean exteranl SPI flash but as u told me uFileErase(uFILE_SYSTEM_START, (MAX_FILE_LENGTH)FILE_SYSTEM_SIZE); should do excatly what i want, cos:
uFILE_SYSTEM_START is
#define uFILE_SYSTEM_START (MEMORY_RANGE_POINTER)(uFILE_START)
and uFILE_START is #define uFILE_START (SPI_FLASH_START)
FILE_SYSTEM_SIZE is #define FILE_SYSTEM_SIZE (128*SINGLE_FILE_SIZE)
and SINGLE_FILE_SIZE is #define SINGLE_FILE_SIZE (FILE_GRANULARITY)
and FILE_GRANULARITY is #define FILE_GRANULARITY (2*SPI_FLASH_BLOCK_LENGTH) // (2 x 4096 byte blocks)
it shoud remove all files on external SPI flash, but i doesn't. This line uFileErase(uFILE_SYSTEM_START, (MAX_FILE_LENGTH)FILE_SYSTEM_SIZE); removes only some part of data and then device is reseting. i Know that in fnEraseFlashSector is WDTICR = 0; but it seems that it is in wrong place. My SPI flash is 1MB big. When i copy to device some files which size is more than 200 kB, not all will be removed and watchdog will reset device. BUT when i turn off watchdog (i use contruction like belove):
WDTLOCK = WD_ACCESS;
WDTCTL &= ~(WD_RESEN | WD_INTEN); // disable watchdog and interru
uFileErase(uFILE_SYSTEM_START, (MAX_FILE_LENGTH)FILE_SYSTEM_SIZE);
WDTCTL = (WD_RESEN | WD_INTEN); // enable watchdog and interrupt
WDTLOCK = 0;
removing files takes like 7 second, but all filles will be removed then, i am wondering , why i need to turn off watchdog, if there is WDTICR = 0; in a loop.
device is not reseting then but is strange problem , that it lose connection but as i sad then delete all files.