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.

Bootloader exit location in C2000

Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE

I wrote my custom bootloader copying TI's example for TMS320F28335
I placed my bootloader in FLASH A and my actual application in FLASH C, FLASH D, FLASH E. Following is my cmd file for actual application.

SCIBOOTINIT : origin = 0x33C000, length = 0x000020 /* flash H */
SCIBOOT     : origin = 0x33C020, length = 0x000200
BEGIN       : origin = 0x33FFF6, length = 0x000002

In actual application, i removed everything from FLASH A and moved to FLASH C, FLASH D and FLASH E, as shown below.
   .cinit              : > FLASHC      PAGE = 0
   .pinit              : > FLASHC,     PAGE = 0
   .text               : > FLASHC      PAGE = 0
   codestart           : > FLASHC/*BEGIN*/       PAGE = 0
   ramfuncs            : LOAD = FLASHD,
                         RUN = RAML0,
                         LOAD_START(_RamfuncsLoadStart),
                         LOAD_END(_RamfuncsLoadEnd),
                         RUN_START(_RamfuncsRunStart),
                         PAGE = 0
..
   csmpasswds          : > CSM_PWL     PAGE = 0
   csm_rsvd            : > CSM_RSVD    PAGE = 0
   ...
      /* Initalized sections go in Flash */
   /* For SDFlash to program these, they must be allocated to page 0 */
   .econst             : > FLASHC      PAGE = 0
   .switch             : > FLASHC      PAGE = 0
   ..
      /* Allocate IQ math areas: */
   IQmath           : > FLASHE      PAGE = 0                  /* Math Code */
   IQmathTables     : > IQTABLES,  PAGE = 0, TYPE = NOLOAD

 
 
   Then, I compiled my main program and generated "map file". "Map file" of my actual program says that my  _c_int00 is at 00334b91.
 
   So in my boot-loader code I have put
   #define FLASH_ENTRY_POINT   0x334b91  
  ( this is the value that is returned to _ExitBoot: from SCI_Boot() at the end in the boot-loader code. )
 
   I can verify that my boot-lader is running, downloading code and exiting, but my actual program is not running.
   Can someone tell me how and where to jump after exiting the _ExitBoot: routine.
   ( _ExitBoot: is part of f280x_otp2spi_boot_rom example provided by IT and i assume it is working as i can successfully download my code via bootloader. )

