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.

SDRAM problems during secindary bootloader

Other Parts Discussed in Thread: TMS320DM642

Hi

I am  facing with very strange and difficult problem . I am trying to solve it or at least to find some reasonable explanation for this , already for few days 

Project description:

We are working with TI  TMS320DM642  DSP,  the DSP program is running from internal RAM and external SDRAM both.

I am trying to implement secondary boot loader for our operational firmware

The operational firmware , loaded by secondary boot loader , its binary boot image file , created  by  “hex6x.exe” utility  , with command file (see command file example attached)

See description of binary boot image in spru186w.pdf

We  have to boot loaders :

First boot loader – small 1k byte program loaded from flash to address 0 in ISRAM  and loads secondary boot loader program from flash and run it

The secondary boot loader  - gets the operational program via TCP/IP from PC ,  loads it to DSP memory , and run to c_init address of loaded program

 The problem happens in second boot loader only:

 Problem description

 

The second boot loader  does the following :

 

  1. Get firmware image from PC via TCP/IP  to buffer located in SDRAM memory
  2. Parse the firmware image , and copy all its section to appropriate location in internal or external memory 
  3. Does compare of copied data for each section, to check , if the memory copy was succeeded  

 

The function and variables of secondary loader code , which executes the image parsing and extract , are located I separated memory segment (there is no code or data of operational firmware image in this segment!)

 

The code of firmware extract function , looks like that.

 

Void ExctractFunction()

{

    IRQ_globalDisable();

 

   //write back invalidate all data cache L2 and L1

   CACHE_wbInvAllL2(CACHE_WAIT);

   CACHE_invAllL1p();

   CACHE_wait();

  //disable L2 cashe

   CACHE_setL2Mode(CACHE_0KCACHE);

   CACHE_wait();

 

 

   src = (Uint8*)FirmwareBuffer;

    //move src on 1k bytes  (reserved for first bootloader)

   src += 0x400;

   entryAddr = (CINIT)(*(Uint32*)src);

   src+=4;

    

src = (Uint8*)FirmwareBuffer;

//move src on 1k bytes  (reserved for first bootloader)

src += 0x400;

entryAddr = (CINIT)(*(Uint32*)src);

src+=4;

 

do

{

 

     cnt = (Uint32)(*(Uint32*)src);

     src+=4;

     addr = (Uint8*)(*(Uint32*)src);

     src+=4;

 

     //save section data , from flash to sdram buffer

     for (iTemp = 0; iTemp < cnt ; iTemp++)

     {

           save_buffer[iTemp] = src[iTemp];

     }

    

     //load  section to memory destination

     for (iTemp = 0; iTemp < cnt ; iTemp++)

     {

           addr[iTemp] = src[iTemp];

     }

 

     ///////////////////////////////////////////////////////////

     //   If I add wait here , the copy check will always succeeded

      //   for (iTemp = 0; iTemp < 1000000 ; iTemp++)  <- wait

      /////////////////////////////////////////////////////////////

     //memory copy check

     for (iTemp = 0; iTemp < cnt ; iTemp++)

     {

           if (addr[iTemp] != save_buffer[iTemp])

           {

                ErrorCounter++; //problem !!!

           }

     }

    

 

     addr = addr + cnt;

     src =  src + cnt;

     //always round address to be aligned to 4

     if ((((Uint32)src)&3) != 0)

     {

           src = (Uint8*)((((Uint32)src)&0xfffffffc)+4);

     }

 

     //the end of binary boot image its always padded with zeroes, means, when count and addr is 0 - > end of image

} while ( (cnt != 0) && (addr != (Uint8*)0) );

 

   entryAddr();

 

}

     The problem :

    

I notice , sometimes the copy of .text section of operation image is failed !!!,

But the problem is solved , when I add some wait , after copy loop .

As I mention before , all variables and buffers of loader are located in separated segment of data, where is no code from operational firmware .

The  code of ExctractFunction its also located in separated code segment

Nothing run , during firmware extraction , the interrupts are disabled

 

The memory map of loader and operational firmware are different .  Where the operational firmware has code, the loader can have data and vice versa .

During extract , the loader override program memory with data , may be its does some problem ?