Other Parts Discussed in Thread: C2000WARE
Tool/software:
Hi,
I discovered that example of flash programming has a bug.
In the source file: C:\ti\c2000\C2000Ware_5_02_00_00\device_support\f2806x\examples\c28\flash_programming\Example_Flash2806x_API.c
there is:
#define WORDS_IN_FLASH_BUFFER 0x100 // Programming data buffer, Words
Uint16 Buffer[WORDS_IN_FLASH_BUFFER];
[...]
Flash_ptr = Sector[1].StartAddr;
Length = 0x400; //<------ HERE IS THE BUG !!!
Status = Flash_Program(Flash_ptr,Buffer,Length,&FlashStatus);
if(Status != STATUS_SUCCESS)
{
Example_Error(Status);
}
Status = Flash_Verify(Flash_ptr,Buffer,Length,&FlashStatus);
if(Status != STATUS_SUCCESS)
{
Example_Error(Status);
}
Buffer has a size of 0x100 words and has been correctly initialized prior cited part of code.
Unfortunatelly, programmed size if 0x400, that excides size of the Buffer and programs some unexpected contents into flash memory.
After that verification unexpected fails because contents of the memory behind Buffer changed.
From the static analysis point this is usage of undefined memory.
How to fix it:
change the value from 0x400 to symbol WORDS_IN_FLASH_BUFFER
Regards,
Piotr Romaniuk