A large program to load and boot in the TMS320C28346 (Delfino) DSP has a .text code section bigger than 0xFFFF words.
I use the hex2000 provided with the code composer utility to create the boot data. As the segment size of the DSP's boot loader is a 16 bit value, the segment size is limited 0xFFFF words, however the hex2000 utility correctly splits up the section into two consecutive segments with the first segment having the maximum segment size of 0xFFFF words and the next segment with the remaining size.
The DSP's boot loader however seems to hang with that data. I reviewed the boot loader's source code provided with the control suite. My question is whether the CopyData routine of the boot loader might have a bug ?
As can be seen in the source code below, the loop variable i is declared 16 bit wide and therefore can have a maimum value of 0xFFFF. In the for statement
for(i = 1; i <= BlockHeader.BlockSize; i++)
the termination condition of the loop can never be reached with a blocksize of 0xFFFF, because i overflows before reaching 0x10000, resulting in an infinite loop.
Can anyone confirm this and if so, is a workaround available ?
void CopyData()
{
struct HEADER {
Uint16 BlockSize;
Uint32 DestAddr;
} BlockHeader;
Uint16 wordData;
Uint16 i;
// Get the size in words of the first block
BlockHeader.BlockSize = (*GetWordData)();
// While the block size is > 0 copy the data
// to the DestAddr. There is no error checking
// as it is assumed the DestAddr is a valid
// memory location
while(BlockHeader.BlockSize != (Uint16)0x0000)
{
BlockHeader.DestAddr = GetLongData();
for(i = 1; i <= BlockHeader.BlockSize; i++)
{
wordData = (*GetWordData)();
*(Uint16 *)BlockHeader.DestAddr++ = wordData;
}
// Get the size of the next block
BlockHeader.BlockSize = (*GetWordData)();
}
return;
}
What is the correct method debugging the boot loader with code composer ?
It should not load nor recompile the source to ensure a 100% match of the code in the code composer's memory and the DSP's ROM..
Eckart Märkel