This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/TM4C1292NCPDT: Flash write driver issue

Part Number: TM4C1292NCPDT

Tool/software: TI-RTOS

Hello,

I am using tirtos_tivac_2_16_01_14 and TivaWare_C_Series-2.1.4.178 for project. I am using one of the flash segment for storing non-volatile data for my application and this data will be written from one of the task in my application. This flash read and write will be frequent in my application.

After some times flash write, the entire flash is getting corrupted and reading all the values as 0xFFFFFFFF.

i thought there may task switching between flash erase and flash write and that causing the flash data is getting corrupted. then i changed the priority of flash write task to higher and checked but still the problem exist. can any one suggest what is happening here and why its getting corrupted after few writes?

is FlashProgram() and FlashErase() preempted? if so how do we block from preemption in TI RTOS?

please find the code snippet.

/* Flash Write */
void flashWrite(BOOT_STRUCT *stFlashData) { int ret; Semaphore_pend(Sem_flash_Handle, BIOS_WAIT_FOREVER); ret = FlashErase((uint32_t ) FLASH_COMMON_MEMORY_ADDRESS); if(ret != NULL) { System_printf("FLash memory is not erased successfully\n"); } ret = FlashProgram((uint32_t *)stFlashData, FLASH_COMMON_MEMORY_ADDRESS, 1024); if(ret != NULL) { System_printf("FLash memory is not programmed successfully\n"); } Semaphore_post(Sem_flash_Handle); }

/* Flash Read */
BOOT_STRUCT  flashRead(BOOT_STRUCT *stFlashData)
{
	Semaphore_pend(Sem_flash_Handle, BIOS_WAIT_FOREVER);

	stFlashData = ((BOOT_STRUCT  *)FLASH_COMMON_MEMORY_ADDRESS );

	Semaphore_post(Sem_flash_Handle);
	return *stFlashData;
}


Regards

Bala

  • There are implications with programming and erasing flash memory in a preemptive operating system. You cannot read or execute from a flash bank that is being erased or programmed (the read or fetch is held off until the program or erase operation completes). Since the four banks of flash on this device are two-way interleaved, you have effectively two 512KB banks. The relatively long erase time of a flash sector will cause problems in the operating system as interrupts cannot be serviced when the CPU is blocked on a read from a flash bank that has a sector which is being erased. Possible solutions are:
    1. Store variables in the emulated EEPROM memory
    2. Partition your code so only flash variables are stored in the upper 512KB of memory and these are never accessed while an erase or program operation is on-going.
    3. Use an external flash