Thanks

  • Can someone answer this question, PLEASE.

    I also tried returning,   _main and  _mainLoop  location ( identified from map file) but without success.

    As stated above, I am just using _ExitBoot routine to exit from bootloader application that is provided in standard IT's bootloader  ( _ExitBoot: is part of f280x_otp2spi_boot_rom example provided by IT  )

    Regards

     

  • Desh said:
    I can verify that my boot-lader is running, downloading code and exiting, but my actual program is not running.

    Desh,

    Can you provide any additional details?  Does the code begin to run - ie you get to _c_int00 but not to main? or?

    Desh said:
    Can someone tell me how and where to jump after exiting the _ExitBoot: routine.

    _c_int00 is the location you want to get to.  In the TI boot ROM / examples we jump to a fixed location in flash where there is a "codestart" section.  This section may disable the watchdog and then jump to _c_int00.  This way if _c_int00 moves after a re-build, the code doesn't get lost.

    In controlSUITE you can find this code under

    C:\ti\controlSUITE\device_support\f2833x\v132\DSP2833x_common\source

    in the DSP2833x_CodeStartBranch.asm file.

    If you are executing _c_int00 from flash it is possible there is enough time initializing variables that the watchdog times out.  Monitoring the XRSn pin will give you clues if this is the case and you can try disabling the watchdog before _c_int00.

    Regards

    Lori

     

  • Hi Lori,
    Thanks for the reply.


    I did had a look at DSP2833x_CodeStartBranch.asm. It is similar to to my DSP2833x_CodeStartBranch.asm (see attached file) file which states that my entry point is "codestart"
    And in my cmd file i have put
     codestart           : > FLASHC/*BEGIN*/       PAGE = 0
     
    I checked my map file which has,  ( see attached file for my map file)
    OUTPUT FILE NAME:   <Example_2833xCpuTimer.out>
    ENTRY POINT SYMBOL: "code_start"  address: 00334ea4


    So in my bootloader code I tried,
    #define FLASH_ENTRY_POINT   0x334ea4


    My bootreturn code is as follows:

    Uint32 SCI_Boot() {
        DRTM;
        DINT; // Disable CPU interrupts
        EALLOW; // disable watchdog
        SysCtrlRegs.WDCR= 0x0068;
        EDIS;  
       
        Uint32 EntryAddr;
        Uint16 lockReturn;
        // Assign GetWordData to the SCI-A version of the
        // function. GetWordData is a pointer to a function.         
        GetWordData = SCIA_GetWordData;
        SCIA_Init();
        lockReturn = SCIA_AutobaudLock();
        if(lockReturn == FAIL)
        {
            EALLOW;
            //  GPIO-00 - PIN FUNCTION = --Spare--
            GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;        // check for LED flash to verify code return.
            GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;       
            GpioDataRegs.GPASET.bit.GPIO0 = 1;       
            EDIS;    // Disable register access   
            return FLASH_ENTRY_POINT;
        } // else vaildate data and download code...
        // If the KeyValue was invalid, abort the load
        // and return the flash entry point.
        if (SCIA_GetWordData() != 0x08AA) return FLASH_ENTRY_POINT;
        ReadReservedFn();
        EntryAddr = GetLongData();
        CopyData();
        return EntryAddr;
    }


    I can see my LED flash so i assume return FLASH_ENTRY_POINT; is executing. This code return to Init_Boot.asm ( unmodified, see attached file) which has _ExitBoot

    My DSP2833x_CodeStartBranch.asm has
    WD_DISABLE    .set    1  ;set to 1 to disable WD, else set to 0
    which means watchdog must be be disabled as well.
    So what should I do so that after exiting the bootloader so that my downloaded application will run.

     

    6076.files.zip

  • I debugged my code and found that after exit, it did jump to  specified FLASH_ENTRY_POINT but after that ended up in

    interrupt void ILLEGAL_ISR(void)   // Illegal operation TRAP
    {
      // Insert ISR Code here
     //  return;
      // Next two lines for debug only to halt the processor here
      // Remove after inserting ISR Code
      asm("          ESTOP0");
      for(;;);

    }

    Any ideas on how to debug this.....

     

  • Desh said:

    I debugged my code and found that after exit, it did jump to  specified FLASH_ENTRY_POINT but after that ended up in

    interrupt void ILLEGAL_ISR(void)   // Illegal operation TRAP
    {
      // Insert ISR Code here
     //  return;
      // Next two lines for debug only to halt the processor here
      // Remove after inserting ISR Code
      asm("          ESTOP0");
      for(;;);

    }

    Any ideas on how to debug this.....

     

    Hi Desh,

    The first step would be to determine where the ITRAP was taken.  ITRAP will occur if the stack is corrupted, or if the code goes into the weeds and fetches an illegal opcode - these are just a couple of examples.

    When an ITRAP is taken it is just like any other interrupt and there is a context save on the stack.  You can look at this information to try and determine where the ITRAP took place.  You can also step through the ITRAP routine and it will return to the location where the ITRAP occurred.  This may give some clues.

    More on ITRAP here:

    http://processors.wiki.ti.com/index.php/Interrupt_FAQ_for_C2000

    and the context save;

    http://processors.wiki.ti.com/index.php/C28x_Context_Save_and_Restore

    Regards

    Lori

     

     

  • Thanks for the reply Lori.

    Finally got the boot-loader going and it was the stack allocation problem.

    My only question would be, why IT wrote is boot-loader that only loads code. Any simple bootloader should jump to actual code after boot-load time out. But in TI's case if baud is not locked, they it just stays in the loop. Unable to lock baud only means user is not try to load new code and thus should return to FLASH_ENTRY_POINT.

     

    Regards

    Desh