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.

Compiler/TMS320F2812: Copying compiler sections using SPRAAU8 files is not working

Part Number: TMS320F2812

Tool/software: TI C/C++ Compiler

Dear All,

I am trying to copy all the compiler sections from FLASH to RAM in TMS320F2812.

I have studied and used the material available at 

http://www.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=spraau8

But I am unable to make my DSP run. After using the files mentioned in the above link, DSP is getting trapped at 0x000066 address and without even entering main(). I tried copying one by one compiler sections into RAM. Only copying of .text section into RAM is creating the problem. Other sections are working fine with the given code. Any leads on this would be very helpful.

Thanks!

Kashyap Gundlapalli

  • Kashyap,

    What type of errors are you observing in the console output?

    Regards,
    Ozino
  • Hi Ozino Odharo,

    Thanks for the reply!

    Console output has no errors.

    The issue got solved yesterday surprisingly by disconnecting and restarting the controller after loading the code.

    Once restarted, if I load the same code into the controller, I was able to debug else it is not working. I am not completely sure of the reason behind this behavior but I find it difficult to disconnect, restart, reconnect and re-load the program to debug small small changes during development and debugging phases.

    Can you please suggest any better way to do this?

    Thanks again!

    Kashyap Gundlapalli 

  • Kashyap,

    Thanks for sharing your findings. By any chance, do you still have flash settings for your project since you are intending to run from RAM. I suspect there may be left over FLASH settings carried over. Start by checking the boot pin configuration.

    Regards,
    Ozino
  • Dear Ozino,

    Thanks for the reply. I have commented the "Initflash()" function provided by TI that deals with flash settings. Please find the related code part below:

    void  HardwareInit(void)

    {

    // Step 1. Initialize System Control:

    // PLL, WatchDog, enable Peripheral Clocks

    // Disable the watchdog

    WatchDog();

    // Initialize the PLLCR to 0xA

    InitPll(0xA);

    // Initialize the peripheral clocks

    InitPeripheralClocks();

    // Step 2. Initalize GPIO:

    InitGpio();

    // Step 3. Clear all interrupts and initialize PIE vector table:

    // Disable CPU interrupts

    DINT;

    // Initialize PIE control registers to their default state.

    // The default state is all PIE interrupts disabled and flags

    // are cleared.

    InitPieCtrl();

    // Disable CPU interrupts and clear all CPU interrupt flags:

    IER = 0x0000;

    IFR = 0x0000;

    // Initialize the PIE vector table with pointers to the shell Interrupt

    // Service Routines (ISR).

    InitPieVectTable();

    // Copy time critical code and Flash setup code to RAM

    // This includes the following ISR functions: EvaTimer1(), EvaTimer2()

    // EvbTimer3 and and InitFlash();

    // The  RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart

    // symbols are created by the linker. Refer to the F2812.cmd file.

    //MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);

    // Step 4. Initialize all the Device Peripherals:

    InitPeripherals(); //

    // Call Flash Initialization to setup flash waitstates

    // This function must reside in RAM

    //InitFlash();

    // Enable PIE group 2 interrupt 4 for T1PINT

    PieCtrlRegs.PIEIER2.all = M_INT4;

    // Enable PIE group 1 interrupt 6 for ADCINT

    PieCtrlRegs.PIEIER1.all = M_INT6;

    IER |=  M_INT2; // Enable interrupt core line 2 (INT2)

    IER |=  M_INT1;                       // Enable ADC interrupt

    // Enable global Interrupts and higher priority real-time debug events:

       EINT;   // Enable Global interrupt INTM

       ERTM;   // Enable Global realtime interrupt DBGM

    }

    .c file is also attached here for your reference

    hardware.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    /*****************************************************************************/
    /* */
    /* INNERVE POWER SOLUTIONS */
    /* */
    /*****************************************************************************/
    /* */
    /* Module name: HARDWARE.C */
    /* */
    /* Programmer: Saikrishna Kashyap */
    /* */
    /* Date: 2018-04-25 */
    /* */
    /* Description: Hardware functions. */
    /* */
    /*****************************************************************************/
    #define HARDWARE
    #include "hardware.h"
    void InitPeripherals(void);
    void InitPieVectTable(void);
    void InitPll(Uint16 val);
    void InitPeripheralClocks(void);
    void InitPieCtrl(void);
    void InitGpio(void);
    void InitEv(void);
    void InitAdc(void);
    // Watchdog functions
    void KickDog(void);
    void WatchDog(void);
    //void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr);
    void InitFlash(void);
    Uint16 CsmUnlock(void);
    const struct PIE_VECT_TABLE PieVectTableInit = {
    PIE_RESERVED, // Reserved space
    PIE_RESERVED,
    PIE_RESERVED,
    PIE_RESERVED,
    PIE_RESERVED,
    PIE_RESERVED,
    PIE_RESERVED,
    PIE_RESERVED,
    PIE_RESERVED,
    PIE_RESERVED,
    PIE_RESERVED,
    PIE_RESERVED,
    PIE_RESERVED,
    // Non-Peripheral Interrupts
    INT13_ISR, // XINT13 or CPU-Timer 1
    INT14_ISR, // CPU-Timer2
    DATALOG_ISR, // Datalogging interrupt
    RTOSINT_ISR, // RTOS interrupt
    EMUINT_ISR, // Emulation interrupt
    NMI_ISR, // Non-maskable interrupt
    ILLEGAL_ISR, // Illegal operation TRAP
    USER1_ISR, // User Defined trap 1
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Kashyap,

    Did you update your linker command file when switching to the RAM build config? I would also make sure you are replacing the existing codestartbranch.asm file with the DSP28xxx version of the file. This is important regarding the code_start sections.

    Regards,
    Ozino
  • Ozino,

    Yes I updated linker command file and codestartbranch.asm files with the DSP28xxx version. Right now as I mentioned before it is running fine but the procedure for debugging is too long. I dunno why it is so complex.

    Thanks!

    Kashyap

  • Kashyap,

    I have gone ahead and asked for a Flash debugging expert to take a look at the issue you are still running into.

    Regards,
    Ozino
  • Please clearly describe your issue? What are the two procedures you are following and what are the behaviors?

    sal
  • Hi Sal,

    Following are the two procedures I followed:

    1) Initially I was using Memcpy() function to copy selected CODE SECTIONS from Flash to RAM during initialization after entering main(). But I wanted to copy all the  code from Flash to RAM.

    2) I have followed the procedure given in SPRAAU8 to copy all the code from flash to RAM at the time of booting. I didn't get any build errors after that. 

    In the first case, once the program is loaded into the DSP, cursor enters main and stops there. I can press the RUN button after that and can debug without any issue.

    In the second case, once the program is loaded into DSP, cursor was not entering main(). I had to disconnect and restart the controller (by powering it OFF and ON). When I reconnect and load the same program it is entering the main() and then it is running properly. So, the problem in the second case is for every small change I had to load the program, disconnect, restart, re-connect and load the same program again to debug using JTAG, which is becoming very long process. I am not sure why it is happening like this. If you can suggest an alternative, it would be very helpful.

    Thanks!

    Kashyap

  • I believe I understand the issue. And it is a fundamental one.

    You are trying to copy all the code, including .text into RAM. Well, in your main(), you copy .text to RAM. But main() is in .text.

    So, according to your linker command file .text is loaded to flash and run from RAM, it has an execution address in RAM. So the program is branching to main() after _c_int00 and is branching to RAM which is the execution address of main(). But the code isn't in RAM. It is in flash since you have not copied it into RAM yet.

    This is a pretty basic issue. You need to understand how the code is loaded and copied and run.

    You cannot run main() from RAM before it has been copied there. Therefore, you will need to run some code in .text from flash in order to copy the code you need to RAM to run it from RAM.

    Thank you, and have a good day.
    sal