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.

pragma CODE_SECTION long jump crashes on C28346

am using a C28346 with DSP/BIOS CCS 3.3 BIOS 5.33.06 Compiler 5.2.2, trying to relocate small section of code for use in copying serial flash contents to program memory for rebooting new firmware download.

I am using a CODE_SECTION pragma with linker cmd section definition which seems to work as far as the linker and disassembly go, everything looks like it maps and loads and relocates correctly to the right address location, but right after the long jump to the relocated function CopyData() it crashes.  I cannot do a single step in assembly mode from the start of the relocated CopyData() function and I cant see why.  I have disabled all interrupt enable IER bits, the stack pointer looks ok, the relocated code looks ok, but it crashes immediately on entering the relocated function. 

I am wondering if it is something to do with the pipeline?  Do I have to flush the pipeline before doing a long jump?

#pragma CODE_SECTION(CopyData, "RamFuncs");
void CopyData()
{

}

 

/**************************************************************/
SECTIONS
{

  
   RamFuncs    :   LOAD = L47SARAM,  PAGE = 0        
                      RUN = L03SARAM,    PAGE = 0
                         LOAD_START(_RamFuncs_loadstart),
                         LOAD_END(_RamFuncs_loadend),
                         RUN_START(_RamFuncs_runstart)

}

  // Section RamFuncs contains relocatable code 

  memcpy( &RamFuncs_runstart,     &RamFuncs_loadstart,    (&RamFuncs_loadend - &RamFuncs_loadstart)+1);
 

 

  • Although the processor has a protected pipeline, reads from the program space are not protected.  Likewise, the program prefetch mechanism assumes the program code is constant and there is no need to wait for it to be updated before fetching an instruction.

    Depending on how your code is copied, the instruction prefetch registers may contain information in the ram location prior to your copy function completing.  Therefore, you should issue at least 8 NOP instructions after finishing copying your code and before jumping to it (or do something else which will flush the pipeline before you jump to the copied code).

    Jim Noxon